babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  686. static readonly GEQUAL: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. private _alignTangentsWithPath;
  4784. private readonly _pointAtData;
  4785. /**
  4786. * new Path3D(path, normal, raw)
  4787. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4788. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4789. * @param path an array of Vector3, the curve axis of the Path3D
  4790. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4791. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4792. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4793. */
  4794. constructor(
  4795. /**
  4796. * an array of Vector3, the curve axis of the Path3D
  4797. */
  4798. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4799. /**
  4800. * Returns the Path3D array of successive Vector3 designing its curve.
  4801. * @returns the Path3D array of successive Vector3 designing its curve.
  4802. */
  4803. getCurve(): Vector3[];
  4804. /**
  4805. * Returns the Path3D array of successive Vector3 designing its curve.
  4806. * @returns the Path3D array of successive Vector3 designing its curve.
  4807. */
  4808. getPoints(): Vector3[];
  4809. /**
  4810. * @returns the computed length (float) of the path.
  4811. */
  4812. length(): number;
  4813. /**
  4814. * Returns an array populated with tangent vectors on each Path3D curve point.
  4815. * @returns an array populated with tangent vectors on each Path3D curve point.
  4816. */
  4817. getTangents(): Vector3[];
  4818. /**
  4819. * Returns an array populated with normal vectors on each Path3D curve point.
  4820. * @returns an array populated with normal vectors on each Path3D curve point.
  4821. */
  4822. getNormals(): Vector3[];
  4823. /**
  4824. * Returns an array populated with binormal vectors on each Path3D curve point.
  4825. * @returns an array populated with binormal vectors on each Path3D curve point.
  4826. */
  4827. getBinormals(): Vector3[];
  4828. /**
  4829. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4830. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4831. */
  4832. getDistances(): number[];
  4833. /**
  4834. * Returns an interpolated point along this path
  4835. * @param position the position of the point along this path, from 0.0 to 1.0
  4836. * @returns a new Vector3 as the point
  4837. */
  4838. getPointAt(position: number): Vector3;
  4839. /**
  4840. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4841. * @param position the position of the point along this path, from 0.0 to 1.0
  4842. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4843. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4844. */
  4845. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4846. /**
  4847. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4850. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4851. */
  4852. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4857. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4858. */
  4859. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4860. /**
  4861. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4864. */
  4865. getDistanceAt(position: number): number;
  4866. /**
  4867. * Returns the array index of the previous point of an interpolated point along this path
  4868. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4869. * @returns the array index
  4870. */
  4871. getPreviousPointIndexAt(position: number): number;
  4872. /**
  4873. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4874. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4875. * @returns the sub position
  4876. */
  4877. getSubPositionAt(position: number): number;
  4878. /**
  4879. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4880. * @param target the vector of which to get the closest position to
  4881. * @returns the position of the closest virtual point on this path to the target vector
  4882. */
  4883. getClosestPositionTo(target: Vector3): number;
  4884. /**
  4885. * Returns a sub path (slice) of this path
  4886. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4887. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4888. * @returns a sub path (slice) of this path
  4889. */
  4890. slice(start?: number, end?: number): Path3D;
  4891. /**
  4892. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4893. * @param path path which all values are copied into the curves points
  4894. * @param firstNormal which should be projected onto the curve
  4895. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4896. * @returns the same object updated.
  4897. */
  4898. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4899. private _compute;
  4900. private _getFirstNonNullVector;
  4901. private _getLastNonNullVector;
  4902. private _normalVector;
  4903. /**
  4904. * Updates the point at data for an interpolated point along this curve
  4905. * @param position the position of the point along this curve, from 0.0 to 1.0
  4906. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4907. * @returns the (updated) point at data
  4908. */
  4909. private _updatePointAtData;
  4910. /**
  4911. * Updates the point at data from the specified parameters
  4912. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4913. * @param point the interpolated point
  4914. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4915. */
  4916. private _setPointAtData;
  4917. /**
  4918. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4919. */
  4920. private _updateInterpolationMatrix;
  4921. }
  4922. /**
  4923. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4924. * A Curve3 is designed from a series of successive Vector3.
  4925. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4926. */
  4927. export class Curve3 {
  4928. private _points;
  4929. private _length;
  4930. /**
  4931. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4932. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4933. * @param v1 (Vector3) the control point
  4934. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4935. * @param nbPoints (integer) the wanted number of points in the curve
  4936. * @returns the created Curve3
  4937. */
  4938. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4939. /**
  4940. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4941. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4942. * @param v1 (Vector3) the first control point
  4943. * @param v2 (Vector3) the second control point
  4944. * @param v3 (Vector3) the end point of the Cubic Bezier
  4945. * @param nbPoints (integer) the wanted number of points in the curve
  4946. * @returns the created Curve3
  4947. */
  4948. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4949. /**
  4950. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4951. * @param p1 (Vector3) the origin point of the Hermite Spline
  4952. * @param t1 (Vector3) the tangent vector at the origin point
  4953. * @param p2 (Vector3) the end point of the Hermite Spline
  4954. * @param t2 (Vector3) the tangent vector at the end point
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a CatmullRom Spline curve :
  4961. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4962. * @param nbPoints (integer) the wanted number of points between each curve control points
  4963. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4964. * @returns the created Curve3
  4965. */
  4966. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4971. * @param points points which make up the curve
  4972. */
  4973. constructor(points: Vector3[]);
  4974. /**
  4975. * @returns the Curve3 stored array of successive Vector3
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the curve.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4984. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4985. * curveA and curveB keep unchanged.
  4986. * @param curve the curve to continue from this curve
  4987. * @returns the newly constructed curve
  4988. */
  4989. continue(curve: DeepImmutable<Curve3>): Curve3;
  4990. private _computeLength;
  4991. }
  4992. }
  4993. declare module "babylonjs/Animations/easing" {
  4994. /**
  4995. * This represents the main contract an easing function should follow.
  4996. * Easing functions are used throughout the animation system.
  4997. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4998. */
  4999. export interface IEasingFunction {
  5000. /**
  5001. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5002. * of the easing function.
  5003. * The link below provides some of the most common examples of easing functions.
  5004. * @see https://easings.net/
  5005. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5006. * @returns the corresponding value on the curve defined by the easing function
  5007. */
  5008. ease(gradient: number): number;
  5009. }
  5010. /**
  5011. * Base class used for every default easing function.
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class EasingFunction implements IEasingFunction {
  5015. /**
  5016. * Interpolation follows the mathematical formula associated with the easing function.
  5017. */
  5018. static readonly EASINGMODE_EASEIN: number;
  5019. /**
  5020. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5021. */
  5022. static readonly EASINGMODE_EASEOUT: number;
  5023. /**
  5024. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5025. */
  5026. static readonly EASINGMODE_EASEINOUT: number;
  5027. private _easingMode;
  5028. /**
  5029. * Sets the easing mode of the current function.
  5030. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5031. */
  5032. setEasingMode(easingMode: number): void;
  5033. /**
  5034. * Gets the current easing mode.
  5035. * @returns the easing mode
  5036. */
  5037. getEasingMode(): number;
  5038. /**
  5039. * @hidden
  5040. */
  5041. easeInCore(gradient: number): number;
  5042. /**
  5043. * Given an input gradient between 0 and 1, this returns the corresponding value
  5044. * of the easing function.
  5045. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5046. * @returns the corresponding value on the curve defined by the easing function
  5047. */
  5048. ease(gradient: number): number;
  5049. }
  5050. /**
  5051. * Easing function with a circle shape (see link below).
  5052. * @see https://easings.net/#easeInCirc
  5053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5054. */
  5055. export class CircleEase extends EasingFunction implements IEasingFunction {
  5056. /** @hidden */
  5057. easeInCore(gradient: number): number;
  5058. }
  5059. /**
  5060. * Easing function with a ease back shape (see link below).
  5061. * @see https://easings.net/#easeInBack
  5062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5063. */
  5064. export class BackEase extends EasingFunction implements IEasingFunction {
  5065. /** Defines the amplitude of the function */
  5066. amplitude: number;
  5067. /**
  5068. * Instantiates a back ease easing
  5069. * @see https://easings.net/#easeInBack
  5070. * @param amplitude Defines the amplitude of the function
  5071. */
  5072. constructor(
  5073. /** Defines the amplitude of the function */
  5074. amplitude?: number);
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a bouncing shape (see link below).
  5080. * @see https://easings.net/#easeInBounce
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BounceEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the number of bounces */
  5085. bounces: number;
  5086. /** Defines the amplitude of the bounce */
  5087. bounciness: number;
  5088. /**
  5089. * Instantiates a bounce easing
  5090. * @see https://easings.net/#easeInBounce
  5091. * @param bounces Defines the number of bounces
  5092. * @param bounciness Defines the amplitude of the bounce
  5093. */
  5094. constructor(
  5095. /** Defines the number of bounces */
  5096. bounces?: number,
  5097. /** Defines the amplitude of the bounce */
  5098. bounciness?: number);
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 3 shape (see link below).
  5104. * @see https://easings.net/#easeInCubic
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class CubicEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with an elastic shape (see link below).
  5113. * @see https://easings.net/#easeInElastic
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5117. /** Defines the number of oscillations*/
  5118. oscillations: number;
  5119. /** Defines the amplitude of the oscillations*/
  5120. springiness: number;
  5121. /**
  5122. * Instantiates an elastic easing function
  5123. * @see https://easings.net/#easeInElastic
  5124. * @param oscillations Defines the number of oscillations
  5125. * @param springiness Defines the amplitude of the oscillations
  5126. */
  5127. constructor(
  5128. /** Defines the number of oscillations*/
  5129. oscillations?: number,
  5130. /** Defines the amplitude of the oscillations*/
  5131. springiness?: number);
  5132. /** @hidden */
  5133. easeInCore(gradient: number): number;
  5134. }
  5135. /**
  5136. * Easing function with an exponential shape (see link below).
  5137. * @see https://easings.net/#easeInExpo
  5138. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5139. */
  5140. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5141. /** Defines the exponent of the function */
  5142. exponent: number;
  5143. /**
  5144. * Instantiates an exponential easing function
  5145. * @see https://easings.net/#easeInExpo
  5146. * @param exponent Defines the exponent of the function
  5147. */
  5148. constructor(
  5149. /** Defines the exponent of the function */
  5150. exponent?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with a power shape (see link below).
  5156. * @see https://easings.net/#easeInQuad
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class PowerEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the power of the function */
  5161. power: number;
  5162. /**
  5163. * Instantiates an power base easing function
  5164. * @see https://easings.net/#easeInQuad
  5165. * @param power Defines the power of the function
  5166. */
  5167. constructor(
  5168. /** Defines the power of the function */
  5169. power?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 2 shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with a power of 4 shape (see link below).
  5184. * @see https://easings.net/#easeInQuart
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with a power of 5 shape (see link below).
  5193. * @see https://easings.net/#easeInQuint
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a sin shape (see link below).
  5202. * @see https://easings.net/#easeInSine
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class SineEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a bezier shape (see link below).
  5211. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the x component of the start tangent in the bezier curve */
  5216. x1: number;
  5217. /** Defines the y component of the start tangent in the bezier curve */
  5218. y1: number;
  5219. /** Defines the x component of the end tangent in the bezier curve */
  5220. x2: number;
  5221. /** Defines the y component of the end tangent in the bezier curve */
  5222. y2: number;
  5223. /**
  5224. * Instantiates a bezier function
  5225. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5226. * @param x1 Defines the x component of the start tangent in the bezier curve
  5227. * @param y1 Defines the y component of the start tangent in the bezier curve
  5228. * @param x2 Defines the x component of the end tangent in the bezier curve
  5229. * @param y2 Defines the y component of the end tangent in the bezier curve
  5230. */
  5231. constructor(
  5232. /** Defines the x component of the start tangent in the bezier curve */
  5233. x1?: number,
  5234. /** Defines the y component of the start tangent in the bezier curve */
  5235. y1?: number,
  5236. /** Defines the x component of the end tangent in the bezier curve */
  5237. x2?: number,
  5238. /** Defines the y component of the end tangent in the bezier curve */
  5239. y2?: number);
  5240. /** @hidden */
  5241. easeInCore(gradient: number): number;
  5242. }
  5243. }
  5244. declare module "babylonjs/Maths/math.color" {
  5245. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5246. /**
  5247. * Class used to hold a RBG color
  5248. */
  5249. export class Color3 {
  5250. /**
  5251. * Defines the red component (between 0 and 1, default is 0)
  5252. */
  5253. r: number;
  5254. /**
  5255. * Defines the green component (between 0 and 1, default is 0)
  5256. */
  5257. g: number;
  5258. /**
  5259. * Defines the blue component (between 0 and 1, default is 0)
  5260. */
  5261. b: number;
  5262. /**
  5263. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5264. * @param r defines the red component (between 0 and 1, default is 0)
  5265. * @param g defines the green component (between 0 and 1, default is 0)
  5266. * @param b defines the blue component (between 0 and 1, default is 0)
  5267. */
  5268. constructor(
  5269. /**
  5270. * Defines the red component (between 0 and 1, default is 0)
  5271. */
  5272. r?: number,
  5273. /**
  5274. * Defines the green component (between 0 and 1, default is 0)
  5275. */
  5276. g?: number,
  5277. /**
  5278. * Defines the blue component (between 0 and 1, default is 0)
  5279. */
  5280. b?: number);
  5281. /**
  5282. * Creates a string with the Color3 current values
  5283. * @returns the string representation of the Color3 object
  5284. */
  5285. toString(): string;
  5286. /**
  5287. * Returns the string "Color3"
  5288. * @returns "Color3"
  5289. */
  5290. getClassName(): string;
  5291. /**
  5292. * Compute the Color3 hash code
  5293. * @returns an unique number that can be used to hash Color3 objects
  5294. */
  5295. getHashCode(): number;
  5296. /**
  5297. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5298. * @param array defines the array where to store the r,g,b components
  5299. * @param index defines an optional index in the target array to define where to start storing values
  5300. * @returns the current Color3 object
  5301. */
  5302. toArray(array: FloatArray, index?: number): Color3;
  5303. /**
  5304. * Returns a new Color4 object from the current Color3 and the given alpha
  5305. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5306. * @returns a new Color4 object
  5307. */
  5308. toColor4(alpha?: number): Color4;
  5309. /**
  5310. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5311. * @returns the new array
  5312. */
  5313. asArray(): number[];
  5314. /**
  5315. * Returns the luminance value
  5316. * @returns a float value
  5317. */
  5318. toLuminance(): number;
  5319. /**
  5320. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5321. * @param otherColor defines the second operand
  5322. * @returns the new Color3 object
  5323. */
  5324. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5325. /**
  5326. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5327. * @param otherColor defines the second operand
  5328. * @param result defines the Color3 object where to store the result
  5329. * @returns the current Color3
  5330. */
  5331. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5332. /**
  5333. * Determines equality between Color3 objects
  5334. * @param otherColor defines the second operand
  5335. * @returns true if the rgb values are equal to the given ones
  5336. */
  5337. equals(otherColor: DeepImmutable<Color3>): boolean;
  5338. /**
  5339. * Determines equality between the current Color3 object and a set of r,b,g values
  5340. * @param r defines the red component to check
  5341. * @param g defines the green component to check
  5342. * @param b defines the blue component to check
  5343. * @returns true if the rgb values are equal to the given ones
  5344. */
  5345. equalsFloats(r: number, g: number, b: number): boolean;
  5346. /**
  5347. * Multiplies in place each rgb value by scale
  5348. * @param scale defines the scaling factor
  5349. * @returns the updated Color3
  5350. */
  5351. scale(scale: number): Color3;
  5352. /**
  5353. * Multiplies the rgb values by scale and stores the result into "result"
  5354. * @param scale defines the scaling factor
  5355. * @param result defines the Color3 object where to store the result
  5356. * @returns the unmodified current Color3
  5357. */
  5358. scaleToRef(scale: number, result: Color3): Color3;
  5359. /**
  5360. * Scale the current Color3 values by a factor and add the result to a given Color3
  5361. * @param scale defines the scale factor
  5362. * @param result defines color to store the result into
  5363. * @returns the unmodified current Color3
  5364. */
  5365. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5366. /**
  5367. * Clamps the rgb values by the min and max values and stores the result into "result"
  5368. * @param min defines minimum clamping value (default is 0)
  5369. * @param max defines maximum clamping value (default is 1)
  5370. * @param result defines color to store the result into
  5371. * @returns the original Color3
  5372. */
  5373. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5374. /**
  5375. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3
  5378. */
  5379. add(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines Color3 object to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5389. * @param otherColor defines the second operand
  5390. * @returns the new Color3
  5391. */
  5392. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5393. /**
  5394. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5395. * @param otherColor defines the second operand
  5396. * @param result defines Color3 object to store the result into
  5397. * @returns the unmodified current Color3
  5398. */
  5399. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5400. /**
  5401. * Copy the current object
  5402. * @returns a new Color3 copied the current one
  5403. */
  5404. clone(): Color3;
  5405. /**
  5406. * Copies the rgb values from the source in the current Color3
  5407. * @param source defines the source Color3 object
  5408. * @returns the updated Color3 object
  5409. */
  5410. copyFrom(source: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Updates the Color3 rgb values from the given floats
  5413. * @param r defines the red component to read from
  5414. * @param g defines the green component to read from
  5415. * @param b defines the blue component to read from
  5416. * @returns the current Color3 object
  5417. */
  5418. copyFromFloats(r: number, g: number, b: number): Color3;
  5419. /**
  5420. * Updates the Color3 rgb values from the given floats
  5421. * @param r defines the red component to read from
  5422. * @param g defines the green component to read from
  5423. * @param b defines the blue component to read from
  5424. * @returns the current Color3 object
  5425. */
  5426. set(r: number, g: number, b: number): Color3;
  5427. /**
  5428. * Compute the Color3 hexadecimal code as a string
  5429. * @returns a string containing the hexadecimal representation of the Color3 object
  5430. */
  5431. toHexString(): string;
  5432. /**
  5433. * Computes a new Color3 converted from the current one to linear space
  5434. * @returns a new Color3 object
  5435. */
  5436. toLinearSpace(): Color3;
  5437. /**
  5438. * Converts current color in rgb space to HSV values
  5439. * @returns a new color3 representing the HSV values
  5440. */
  5441. toHSV(): Color3;
  5442. /**
  5443. * Converts current color in rgb space to HSV values
  5444. * @param result defines the Color3 where to store the HSV values
  5445. */
  5446. toHSVToRef(result: Color3): void;
  5447. /**
  5448. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5449. * @param convertedColor defines the Color3 object where to store the linear space version
  5450. * @returns the unmodified Color3
  5451. */
  5452. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5453. /**
  5454. * Computes a new Color3 converted from the current one to gamma space
  5455. * @returns a new Color3 object
  5456. */
  5457. toGammaSpace(): Color3;
  5458. /**
  5459. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5460. * @param convertedColor defines the Color3 object where to store the gamma space version
  5461. * @returns the unmodified Color3
  5462. */
  5463. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5464. private static _BlackReadOnly;
  5465. /**
  5466. * Convert Hue, saturation and value to a Color3 (RGB)
  5467. * @param hue defines the hue
  5468. * @param saturation defines the saturation
  5469. * @param value defines the value
  5470. * @param result defines the Color3 where to store the RGB values
  5471. */
  5472. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5473. /**
  5474. * Creates a new Color3 from the string containing valid hexadecimal values
  5475. * @param hex defines a string containing valid hexadecimal values
  5476. * @returns a new Color3 object
  5477. */
  5478. static FromHexString(hex: string): Color3;
  5479. /**
  5480. * Creates a new Color3 from the starting index of the given array
  5481. * @param array defines the source array
  5482. * @param offset defines an offset in the source array
  5483. * @returns a new Color3 object
  5484. */
  5485. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5486. /**
  5487. * Creates a new Color3 from integer values (< 256)
  5488. * @param r defines the red component to read from (value between 0 and 255)
  5489. * @param g defines the green component to read from (value between 0 and 255)
  5490. * @param b defines the blue component to read from (value between 0 and 255)
  5491. * @returns a new Color3 object
  5492. */
  5493. static FromInts(r: number, g: number, b: number): Color3;
  5494. /**
  5495. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5496. * @param start defines the start Color3 value
  5497. * @param end defines the end Color3 value
  5498. * @param amount defines the gradient value between start and end
  5499. * @returns a new Color3 object
  5500. */
  5501. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5502. /**
  5503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5504. * @param left defines the start value
  5505. * @param right defines the end value
  5506. * @param amount defines the gradient factor
  5507. * @param result defines the Color3 object where to store the result
  5508. */
  5509. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5510. /**
  5511. * Returns a Color3 value containing a red color
  5512. * @returns a new Color3 object
  5513. */
  5514. static Red(): Color3;
  5515. /**
  5516. * Returns a Color3 value containing a green color
  5517. * @returns a new Color3 object
  5518. */
  5519. static Green(): Color3;
  5520. /**
  5521. * Returns a Color3 value containing a blue color
  5522. * @returns a new Color3 object
  5523. */
  5524. static Blue(): Color3;
  5525. /**
  5526. * Returns a Color3 value containing a black color
  5527. * @returns a new Color3 object
  5528. */
  5529. static Black(): Color3;
  5530. /**
  5531. * Gets a Color3 value containing a black color that must not be updated
  5532. */
  5533. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5534. /**
  5535. * Returns a Color3 value containing a white color
  5536. * @returns a new Color3 object
  5537. */
  5538. static White(): Color3;
  5539. /**
  5540. * Returns a Color3 value containing a purple color
  5541. * @returns a new Color3 object
  5542. */
  5543. static Purple(): Color3;
  5544. /**
  5545. * Returns a Color3 value containing a magenta color
  5546. * @returns a new Color3 object
  5547. */
  5548. static Magenta(): Color3;
  5549. /**
  5550. * Returns a Color3 value containing a yellow color
  5551. * @returns a new Color3 object
  5552. */
  5553. static Yellow(): Color3;
  5554. /**
  5555. * Returns a Color3 value containing a gray color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Gray(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a teal color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Teal(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a random color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Random(): Color3;
  5569. }
  5570. /**
  5571. * Class used to hold a RBGA color
  5572. */
  5573. export class Color4 {
  5574. /**
  5575. * Defines the red component (between 0 and 1, default is 0)
  5576. */
  5577. r: number;
  5578. /**
  5579. * Defines the green component (between 0 and 1, default is 0)
  5580. */
  5581. g: number;
  5582. /**
  5583. * Defines the blue component (between 0 and 1, default is 0)
  5584. */
  5585. b: number;
  5586. /**
  5587. * Defines the alpha component (between 0 and 1, default is 1)
  5588. */
  5589. a: number;
  5590. /**
  5591. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5592. * @param r defines the red component (between 0 and 1, default is 0)
  5593. * @param g defines the green component (between 0 and 1, default is 0)
  5594. * @param b defines the blue component (between 0 and 1, default is 0)
  5595. * @param a defines the alpha component (between 0 and 1, default is 1)
  5596. */
  5597. constructor(
  5598. /**
  5599. * Defines the red component (between 0 and 1, default is 0)
  5600. */
  5601. r?: number,
  5602. /**
  5603. * Defines the green component (between 0 and 1, default is 0)
  5604. */
  5605. g?: number,
  5606. /**
  5607. * Defines the blue component (between 0 and 1, default is 0)
  5608. */
  5609. b?: number,
  5610. /**
  5611. * Defines the alpha component (between 0 and 1, default is 1)
  5612. */
  5613. a?: number);
  5614. /**
  5615. * Adds in place the given Color4 values to the current Color4 object
  5616. * @param right defines the second operand
  5617. * @returns the current updated Color4 object
  5618. */
  5619. addInPlace(right: DeepImmutable<Color4>): Color4;
  5620. /**
  5621. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5622. * @returns the new array
  5623. */
  5624. asArray(): number[];
  5625. /**
  5626. * Stores from the starting index in the given array the Color4 successive values
  5627. * @param array defines the array where to store the r,g,b components
  5628. * @param index defines an optional index in the target array to define where to start storing values
  5629. * @returns the current Color4 object
  5630. */
  5631. toArray(array: number[], index?: number): Color4;
  5632. /**
  5633. * Determines equality between Color4 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgba values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color4>): boolean;
  5638. /**
  5639. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5640. * @param right defines the second operand
  5641. * @returns a new Color4 object
  5642. */
  5643. add(right: DeepImmutable<Color4>): Color4;
  5644. /**
  5645. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5646. * @param right defines the second operand
  5647. * @returns a new Color4 object
  5648. */
  5649. subtract(right: DeepImmutable<Color4>): Color4;
  5650. /**
  5651. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5652. * @param right defines the second operand
  5653. * @param result defines the Color4 object where to store the result
  5654. * @returns the current Color4 object
  5655. */
  5656. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5657. /**
  5658. * Creates a new Color4 with the current Color4 values multiplied by scale
  5659. * @param scale defines the scaling factor to apply
  5660. * @returns a new Color4 object
  5661. */
  5662. scale(scale: number): Color4;
  5663. /**
  5664. * Multiplies the current Color4 values by scale and stores the result in "result"
  5665. * @param scale defines the scaling factor to apply
  5666. * @param result defines the Color4 object where to store the result
  5667. * @returns the current unmodified Color4
  5668. */
  5669. scaleToRef(scale: number, result: Color4): Color4;
  5670. /**
  5671. * Scale the current Color4 values by a factor and add the result to a given Color4
  5672. * @param scale defines the scale factor
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the unmodified current Color4
  5675. */
  5676. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5677. /**
  5678. * Clamps the rgb values by the min and max values and stores the result into "result"
  5679. * @param min defines minimum clamping value (default is 0)
  5680. * @param max defines maximum clamping value (default is 1)
  5681. * @param result defines color to store the result into.
  5682. * @returns the cuurent Color4
  5683. */
  5684. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5685. /**
  5686. * Multipy an Color4 value by another and return a new Color4 object
  5687. * @param color defines the Color4 value to multiply by
  5688. * @returns a new Color4 object
  5689. */
  5690. multiply(color: Color4): Color4;
  5691. /**
  5692. * Multipy a Color4 value by another and push the result in a reference value
  5693. * @param color defines the Color4 value to multiply by
  5694. * @param result defines the Color4 to fill the result in
  5695. * @returns the result Color4
  5696. */
  5697. multiplyToRef(color: Color4, result: Color4): Color4;
  5698. /**
  5699. * Creates a string with the Color4 current values
  5700. * @returns the string representation of the Color4 object
  5701. */
  5702. toString(): string;
  5703. /**
  5704. * Returns the string "Color4"
  5705. * @returns "Color4"
  5706. */
  5707. getClassName(): string;
  5708. /**
  5709. * Compute the Color4 hash code
  5710. * @returns an unique number that can be used to hash Color4 objects
  5711. */
  5712. getHashCode(): number;
  5713. /**
  5714. * Creates a new Color4 copied from the current one
  5715. * @returns a new Color4 object
  5716. */
  5717. clone(): Color4;
  5718. /**
  5719. * Copies the given Color4 values into the current one
  5720. * @param source defines the source Color4 object
  5721. * @returns the current updated Color4 object
  5722. */
  5723. copyFrom(source: Color4): Color4;
  5724. /**
  5725. * Copies the given float values into the current one
  5726. * @param r defines the red component to read from
  5727. * @param g defines the green component to read from
  5728. * @param b defines the blue component to read from
  5729. * @param a defines the alpha component to read from
  5730. * @returns the current updated Color4 object
  5731. */
  5732. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5733. /**
  5734. * Copies the given float values into the current one
  5735. * @param r defines the red component to read from
  5736. * @param g defines the green component to read from
  5737. * @param b defines the blue component to read from
  5738. * @param a defines the alpha component to read from
  5739. * @returns the current updated Color4 object
  5740. */
  5741. set(r: number, g: number, b: number, a: number): Color4;
  5742. /**
  5743. * Compute the Color4 hexadecimal code as a string
  5744. * @returns a string containing the hexadecimal representation of the Color4 object
  5745. */
  5746. toHexString(): string;
  5747. /**
  5748. * Computes a new Color4 converted from the current one to linear space
  5749. * @returns a new Color4 object
  5750. */
  5751. toLinearSpace(): Color4;
  5752. /**
  5753. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5754. * @param convertedColor defines the Color4 object where to store the linear space version
  5755. * @returns the unmodified Color4
  5756. */
  5757. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5758. /**
  5759. * Computes a new Color4 converted from the current one to gamma space
  5760. * @returns a new Color4 object
  5761. */
  5762. toGammaSpace(): Color4;
  5763. /**
  5764. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5765. * @param convertedColor defines the Color4 object where to store the gamma space version
  5766. * @returns the unmodified Color4
  5767. */
  5768. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5769. /**
  5770. * Creates a new Color4 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color4 object
  5773. */
  5774. static FromHexString(hex: string): Color4;
  5775. /**
  5776. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5777. * @param left defines the start value
  5778. * @param right defines the end value
  5779. * @param amount defines the gradient factor
  5780. * @returns a new Color4 object
  5781. */
  5782. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5783. /**
  5784. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5785. * @param left defines the start value
  5786. * @param right defines the end value
  5787. * @param amount defines the gradient factor
  5788. * @param result defines the Color4 object where to store data
  5789. */
  5790. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5791. /**
  5792. * Creates a new Color4 from a Color3 and an alpha value
  5793. * @param color3 defines the source Color3 to read from
  5794. * @param alpha defines the alpha component (1.0 by default)
  5795. * @returns a new Color4 object
  5796. */
  5797. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5798. /**
  5799. * Creates a new Color4 from the starting index element of the given array
  5800. * @param array defines the source array to read from
  5801. * @param offset defines the offset in the source array
  5802. * @returns a new Color4 object
  5803. */
  5804. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5805. /**
  5806. * Creates a new Color3 from integer values (< 256)
  5807. * @param r defines the red component to read from (value between 0 and 255)
  5808. * @param g defines the green component to read from (value between 0 and 255)
  5809. * @param b defines the blue component to read from (value between 0 and 255)
  5810. * @param a defines the alpha component to read from (value between 0 and 255)
  5811. * @returns a new Color3 object
  5812. */
  5813. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5814. /**
  5815. * Check the content of a given array and convert it to an array containing RGBA data
  5816. * If the original array was already containing count * 4 values then it is returned directly
  5817. * @param colors defines the array to check
  5818. * @param count defines the number of RGBA data to expect
  5819. * @returns an array containing count * 4 values (RGBA)
  5820. */
  5821. static CheckColors4(colors: number[], count: number): number[];
  5822. }
  5823. /**
  5824. * @hidden
  5825. */
  5826. export class TmpColors {
  5827. static Color3: Color3[];
  5828. static Color4: Color4[];
  5829. }
  5830. }
  5831. declare module "babylonjs/Animations/animationKey" {
  5832. /**
  5833. * Defines an interface which represents an animation key frame
  5834. */
  5835. export interface IAnimationKey {
  5836. /**
  5837. * Frame of the key frame
  5838. */
  5839. frame: number;
  5840. /**
  5841. * Value at the specifies key frame
  5842. */
  5843. value: any;
  5844. /**
  5845. * The input tangent for the cubic hermite spline
  5846. */
  5847. inTangent?: any;
  5848. /**
  5849. * The output tangent for the cubic hermite spline
  5850. */
  5851. outTangent?: any;
  5852. /**
  5853. * The animation interpolation type
  5854. */
  5855. interpolation?: AnimationKeyInterpolation;
  5856. }
  5857. /**
  5858. * Enum for the animation key frame interpolation type
  5859. */
  5860. export enum AnimationKeyInterpolation {
  5861. /**
  5862. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5863. */
  5864. STEP = 1
  5865. }
  5866. }
  5867. declare module "babylonjs/Animations/animationRange" {
  5868. /**
  5869. * Represents the range of an animation
  5870. */
  5871. export class AnimationRange {
  5872. /**The name of the animation range**/
  5873. name: string;
  5874. /**The starting frame of the animation */
  5875. from: number;
  5876. /**The ending frame of the animation*/
  5877. to: number;
  5878. /**
  5879. * Initializes the range of an animation
  5880. * @param name The name of the animation range
  5881. * @param from The starting frame of the animation
  5882. * @param to The ending frame of the animation
  5883. */
  5884. constructor(
  5885. /**The name of the animation range**/
  5886. name: string,
  5887. /**The starting frame of the animation */
  5888. from: number,
  5889. /**The ending frame of the animation*/
  5890. to: number);
  5891. /**
  5892. * Makes a copy of the animation range
  5893. * @returns A copy of the animation range
  5894. */
  5895. clone(): AnimationRange;
  5896. }
  5897. }
  5898. declare module "babylonjs/Animations/animationEvent" {
  5899. /**
  5900. * Composed of a frame, and an action function
  5901. */
  5902. export class AnimationEvent {
  5903. /** The frame for which the event is triggered **/
  5904. frame: number;
  5905. /** The event to perform when triggered **/
  5906. action: (currentFrame: number) => void;
  5907. /** Specifies if the event should be triggered only once**/
  5908. onlyOnce?: boolean | undefined;
  5909. /**
  5910. * Specifies if the animation event is done
  5911. */
  5912. isDone: boolean;
  5913. /**
  5914. * Initializes the animation event
  5915. * @param frame The frame for which the event is triggered
  5916. * @param action The event to perform when triggered
  5917. * @param onlyOnce Specifies if the event should be triggered only once
  5918. */
  5919. constructor(
  5920. /** The frame for which the event is triggered **/
  5921. frame: number,
  5922. /** The event to perform when triggered **/
  5923. action: (currentFrame: number) => void,
  5924. /** Specifies if the event should be triggered only once**/
  5925. onlyOnce?: boolean | undefined);
  5926. /** @hidden */
  5927. _clone(): AnimationEvent;
  5928. }
  5929. }
  5930. declare module "babylonjs/Behaviors/behavior" {
  5931. import { Nullable } from "babylonjs/types";
  5932. /**
  5933. * Interface used to define a behavior
  5934. */
  5935. export interface Behavior<T> {
  5936. /** gets or sets behavior's name */
  5937. name: string;
  5938. /**
  5939. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5940. */
  5941. init(): void;
  5942. /**
  5943. * Called when the behavior is attached to a target
  5944. * @param target defines the target where the behavior is attached to
  5945. */
  5946. attach(target: T): void;
  5947. /**
  5948. * Called when the behavior is detached from its target
  5949. */
  5950. detach(): void;
  5951. }
  5952. /**
  5953. * Interface implemented by classes supporting behaviors
  5954. */
  5955. export interface IBehaviorAware<T> {
  5956. /**
  5957. * Attach a behavior
  5958. * @param behavior defines the behavior to attach
  5959. * @returns the current host
  5960. */
  5961. addBehavior(behavior: Behavior<T>): T;
  5962. /**
  5963. * Remove a behavior from the current object
  5964. * @param behavior defines the behavior to detach
  5965. * @returns the current host
  5966. */
  5967. removeBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Gets a behavior using its name to search
  5970. * @param name defines the name to search
  5971. * @returns the behavior or null if not found
  5972. */
  5973. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5974. }
  5975. }
  5976. declare module "babylonjs/Misc/smartArray" {
  5977. /**
  5978. * Defines an array and its length.
  5979. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5980. */
  5981. export interface ISmartArrayLike<T> {
  5982. /**
  5983. * The data of the array.
  5984. */
  5985. data: Array<T>;
  5986. /**
  5987. * The active length of the array.
  5988. */
  5989. length: number;
  5990. }
  5991. /**
  5992. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5993. */
  5994. export class SmartArray<T> implements ISmartArrayLike<T> {
  5995. /**
  5996. * The full set of data from the array.
  5997. */
  5998. data: Array<T>;
  5999. /**
  6000. * The active length of the array.
  6001. */
  6002. length: number;
  6003. protected _id: number;
  6004. /**
  6005. * Instantiates a Smart Array.
  6006. * @param capacity defines the default capacity of the array.
  6007. */
  6008. constructor(capacity: number);
  6009. /**
  6010. * Pushes a value at the end of the active data.
  6011. * @param value defines the object to push in the array.
  6012. */
  6013. push(value: T): void;
  6014. /**
  6015. * Iterates over the active data and apply the lambda to them.
  6016. * @param func defines the action to apply on each value.
  6017. */
  6018. forEach(func: (content: T) => void): void;
  6019. /**
  6020. * Sorts the full sets of data.
  6021. * @param compareFn defines the comparison function to apply.
  6022. */
  6023. sort(compareFn: (a: T, b: T) => number): void;
  6024. /**
  6025. * Resets the active data to an empty array.
  6026. */
  6027. reset(): void;
  6028. /**
  6029. * Releases all the data from the array as well as the array.
  6030. */
  6031. dispose(): void;
  6032. /**
  6033. * Concats the active data with a given array.
  6034. * @param array defines the data to concatenate with.
  6035. */
  6036. concat(array: any): void;
  6037. /**
  6038. * Returns the position of a value in the active data.
  6039. * @param value defines the value to find the index for
  6040. * @returns the index if found in the active data otherwise -1
  6041. */
  6042. indexOf(value: T): number;
  6043. /**
  6044. * Returns whether an element is part of the active data.
  6045. * @param value defines the value to look for
  6046. * @returns true if found in the active data otherwise false
  6047. */
  6048. contains(value: T): boolean;
  6049. private static _GlobalId;
  6050. }
  6051. /**
  6052. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6053. * The data in this array can only be present once
  6054. */
  6055. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6056. private _duplicateId;
  6057. /**
  6058. * Pushes a value at the end of the active data.
  6059. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6060. * @param value defines the object to push in the array.
  6061. */
  6062. push(value: T): void;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * If the data is already present, it won t be added again
  6066. * @param value defines the object to push in the array.
  6067. * @returns true if added false if it was already present
  6068. */
  6069. pushNoDuplicate(value: T): boolean;
  6070. /**
  6071. * Resets the active data to an empty array.
  6072. */
  6073. reset(): void;
  6074. /**
  6075. * Concats the active data with a given array.
  6076. * This ensures no dupplicate will be present in the result.
  6077. * @param array defines the data to concatenate with.
  6078. */
  6079. concatWithNoDuplicate(array: any): void;
  6080. }
  6081. }
  6082. declare module "babylonjs/Cameras/cameraInputsManager" {
  6083. import { Nullable } from "babylonjs/types";
  6084. import { Camera } from "babylonjs/Cameras/camera";
  6085. /**
  6086. * @ignore
  6087. * This is a list of all the different input types that are available in the application.
  6088. * Fo instance: ArcRotateCameraGamepadInput...
  6089. */
  6090. export var CameraInputTypes: {};
  6091. /**
  6092. * This is the contract to implement in order to create a new input class.
  6093. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6094. */
  6095. export interface ICameraInput<TCamera extends Camera> {
  6096. /**
  6097. * Defines the camera the input is attached to.
  6098. */
  6099. camera: Nullable<TCamera>;
  6100. /**
  6101. * Gets the class name of the current intput.
  6102. * @returns the class name
  6103. */
  6104. getClassName(): string;
  6105. /**
  6106. * Get the friendly name associated with the input class.
  6107. * @returns the input friendly name
  6108. */
  6109. getSimpleName(): string;
  6110. /**
  6111. * Attach the input controls to a specific dom element to get the input from.
  6112. * @param element Defines the element the controls should be listened from
  6113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6114. */
  6115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6116. /**
  6117. * Detach the current controls from the specified dom element.
  6118. * @param element Defines the element to stop listening the inputs from
  6119. */
  6120. detachControl(element: Nullable<HTMLElement>): void;
  6121. /**
  6122. * Update the current camera state depending on the inputs that have been used this frame.
  6123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6124. */
  6125. checkInputs?: () => void;
  6126. }
  6127. /**
  6128. * Represents a map of input types to input instance or input index to input instance.
  6129. */
  6130. export interface CameraInputsMap<TCamera extends Camera> {
  6131. /**
  6132. * Accessor to the input by input type.
  6133. */
  6134. [name: string]: ICameraInput<TCamera>;
  6135. /**
  6136. * Accessor to the input by input index.
  6137. */
  6138. [idx: number]: ICameraInput<TCamera>;
  6139. }
  6140. /**
  6141. * This represents the input manager used within a camera.
  6142. * It helps dealing with all the different kind of input attached to a camera.
  6143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6144. */
  6145. export class CameraInputsManager<TCamera extends Camera> {
  6146. /**
  6147. * Defines the list of inputs attahed to the camera.
  6148. */
  6149. attached: CameraInputsMap<TCamera>;
  6150. /**
  6151. * Defines the dom element the camera is collecting inputs from.
  6152. * This is null if the controls have not been attached.
  6153. */
  6154. attachedElement: Nullable<HTMLElement>;
  6155. /**
  6156. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6157. */
  6158. noPreventDefault: boolean;
  6159. /**
  6160. * Defined the camera the input manager belongs to.
  6161. */
  6162. camera: TCamera;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs: () => void;
  6168. /**
  6169. * Instantiate a new Camera Input Manager.
  6170. * @param camera Defines the camera the input manager blongs to
  6171. */
  6172. constructor(camera: TCamera);
  6173. /**
  6174. * Add an input method to a camera
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. * @param input camera input method
  6177. */
  6178. add(input: ICameraInput<TCamera>): void;
  6179. /**
  6180. * Remove a specific input method from a camera
  6181. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6182. * @param inputToRemove camera input method
  6183. */
  6184. remove(inputToRemove: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input type from a camera
  6187. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6188. * @param inputType the type of the input to remove
  6189. */
  6190. removeByType(inputType: string): void;
  6191. private _addCheckInputs;
  6192. /**
  6193. * Attach the input controls to the currently attached dom element to listen the events from.
  6194. * @param input Defines the input to attach
  6195. */
  6196. attachInput(input: ICameraInput<TCamera>): void;
  6197. /**
  6198. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6199. * @param element Defines the dom element to collect the events from
  6200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6201. */
  6202. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6203. /**
  6204. * Detach the current manager inputs controls from a specific dom element.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6207. */
  6208. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6209. /**
  6210. * Rebuild the dynamic inputCheck function from the current list of
  6211. * defined inputs in the manager.
  6212. */
  6213. rebuildInputCheck(): void;
  6214. /**
  6215. * Remove all attached input methods from a camera
  6216. */
  6217. clear(): void;
  6218. /**
  6219. * Serialize the current input manager attached to a camera.
  6220. * This ensures than once parsed,
  6221. * the input associated to the camera will be identical to the current ones
  6222. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6223. */
  6224. serialize(serializedCamera: any): void;
  6225. /**
  6226. * Parses an input manager serialized JSON to restore the previous list of inputs
  6227. * and states associated to a camera.
  6228. * @param parsedCamera Defines the JSON to parse
  6229. */
  6230. parse(parsedCamera: any): void;
  6231. }
  6232. }
  6233. declare module "babylonjs/Meshes/buffer" {
  6234. import { Nullable, DataArray } from "babylonjs/types";
  6235. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6236. /**
  6237. * Class used to store data that will be store in GPU memory
  6238. */
  6239. export class Buffer {
  6240. private _engine;
  6241. private _buffer;
  6242. /** @hidden */
  6243. _data: Nullable<DataArray>;
  6244. private _updatable;
  6245. private _instanced;
  6246. private _divisor;
  6247. /**
  6248. * Gets the byte stride.
  6249. */
  6250. readonly byteStride: number;
  6251. /**
  6252. * Constructor
  6253. * @param engine the engine
  6254. * @param data the data to use for this buffer
  6255. * @param updatable whether the data is updatable
  6256. * @param stride the stride (optional)
  6257. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6258. * @param instanced whether the buffer is instanced (optional)
  6259. * @param useBytes set to true if the stride in in bytes (optional)
  6260. * @param divisor sets an optional divisor for instances (1 by default)
  6261. */
  6262. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6263. /**
  6264. * Create a new VertexBuffer based on the current buffer
  6265. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6266. * @param offset defines offset in the buffer (0 by default)
  6267. * @param size defines the size in floats of attributes (position is 3 for instance)
  6268. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6269. * @param instanced defines if the vertex buffer contains indexed data
  6270. * @param useBytes defines if the offset and stride are in bytes *
  6271. * @param divisor sets an optional divisor for instances (1 by default)
  6272. * @returns the new vertex buffer
  6273. */
  6274. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6275. /**
  6276. * Gets a boolean indicating if the Buffer is updatable?
  6277. * @returns true if the buffer is updatable
  6278. */
  6279. isUpdatable(): boolean;
  6280. /**
  6281. * Gets current buffer's data
  6282. * @returns a DataArray or null
  6283. */
  6284. getData(): Nullable<DataArray>;
  6285. /**
  6286. * Gets underlying native buffer
  6287. * @returns underlying native buffer
  6288. */
  6289. getBuffer(): Nullable<DataBuffer>;
  6290. /**
  6291. * Gets the stride in float32 units (i.e. byte stride / 4).
  6292. * May not be an integer if the byte stride is not divisible by 4.
  6293. * DEPRECATED. Use byteStride instead.
  6294. * @returns the stride in float32 units
  6295. */
  6296. getStrideSize(): number;
  6297. /**
  6298. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6299. * @param data defines the data to store
  6300. */
  6301. create(data?: Nullable<DataArray>): void;
  6302. /** @hidden */
  6303. _rebuild(): void;
  6304. /**
  6305. * Update current buffer data
  6306. * @param data defines the data to store
  6307. */
  6308. update(data: DataArray): void;
  6309. /**
  6310. * Updates the data directly.
  6311. * @param data the new data
  6312. * @param offset the new offset
  6313. * @param vertexCount the vertex count (optional)
  6314. * @param useBytes set to true if the offset is in bytes
  6315. */
  6316. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6317. /**
  6318. * Release all resources
  6319. */
  6320. dispose(): void;
  6321. }
  6322. /**
  6323. * Specialized buffer used to store vertex data
  6324. */
  6325. export class VertexBuffer {
  6326. /** @hidden */
  6327. _buffer: Buffer;
  6328. private _kind;
  6329. private _size;
  6330. private _ownsBuffer;
  6331. private _instanced;
  6332. private _instanceDivisor;
  6333. /**
  6334. * The byte type.
  6335. */
  6336. static readonly BYTE: number;
  6337. /**
  6338. * The unsigned byte type.
  6339. */
  6340. static readonly UNSIGNED_BYTE: number;
  6341. /**
  6342. * The short type.
  6343. */
  6344. static readonly SHORT: number;
  6345. /**
  6346. * The unsigned short type.
  6347. */
  6348. static readonly UNSIGNED_SHORT: number;
  6349. /**
  6350. * The integer type.
  6351. */
  6352. static readonly INT: number;
  6353. /**
  6354. * The unsigned integer type.
  6355. */
  6356. static readonly UNSIGNED_INT: number;
  6357. /**
  6358. * The float type.
  6359. */
  6360. static readonly FLOAT: number;
  6361. /**
  6362. * Gets or sets the instance divisor when in instanced mode
  6363. */
  6364. instanceDivisor: number;
  6365. /**
  6366. * Gets the byte stride.
  6367. */
  6368. readonly byteStride: number;
  6369. /**
  6370. * Gets the byte offset.
  6371. */
  6372. readonly byteOffset: number;
  6373. /**
  6374. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6375. */
  6376. readonly normalized: boolean;
  6377. /**
  6378. * Gets the data type of each component in the array.
  6379. */
  6380. readonly type: number;
  6381. /**
  6382. * Constructor
  6383. * @param engine the engine
  6384. * @param data the data to use for this vertex buffer
  6385. * @param kind the vertex buffer kind
  6386. * @param updatable whether the data is updatable
  6387. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6388. * @param stride the stride (optional)
  6389. * @param instanced whether the buffer is instanced (optional)
  6390. * @param offset the offset of the data (optional)
  6391. * @param size the number of components (optional)
  6392. * @param type the type of the component (optional)
  6393. * @param normalized whether the data contains normalized data (optional)
  6394. * @param useBytes set to true if stride and offset are in bytes (optional)
  6395. * @param divisor defines the instance divisor to use (1 by default)
  6396. */
  6397. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6398. /** @hidden */
  6399. _rebuild(): void;
  6400. /**
  6401. * Returns the kind of the VertexBuffer (string)
  6402. * @returns a string
  6403. */
  6404. getKind(): string;
  6405. /**
  6406. * Gets a boolean indicating if the VertexBuffer is updatable?
  6407. * @returns true if the buffer is updatable
  6408. */
  6409. isUpdatable(): boolean;
  6410. /**
  6411. * Gets current buffer's data
  6412. * @returns a DataArray or null
  6413. */
  6414. getData(): Nullable<DataArray>;
  6415. /**
  6416. * Gets underlying native buffer
  6417. * @returns underlying native buffer
  6418. */
  6419. getBuffer(): Nullable<DataBuffer>;
  6420. /**
  6421. * Gets the stride in float32 units (i.e. byte stride / 4).
  6422. * May not be an integer if the byte stride is not divisible by 4.
  6423. * DEPRECATED. Use byteStride instead.
  6424. * @returns the stride in float32 units
  6425. */
  6426. getStrideSize(): number;
  6427. /**
  6428. * Returns the offset as a multiple of the type byte length.
  6429. * DEPRECATED. Use byteOffset instead.
  6430. * @returns the offset in bytes
  6431. */
  6432. getOffset(): number;
  6433. /**
  6434. * Returns the number of components per vertex attribute (integer)
  6435. * @returns the size in float
  6436. */
  6437. getSize(): number;
  6438. /**
  6439. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6440. * @returns true if this buffer is instanced
  6441. */
  6442. getIsInstanced(): boolean;
  6443. /**
  6444. * Returns the instancing divisor, zero for non-instanced (integer).
  6445. * @returns a number
  6446. */
  6447. getInstanceDivisor(): number;
  6448. /**
  6449. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6450. * @param data defines the data to store
  6451. */
  6452. create(data?: DataArray): void;
  6453. /**
  6454. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6455. * This function will create a new buffer if the current one is not updatable
  6456. * @param data defines the data to store
  6457. */
  6458. update(data: DataArray): void;
  6459. /**
  6460. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6461. * Returns the directly updated WebGLBuffer.
  6462. * @param data the new data
  6463. * @param offset the new offset
  6464. * @param useBytes set to true if the offset is in bytes
  6465. */
  6466. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6467. /**
  6468. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6469. */
  6470. dispose(): void;
  6471. /**
  6472. * Enumerates each value of this vertex buffer as numbers.
  6473. * @param count the number of values to enumerate
  6474. * @param callback the callback function called for each value
  6475. */
  6476. forEach(count: number, callback: (value: number, index: number) => void): void;
  6477. /**
  6478. * Positions
  6479. */
  6480. static readonly PositionKind: string;
  6481. /**
  6482. * Normals
  6483. */
  6484. static readonly NormalKind: string;
  6485. /**
  6486. * Tangents
  6487. */
  6488. static readonly TangentKind: string;
  6489. /**
  6490. * Texture coordinates
  6491. */
  6492. static readonly UVKind: string;
  6493. /**
  6494. * Texture coordinates 2
  6495. */
  6496. static readonly UV2Kind: string;
  6497. /**
  6498. * Texture coordinates 3
  6499. */
  6500. static readonly UV3Kind: string;
  6501. /**
  6502. * Texture coordinates 4
  6503. */
  6504. static readonly UV4Kind: string;
  6505. /**
  6506. * Texture coordinates 5
  6507. */
  6508. static readonly UV5Kind: string;
  6509. /**
  6510. * Texture coordinates 6
  6511. */
  6512. static readonly UV6Kind: string;
  6513. /**
  6514. * Colors
  6515. */
  6516. static readonly ColorKind: string;
  6517. /**
  6518. * Matrix indices (for bones)
  6519. */
  6520. static readonly MatricesIndicesKind: string;
  6521. /**
  6522. * Matrix weights (for bones)
  6523. */
  6524. static readonly MatricesWeightsKind: string;
  6525. /**
  6526. * Additional matrix indices (for bones)
  6527. */
  6528. static readonly MatricesIndicesExtraKind: string;
  6529. /**
  6530. * Additional matrix weights (for bones)
  6531. */
  6532. static readonly MatricesWeightsExtraKind: string;
  6533. /**
  6534. * Deduces the stride given a kind.
  6535. * @param kind The kind string to deduce
  6536. * @returns The deduced stride
  6537. */
  6538. static DeduceStride(kind: string): number;
  6539. /**
  6540. * Gets the byte length of the given type.
  6541. * @param type the type
  6542. * @returns the number of bytes
  6543. */
  6544. static GetTypeByteLength(type: number): number;
  6545. /**
  6546. * Enumerates each value of the given parameters as numbers.
  6547. * @param data the data to enumerate
  6548. * @param byteOffset the byte offset of the data
  6549. * @param byteStride the byte stride of the data
  6550. * @param componentCount the number of components per element
  6551. * @param componentType the type of the component
  6552. * @param count the number of values to enumerate
  6553. * @param normalized whether the data is normalized
  6554. * @param callback the callback function called for each value
  6555. */
  6556. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6557. private static _GetFloatValue;
  6558. }
  6559. }
  6560. declare module "babylonjs/Collisions/intersectionInfo" {
  6561. import { Nullable } from "babylonjs/types";
  6562. /**
  6563. * @hidden
  6564. */
  6565. export class IntersectionInfo {
  6566. bu: Nullable<number>;
  6567. bv: Nullable<number>;
  6568. distance: number;
  6569. faceId: number;
  6570. subMeshId: number;
  6571. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6572. }
  6573. }
  6574. declare module "babylonjs/Maths/math.plane" {
  6575. import { DeepImmutable } from "babylonjs/types";
  6576. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6577. /**
  6578. * Represens a plane by the equation ax + by + cz + d = 0
  6579. */
  6580. export class Plane {
  6581. private static _TmpMatrix;
  6582. /**
  6583. * Normal of the plane (a,b,c)
  6584. */
  6585. normal: Vector3;
  6586. /**
  6587. * d component of the plane
  6588. */
  6589. d: number;
  6590. /**
  6591. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6592. * @param a a component of the plane
  6593. * @param b b component of the plane
  6594. * @param c c component of the plane
  6595. * @param d d component of the plane
  6596. */
  6597. constructor(a: number, b: number, c: number, d: number);
  6598. /**
  6599. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6600. */
  6601. asArray(): number[];
  6602. /**
  6603. * @returns a new plane copied from the current Plane.
  6604. */
  6605. clone(): Plane;
  6606. /**
  6607. * @returns the string "Plane".
  6608. */
  6609. getClassName(): string;
  6610. /**
  6611. * @returns the Plane hash code.
  6612. */
  6613. getHashCode(): number;
  6614. /**
  6615. * Normalize the current Plane in place.
  6616. * @returns the updated Plane.
  6617. */
  6618. normalize(): Plane;
  6619. /**
  6620. * Applies a transformation the plane and returns the result
  6621. * @param transformation the transformation matrix to be applied to the plane
  6622. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6623. */
  6624. transform(transformation: DeepImmutable<Matrix>): Plane;
  6625. /**
  6626. * Calcualtte the dot product between the point and the plane normal
  6627. * @param point point to calculate the dot product with
  6628. * @returns the dot product (float) of the point coordinates and the plane normal.
  6629. */
  6630. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6631. /**
  6632. * Updates the current Plane from the plane defined by the three given points.
  6633. * @param point1 one of the points used to contruct the plane
  6634. * @param point2 one of the points used to contruct the plane
  6635. * @param point3 one of the points used to contruct the plane
  6636. * @returns the updated Plane.
  6637. */
  6638. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6639. /**
  6640. * Checks if the plane is facing a given direction
  6641. * @param direction the direction to check if the plane is facing
  6642. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6643. * @returns True is the vector "direction" is the same side than the plane normal.
  6644. */
  6645. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6646. /**
  6647. * Calculates the distance to a point
  6648. * @param point point to calculate distance to
  6649. * @returns the signed distance (float) from the given point to the Plane.
  6650. */
  6651. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6652. /**
  6653. * Creates a plane from an array
  6654. * @param array the array to create a plane from
  6655. * @returns a new Plane from the given array.
  6656. */
  6657. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6658. /**
  6659. * Creates a plane from three points
  6660. * @param point1 point used to create the plane
  6661. * @param point2 point used to create the plane
  6662. * @param point3 point used to create the plane
  6663. * @returns a new Plane defined by the three given points.
  6664. */
  6665. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6666. /**
  6667. * Creates a plane from an origin point and a normal
  6668. * @param origin origin of the plane to be constructed
  6669. * @param normal normal of the plane to be constructed
  6670. * @returns a new Plane the normal vector to this plane at the given origin point.
  6671. * Note : the vector "normal" is updated because normalized.
  6672. */
  6673. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6674. /**
  6675. * Calculates the distance from a plane and a point
  6676. * @param origin origin of the plane to be constructed
  6677. * @param normal normal of the plane to be constructed
  6678. * @param point point to calculate distance to
  6679. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6680. */
  6681. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingSphere" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { Plane } from "babylonjs/Maths/math.plane";
  6688. /**
  6689. * Class used to store bounding sphere information
  6690. */
  6691. export class BoundingSphere {
  6692. /**
  6693. * Gets the center of the bounding sphere in local space
  6694. */
  6695. readonly center: Vector3;
  6696. /**
  6697. * Radius of the bounding sphere in local space
  6698. */
  6699. radius: number;
  6700. /**
  6701. * Gets the center of the bounding sphere in world space
  6702. */
  6703. readonly centerWorld: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in world space
  6706. */
  6707. radiusWorld: number;
  6708. /**
  6709. * Gets the minimum vector in local space
  6710. */
  6711. readonly minimum: Vector3;
  6712. /**
  6713. * Gets the maximum vector in local space
  6714. */
  6715. readonly maximum: Vector3;
  6716. private _worldMatrix;
  6717. private static readonly TmpVector3;
  6718. /**
  6719. * Creates a new bounding sphere
  6720. * @param min defines the minimum vector (in local space)
  6721. * @param max defines the maximum vector (in local space)
  6722. * @param worldMatrix defines the new world matrix
  6723. */
  6724. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6725. /**
  6726. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6727. * @param min defines the new minimum vector (in local space)
  6728. * @param max defines the new maximum vector (in local space)
  6729. * @param worldMatrix defines the new world matrix
  6730. */
  6731. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6732. /**
  6733. * Scale the current bounding sphere by applying a scale factor
  6734. * @param factor defines the scale factor to apply
  6735. * @returns the current bounding box
  6736. */
  6737. scale(factor: number): BoundingSphere;
  6738. /**
  6739. * Gets the world matrix of the bounding box
  6740. * @returns a matrix
  6741. */
  6742. getWorldMatrix(): DeepImmutable<Matrix>;
  6743. /** @hidden */
  6744. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6745. /**
  6746. * Tests if the bounding sphere is intersecting the frustum planes
  6747. * @param frustumPlanes defines the frustum planes to test
  6748. * @returns true if there is an intersection
  6749. */
  6750. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6751. /**
  6752. * Tests if the bounding sphere center is in between the frustum planes.
  6753. * Used for optimistic fast inclusion.
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @returns true if the sphere center is in between the frustum planes
  6756. */
  6757. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if a point is inside the bounding sphere
  6760. * @param point defines the point to test
  6761. * @returns true if the point is inside the bounding sphere
  6762. */
  6763. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6764. /**
  6765. * Checks if two sphere intersct
  6766. * @param sphere0 sphere 0
  6767. * @param sphere1 sphere 1
  6768. * @returns true if the speres intersect
  6769. */
  6770. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6771. }
  6772. }
  6773. declare module "babylonjs/Culling/boundingBox" {
  6774. import { DeepImmutable } from "babylonjs/types";
  6775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6776. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6777. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /**
  6780. * Class used to store bounding box information
  6781. */
  6782. export class BoundingBox implements ICullable {
  6783. /**
  6784. * Gets the 8 vectors representing the bounding box in local space
  6785. */
  6786. readonly vectors: Vector3[];
  6787. /**
  6788. * Gets the center of the bounding box in local space
  6789. */
  6790. readonly center: Vector3;
  6791. /**
  6792. * Gets the center of the bounding box in world space
  6793. */
  6794. readonly centerWorld: Vector3;
  6795. /**
  6796. * Gets the extend size in local space
  6797. */
  6798. readonly extendSize: Vector3;
  6799. /**
  6800. * Gets the extend size in world space
  6801. */
  6802. readonly extendSizeWorld: Vector3;
  6803. /**
  6804. * Gets the OBB (object bounding box) directions
  6805. */
  6806. readonly directions: Vector3[];
  6807. /**
  6808. * Gets the 8 vectors representing the bounding box in world space
  6809. */
  6810. readonly vectorsWorld: Vector3[];
  6811. /**
  6812. * Gets the minimum vector in world space
  6813. */
  6814. readonly minimumWorld: Vector3;
  6815. /**
  6816. * Gets the maximum vector in world space
  6817. */
  6818. readonly maximumWorld: Vector3;
  6819. /**
  6820. * Gets the minimum vector in local space
  6821. */
  6822. readonly minimum: Vector3;
  6823. /**
  6824. * Gets the maximum vector in local space
  6825. */
  6826. readonly maximum: Vector3;
  6827. private _worldMatrix;
  6828. private static readonly TmpVector3;
  6829. /**
  6830. * @hidden
  6831. */
  6832. _tag: number;
  6833. /**
  6834. * Creates a new bounding box
  6835. * @param min defines the minimum vector (in local space)
  6836. * @param max defines the maximum vector (in local space)
  6837. * @param worldMatrix defines the new world matrix
  6838. */
  6839. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6840. /**
  6841. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6842. * @param min defines the new minimum vector (in local space)
  6843. * @param max defines the new maximum vector (in local space)
  6844. * @param worldMatrix defines the new world matrix
  6845. */
  6846. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6847. /**
  6848. * Scale the current bounding box by applying a scale factor
  6849. * @param factor defines the scale factor to apply
  6850. * @returns the current bounding box
  6851. */
  6852. scale(factor: number): BoundingBox;
  6853. /**
  6854. * Gets the world matrix of the bounding box
  6855. * @returns a matrix
  6856. */
  6857. getWorldMatrix(): DeepImmutable<Matrix>;
  6858. /** @hidden */
  6859. _update(world: DeepImmutable<Matrix>): void;
  6860. /**
  6861. * Tests if the bounding box is intersecting the frustum planes
  6862. * @param frustumPlanes defines the frustum planes to test
  6863. * @returns true if there is an intersection
  6864. */
  6865. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6866. /**
  6867. * Tests if the bounding box is entirely inside the frustum planes
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @returns true if there is an inclusion
  6870. */
  6871. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. /**
  6873. * Tests if a point is inside the bounding box
  6874. * @param point defines the point to test
  6875. * @returns true if the point is inside the bounding box
  6876. */
  6877. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6878. /**
  6879. * Tests if the bounding box intersects with a bounding sphere
  6880. * @param sphere defines the sphere to test
  6881. * @returns true if there is an intersection
  6882. */
  6883. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6884. /**
  6885. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6886. * @param min defines the min vector to use
  6887. * @param max defines the max vector to use
  6888. * @returns true if there is an intersection
  6889. */
  6890. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6891. /**
  6892. * Tests if two bounding boxes are intersections
  6893. * @param box0 defines the first box to test
  6894. * @param box1 defines the second box to test
  6895. * @returns true if there is an intersection
  6896. */
  6897. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6898. /**
  6899. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6900. * @param minPoint defines the minimum vector of the bounding box
  6901. * @param maxPoint defines the maximum vector of the bounding box
  6902. * @param sphereCenter defines the sphere center
  6903. * @param sphereRadius defines the sphere radius
  6904. * @returns true if there is an intersection
  6905. */
  6906. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6907. /**
  6908. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6909. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6910. * @param frustumPlanes defines the frustum planes to test
  6911. * @return true if there is an inclusion
  6912. */
  6913. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6914. /**
  6915. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6916. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6917. * @param frustumPlanes defines the frustum planes to test
  6918. * @return true if there is an intersection
  6919. */
  6920. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6921. }
  6922. }
  6923. declare module "babylonjs/Collisions/collider" {
  6924. import { Nullable, IndicesArray } from "babylonjs/types";
  6925. import { Vector3 } from "babylonjs/Maths/math.vector";
  6926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6927. import { Plane } from "babylonjs/Maths/math.plane";
  6928. /** @hidden */
  6929. export class Collider {
  6930. /** Define if a collision was found */
  6931. collisionFound: boolean;
  6932. /**
  6933. * Define last intersection point in local space
  6934. */
  6935. intersectionPoint: Vector3;
  6936. /**
  6937. * Define last collided mesh
  6938. */
  6939. collidedMesh: Nullable<AbstractMesh>;
  6940. private _collisionPoint;
  6941. private _planeIntersectionPoint;
  6942. private _tempVector;
  6943. private _tempVector2;
  6944. private _tempVector3;
  6945. private _tempVector4;
  6946. private _edge;
  6947. private _baseToVertex;
  6948. private _destinationPoint;
  6949. private _slidePlaneNormal;
  6950. private _displacementVector;
  6951. /** @hidden */
  6952. _radius: Vector3;
  6953. /** @hidden */
  6954. _retry: number;
  6955. private _velocity;
  6956. private _basePoint;
  6957. private _epsilon;
  6958. /** @hidden */
  6959. _velocityWorldLength: number;
  6960. /** @hidden */
  6961. _basePointWorld: Vector3;
  6962. private _velocityWorld;
  6963. private _normalizedVelocity;
  6964. /** @hidden */
  6965. _initialVelocity: Vector3;
  6966. /** @hidden */
  6967. _initialPosition: Vector3;
  6968. private _nearestDistance;
  6969. private _collisionMask;
  6970. collisionMask: number;
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. readonly slidePlaneNormal: Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module "babylonjs/Culling/boundingInfo" {
  6990. import { DeepImmutable } from "babylonjs/types";
  6991. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6992. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6993. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6994. import { Plane } from "babylonjs/Maths/math.plane";
  6995. import { Collider } from "babylonjs/Collisions/collider";
  6996. /**
  6997. * Interface for cullable objects
  6998. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6999. */
  7000. export interface ICullable {
  7001. /**
  7002. * Checks if the object or part of the object is in the frustum
  7003. * @param frustumPlanes Camera near/planes
  7004. * @returns true if the object is in frustum otherwise false
  7005. */
  7006. isInFrustum(frustumPlanes: Plane[]): boolean;
  7007. /**
  7008. * Checks if a cullable object (mesh...) is in the camera frustum
  7009. * Unlike isInFrustum this cheks the full bounding box
  7010. * @param frustumPlanes Camera near/planes
  7011. * @returns true if the object is in frustum otherwise false
  7012. */
  7013. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7014. }
  7015. /**
  7016. * Info for a bounding data of a mesh
  7017. */
  7018. export class BoundingInfo implements ICullable {
  7019. /**
  7020. * Bounding box for the mesh
  7021. */
  7022. readonly boundingBox: BoundingBox;
  7023. /**
  7024. * Bounding sphere for the mesh
  7025. */
  7026. readonly boundingSphere: BoundingSphere;
  7027. private _isLocked;
  7028. private static readonly TmpVector3;
  7029. /**
  7030. * Constructs bounding info
  7031. * @param minimum min vector of the bounding box/sphere
  7032. * @param maximum max vector of the bounding box/sphere
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7036. /**
  7037. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7038. * @param min defines the new minimum vector (in local space)
  7039. * @param max defines the new maximum vector (in local space)
  7040. * @param worldMatrix defines the new world matrix
  7041. */
  7042. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * min vector of the bounding box/sphere
  7045. */
  7046. readonly minimum: Vector3;
  7047. /**
  7048. * max vector of the bounding box/sphere
  7049. */
  7050. readonly maximum: Vector3;
  7051. /**
  7052. * If the info is locked and won't be updated to avoid perf overhead
  7053. */
  7054. isLocked: boolean;
  7055. /**
  7056. * Updates the bounding sphere and box
  7057. * @param world world matrix to be used to update
  7058. */
  7059. update(world: DeepImmutable<Matrix>): void;
  7060. /**
  7061. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7062. * @param center New center of the bounding info
  7063. * @param extend New extend of the bounding info
  7064. * @returns the current bounding info
  7065. */
  7066. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7067. /**
  7068. * Scale the current bounding info by applying a scale factor
  7069. * @param factor defines the scale factor to apply
  7070. * @returns the current bounding info
  7071. */
  7072. scale(factor: number): BoundingInfo;
  7073. /**
  7074. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7075. * @param frustumPlanes defines the frustum to test
  7076. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7077. * @returns true if the bounding info is in the frustum planes
  7078. */
  7079. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7080. /**
  7081. * Gets the world distance between the min and max points of the bounding box
  7082. */
  7083. readonly diagonalLength: number;
  7084. /**
  7085. * Checks if a cullable object (mesh...) is in the camera frustum
  7086. * Unlike isInFrustum this cheks the full bounding box
  7087. * @param frustumPlanes Camera near/planes
  7088. * @returns true if the object is in frustum otherwise false
  7089. */
  7090. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. /** @hidden */
  7092. _checkCollision(collider: Collider): boolean;
  7093. /**
  7094. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7095. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7096. * @param point the point to check intersection with
  7097. * @returns if the point intersects
  7098. */
  7099. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7100. /**
  7101. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7102. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7103. * @param boundingInfo the bounding info to check intersection with
  7104. * @param precise if the intersection should be done using OBB
  7105. * @returns if the bounding info intersects
  7106. */
  7107. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7108. }
  7109. }
  7110. declare module "babylonjs/Maths/math.functions" {
  7111. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7112. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7113. /**
  7114. * Extracts minimum and maximum values from a list of indexed positions
  7115. * @param positions defines the positions to use
  7116. * @param indices defines the indices to the positions
  7117. * @param indexStart defines the start index
  7118. * @param indexCount defines the end index
  7119. * @param bias defines bias value to add to the result
  7120. * @return minimum and maximum values
  7121. */
  7122. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7123. minimum: Vector3;
  7124. maximum: Vector3;
  7125. };
  7126. /**
  7127. * Extracts minimum and maximum values from a list of positions
  7128. * @param positions defines the positions to use
  7129. * @param start defines the start index in the positions array
  7130. * @param count defines the number of positions to handle
  7131. * @param bias defines bias value to add to the result
  7132. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7133. * @return minimum and maximum values
  7134. */
  7135. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7136. minimum: Vector3;
  7137. maximum: Vector3;
  7138. };
  7139. }
  7140. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7141. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7142. /** @hidden */
  7143. export class WebGLDataBuffer extends DataBuffer {
  7144. private _buffer;
  7145. constructor(resource: WebGLBuffer);
  7146. readonly underlyingResource: any;
  7147. }
  7148. }
  7149. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7150. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7151. import { Nullable } from "babylonjs/types";
  7152. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7153. /** @hidden */
  7154. export class WebGLPipelineContext implements IPipelineContext {
  7155. engine: ThinEngine;
  7156. program: Nullable<WebGLProgram>;
  7157. context?: WebGLRenderingContext;
  7158. vertexShader?: WebGLShader;
  7159. fragmentShader?: WebGLShader;
  7160. isParallelCompiled: boolean;
  7161. onCompiled?: () => void;
  7162. transformFeedback?: WebGLTransformFeedback | null;
  7163. readonly isAsync: boolean;
  7164. readonly isReady: boolean;
  7165. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7166. }
  7167. }
  7168. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7169. import { FloatArray, Nullable } from "babylonjs/types";
  7170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7171. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7172. module "babylonjs/Engines/thinEngine" {
  7173. interface ThinEngine {
  7174. /**
  7175. * Create an uniform buffer
  7176. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7177. * @param elements defines the content of the uniform buffer
  7178. * @returns the webGL uniform buffer
  7179. */
  7180. createUniformBuffer(elements: FloatArray): DataBuffer;
  7181. /**
  7182. * Create a dynamic uniform buffer
  7183. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7184. * @param elements defines the content of the uniform buffer
  7185. * @returns the webGL uniform buffer
  7186. */
  7187. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7188. /**
  7189. * Update an existing uniform buffer
  7190. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7191. * @param uniformBuffer defines the target uniform buffer
  7192. * @param elements defines the content to update
  7193. * @param offset defines the offset in the uniform buffer where update should start
  7194. * @param count defines the size of the data to update
  7195. */
  7196. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7197. /**
  7198. * Bind an uniform buffer to the current webGL context
  7199. * @param buffer defines the buffer to bind
  7200. */
  7201. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7202. /**
  7203. * Bind a buffer to the current webGL context at a given location
  7204. * @param buffer defines the buffer to bind
  7205. * @param location defines the index where to bind the buffer
  7206. */
  7207. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7208. /**
  7209. * Bind a specific block at a given index in a specific shader program
  7210. * @param pipelineContext defines the pipeline context to use
  7211. * @param blockName defines the block name
  7212. * @param index defines the index where to bind the block
  7213. */
  7214. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7215. }
  7216. }
  7217. }
  7218. declare module "babylonjs/Materials/uniformBuffer" {
  7219. import { Nullable, FloatArray } from "babylonjs/types";
  7220. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7221. import { Engine } from "babylonjs/Engines/engine";
  7222. import { Effect } from "babylonjs/Materials/effect";
  7223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7224. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7225. import { Color3 } from "babylonjs/Maths/math.color";
  7226. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7227. /**
  7228. * Uniform buffer objects.
  7229. *
  7230. * Handles blocks of uniform on the GPU.
  7231. *
  7232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7233. *
  7234. * For more information, please refer to :
  7235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7236. */
  7237. export class UniformBuffer {
  7238. private _engine;
  7239. private _buffer;
  7240. private _data;
  7241. private _bufferData;
  7242. private _dynamic?;
  7243. private _uniformLocations;
  7244. private _uniformSizes;
  7245. private _uniformLocationPointer;
  7246. private _needSync;
  7247. private _noUBO;
  7248. private _currentEffect;
  7249. /** @hidden */
  7250. _alreadyBound: boolean;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /**
  7672. * @hidden
  7673. */
  7674. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7675. }
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7679. import { Nullable } from "babylonjs/types";
  7680. import { Scene } from "babylonjs/scene";
  7681. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7683. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7684. /**
  7685. * Class for creating a cube texture
  7686. */
  7687. export class CubeTexture extends BaseTexture {
  7688. private _delayedOnLoad;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. /**
  7707. * Returns the bounding box size
  7708. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7709. */
  7710. boundingBoxSize: Vector3;
  7711. protected _rotationY: number;
  7712. /**
  7713. * Sets texture matrix rotation angle around Y axis in radians.
  7714. */
  7715. /**
  7716. * Gets texture matrix rotation angle around Y axis radians.
  7717. */
  7718. rotationY: number;
  7719. /**
  7720. * Are mip maps generated for this texture or not.
  7721. */
  7722. readonly noMipmap: boolean;
  7723. private _noMipmap;
  7724. private _files;
  7725. protected _forcedExtension: Nullable<string>;
  7726. private _extensions;
  7727. private _textureMatrix;
  7728. private _format;
  7729. private _createPolynomials;
  7730. /** @hidden */
  7731. _prefiltered: boolean;
  7732. /**
  7733. * Creates a cube texture from an array of image urls
  7734. * @param files defines an array of image urls
  7735. * @param scene defines the hosting scene
  7736. * @param noMipmap specifies if mip maps are not used
  7737. * @returns a cube texture
  7738. */
  7739. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7740. /**
  7741. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7742. * @param url defines the url of the prefiltered texture
  7743. * @param scene defines the scene the texture is attached to
  7744. * @param forcedExtension defines the extension of the file if different from the url
  7745. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7746. * @return the prefiltered texture
  7747. */
  7748. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7749. /**
  7750. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7751. * as prefiltered data.
  7752. * @param rootUrl defines the url of the texture or the root name of the six images
  7753. * @param scene defines the scene the texture is attached to
  7754. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7755. * @param noMipmap defines if mipmaps should be created or not
  7756. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7757. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7758. * @param onError defines a callback triggered in case of error during load
  7759. * @param format defines the internal format to use for the texture once loaded
  7760. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7761. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7762. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @return the cube texture
  7766. */
  7767. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7768. /**
  7769. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7770. */
  7771. readonly isPrefiltered: boolean;
  7772. /**
  7773. * Get the current class name of the texture useful for serialization or dynamic coding.
  7774. * @returns "CubeTexture"
  7775. */
  7776. getClassName(): string;
  7777. /**
  7778. * Update the url (and optional buffer) of this texture if url was null during construction.
  7779. * @param url the url of the texture
  7780. * @param forcedExtension defines the extension to use
  7781. * @param onLoad callback called when the texture is loaded (defaults to null)
  7782. */
  7783. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7784. /**
  7785. * Delays loading of the cube texture
  7786. * @param forcedExtension defines the extension to use
  7787. */
  7788. delayLoad(forcedExtension?: string): void;
  7789. /**
  7790. * Returns the reflection texture matrix
  7791. * @returns the reflection texture matrix
  7792. */
  7793. getReflectionTextureMatrix(): Matrix;
  7794. /**
  7795. * Sets the reflection texture matrix
  7796. * @param value Reflection texture matrix
  7797. */
  7798. setReflectionTextureMatrix(value: Matrix): void;
  7799. /**
  7800. * Parses text to create a cube texture
  7801. * @param parsedTexture define the serialized text to read from
  7802. * @param scene defines the hosting scene
  7803. * @param rootUrl defines the root url of the cube texture
  7804. * @returns a cube texture
  7805. */
  7806. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7807. /**
  7808. * Makes a clone, or deep copy, of the cube texture
  7809. * @returns a new cube texture
  7810. */
  7811. clone(): CubeTexture;
  7812. }
  7813. }
  7814. declare module "babylonjs/Materials/materialDefines" {
  7815. /**
  7816. * Manages the defines for the Material
  7817. */
  7818. export class MaterialDefines {
  7819. /** @hidden */
  7820. protected _keys: string[];
  7821. private _isDirty;
  7822. /** @hidden */
  7823. _renderId: number;
  7824. /** @hidden */
  7825. _areLightsDirty: boolean;
  7826. /** @hidden */
  7827. _areLightsDisposed: boolean;
  7828. /** @hidden */
  7829. _areAttributesDirty: boolean;
  7830. /** @hidden */
  7831. _areTexturesDirty: boolean;
  7832. /** @hidden */
  7833. _areFresnelDirty: boolean;
  7834. /** @hidden */
  7835. _areMiscDirty: boolean;
  7836. /** @hidden */
  7837. _areImageProcessingDirty: boolean;
  7838. /** @hidden */
  7839. _normals: boolean;
  7840. /** @hidden */
  7841. _uvs: boolean;
  7842. /** @hidden */
  7843. _needNormals: boolean;
  7844. /** @hidden */
  7845. _needUVs: boolean;
  7846. [id: string]: any;
  7847. /**
  7848. * Specifies if the material needs to be re-calculated
  7849. */
  7850. readonly isDirty: boolean;
  7851. /**
  7852. * Marks the material to indicate that it has been re-calculated
  7853. */
  7854. markAsProcessed(): void;
  7855. /**
  7856. * Marks the material to indicate that it needs to be re-calculated
  7857. */
  7858. markAsUnprocessed(): void;
  7859. /**
  7860. * Marks the material to indicate all of its defines need to be re-calculated
  7861. */
  7862. markAllAsDirty(): void;
  7863. /**
  7864. * Marks the material to indicate that image processing needs to be re-calculated
  7865. */
  7866. markAsImageProcessingDirty(): void;
  7867. /**
  7868. * Marks the material to indicate the lights need to be re-calculated
  7869. * @param disposed Defines whether the light is dirty due to dispose or not
  7870. */
  7871. markAsLightDirty(disposed?: boolean): void;
  7872. /**
  7873. * Marks the attribute state as changed
  7874. */
  7875. markAsAttributesDirty(): void;
  7876. /**
  7877. * Marks the texture state as changed
  7878. */
  7879. markAsTexturesDirty(): void;
  7880. /**
  7881. * Marks the fresnel state as changed
  7882. */
  7883. markAsFresnelDirty(): void;
  7884. /**
  7885. * Marks the misc state as changed
  7886. */
  7887. markAsMiscDirty(): void;
  7888. /**
  7889. * Rebuilds the material defines
  7890. */
  7891. rebuild(): void;
  7892. /**
  7893. * Specifies if two material defines are equal
  7894. * @param other - A material define instance to compare to
  7895. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7896. */
  7897. isEqual(other: MaterialDefines): boolean;
  7898. /**
  7899. * Clones this instance's defines to another instance
  7900. * @param other - material defines to clone values to
  7901. */
  7902. cloneTo(other: MaterialDefines): void;
  7903. /**
  7904. * Resets the material define values
  7905. */
  7906. reset(): void;
  7907. /**
  7908. * Converts the material define values to a string
  7909. * @returns - String of material define information
  7910. */
  7911. toString(): string;
  7912. }
  7913. }
  7914. declare module "babylonjs/Materials/colorCurves" {
  7915. import { Effect } from "babylonjs/Materials/effect";
  7916. /**
  7917. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7918. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7919. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7920. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7921. */
  7922. export class ColorCurves {
  7923. private _dirty;
  7924. private _tempColor;
  7925. private _globalCurve;
  7926. private _highlightsCurve;
  7927. private _midtonesCurve;
  7928. private _shadowsCurve;
  7929. private _positiveCurve;
  7930. private _negativeCurve;
  7931. private _globalHue;
  7932. private _globalDensity;
  7933. private _globalSaturation;
  7934. private _globalExposure;
  7935. /**
  7936. * Gets the global Hue value.
  7937. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7938. */
  7939. /**
  7940. * Sets the global Hue value.
  7941. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7942. */
  7943. globalHue: number;
  7944. /**
  7945. * Gets the global Density value.
  7946. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. /**
  7950. * Sets the global Density value.
  7951. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. globalDensity: number;
  7955. /**
  7956. * Gets the global Saturation value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7958. */
  7959. /**
  7960. * Sets the global Saturation value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7962. */
  7963. globalSaturation: number;
  7964. /**
  7965. * Gets the global Exposure value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7967. */
  7968. /**
  7969. * Sets the global Exposure value.
  7970. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7971. */
  7972. globalExposure: number;
  7973. private _highlightsHue;
  7974. private _highlightsDensity;
  7975. private _highlightsSaturation;
  7976. private _highlightsExposure;
  7977. /**
  7978. * Gets the highlights Hue value.
  7979. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7980. */
  7981. /**
  7982. * Sets the highlights Hue value.
  7983. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7984. */
  7985. highlightsHue: number;
  7986. /**
  7987. * Gets the highlights Density value.
  7988. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. /**
  7992. * Sets the highlights Density value.
  7993. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7994. * Values less than zero provide a filter of opposite hue.
  7995. */
  7996. highlightsDensity: number;
  7997. /**
  7998. * Gets the highlights Saturation value.
  7999. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8000. */
  8001. /**
  8002. * Sets the highlights Saturation value.
  8003. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8004. */
  8005. highlightsSaturation: number;
  8006. /**
  8007. * Gets the highlights Exposure value.
  8008. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8009. */
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8013. */
  8014. highlightsExposure: number;
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8022. */
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8026. */
  8027. midtonesHue: number;
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. /**
  8034. * Sets the midtones Density value.
  8035. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. midtonesDensity: number;
  8039. /**
  8040. * Gets the midtones Saturation value.
  8041. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8042. */
  8043. /**
  8044. * Sets the midtones Saturation value.
  8045. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8046. */
  8047. midtonesSaturation: number;
  8048. /**
  8049. * Gets the midtones Exposure value.
  8050. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8051. */
  8052. /**
  8053. * Sets the midtones Exposure value.
  8054. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8055. */
  8056. midtonesExposure: number;
  8057. private _shadowsHue;
  8058. private _shadowsDensity;
  8059. private _shadowsSaturation;
  8060. private _shadowsExposure;
  8061. /**
  8062. * Gets the shadows Hue value.
  8063. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8064. */
  8065. /**
  8066. * Sets the shadows Hue value.
  8067. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8068. */
  8069. shadowsHue: number;
  8070. /**
  8071. * Gets the shadows Density value.
  8072. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. /**
  8076. * Sets the shadows Density value.
  8077. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. shadowsDensity: number;
  8081. /**
  8082. * Gets the shadows Saturation value.
  8083. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8084. */
  8085. /**
  8086. * Sets the shadows Saturation value.
  8087. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8088. */
  8089. shadowsSaturation: number;
  8090. /**
  8091. * Gets the shadows Exposure value.
  8092. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8093. */
  8094. /**
  8095. * Sets the shadows Exposure value.
  8096. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8097. */
  8098. shadowsExposure: number;
  8099. /**
  8100. * Returns the class name
  8101. * @returns The class name
  8102. */
  8103. getClassName(): string;
  8104. /**
  8105. * Binds the color curves to the shader.
  8106. * @param colorCurves The color curve to bind
  8107. * @param effect The effect to bind to
  8108. * @param positiveUniform The positive uniform shader parameter
  8109. * @param neutralUniform The neutral uniform shader parameter
  8110. * @param negativeUniform The negative uniform shader parameter
  8111. */
  8112. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8113. /**
  8114. * Prepare the list of uniforms associated with the ColorCurves effects.
  8115. * @param uniformsList The list of uniforms used in the effect
  8116. */
  8117. static PrepareUniforms(uniformsList: string[]): void;
  8118. /**
  8119. * Returns color grading data based on a hue, density, saturation and exposure value.
  8120. * @param filterHue The hue of the color filter.
  8121. * @param filterDensity The density of the color filter.
  8122. * @param saturation The saturation.
  8123. * @param exposure The exposure.
  8124. * @param result The result data container.
  8125. */
  8126. private getColorGradingDataToRef;
  8127. /**
  8128. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8129. * @param value The input slider value in range [-100,100].
  8130. * @returns Adjusted value.
  8131. */
  8132. private static applyColorGradingSliderNonlinear;
  8133. /**
  8134. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8135. * @param hue The hue (H) input.
  8136. * @param saturation The saturation (S) input.
  8137. * @param brightness The brightness (B) input.
  8138. * @result An RGBA color represented as Vector4.
  8139. */
  8140. private static fromHSBToRef;
  8141. /**
  8142. * Returns a value clamped between min and max
  8143. * @param value The value to clamp
  8144. * @param min The minimum of value
  8145. * @param max The maximum of value
  8146. * @returns The clamped value.
  8147. */
  8148. private static clamp;
  8149. /**
  8150. * Clones the current color curve instance.
  8151. * @return The cloned curves
  8152. */
  8153. clone(): ColorCurves;
  8154. /**
  8155. * Serializes the current color curve instance to a json representation.
  8156. * @return a JSON representation
  8157. */
  8158. serialize(): any;
  8159. /**
  8160. * Parses the color curve from a json representation.
  8161. * @param source the JSON source to parse
  8162. * @return The parsed curves
  8163. */
  8164. static Parse(source: any): ColorCurves;
  8165. }
  8166. }
  8167. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8168. import { Observable } from "babylonjs/Misc/observable";
  8169. import { Nullable } from "babylonjs/types";
  8170. import { Color4 } from "babylonjs/Maths/math.color";
  8171. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8172. import { Effect } from "babylonjs/Materials/effect";
  8173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8174. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. /**
  8240. * Sets wether the color curves effect is enabled.
  8241. */
  8242. colorCurvesEnabled: boolean;
  8243. private _colorGradingTexture;
  8244. /**
  8245. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8246. */
  8247. /**
  8248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8249. */
  8250. colorGradingTexture: Nullable<BaseTexture>;
  8251. private _colorGradingEnabled;
  8252. /**
  8253. * Gets wether the color grading effect is enabled.
  8254. */
  8255. /**
  8256. * Sets wether the color grading effect is enabled.
  8257. */
  8258. colorGradingEnabled: boolean;
  8259. private _colorGradingWithGreenDepth;
  8260. /**
  8261. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8262. */
  8263. /**
  8264. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. colorGradingWithGreenDepth: boolean;
  8267. private _colorGradingBGR;
  8268. /**
  8269. * Gets wether the color grading texture contains BGR values.
  8270. */
  8271. /**
  8272. * Sets wether the color grading texture contains BGR values.
  8273. */
  8274. colorGradingBGR: boolean;
  8275. /** @hidden */
  8276. _exposure: number;
  8277. /**
  8278. * Gets the Exposure used in the effect.
  8279. */
  8280. /**
  8281. * Sets the Exposure used in the effect.
  8282. */
  8283. exposure: number;
  8284. private _toneMappingEnabled;
  8285. /**
  8286. * Gets wether the tone mapping effect is enabled.
  8287. */
  8288. /**
  8289. * Sets wether the tone mapping effect is enabled.
  8290. */
  8291. toneMappingEnabled: boolean;
  8292. private _toneMappingType;
  8293. /**
  8294. * Gets the type of tone mapping effect.
  8295. */
  8296. /**
  8297. * Sets the type of tone mapping effect used in BabylonJS.
  8298. */
  8299. toneMappingType: number;
  8300. protected _contrast: number;
  8301. /**
  8302. * Gets the contrast used in the effect.
  8303. */
  8304. /**
  8305. * Sets the contrast used in the effect.
  8306. */
  8307. contrast: number;
  8308. /**
  8309. * Vignette stretch size.
  8310. */
  8311. vignetteStretch: number;
  8312. /**
  8313. * Vignette centre X Offset.
  8314. */
  8315. vignetteCentreX: number;
  8316. /**
  8317. * Vignette centre Y Offset.
  8318. */
  8319. vignetteCentreY: number;
  8320. /**
  8321. * Vignette weight or intensity of the vignette effect.
  8322. */
  8323. vignetteWeight: number;
  8324. /**
  8325. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8326. * if vignetteEnabled is set to true.
  8327. */
  8328. vignetteColor: Color4;
  8329. /**
  8330. * Camera field of view used by the Vignette effect.
  8331. */
  8332. vignetteCameraFov: number;
  8333. private _vignetteBlendMode;
  8334. /**
  8335. * Gets the vignette blend mode allowing different kind of effect.
  8336. */
  8337. /**
  8338. * Sets the vignette blend mode allowing different kind of effect.
  8339. */
  8340. vignetteBlendMode: number;
  8341. private _vignetteEnabled;
  8342. /**
  8343. * Gets wether the vignette effect is enabled.
  8344. */
  8345. /**
  8346. * Sets wether the vignette effect is enabled.
  8347. */
  8348. vignetteEnabled: boolean;
  8349. private _applyByPostProcess;
  8350. /**
  8351. * Gets wether the image processing is applied through a post process or not.
  8352. */
  8353. /**
  8354. * Sets wether the image processing is applied through a post process or not.
  8355. */
  8356. applyByPostProcess: boolean;
  8357. private _isEnabled;
  8358. /**
  8359. * Gets wether the image processing is enabled or not.
  8360. */
  8361. /**
  8362. * Sets wether the image processing is enabled or not.
  8363. */
  8364. isEnabled: boolean;
  8365. /**
  8366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8367. */
  8368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8369. /**
  8370. * Method called each time the image processing information changes requires to recompile the effect.
  8371. */
  8372. protected _updateParameters(): void;
  8373. /**
  8374. * Gets the current class name.
  8375. * @return "ImageProcessingConfiguration"
  8376. */
  8377. getClassName(): string;
  8378. /**
  8379. * Prepare the list of uniforms associated with the Image Processing effects.
  8380. * @param uniforms The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of samplers associated with the Image Processing effects.
  8386. * @param samplersList The list of uniforms used in the effect
  8387. * @param defines the list of defines currently in use
  8388. */
  8389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8390. /**
  8391. * Prepare the list of defines associated to the shader.
  8392. * @param defines the list of defines to complete
  8393. * @param forPostProcess Define if we are currently in post process mode or not
  8394. */
  8395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8396. /**
  8397. * Returns true if all the image processing information are ready.
  8398. * @returns True if ready, otherwise, false
  8399. */
  8400. isReady(): boolean;
  8401. /**
  8402. * Binds the image processing to the shader.
  8403. * @param effect The effect to bind to
  8404. * @param overrideAspectRatio Override the aspect ratio of the effect
  8405. */
  8406. bind(effect: Effect, overrideAspectRatio?: number): void;
  8407. /**
  8408. * Clones the current image processing instance.
  8409. * @return The cloned image processing
  8410. */
  8411. clone(): ImageProcessingConfiguration;
  8412. /**
  8413. * Serializes the current image processing instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the image processing from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed image processing
  8421. */
  8422. static Parse(source: any): ImageProcessingConfiguration;
  8423. private static _VIGNETTEMODE_MULTIPLY;
  8424. private static _VIGNETTEMODE_OPAQUE;
  8425. /**
  8426. * Used to apply the vignette as a mix with the pixel color.
  8427. */
  8428. static readonly VIGNETTEMODE_MULTIPLY: number;
  8429. /**
  8430. * Used to apply the vignette as a replacement of the pixel color.
  8431. */
  8432. static readonly VIGNETTEMODE_OPAQUE: number;
  8433. }
  8434. }
  8435. declare module "babylonjs/Shaders/postprocess.vertex" {
  8436. /** @hidden */
  8437. export var postprocessVertexShader: {
  8438. name: string;
  8439. shader: string;
  8440. };
  8441. }
  8442. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8445. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8446. module "babylonjs/Engines/thinEngine" {
  8447. interface ThinEngine {
  8448. /**
  8449. * Creates a new render target texture
  8450. * @param size defines the size of the texture
  8451. * @param options defines the options used to create the texture
  8452. * @returns a new render target texture stored in an InternalTexture
  8453. */
  8454. createRenderTargetTexture(size: number | {
  8455. width: number;
  8456. height: number;
  8457. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8458. /**
  8459. * Creates a depth stencil texture.
  8460. * This is only available in WebGL 2 or with the depth texture extension available.
  8461. * @param size The size of face edge in the texture.
  8462. * @param options The options defining the texture.
  8463. * @returns The texture
  8464. */
  8465. createDepthStencilTexture(size: number | {
  8466. width: number;
  8467. height: number;
  8468. }, options: DepthTextureCreationOptions): InternalTexture;
  8469. /** @hidden */
  8470. _createDepthStencilTexture(size: number | {
  8471. width: number;
  8472. height: number;
  8473. }, options: DepthTextureCreationOptions): InternalTexture;
  8474. }
  8475. }
  8476. }
  8477. declare module "babylonjs/Maths/math.axis" {
  8478. import { Vector3 } from "babylonjs/Maths/math.vector";
  8479. /** Defines supported spaces */
  8480. export enum Space {
  8481. /** Local (object) space */
  8482. LOCAL = 0,
  8483. /** World space */
  8484. WORLD = 1,
  8485. /** Bone space */
  8486. BONE = 2
  8487. }
  8488. /** Defines the 3 main axes */
  8489. export class Axis {
  8490. /** X axis */
  8491. static X: Vector3;
  8492. /** Y axis */
  8493. static Y: Vector3;
  8494. /** Z axis */
  8495. static Z: Vector3;
  8496. }
  8497. }
  8498. declare module "babylonjs/Cameras/targetCamera" {
  8499. import { Nullable } from "babylonjs/types";
  8500. import { Camera } from "babylonjs/Cameras/camera";
  8501. import { Scene } from "babylonjs/scene";
  8502. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8503. /**
  8504. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8505. * This is the base of the follow, arc rotate cameras and Free camera
  8506. * @see http://doc.babylonjs.com/features/cameras
  8507. */
  8508. export class TargetCamera extends Camera {
  8509. private static _RigCamTransformMatrix;
  8510. private static _TargetTransformMatrix;
  8511. private static _TargetFocalPoint;
  8512. /**
  8513. * Define the current direction the camera is moving to
  8514. */
  8515. cameraDirection: Vector3;
  8516. /**
  8517. * Define the current rotation the camera is rotating to
  8518. */
  8519. cameraRotation: Vector2;
  8520. /**
  8521. * When set, the up vector of the camera will be updated by the rotation of the camera
  8522. */
  8523. updateUpVectorFromRotation: boolean;
  8524. private _tmpQuaternion;
  8525. /**
  8526. * Define the current rotation of the camera
  8527. */
  8528. rotation: Vector3;
  8529. /**
  8530. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8531. */
  8532. rotationQuaternion: Quaternion;
  8533. /**
  8534. * Define the current speed of the camera
  8535. */
  8536. speed: number;
  8537. /**
  8538. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8539. * around all axis.
  8540. */
  8541. noRotationConstraint: boolean;
  8542. /**
  8543. * Define the current target of the camera as an object or a position.
  8544. */
  8545. lockedTarget: any;
  8546. /** @hidden */
  8547. _currentTarget: Vector3;
  8548. /** @hidden */
  8549. _initialFocalDistance: number;
  8550. /** @hidden */
  8551. _viewMatrix: Matrix;
  8552. /** @hidden */
  8553. _camMatrix: Matrix;
  8554. /** @hidden */
  8555. _cameraTransformMatrix: Matrix;
  8556. /** @hidden */
  8557. _cameraRotationMatrix: Matrix;
  8558. /** @hidden */
  8559. _referencePoint: Vector3;
  8560. /** @hidden */
  8561. _transformedReferencePoint: Vector3;
  8562. protected _globalCurrentTarget: Vector3;
  8563. protected _globalCurrentUpVector: Vector3;
  8564. /** @hidden */
  8565. _reset: () => void;
  8566. private _defaultUp;
  8567. /**
  8568. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8569. * This is the base of the follow, arc rotate cameras and Free camera
  8570. * @see http://doc.babylonjs.com/features/cameras
  8571. * @param name Defines the name of the camera in the scene
  8572. * @param position Defines the start position of the camera in the scene
  8573. * @param scene Defines the scene the camera belongs to
  8574. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8575. */
  8576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8577. /**
  8578. * Gets the position in front of the camera at a given distance.
  8579. * @param distance The distance from the camera we want the position to be
  8580. * @returns the position
  8581. */
  8582. getFrontPosition(distance: number): Vector3;
  8583. /** @hidden */
  8584. _getLockedTargetPosition(): Nullable<Vector3>;
  8585. private _storedPosition;
  8586. private _storedRotation;
  8587. private _storedRotationQuaternion;
  8588. /**
  8589. * Store current camera state of the camera (fov, position, rotation, etc..)
  8590. * @returns the camera
  8591. */
  8592. storeState(): Camera;
  8593. /**
  8594. * Restored camera state. You must call storeState() first
  8595. * @returns whether it was successful or not
  8596. * @hidden
  8597. */
  8598. _restoreStateValues(): boolean;
  8599. /** @hidden */
  8600. _initCache(): void;
  8601. /** @hidden */
  8602. _updateCache(ignoreParentClass?: boolean): void;
  8603. /** @hidden */
  8604. _isSynchronizedViewMatrix(): boolean;
  8605. /** @hidden */
  8606. _computeLocalCameraSpeed(): number;
  8607. /**
  8608. * Defines the target the camera should look at.
  8609. * @param target Defines the new target as a Vector or a mesh
  8610. */
  8611. setTarget(target: Vector3): void;
  8612. /**
  8613. * Return the current target position of the camera. This value is expressed in local space.
  8614. * @returns the target position
  8615. */
  8616. getTarget(): Vector3;
  8617. /** @hidden */
  8618. _decideIfNeedsToMove(): boolean;
  8619. /** @hidden */
  8620. _updatePosition(): void;
  8621. /** @hidden */
  8622. _checkInputs(): void;
  8623. protected _updateCameraRotationMatrix(): void;
  8624. /**
  8625. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8626. * @returns the current camera
  8627. */
  8628. private _rotateUpVectorWithCameraRotationMatrix;
  8629. private _cachedRotationZ;
  8630. private _cachedQuaternionRotationZ;
  8631. /** @hidden */
  8632. _getViewMatrix(): Matrix;
  8633. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8634. /**
  8635. * @hidden
  8636. */
  8637. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8638. /**
  8639. * @hidden
  8640. */
  8641. _updateRigCameras(): void;
  8642. private _getRigCamPositionAndTarget;
  8643. /**
  8644. * Gets the current object class name.
  8645. * @return the class name
  8646. */
  8647. getClassName(): string;
  8648. }
  8649. }
  8650. declare module "babylonjs/Events/keyboardEvents" {
  8651. /**
  8652. * Gather the list of keyboard event types as constants.
  8653. */
  8654. export class KeyboardEventTypes {
  8655. /**
  8656. * The keydown event is fired when a key becomes active (pressed).
  8657. */
  8658. static readonly KEYDOWN: number;
  8659. /**
  8660. * The keyup event is fired when a key has been released.
  8661. */
  8662. static readonly KEYUP: number;
  8663. }
  8664. /**
  8665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8666. */
  8667. export class KeyboardInfo {
  8668. /**
  8669. * Defines the type of event (KeyboardEventTypes)
  8670. */
  8671. type: number;
  8672. /**
  8673. * Defines the related dom event
  8674. */
  8675. event: KeyboardEvent;
  8676. /**
  8677. * Instantiates a new keyboard info.
  8678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8679. * @param type Defines the type of event (KeyboardEventTypes)
  8680. * @param event Defines the related dom event
  8681. */
  8682. constructor(
  8683. /**
  8684. * Defines the type of event (KeyboardEventTypes)
  8685. */
  8686. type: number,
  8687. /**
  8688. * Defines the related dom event
  8689. */
  8690. event: KeyboardEvent);
  8691. }
  8692. /**
  8693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8694. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8695. */
  8696. export class KeyboardInfoPre extends KeyboardInfo {
  8697. /**
  8698. * Defines the type of event (KeyboardEventTypes)
  8699. */
  8700. type: number;
  8701. /**
  8702. * Defines the related dom event
  8703. */
  8704. event: KeyboardEvent;
  8705. /**
  8706. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8707. */
  8708. skipOnPointerObservable: boolean;
  8709. /**
  8710. * Instantiates a new keyboard pre info.
  8711. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8712. * @param type Defines the type of event (KeyboardEventTypes)
  8713. * @param event Defines the related dom event
  8714. */
  8715. constructor(
  8716. /**
  8717. * Defines the type of event (KeyboardEventTypes)
  8718. */
  8719. type: number,
  8720. /**
  8721. * Defines the related dom event
  8722. */
  8723. event: KeyboardEvent);
  8724. }
  8725. }
  8726. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8727. import { Nullable } from "babylonjs/types";
  8728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8729. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8730. /**
  8731. * Manage the keyboard inputs to control the movement of a free camera.
  8732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8733. */
  8734. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8735. /**
  8736. * Defines the camera the input is attached to.
  8737. */
  8738. camera: FreeCamera;
  8739. /**
  8740. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8741. */
  8742. keysUp: number[];
  8743. /**
  8744. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8745. */
  8746. keysDown: number[];
  8747. /**
  8748. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8749. */
  8750. keysLeft: number[];
  8751. /**
  8752. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8753. */
  8754. keysRight: number[];
  8755. private _keys;
  8756. private _onCanvasBlurObserver;
  8757. private _onKeyboardObserver;
  8758. private _engine;
  8759. private _scene;
  8760. /**
  8761. * Attach the input controls to a specific dom element to get the input from.
  8762. * @param element Defines the element the controls should be listened from
  8763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8764. */
  8765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8766. /**
  8767. * Detach the current controls from the specified dom element.
  8768. * @param element Defines the element to stop listening the inputs from
  8769. */
  8770. detachControl(element: Nullable<HTMLElement>): void;
  8771. /**
  8772. * Update the current camera state depending on the inputs that have been used this frame.
  8773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8774. */
  8775. checkInputs(): void;
  8776. /**
  8777. * Gets the class name of the current intput.
  8778. * @returns the class name
  8779. */
  8780. getClassName(): string;
  8781. /** @hidden */
  8782. _onLostFocus(): void;
  8783. /**
  8784. * Get the friendly name associated with the input class.
  8785. * @returns the input friendly name
  8786. */
  8787. getSimpleName(): string;
  8788. }
  8789. }
  8790. declare module "babylonjs/Lights/shadowLight" {
  8791. import { Camera } from "babylonjs/Cameras/camera";
  8792. import { Scene } from "babylonjs/scene";
  8793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8795. import { Light } from "babylonjs/Lights/light";
  8796. /**
  8797. * Interface describing all the common properties and methods a shadow light needs to implement.
  8798. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8799. * as well as binding the different shadow properties to the effects.
  8800. */
  8801. export interface IShadowLight extends Light {
  8802. /**
  8803. * The light id in the scene (used in scene.findLighById for instance)
  8804. */
  8805. id: string;
  8806. /**
  8807. * The position the shdow will be casted from.
  8808. */
  8809. position: Vector3;
  8810. /**
  8811. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8812. */
  8813. direction: Vector3;
  8814. /**
  8815. * The transformed position. Position of the light in world space taking parenting in account.
  8816. */
  8817. transformedPosition: Vector3;
  8818. /**
  8819. * The transformed direction. Direction of the light in world space taking parenting in account.
  8820. */
  8821. transformedDirection: Vector3;
  8822. /**
  8823. * The friendly name of the light in the scene.
  8824. */
  8825. name: string;
  8826. /**
  8827. * Defines the shadow projection clipping minimum z value.
  8828. */
  8829. shadowMinZ: number;
  8830. /**
  8831. * Defines the shadow projection clipping maximum z value.
  8832. */
  8833. shadowMaxZ: number;
  8834. /**
  8835. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8836. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8837. */
  8838. computeTransformedInformation(): boolean;
  8839. /**
  8840. * Gets the scene the light belongs to.
  8841. * @returns The scene
  8842. */
  8843. getScene(): Scene;
  8844. /**
  8845. * Callback defining a custom Projection Matrix Builder.
  8846. * This can be used to override the default projection matrix computation.
  8847. */
  8848. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. /**
  8858. * Gets the current depth scale used in ESM.
  8859. * @returns The scale
  8860. */
  8861. getDepthScale(): number;
  8862. /**
  8863. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8864. * @returns true if a cube texture needs to be use
  8865. */
  8866. needCube(): boolean;
  8867. /**
  8868. * Detects if the projection matrix requires to be recomputed this frame.
  8869. * @returns true if it requires to be recomputed otherwise, false.
  8870. */
  8871. needProjectionMatrixCompute(): boolean;
  8872. /**
  8873. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8874. */
  8875. forceProjectionMatrixCompute(): void;
  8876. /**
  8877. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8878. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8879. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8880. */
  8881. getShadowDirection(faceIndex?: number): Vector3;
  8882. /**
  8883. * Gets the minZ used for shadow according to both the scene and the light.
  8884. * @param activeCamera The camera we are returning the min for
  8885. * @returns the depth min z
  8886. */
  8887. getDepthMinZ(activeCamera: Camera): number;
  8888. /**
  8889. * Gets the maxZ used for shadow according to both the scene and the light.
  8890. * @param activeCamera The camera we are returning the max for
  8891. * @returns the depth max z
  8892. */
  8893. getDepthMaxZ(activeCamera: Camera): number;
  8894. }
  8895. /**
  8896. * Base implementation IShadowLight
  8897. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8898. */
  8899. export abstract class ShadowLight extends Light implements IShadowLight {
  8900. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8901. protected _position: Vector3;
  8902. protected _setPosition(value: Vector3): void;
  8903. /**
  8904. * Sets the position the shadow will be casted from. Also use as the light position for both
  8905. * point and spot lights.
  8906. */
  8907. /**
  8908. * Sets the position the shadow will be casted from. Also use as the light position for both
  8909. * point and spot lights.
  8910. */
  8911. position: Vector3;
  8912. protected _direction: Vector3;
  8913. protected _setDirection(value: Vector3): void;
  8914. /**
  8915. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8916. * Also use as the light direction on spot and directional lights.
  8917. */
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. direction: Vector3;
  8923. private _shadowMinZ;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. /**
  8928. * Sets the shadow projection clipping minimum z value.
  8929. */
  8930. shadowMinZ: number;
  8931. private _shadowMaxZ;
  8932. /**
  8933. * Sets the shadow projection clipping maximum z value.
  8934. */
  8935. /**
  8936. * Gets the shadow projection clipping maximum z value.
  8937. */
  8938. shadowMaxZ: number;
  8939. /**
  8940. * Callback defining a custom Projection Matrix Builder.
  8941. * This can be used to override the default projection matrix computation.
  8942. */
  8943. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8944. /**
  8945. * The transformed position. Position of the light in world space taking parenting in account.
  8946. */
  8947. transformedPosition: Vector3;
  8948. /**
  8949. * The transformed direction. Direction of the light in world space taking parenting in account.
  8950. */
  8951. transformedDirection: Vector3;
  8952. private _needProjectionMatrixCompute;
  8953. /**
  8954. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8955. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8956. */
  8957. computeTransformedInformation(): boolean;
  8958. /**
  8959. * Return the depth scale used for the shadow map.
  8960. * @returns the depth scale.
  8961. */
  8962. getDepthScale(): number;
  8963. /**
  8964. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8965. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8966. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8967. */
  8968. getShadowDirection(faceIndex?: number): Vector3;
  8969. /**
  8970. * Returns the ShadowLight absolute position in the World.
  8971. * @returns the position vector in world space
  8972. */
  8973. getAbsolutePosition(): Vector3;
  8974. /**
  8975. * Sets the ShadowLight direction toward the passed target.
  8976. * @param target The point to target in local space
  8977. * @returns the updated ShadowLight direction
  8978. */
  8979. setDirectionToTarget(target: Vector3): Vector3;
  8980. /**
  8981. * Returns the light rotation in euler definition.
  8982. * @returns the x y z rotation in local space.
  8983. */
  8984. getRotation(): Vector3;
  8985. /**
  8986. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8987. * @returns true if a cube texture needs to be use
  8988. */
  8989. needCube(): boolean;
  8990. /**
  8991. * Detects if the projection matrix requires to be recomputed this frame.
  8992. * @returns true if it requires to be recomputed otherwise, false.
  8993. */
  8994. needProjectionMatrixCompute(): boolean;
  8995. /**
  8996. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8997. */
  8998. forceProjectionMatrixCompute(): void;
  8999. /** @hidden */
  9000. _initCache(): void;
  9001. /** @hidden */
  9002. _isSynchronized(): boolean;
  9003. /**
  9004. * Computes the world matrix of the node
  9005. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9006. * @returns the world matrix
  9007. */
  9008. computeWorldMatrix(force?: boolean): Matrix;
  9009. /**
  9010. * Gets the minZ used for shadow according to both the scene and the light.
  9011. * @param activeCamera The camera we are returning the min for
  9012. * @returns the depth min z
  9013. */
  9014. getDepthMinZ(activeCamera: Camera): number;
  9015. /**
  9016. * Gets the maxZ used for shadow according to both the scene and the light.
  9017. * @param activeCamera The camera we are returning the max for
  9018. * @returns the depth max z
  9019. */
  9020. getDepthMaxZ(activeCamera: Camera): number;
  9021. /**
  9022. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9023. * @param matrix The materix to updated with the projection information
  9024. * @param viewMatrix The transform matrix of the light
  9025. * @param renderList The list of mesh to render in the map
  9026. * @returns The current light
  9027. */
  9028. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9029. }
  9030. }
  9031. declare module "babylonjs/Materials/effectFallbacks" {
  9032. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9033. import { Effect } from "babylonjs/Materials/effect";
  9034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9035. /**
  9036. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9037. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9038. */
  9039. export class EffectFallbacks implements IEffectFallbacks {
  9040. private _defines;
  9041. private _currentRank;
  9042. private _maxRank;
  9043. private _mesh;
  9044. /**
  9045. * Removes the fallback from the bound mesh.
  9046. */
  9047. unBindMesh(): void;
  9048. /**
  9049. * Adds a fallback on the specified property.
  9050. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9051. * @param define The name of the define in the shader
  9052. */
  9053. addFallback(rank: number, define: string): void;
  9054. /**
  9055. * Sets the mesh to use CPU skinning when needing to fallback.
  9056. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9057. * @param mesh The mesh to use the fallbacks.
  9058. */
  9059. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9060. /**
  9061. * Checks to see if more fallbacks are still availible.
  9062. */
  9063. readonly hasMoreFallbacks: boolean;
  9064. /**
  9065. * Removes the defines that should be removed when falling back.
  9066. * @param currentDefines defines the current define statements for the shader.
  9067. * @param effect defines the current effect we try to compile
  9068. * @returns The resulting defines with defines of the current rank removed.
  9069. */
  9070. reduce(currentDefines: string, effect: Effect): string;
  9071. }
  9072. }
  9073. declare module "babylonjs/Materials/materialHelper" {
  9074. import { Nullable } from "babylonjs/types";
  9075. import { Scene } from "babylonjs/scene";
  9076. import { Engine } from "babylonjs/Engines/engine";
  9077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9078. import { Light } from "babylonjs/Lights/light";
  9079. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9080. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9083. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9084. /**
  9085. * "Static Class" containing the most commonly used helper while dealing with material for
  9086. * rendering purpose.
  9087. *
  9088. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9089. *
  9090. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9091. */
  9092. export class MaterialHelper {
  9093. /**
  9094. * Bind the current view position to an effect.
  9095. * @param effect The effect to be bound
  9096. * @param scene The scene the eyes position is used from
  9097. */
  9098. static BindEyePosition(effect: Effect, scene: Scene): void;
  9099. /**
  9100. * Helps preparing the defines values about the UVs in used in the effect.
  9101. * UVs are shared as much as we can accross channels in the shaders.
  9102. * @param texture The texture we are preparing the UVs for
  9103. * @param defines The defines to update
  9104. * @param key The channel key "diffuse", "specular"... used in the shader
  9105. */
  9106. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9107. /**
  9108. * Binds a texture matrix value to its corrsponding uniform
  9109. * @param texture The texture to bind the matrix for
  9110. * @param uniformBuffer The uniform buffer receivin the data
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9114. /**
  9115. * Gets the current status of the fog (should it be enabled?)
  9116. * @param mesh defines the mesh to evaluate for fog support
  9117. * @param scene defines the hosting scene
  9118. * @returns true if fog must be enabled
  9119. */
  9120. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9123. * @param mesh defines the current mesh
  9124. * @param scene defines the current scene
  9125. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9126. * @param pointsCloud defines if point cloud rendering has to be turned on
  9127. * @param fogEnabled defines if fog has to be turned on
  9128. * @param alphaTest defines if alpha testing has to be turned on
  9129. * @param defines defines the current list of defines
  9130. */
  9131. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9132. /**
  9133. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9134. * @param scene defines the current scene
  9135. * @param engine defines the current engine
  9136. * @param defines specifies the list of active defines
  9137. * @param useInstances defines if instances have to be turned on
  9138. * @param useClipPlane defines if clip plane have to be turned on
  9139. */
  9140. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9141. /**
  9142. * Prepares the defines for bones
  9143. * @param mesh The mesh containing the geometry data we will draw
  9144. * @param defines The defines to update
  9145. */
  9146. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9147. /**
  9148. * Prepares the defines for morph targets
  9149. * @param mesh The mesh containing the geometry data we will draw
  9150. * @param defines The defines to update
  9151. */
  9152. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9153. /**
  9154. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9155. * @param mesh The mesh containing the geometry data we will draw
  9156. * @param defines The defines to update
  9157. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9158. * @param useBones Precise whether bones should be used or not (override mesh info)
  9159. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9160. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9161. * @returns false if defines are considered not dirty and have not been checked
  9162. */
  9163. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9164. /**
  9165. * Prepares the defines related to multiview
  9166. * @param scene The scene we are intending to draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9170. /**
  9171. * Prepares the defines related to the light information passed in parameter
  9172. * @param scene The scene we are intending to draw
  9173. * @param mesh The mesh the effect is compiling for
  9174. * @param light The light the effect is compiling for
  9175. * @param lightIndex The index of the light
  9176. * @param defines The defines to update
  9177. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9178. * @param state Defines the current state regarding what is needed (normals, etc...)
  9179. */
  9180. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9181. needNormals: boolean;
  9182. needRebuild: boolean;
  9183. shadowEnabled: boolean;
  9184. specularEnabled: boolean;
  9185. lightmapMode: boolean;
  9186. }): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param defines The defines to update
  9192. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9193. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9194. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9195. * @returns true if normals will be required for the rest of the effect
  9196. */
  9197. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9198. /**
  9199. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9200. * @param lightIndex defines the light index
  9201. * @param uniformsList The uniform list
  9202. * @param samplersList The sampler list
  9203. * @param projectedLightTexture defines if projected texture must be used
  9204. * @param uniformBuffersList defines an optional list of uniform buffers
  9205. */
  9206. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9207. /**
  9208. * Prepares the uniforms and samplers list to be used in the effect
  9209. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9210. * @param samplersList The sampler list
  9211. * @param defines The defines helping in the list generation
  9212. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9213. */
  9214. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9215. /**
  9216. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9217. * @param defines The defines to update while falling back
  9218. * @param fallbacks The authorized effect fallbacks
  9219. * @param maxSimultaneousLights The maximum number of lights allowed
  9220. * @param rank the current rank of the Effect
  9221. * @returns The newly affected rank
  9222. */
  9223. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9224. private static _TmpMorphInfluencers;
  9225. /**
  9226. * Prepares the list of attributes required for morph targets according to the effect defines.
  9227. * @param attribs The current list of supported attribs
  9228. * @param mesh The mesh to prepare the morph targets attributes for
  9229. * @param influencers The number of influencers
  9230. */
  9231. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param defines The current Defines of the effect
  9237. */
  9238. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9239. /**
  9240. * Prepares the list of attributes required for bones according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the bones attributes for
  9243. * @param defines The current Defines of the effect
  9244. * @param fallbacks The current efffect fallback strategy
  9245. */
  9246. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9247. /**
  9248. * Check and prepare the list of attributes required for instances according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param defines The current MaterialDefines of the effect
  9251. */
  9252. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9253. /**
  9254. * Add the list of attributes required for instances to the attribs array.
  9255. * @param attribs The current list of supported attribs
  9256. */
  9257. static PushAttributesForInstances(attribs: string[]): void;
  9258. /**
  9259. * Binds the light information to the effect.
  9260. * @param light The light containing the generator
  9261. * @param effect The effect we are binding the data to
  9262. * @param lightIndex The light index in the effect used to render
  9263. */
  9264. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9265. /**
  9266. * Binds the lights information from the scene to the effect for the given mesh.
  9267. * @param light Light to bind
  9268. * @param lightIndex Light index
  9269. * @param scene The scene where the light belongs to
  9270. * @param effect The effect we are binding the data to
  9271. * @param useSpecular Defines if specular is supported
  9272. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9273. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9274. */
  9275. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9276. /**
  9277. * Binds the lights information from the scene to the effect for the given mesh.
  9278. * @param scene The scene the lights belongs to
  9279. * @param mesh The mesh we are binding the information to render
  9280. * @param effect The effect we are binding the data to
  9281. * @param defines The generated defines for the effect
  9282. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9283. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9284. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9285. */
  9286. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9287. private static _tempFogColor;
  9288. /**
  9289. * Binds the fog information from the scene to the effect for the given mesh.
  9290. * @param scene The scene the lights belongs to
  9291. * @param mesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. * @param linearSpace Defines if the fog effect is applied in linear space
  9294. */
  9295. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9296. /**
  9297. * Binds the bones information from the mesh to the effect.
  9298. * @param mesh The mesh we are binding the information to render
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9302. /**
  9303. * Binds the morph targets information from the mesh to the effect.
  9304. * @param abstractMesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9308. /**
  9309. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9310. * @param defines The generated defines used in the effect
  9311. * @param effect The effect we are binding the data to
  9312. * @param scene The scene we are willing to render with logarithmic scale for
  9313. */
  9314. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9315. /**
  9316. * Binds the clip plane information from the scene to the effect.
  9317. * @param scene The scene the clip plane information are extracted from
  9318. * @param effect The effect we are binding the data to
  9319. */
  9320. static BindClipPlane(effect: Effect, scene: Scene): void;
  9321. }
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9324. /** @hidden */
  9325. export var packingFunctions: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9331. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9374. /** @hidden */
  9375. export var morphTargetsVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9381. /** @hidden */
  9382. export var instancesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9388. /** @hidden */
  9389. export var bonesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9395. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9398. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9399. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9403. /** @hidden */
  9404. export var shadowMapVertexShader: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9410. /** @hidden */
  9411. export var depthBoxBlurPixelShader: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9417. import { Nullable } from "babylonjs/types";
  9418. import { Scene } from "babylonjs/scene";
  9419. import { Matrix } from "babylonjs/Maths/math.vector";
  9420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9422. import { Mesh } from "babylonjs/Meshes/mesh";
  9423. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9424. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9425. import { Effect } from "babylonjs/Materials/effect";
  9426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9427. import "babylonjs/Shaders/shadowMap.fragment";
  9428. import "babylonjs/Shaders/shadowMap.vertex";
  9429. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9430. import { Observable } from "babylonjs/Misc/observable";
  9431. /**
  9432. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9433. */
  9434. export interface ICustomShaderOptions {
  9435. /**
  9436. * Gets or sets the custom shader name to use
  9437. */
  9438. shaderName: string;
  9439. /**
  9440. * The list of attribute names used in the shader
  9441. */
  9442. attributes?: string[];
  9443. /**
  9444. * The list of unifrom names used in the shader
  9445. */
  9446. uniforms?: string[];
  9447. /**
  9448. * The list of sampler names used in the shader
  9449. */
  9450. samplers?: string[];
  9451. /**
  9452. * The list of defines used in the shader
  9453. */
  9454. defines?: string[];
  9455. }
  9456. /**
  9457. * Interface to implement to create a shadow generator compatible with BJS.
  9458. */
  9459. export interface IShadowGenerator {
  9460. /**
  9461. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9462. * @returns The render target texture if present otherwise, null
  9463. */
  9464. getShadowMap(): Nullable<RenderTargetTexture>;
  9465. /**
  9466. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9467. * @returns The render target texture if the shadow map is present otherwise, null
  9468. */
  9469. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9470. /**
  9471. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9472. * @param subMesh The submesh we want to render in the shadow map
  9473. * @param useInstances Defines wether will draw in the map using instances
  9474. * @returns true if ready otherwise, false
  9475. */
  9476. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9477. /**
  9478. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9479. * @param defines Defines of the material we want to update
  9480. * @param lightIndex Index of the light in the enabled light list of the material
  9481. */
  9482. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9483. /**
  9484. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9485. * defined in the generator but impacting the effect).
  9486. * It implies the unifroms available on the materials are the standard BJS ones.
  9487. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9488. * @param effect The effect we are binfing the information for
  9489. */
  9490. bindShadowLight(lightIndex: string, effect: Effect): void;
  9491. /**
  9492. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9493. * (eq to shadow prjection matrix * light transform matrix)
  9494. * @returns The transform matrix used to create the shadow map
  9495. */
  9496. getTransformMatrix(): Matrix;
  9497. /**
  9498. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9499. * Cube and 2D textures for instance.
  9500. */
  9501. recreateShadowMap(): void;
  9502. /**
  9503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9504. * @param onCompiled Callback triggered at the and of the effects compilation
  9505. * @param options Sets of optional options forcing the compilation with different modes
  9506. */
  9507. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9508. useInstances: boolean;
  9509. }>): void;
  9510. /**
  9511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9512. * @param options Sets of optional options forcing the compilation with different modes
  9513. * @returns A promise that resolves when the compilation completes
  9514. */
  9515. forceCompilationAsync(options?: Partial<{
  9516. useInstances: boolean;
  9517. }>): Promise<void>;
  9518. /**
  9519. * Serializes the shadow generator setup to a json object.
  9520. * @returns The serialized JSON object
  9521. */
  9522. serialize(): any;
  9523. /**
  9524. * Disposes the Shadow map and related Textures and effects.
  9525. */
  9526. dispose(): void;
  9527. }
  9528. /**
  9529. * Default implementation IShadowGenerator.
  9530. * This is the main object responsible of generating shadows in the framework.
  9531. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9532. */
  9533. export class ShadowGenerator implements IShadowGenerator {
  9534. /**
  9535. * Shadow generator mode None: no filtering applied.
  9536. */
  9537. static readonly FILTER_NONE: number;
  9538. /**
  9539. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9540. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9541. */
  9542. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9543. /**
  9544. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9545. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9546. */
  9547. static readonly FILTER_POISSONSAMPLING: number;
  9548. /**
  9549. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9550. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9551. */
  9552. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9553. /**
  9554. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9555. * edge artifacts on steep falloff.
  9556. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9557. */
  9558. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9559. /**
  9560. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9561. * edge artifacts on steep falloff.
  9562. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9563. */
  9564. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9565. /**
  9566. * Shadow generator mode PCF: Percentage Closer Filtering
  9567. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9568. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9569. */
  9570. static readonly FILTER_PCF: number;
  9571. /**
  9572. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9573. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9574. * Contact Hardening
  9575. */
  9576. static readonly FILTER_PCSS: number;
  9577. /**
  9578. * Reserved for PCF and PCSS
  9579. * Highest Quality.
  9580. *
  9581. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9582. *
  9583. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9584. */
  9585. static readonly QUALITY_HIGH: number;
  9586. /**
  9587. * Reserved for PCF and PCSS
  9588. * Good tradeoff for quality/perf cross devices
  9589. *
  9590. * Execute PCF on a 3*3 kernel.
  9591. *
  9592. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9593. */
  9594. static readonly QUALITY_MEDIUM: number;
  9595. /**
  9596. * Reserved for PCF and PCSS
  9597. * The lowest quality but the fastest.
  9598. *
  9599. * Execute PCF on a 1*1 kernel.
  9600. *
  9601. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9602. */
  9603. static readonly QUALITY_LOW: number;
  9604. /** Gets or sets the custom shader name to use */
  9605. customShaderOptions: ICustomShaderOptions;
  9606. /**
  9607. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9608. */
  9609. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9610. /**
  9611. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9612. */
  9613. onAfterShadowMapRenderObservable: Observable<Effect>;
  9614. /**
  9615. * Observable triggered before a mesh is rendered in the shadow map.
  9616. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9617. */
  9618. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9619. /**
  9620. * Observable triggered after a mesh is rendered in the shadow map.
  9621. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9622. */
  9623. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9624. private _bias;
  9625. /**
  9626. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9627. */
  9628. /**
  9629. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9630. */
  9631. bias: number;
  9632. private _normalBias;
  9633. /**
  9634. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9635. */
  9636. /**
  9637. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9638. */
  9639. normalBias: number;
  9640. private _blurBoxOffset;
  9641. /**
  9642. * Gets the blur box offset: offset applied during the blur pass.
  9643. * Only useful if useKernelBlur = false
  9644. */
  9645. /**
  9646. * Sets the blur box offset: offset applied during the blur pass.
  9647. * Only useful if useKernelBlur = false
  9648. */
  9649. blurBoxOffset: number;
  9650. private _blurScale;
  9651. /**
  9652. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9653. * 2 means half of the size.
  9654. */
  9655. /**
  9656. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9657. * 2 means half of the size.
  9658. */
  9659. blurScale: number;
  9660. private _blurKernel;
  9661. /**
  9662. * Gets the blur kernel: kernel size of the blur pass.
  9663. * Only useful if useKernelBlur = true
  9664. */
  9665. /**
  9666. * Sets the blur kernel: kernel size of the blur pass.
  9667. * Only useful if useKernelBlur = true
  9668. */
  9669. blurKernel: number;
  9670. private _useKernelBlur;
  9671. /**
  9672. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9673. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9674. */
  9675. /**
  9676. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9677. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9678. */
  9679. useKernelBlur: boolean;
  9680. private _depthScale;
  9681. /**
  9682. * Gets the depth scale used in ESM mode.
  9683. */
  9684. /**
  9685. * Sets the depth scale used in ESM mode.
  9686. * This can override the scale stored on the light.
  9687. */
  9688. depthScale: number;
  9689. private _filter;
  9690. /**
  9691. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9692. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9693. */
  9694. /**
  9695. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9696. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9697. */
  9698. filter: number;
  9699. /**
  9700. * Gets if the current filter is set to Poisson Sampling.
  9701. */
  9702. /**
  9703. * Sets the current filter to Poisson Sampling.
  9704. */
  9705. usePoissonSampling: boolean;
  9706. /**
  9707. * Gets if the current filter is set to ESM.
  9708. */
  9709. /**
  9710. * Sets the current filter is to ESM.
  9711. */
  9712. useExponentialShadowMap: boolean;
  9713. /**
  9714. * Gets if the current filter is set to filtered ESM.
  9715. */
  9716. /**
  9717. * Gets if the current filter is set to filtered ESM.
  9718. */
  9719. useBlurExponentialShadowMap: boolean;
  9720. /**
  9721. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9722. * exponential to prevent steep falloff artifacts).
  9723. */
  9724. /**
  9725. * Sets the current filter to "close ESM" (using the inverse of the
  9726. * exponential to prevent steep falloff artifacts).
  9727. */
  9728. useCloseExponentialShadowMap: boolean;
  9729. /**
  9730. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9731. * exponential to prevent steep falloff artifacts).
  9732. */
  9733. /**
  9734. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9735. * exponential to prevent steep falloff artifacts).
  9736. */
  9737. useBlurCloseExponentialShadowMap: boolean;
  9738. /**
  9739. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9740. */
  9741. /**
  9742. * Sets the current filter to "PCF" (percentage closer filtering).
  9743. */
  9744. usePercentageCloserFiltering: boolean;
  9745. private _filteringQuality;
  9746. /**
  9747. * Gets the PCF or PCSS Quality.
  9748. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9749. */
  9750. /**
  9751. * Sets the PCF or PCSS Quality.
  9752. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9753. */
  9754. filteringQuality: number;
  9755. /**
  9756. * Gets if the current filter is set to "PCSS" (contact hardening).
  9757. */
  9758. /**
  9759. * Sets the current filter to "PCSS" (contact hardening).
  9760. */
  9761. useContactHardeningShadow: boolean;
  9762. private _contactHardeningLightSizeUVRatio;
  9763. /**
  9764. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9765. * Using a ratio helps keeping shape stability independently of the map size.
  9766. *
  9767. * It does not account for the light projection as it was having too much
  9768. * instability during the light setup or during light position changes.
  9769. *
  9770. * Only valid if useContactHardeningShadow is true.
  9771. */
  9772. /**
  9773. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9774. * Using a ratio helps keeping shape stability independently of the map size.
  9775. *
  9776. * It does not account for the light projection as it was having too much
  9777. * instability during the light setup or during light position changes.
  9778. *
  9779. * Only valid if useContactHardeningShadow is true.
  9780. */
  9781. contactHardeningLightSizeUVRatio: number;
  9782. private _darkness;
  9783. /** Gets or sets the actual darkness of a shadow */
  9784. darkness: number;
  9785. /**
  9786. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9787. * 0 means strongest and 1 would means no shadow.
  9788. * @returns the darkness.
  9789. */
  9790. getDarkness(): number;
  9791. /**
  9792. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9793. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9794. * @returns the shadow generator allowing fluent coding.
  9795. */
  9796. setDarkness(darkness: number): ShadowGenerator;
  9797. private _transparencyShadow;
  9798. /** Gets or sets the ability to have transparent shadow */
  9799. transparencyShadow: boolean;
  9800. /**
  9801. * Sets the ability to have transparent shadow (boolean).
  9802. * @param transparent True if transparent else False
  9803. * @returns the shadow generator allowing fluent coding
  9804. */
  9805. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9806. private _shadowMap;
  9807. private _shadowMap2;
  9808. /**
  9809. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9810. * @returns The render target texture if present otherwise, null
  9811. */
  9812. getShadowMap(): Nullable<RenderTargetTexture>;
  9813. /**
  9814. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9815. * @returns The render target texture if the shadow map is present otherwise, null
  9816. */
  9817. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9818. /**
  9819. * Gets the class name of that object
  9820. * @returns "ShadowGenerator"
  9821. */
  9822. getClassName(): string;
  9823. /**
  9824. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9825. * @param mesh Mesh to add
  9826. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9827. * @returns the Shadow Generator itself
  9828. */
  9829. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9830. /**
  9831. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9832. * @param mesh Mesh to remove
  9833. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9834. * @returns the Shadow Generator itself
  9835. */
  9836. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9837. /**
  9838. * Controls the extent to which the shadows fade out at the edge of the frustum
  9839. * Used only by directionals and spots
  9840. */
  9841. frustumEdgeFalloff: number;
  9842. private _light;
  9843. /**
  9844. * Returns the associated light object.
  9845. * @returns the light generating the shadow
  9846. */
  9847. getLight(): IShadowLight;
  9848. /**
  9849. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9850. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9851. * It might on the other hand introduce peter panning.
  9852. */
  9853. forceBackFacesOnly: boolean;
  9854. private _scene;
  9855. private _lightDirection;
  9856. private _effect;
  9857. private _viewMatrix;
  9858. private _projectionMatrix;
  9859. private _transformMatrix;
  9860. private _cachedPosition;
  9861. private _cachedDirection;
  9862. private _cachedDefines;
  9863. private _currentRenderID;
  9864. private _boxBlurPostprocess;
  9865. private _kernelBlurXPostprocess;
  9866. private _kernelBlurYPostprocess;
  9867. private _blurPostProcesses;
  9868. private _mapSize;
  9869. private _currentFaceIndex;
  9870. private _currentFaceIndexCache;
  9871. private _textureType;
  9872. private _defaultTextureMatrix;
  9873. private _storedUniqueId;
  9874. /** @hidden */
  9875. static _SceneComponentInitialization: (scene: Scene) => void;
  9876. /**
  9877. * Creates a ShadowGenerator object.
  9878. * A ShadowGenerator is the required tool to use the shadows.
  9879. * Each light casting shadows needs to use its own ShadowGenerator.
  9880. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9881. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9882. * @param light The light object generating the shadows.
  9883. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9884. */
  9885. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9886. private _initializeGenerator;
  9887. private _initializeShadowMap;
  9888. private _initializeBlurRTTAndPostProcesses;
  9889. private _renderForShadowMap;
  9890. private _renderSubMeshForShadowMap;
  9891. private _applyFilterValues;
  9892. /**
  9893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9894. * @param onCompiled Callback triggered at the and of the effects compilation
  9895. * @param options Sets of optional options forcing the compilation with different modes
  9896. */
  9897. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9898. useInstances: boolean;
  9899. }>): void;
  9900. /**
  9901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9902. * @param options Sets of optional options forcing the compilation with different modes
  9903. * @returns A promise that resolves when the compilation completes
  9904. */
  9905. forceCompilationAsync(options?: Partial<{
  9906. useInstances: boolean;
  9907. }>): Promise<void>;
  9908. /**
  9909. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9910. * @param subMesh The submesh we want to render in the shadow map
  9911. * @param useInstances Defines wether will draw in the map using instances
  9912. * @returns true if ready otherwise, false
  9913. */
  9914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9915. /**
  9916. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9917. * @param defines Defines of the material we want to update
  9918. * @param lightIndex Index of the light in the enabled light list of the material
  9919. */
  9920. prepareDefines(defines: any, lightIndex: number): void;
  9921. /**
  9922. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9923. * defined in the generator but impacting the effect).
  9924. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9925. * @param effect The effect we are binfing the information for
  9926. */
  9927. bindShadowLight(lightIndex: string, effect: Effect): void;
  9928. /**
  9929. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9930. * (eq to shadow prjection matrix * light transform matrix)
  9931. * @returns The transform matrix used to create the shadow map
  9932. */
  9933. getTransformMatrix(): Matrix;
  9934. /**
  9935. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9936. * Cube and 2D textures for instance.
  9937. */
  9938. recreateShadowMap(): void;
  9939. private _disposeBlurPostProcesses;
  9940. private _disposeRTTandPostProcesses;
  9941. /**
  9942. * Disposes the ShadowGenerator.
  9943. * Returns nothing.
  9944. */
  9945. dispose(): void;
  9946. /**
  9947. * Serializes the shadow generator setup to a json object.
  9948. * @returns The serialized JSON object
  9949. */
  9950. serialize(): any;
  9951. /**
  9952. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9953. * @param parsedShadowGenerator The JSON object to parse
  9954. * @param scene The scene to create the shadow map for
  9955. * @returns The parsed shadow generator
  9956. */
  9957. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9958. }
  9959. }
  9960. declare module "babylonjs/Lights/light" {
  9961. import { Nullable } from "babylonjs/types";
  9962. import { Scene } from "babylonjs/scene";
  9963. import { Vector3 } from "babylonjs/Maths/math.vector";
  9964. import { Color3 } from "babylonjs/Maths/math.color";
  9965. import { Node } from "babylonjs/node";
  9966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9967. import { Effect } from "babylonjs/Materials/effect";
  9968. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9969. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9970. /**
  9971. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9972. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9973. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9974. */
  9975. export abstract class Light extends Node {
  9976. /**
  9977. * Falloff Default: light is falling off following the material specification:
  9978. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9979. */
  9980. static readonly FALLOFF_DEFAULT: number;
  9981. /**
  9982. * Falloff Physical: light is falling off following the inverse squared distance law.
  9983. */
  9984. static readonly FALLOFF_PHYSICAL: number;
  9985. /**
  9986. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9987. * to enhance interoperability with other engines.
  9988. */
  9989. static readonly FALLOFF_GLTF: number;
  9990. /**
  9991. * Falloff Standard: light is falling off like in the standard material
  9992. * to enhance interoperability with other materials.
  9993. */
  9994. static readonly FALLOFF_STANDARD: number;
  9995. /**
  9996. * If every light affecting the material is in this lightmapMode,
  9997. * material.lightmapTexture adds or multiplies
  9998. * (depends on material.useLightmapAsShadowmap)
  9999. * after every other light calculations.
  10000. */
  10001. static readonly LIGHTMAP_DEFAULT: number;
  10002. /**
  10003. * material.lightmapTexture as only diffuse lighting from this light
  10004. * adds only specular lighting from this light
  10005. * adds dynamic shadows
  10006. */
  10007. static readonly LIGHTMAP_SPECULAR: number;
  10008. /**
  10009. * material.lightmapTexture as only lighting
  10010. * no light calculation from this light
  10011. * only adds dynamic shadows from this light
  10012. */
  10013. static readonly LIGHTMAP_SHADOWSONLY: number;
  10014. /**
  10015. * Each light type uses the default quantity according to its type:
  10016. * point/spot lights use luminous intensity
  10017. * directional lights use illuminance
  10018. */
  10019. static readonly INTENSITYMODE_AUTOMATIC: number;
  10020. /**
  10021. * lumen (lm)
  10022. */
  10023. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10024. /**
  10025. * candela (lm/sr)
  10026. */
  10027. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10028. /**
  10029. * lux (lm/m^2)
  10030. */
  10031. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10032. /**
  10033. * nit (cd/m^2)
  10034. */
  10035. static readonly INTENSITYMODE_LUMINANCE: number;
  10036. /**
  10037. * Light type const id of the point light.
  10038. */
  10039. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10040. /**
  10041. * Light type const id of the directional light.
  10042. */
  10043. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10044. /**
  10045. * Light type const id of the spot light.
  10046. */
  10047. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10048. /**
  10049. * Light type const id of the hemispheric light.
  10050. */
  10051. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10052. /**
  10053. * Diffuse gives the basic color to an object.
  10054. */
  10055. diffuse: Color3;
  10056. /**
  10057. * Specular produces a highlight color on an object.
  10058. * Note: This is note affecting PBR materials.
  10059. */
  10060. specular: Color3;
  10061. /**
  10062. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10063. * falling off base on range or angle.
  10064. * This can be set to any values in Light.FALLOFF_x.
  10065. *
  10066. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10067. * other types of materials.
  10068. */
  10069. falloffType: number;
  10070. /**
  10071. * Strength of the light.
  10072. * Note: By default it is define in the framework own unit.
  10073. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10074. */
  10075. intensity: number;
  10076. private _range;
  10077. protected _inverseSquaredRange: number;
  10078. /**
  10079. * Defines how far from the source the light is impacting in scene units.
  10080. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10081. */
  10082. /**
  10083. * Defines how far from the source the light is impacting in scene units.
  10084. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10085. */
  10086. range: number;
  10087. /**
  10088. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10089. * of light.
  10090. */
  10091. private _photometricScale;
  10092. private _intensityMode;
  10093. /**
  10094. * Gets the photometric scale used to interpret the intensity.
  10095. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10096. */
  10097. /**
  10098. * Sets the photometric scale used to interpret the intensity.
  10099. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10100. */
  10101. intensityMode: number;
  10102. private _radius;
  10103. /**
  10104. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10105. */
  10106. /**
  10107. * sets the light radius used by PBR Materials to simulate soft area lights.
  10108. */
  10109. radius: number;
  10110. private _renderPriority;
  10111. /**
  10112. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10113. * exceeding the number allowed of the materials.
  10114. */
  10115. renderPriority: number;
  10116. private _shadowEnabled;
  10117. /**
  10118. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10119. * the current shadow generator.
  10120. */
  10121. /**
  10122. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10123. * the current shadow generator.
  10124. */
  10125. shadowEnabled: boolean;
  10126. private _includedOnlyMeshes;
  10127. /**
  10128. * Gets the only meshes impacted by this light.
  10129. */
  10130. /**
  10131. * Sets the only meshes impacted by this light.
  10132. */
  10133. includedOnlyMeshes: AbstractMesh[];
  10134. private _excludedMeshes;
  10135. /**
  10136. * Gets the meshes not impacted by this light.
  10137. */
  10138. /**
  10139. * Sets the meshes not impacted by this light.
  10140. */
  10141. excludedMeshes: AbstractMesh[];
  10142. private _excludeWithLayerMask;
  10143. /**
  10144. * Gets the layer id use to find what meshes are not impacted by the light.
  10145. * Inactive if 0
  10146. */
  10147. /**
  10148. * Sets the layer id use to find what meshes are not impacted by the light.
  10149. * Inactive if 0
  10150. */
  10151. excludeWithLayerMask: number;
  10152. private _includeOnlyWithLayerMask;
  10153. /**
  10154. * Gets the layer id use to find what meshes are impacted by the light.
  10155. * Inactive if 0
  10156. */
  10157. /**
  10158. * Sets the layer id use to find what meshes are impacted by the light.
  10159. * Inactive if 0
  10160. */
  10161. includeOnlyWithLayerMask: number;
  10162. private _lightmapMode;
  10163. /**
  10164. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10165. */
  10166. /**
  10167. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10168. */
  10169. lightmapMode: number;
  10170. /**
  10171. * Shadow generator associted to the light.
  10172. * @hidden Internal use only.
  10173. */
  10174. _shadowGenerator: Nullable<IShadowGenerator>;
  10175. /**
  10176. * @hidden Internal use only.
  10177. */
  10178. _excludedMeshesIds: string[];
  10179. /**
  10180. * @hidden Internal use only.
  10181. */
  10182. _includedOnlyMeshesIds: string[];
  10183. /**
  10184. * The current light unifom buffer.
  10185. * @hidden Internal use only.
  10186. */
  10187. _uniformBuffer: UniformBuffer;
  10188. /** @hidden */
  10189. _renderId: number;
  10190. /**
  10191. * Creates a Light object in the scene.
  10192. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10193. * @param name The firendly name of the light
  10194. * @param scene The scene the light belongs too
  10195. */
  10196. constructor(name: string, scene: Scene);
  10197. protected abstract _buildUniformLayout(): void;
  10198. /**
  10199. * Sets the passed Effect "effect" with the Light information.
  10200. * @param effect The effect to update
  10201. * @param lightIndex The index of the light in the effect to update
  10202. * @returns The light
  10203. */
  10204. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10205. /**
  10206. * Sets the passed Effect "effect" with the Light information.
  10207. * @param effect The effect to update
  10208. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10209. * @returns The light
  10210. */
  10211. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10212. /**
  10213. * Returns the string "Light".
  10214. * @returns the class name
  10215. */
  10216. getClassName(): string;
  10217. /** @hidden */
  10218. readonly _isLight: boolean;
  10219. /**
  10220. * Converts the light information to a readable string for debug purpose.
  10221. * @param fullDetails Supports for multiple levels of logging within scene loading
  10222. * @returns the human readable light info
  10223. */
  10224. toString(fullDetails?: boolean): string;
  10225. /** @hidden */
  10226. protected _syncParentEnabledState(): void;
  10227. /**
  10228. * Set the enabled state of this node.
  10229. * @param value - the new enabled state
  10230. */
  10231. setEnabled(value: boolean): void;
  10232. /**
  10233. * Returns the Light associated shadow generator if any.
  10234. * @return the associated shadow generator.
  10235. */
  10236. getShadowGenerator(): Nullable<IShadowGenerator>;
  10237. /**
  10238. * Returns a Vector3, the absolute light position in the World.
  10239. * @returns the world space position of the light
  10240. */
  10241. getAbsolutePosition(): Vector3;
  10242. /**
  10243. * Specifies if the light will affect the passed mesh.
  10244. * @param mesh The mesh to test against the light
  10245. * @return true the mesh is affected otherwise, false.
  10246. */
  10247. canAffectMesh(mesh: AbstractMesh): boolean;
  10248. /**
  10249. * Sort function to order lights for rendering.
  10250. * @param a First Light object to compare to second.
  10251. * @param b Second Light object to compare first.
  10252. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10253. */
  10254. static CompareLightsPriority(a: Light, b: Light): number;
  10255. /**
  10256. * Releases resources associated with this node.
  10257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10259. */
  10260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10261. /**
  10262. * Returns the light type ID (integer).
  10263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10264. */
  10265. getTypeID(): number;
  10266. /**
  10267. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10268. * @returns the scaled intensity in intensity mode unit
  10269. */
  10270. getScaledIntensity(): number;
  10271. /**
  10272. * Returns a new Light object, named "name", from the current one.
  10273. * @param name The name of the cloned light
  10274. * @returns the new created light
  10275. */
  10276. clone(name: string): Nullable<Light>;
  10277. /**
  10278. * Serializes the current light into a Serialization object.
  10279. * @returns the serialized object.
  10280. */
  10281. serialize(): any;
  10282. /**
  10283. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10284. * This new light is named "name" and added to the passed scene.
  10285. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10286. * @param name The friendly name of the light
  10287. * @param scene The scene the new light will belong to
  10288. * @returns the constructor function
  10289. */
  10290. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10291. /**
  10292. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10293. * @param parsedLight The JSON representation of the light
  10294. * @param scene The scene to create the parsed light in
  10295. * @returns the created light after parsing
  10296. */
  10297. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10298. private _hookArrayForExcluded;
  10299. private _hookArrayForIncludedOnly;
  10300. private _resyncMeshes;
  10301. /**
  10302. * Forces the meshes to update their light related information in their rendering used effects
  10303. * @hidden Internal Use Only
  10304. */
  10305. _markMeshesAsLightDirty(): void;
  10306. /**
  10307. * Recomputes the cached photometric scale if needed.
  10308. */
  10309. private _computePhotometricScale;
  10310. /**
  10311. * Returns the Photometric Scale according to the light type and intensity mode.
  10312. */
  10313. private _getPhotometricScale;
  10314. /**
  10315. * Reorder the light in the scene according to their defined priority.
  10316. * @hidden Internal Use Only
  10317. */
  10318. _reorderLightsInScene(): void;
  10319. /**
  10320. * Prepares the list of defines specific to the light type.
  10321. * @param defines the list of defines
  10322. * @param lightIndex defines the index of the light for the effect
  10323. */
  10324. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Actions/action" {
  10328. import { Observable } from "babylonjs/Misc/observable";
  10329. import { Condition } from "babylonjs/Actions/condition";
  10330. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10331. import { ActionManager } from "babylonjs/Actions/actionManager";
  10332. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10333. /**
  10334. * Interface used to define Action
  10335. */
  10336. export interface IAction {
  10337. /**
  10338. * Trigger for the action
  10339. */
  10340. trigger: number;
  10341. /** Options of the trigger */
  10342. triggerOptions: any;
  10343. /**
  10344. * Gets the trigger parameters
  10345. * @returns the trigger parameters
  10346. */
  10347. getTriggerParameter(): any;
  10348. /**
  10349. * Internal only - executes current action event
  10350. * @hidden
  10351. */
  10352. _executeCurrent(evt?: ActionEvent): void;
  10353. /**
  10354. * Serialize placeholder for child classes
  10355. * @param parent of child
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. _prepare(): void;
  10364. /**
  10365. * Internal only - manager for action
  10366. * @hidden
  10367. */
  10368. _actionManager: AbstractActionManager;
  10369. /**
  10370. * Adds action to chain of actions, may be a DoNothingAction
  10371. * @param action defines the next action to execute
  10372. * @returns The action passed in
  10373. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10374. */
  10375. then(action: IAction): IAction;
  10376. }
  10377. /**
  10378. * The action to be carried out following a trigger
  10379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10380. */
  10381. export class Action implements IAction {
  10382. /** the trigger, with or without parameters, for the action */
  10383. triggerOptions: any;
  10384. /**
  10385. * Trigger for the action
  10386. */
  10387. trigger: number;
  10388. /**
  10389. * Internal only - manager for action
  10390. * @hidden
  10391. */
  10392. _actionManager: ActionManager;
  10393. private _nextActiveAction;
  10394. private _child;
  10395. private _condition?;
  10396. private _triggerParameter;
  10397. /**
  10398. * An event triggered prior to action being executed.
  10399. */
  10400. onBeforeExecuteObservable: Observable<Action>;
  10401. /**
  10402. * Creates a new Action
  10403. * @param triggerOptions the trigger, with or without parameters, for the action
  10404. * @param condition an optional determinant of action
  10405. */
  10406. constructor(
  10407. /** the trigger, with or without parameters, for the action */
  10408. triggerOptions: any, condition?: Condition);
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. _prepare(): void;
  10414. /**
  10415. * Gets the trigger parameters
  10416. * @returns the trigger parameters
  10417. */
  10418. getTriggerParameter(): any;
  10419. /**
  10420. * Internal only - executes current action event
  10421. * @hidden
  10422. */
  10423. _executeCurrent(evt?: ActionEvent): void;
  10424. /**
  10425. * Execute placeholder for child classes
  10426. * @param evt optional action event
  10427. */
  10428. execute(evt?: ActionEvent): void;
  10429. /**
  10430. * Skips to next active action
  10431. */
  10432. skipToNextActiveAction(): void;
  10433. /**
  10434. * Adds action to chain of actions, may be a DoNothingAction
  10435. * @param action defines the next action to execute
  10436. * @returns The action passed in
  10437. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10438. */
  10439. then(action: Action): Action;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. _getProperty(propertyPath: string): string;
  10445. /**
  10446. * Internal only
  10447. * @hidden
  10448. */
  10449. _getEffectiveTarget(target: any, propertyPath: string): any;
  10450. /**
  10451. * Serialize placeholder for child classes
  10452. * @param parent of child
  10453. * @returns the serialized object
  10454. */
  10455. serialize(parent: any): any;
  10456. /**
  10457. * Internal only called by serialize
  10458. * @hidden
  10459. */
  10460. protected _serialize(serializedAction: any, parent?: any): any;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. static _SerializeValueAsString: (value: any) => string;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10471. name: string;
  10472. targetType: string;
  10473. value: string;
  10474. };
  10475. }
  10476. }
  10477. declare module "babylonjs/Actions/condition" {
  10478. import { ActionManager } from "babylonjs/Actions/actionManager";
  10479. /**
  10480. * A Condition applied to an Action
  10481. */
  10482. export class Condition {
  10483. /**
  10484. * Internal only - manager for action
  10485. * @hidden
  10486. */
  10487. _actionManager: ActionManager;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. _evaluationId: number;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. _currentResult: boolean;
  10498. /**
  10499. * Creates a new Condition
  10500. * @param actionManager the manager of the action the condition is applied to
  10501. */
  10502. constructor(actionManager: ActionManager);
  10503. /**
  10504. * Check if the current condition is valid
  10505. * @returns a boolean
  10506. */
  10507. isValid(): boolean;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _getProperty(propertyPath: string): string;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _getEffectiveTarget(target: any, propertyPath: string): any;
  10518. /**
  10519. * Serialize placeholder for child classes
  10520. * @returns the serialized object
  10521. */
  10522. serialize(): any;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. protected _serialize(serializedCondition: any): any;
  10528. }
  10529. /**
  10530. * Defines specific conditional operators as extensions of Condition
  10531. */
  10532. export class ValueCondition extends Condition {
  10533. /** path to specify the property of the target the conditional operator uses */
  10534. propertyPath: string;
  10535. /** the value compared by the conditional operator against the current value of the property */
  10536. value: any;
  10537. /** the conditional operator, default ValueCondition.IsEqual */
  10538. operator: number;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. private static _IsEqual;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. private static _IsDifferent;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. private static _IsGreater;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private static _IsLesser;
  10559. /**
  10560. * returns the number for IsEqual
  10561. */
  10562. static readonly IsEqual: number;
  10563. /**
  10564. * Returns the number for IsDifferent
  10565. */
  10566. static readonly IsDifferent: number;
  10567. /**
  10568. * Returns the number for IsGreater
  10569. */
  10570. static readonly IsGreater: number;
  10571. /**
  10572. * Returns the number for IsLesser
  10573. */
  10574. static readonly IsLesser: number;
  10575. /**
  10576. * Internal only The action manager for the condition
  10577. * @hidden
  10578. */
  10579. _actionManager: ActionManager;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private _target;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private _effectiveTarget;
  10590. /**
  10591. * Internal only
  10592. * @hidden
  10593. */
  10594. private _property;
  10595. /**
  10596. * Creates a new ValueCondition
  10597. * @param actionManager manager for the action the condition applies to
  10598. * @param target for the action
  10599. * @param propertyPath path to specify the property of the target the conditional operator uses
  10600. * @param value the value compared by the conditional operator against the current value of the property
  10601. * @param operator the conditional operator, default ValueCondition.IsEqual
  10602. */
  10603. constructor(actionManager: ActionManager, target: any,
  10604. /** path to specify the property of the target the conditional operator uses */
  10605. propertyPath: string,
  10606. /** the value compared by the conditional operator against the current value of the property */
  10607. value: any,
  10608. /** the conditional operator, default ValueCondition.IsEqual */
  10609. operator?: number);
  10610. /**
  10611. * Compares the given value with the property value for the specified conditional operator
  10612. * @returns the result of the comparison
  10613. */
  10614. isValid(): boolean;
  10615. /**
  10616. * Serialize the ValueCondition into a JSON compatible object
  10617. * @returns serialization object
  10618. */
  10619. serialize(): any;
  10620. /**
  10621. * Gets the name of the conditional operator for the ValueCondition
  10622. * @param operator the conditional operator
  10623. * @returns the name
  10624. */
  10625. static GetOperatorName(operator: number): string;
  10626. }
  10627. /**
  10628. * Defines a predicate condition as an extension of Condition
  10629. */
  10630. export class PredicateCondition extends Condition {
  10631. /** defines the predicate function used to validate the condition */
  10632. predicate: () => boolean;
  10633. /**
  10634. * Internal only - manager for action
  10635. * @hidden
  10636. */
  10637. _actionManager: ActionManager;
  10638. /**
  10639. * Creates a new PredicateCondition
  10640. * @param actionManager manager for the action the condition applies to
  10641. * @param predicate defines the predicate function used to validate the condition
  10642. */
  10643. constructor(actionManager: ActionManager,
  10644. /** defines the predicate function used to validate the condition */
  10645. predicate: () => boolean);
  10646. /**
  10647. * @returns the validity of the predicate condition
  10648. */
  10649. isValid(): boolean;
  10650. }
  10651. /**
  10652. * Defines a state condition as an extension of Condition
  10653. */
  10654. export class StateCondition extends Condition {
  10655. /** Value to compare with target state */
  10656. value: string;
  10657. /**
  10658. * Internal only - manager for action
  10659. * @hidden
  10660. */
  10661. _actionManager: ActionManager;
  10662. /**
  10663. * Internal only
  10664. * @hidden
  10665. */
  10666. private _target;
  10667. /**
  10668. * Creates a new StateCondition
  10669. * @param actionManager manager for the action the condition applies to
  10670. * @param target of the condition
  10671. * @param value to compare with target state
  10672. */
  10673. constructor(actionManager: ActionManager, target: any,
  10674. /** Value to compare with target state */
  10675. value: string);
  10676. /**
  10677. * Gets a boolean indicating if the current condition is met
  10678. * @returns the validity of the state
  10679. */
  10680. isValid(): boolean;
  10681. /**
  10682. * Serialize the StateCondition into a JSON compatible object
  10683. * @returns serialization object
  10684. */
  10685. serialize(): any;
  10686. }
  10687. }
  10688. declare module "babylonjs/Actions/directActions" {
  10689. import { Action } from "babylonjs/Actions/action";
  10690. import { Condition } from "babylonjs/Actions/condition";
  10691. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10692. /**
  10693. * This defines an action responsible to toggle a boolean once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SwitchBooleanAction extends Action {
  10697. /**
  10698. * The path to the boolean property in the target object
  10699. */
  10700. propertyPath: string;
  10701. private _target;
  10702. private _effectiveTarget;
  10703. private _property;
  10704. /**
  10705. * Instantiate the action
  10706. * @param triggerOptions defines the trigger options
  10707. * @param target defines the object containing the boolean
  10708. * @param propertyPath defines the path to the boolean property in the target object
  10709. * @param condition defines the trigger related conditions
  10710. */
  10711. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10712. /** @hidden */
  10713. _prepare(): void;
  10714. /**
  10715. * Execute the action toggle the boolean value.
  10716. */
  10717. execute(): void;
  10718. /**
  10719. * Serializes the actions and its related information.
  10720. * @param parent defines the object to serialize in
  10721. * @returns the serialized object
  10722. */
  10723. serialize(parent: any): any;
  10724. }
  10725. /**
  10726. * This defines an action responsible to set a the state field of the target
  10727. * to a desired value once triggered.
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10729. */
  10730. export class SetStateAction extends Action {
  10731. /**
  10732. * The value to store in the state field.
  10733. */
  10734. value: string;
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the object containing the state property
  10740. * @param value defines the value to store in the state field
  10741. * @param condition defines the trigger related conditions
  10742. */
  10743. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10744. /**
  10745. * Execute the action and store the value on the target state property.
  10746. */
  10747. execute(): void;
  10748. /**
  10749. * Serializes the actions and its related information.
  10750. * @param parent defines the object to serialize in
  10751. * @returns the serialized object
  10752. */
  10753. serialize(parent: any): any;
  10754. }
  10755. /**
  10756. * This defines an action responsible to set a property of the target
  10757. * to a desired value once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class SetValueAction extends Action {
  10761. /**
  10762. * The path of the property to set in the target.
  10763. */
  10764. propertyPath: string;
  10765. /**
  10766. * The value to set in the property
  10767. */
  10768. value: any;
  10769. private _target;
  10770. private _effectiveTarget;
  10771. private _property;
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param target defines the object containing the property
  10776. * @param propertyPath defines the path of the property to set in the target
  10777. * @param value defines the value to set in the property
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10781. /** @hidden */
  10782. _prepare(): void;
  10783. /**
  10784. * Execute the action and set the targetted property to the desired value.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to increment the target value
  10796. * to a desired value once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class IncrementValueAction extends Action {
  10800. /**
  10801. * The path of the property to increment in the target.
  10802. */
  10803. propertyPath: string;
  10804. /**
  10805. * The value we should increment the property by.
  10806. */
  10807. value: any;
  10808. private _target;
  10809. private _effectiveTarget;
  10810. private _property;
  10811. /**
  10812. * Instantiate the action
  10813. * @param triggerOptions defines the trigger options
  10814. * @param target defines the object containing the property
  10815. * @param propertyPath defines the path of the property to increment in the target
  10816. * @param value defines the value value we should increment the property by
  10817. * @param condition defines the trigger related conditions
  10818. */
  10819. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10820. /** @hidden */
  10821. _prepare(): void;
  10822. /**
  10823. * Execute the action and increment the target of the value amount.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to start an animation once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class PlayAnimationAction extends Action {
  10838. /**
  10839. * Where the animation should start (animation frame)
  10840. */
  10841. from: number;
  10842. /**
  10843. * Where the animation should stop (animation frame)
  10844. */
  10845. to: number;
  10846. /**
  10847. * Define if the animation should loop or stop after the first play.
  10848. */
  10849. loop?: boolean;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target animation or animation name
  10855. * @param from defines from where the animation should start (animation frame)
  10856. * @param end defines where the animation should stop (animation frame)
  10857. * @param loop defines if the animation should loop or stop after the first play
  10858. * @param condition defines the trigger related conditions
  10859. */
  10860. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10861. /** @hidden */
  10862. _prepare(): void;
  10863. /**
  10864. * Execute the action and play the animation.
  10865. */
  10866. execute(): void;
  10867. /**
  10868. * Serializes the actions and its related information.
  10869. * @param parent defines the object to serialize in
  10870. * @returns the serialized object
  10871. */
  10872. serialize(parent: any): any;
  10873. }
  10874. /**
  10875. * This defines an action responsible to stop an animation once triggered.
  10876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10877. */
  10878. export class StopAnimationAction extends Action {
  10879. private _target;
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param target defines the target animation or animation name
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, condition?: Condition);
  10887. /** @hidden */
  10888. _prepare(): void;
  10889. /**
  10890. * Execute the action and stop the animation.
  10891. */
  10892. execute(): void;
  10893. /**
  10894. * Serializes the actions and its related information.
  10895. * @param parent defines the object to serialize in
  10896. * @returns the serialized object
  10897. */
  10898. serialize(parent: any): any;
  10899. }
  10900. /**
  10901. * This defines an action responsible that does nothing once triggered.
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10903. */
  10904. export class DoNothingAction extends Action {
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions?: any, condition?: Condition);
  10911. /**
  10912. * Execute the action and do nothing.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible to trigger several actions once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class CombineAction extends Action {
  10927. /**
  10928. * The list of aggregated animations to run.
  10929. */
  10930. children: Action[];
  10931. /**
  10932. * Instantiate the action
  10933. * @param triggerOptions defines the trigger options
  10934. * @param children defines the list of aggregated animations to run
  10935. * @param condition defines the trigger related conditions
  10936. */
  10937. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10938. /** @hidden */
  10939. _prepare(): void;
  10940. /**
  10941. * Execute the action and executes all the aggregated actions.
  10942. */
  10943. execute(evt: ActionEvent): void;
  10944. /**
  10945. * Serializes the actions and its related information.
  10946. * @param parent defines the object to serialize in
  10947. * @returns the serialized object
  10948. */
  10949. serialize(parent: any): any;
  10950. }
  10951. /**
  10952. * This defines an action responsible to run code (external event) once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class ExecuteCodeAction extends Action {
  10956. /**
  10957. * The callback function to run.
  10958. */
  10959. func: (evt: ActionEvent) => void;
  10960. /**
  10961. * Instantiate the action
  10962. * @param triggerOptions defines the trigger options
  10963. * @param func defines the callback function to run
  10964. * @param condition defines the trigger related conditions
  10965. */
  10966. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10967. /**
  10968. * Execute the action and run the attached code.
  10969. */
  10970. execute(evt: ActionEvent): void;
  10971. }
  10972. /**
  10973. * This defines an action responsible to set the parent property of the target once triggered.
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10975. */
  10976. export class SetParentAction extends Action {
  10977. private _parent;
  10978. private _target;
  10979. /**
  10980. * Instantiate the action
  10981. * @param triggerOptions defines the trigger options
  10982. * @param target defines the target containing the parent property
  10983. * @param parent defines from where the animation should start (animation frame)
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10987. /** @hidden */
  10988. _prepare(): void;
  10989. /**
  10990. * Execute the action and set the parent property.
  10991. */
  10992. execute(): void;
  10993. /**
  10994. * Serializes the actions and its related information.
  10995. * @param parent defines the object to serialize in
  10996. * @returns the serialized object
  10997. */
  10998. serialize(parent: any): any;
  10999. }
  11000. }
  11001. declare module "babylonjs/Actions/actionManager" {
  11002. import { Nullable } from "babylonjs/types";
  11003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11004. import { Scene } from "babylonjs/scene";
  11005. import { IAction } from "babylonjs/Actions/action";
  11006. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11007. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11008. /**
  11009. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11010. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class ActionManager extends AbstractActionManager {
  11014. /**
  11015. * Nothing
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11017. */
  11018. static readonly NothingTrigger: number;
  11019. /**
  11020. * On pick
  11021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11022. */
  11023. static readonly OnPickTrigger: number;
  11024. /**
  11025. * On left pick
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11027. */
  11028. static readonly OnLeftPickTrigger: number;
  11029. /**
  11030. * On right pick
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly OnRightPickTrigger: number;
  11034. /**
  11035. * On center pick
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnCenterPickTrigger: number;
  11039. /**
  11040. * On pick down
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickDownTrigger: number;
  11044. /**
  11045. * On double pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnDoublePickTrigger: number;
  11049. /**
  11050. * On pick up
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnPickUpTrigger: number;
  11054. /**
  11055. * On pick out.
  11056. * This trigger will only be raised if you also declared a OnPickDown
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickOutTrigger: number;
  11060. /**
  11061. * On long press
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnLongPressTrigger: number;
  11065. /**
  11066. * On pointer over
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPointerOverTrigger: number;
  11070. /**
  11071. * On pointer out
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnPointerOutTrigger: number;
  11075. /**
  11076. * On every frame
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnEveryFrameTrigger: number;
  11080. /**
  11081. * On intersection enter
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnIntersectionEnterTrigger: number;
  11085. /**
  11086. * On intersection exit
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnIntersectionExitTrigger: number;
  11090. /**
  11091. * On key down
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnKeyDownTrigger: number;
  11095. /**
  11096. * On key up
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnKeyUpTrigger: number;
  11100. private _scene;
  11101. /**
  11102. * Creates a new action manager
  11103. * @param scene defines the hosting scene
  11104. */
  11105. constructor(scene: Scene);
  11106. /**
  11107. * Releases all associated resources
  11108. */
  11109. dispose(): void;
  11110. /**
  11111. * Gets hosting scene
  11112. * @returns the hosting scene
  11113. */
  11114. getScene(): Scene;
  11115. /**
  11116. * Does this action manager handles actions of any of the given triggers
  11117. * @param triggers defines the triggers to be tested
  11118. * @return a boolean indicating whether one (or more) of the triggers is handled
  11119. */
  11120. hasSpecificTriggers(triggers: number[]): boolean;
  11121. /**
  11122. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11123. * speed.
  11124. * @param triggerA defines the trigger to be tested
  11125. * @param triggerB defines the trigger to be tested
  11126. * @return a boolean indicating whether one (or more) of the triggers is handled
  11127. */
  11128. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11129. /**
  11130. * Does this action manager handles actions of a given trigger
  11131. * @param trigger defines the trigger to be tested
  11132. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11133. * @return whether the trigger is handled
  11134. */
  11135. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11136. /**
  11137. * Does this action manager has pointer triggers
  11138. */
  11139. readonly hasPointerTriggers: boolean;
  11140. /**
  11141. * Does this action manager has pick triggers
  11142. */
  11143. readonly hasPickTriggers: boolean;
  11144. /**
  11145. * Registers an action to this action manager
  11146. * @param action defines the action to be registered
  11147. * @return the action amended (prepared) after registration
  11148. */
  11149. registerAction(action: IAction): Nullable<IAction>;
  11150. /**
  11151. * Unregisters an action to this action manager
  11152. * @param action defines the action to be unregistered
  11153. * @return a boolean indicating whether the action has been unregistered
  11154. */
  11155. unregisterAction(action: IAction): Boolean;
  11156. /**
  11157. * Process a specific trigger
  11158. * @param trigger defines the trigger to process
  11159. * @param evt defines the event details to be processed
  11160. */
  11161. processTrigger(trigger: number, evt?: IActionEvent): void;
  11162. /** @hidden */
  11163. _getEffectiveTarget(target: any, propertyPath: string): any;
  11164. /** @hidden */
  11165. _getProperty(propertyPath: string): string;
  11166. /**
  11167. * Serialize this manager to a JSON object
  11168. * @param name defines the property name to store this manager
  11169. * @returns a JSON representation of this manager
  11170. */
  11171. serialize(name: string): any;
  11172. /**
  11173. * Creates a new ActionManager from a JSON data
  11174. * @param parsedActions defines the JSON data to read from
  11175. * @param object defines the hosting mesh
  11176. * @param scene defines the hosting scene
  11177. */
  11178. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11179. /**
  11180. * Get a trigger name by index
  11181. * @param trigger defines the trigger index
  11182. * @returns a trigger name
  11183. */
  11184. static GetTriggerName(trigger: number): string;
  11185. }
  11186. }
  11187. declare module "babylonjs/Culling/ray" {
  11188. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11191. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11192. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11193. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11194. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11195. import { Plane } from "babylonjs/Maths/math.plane";
  11196. /**
  11197. * Class representing a ray with position and direction
  11198. */
  11199. export class Ray {
  11200. /** origin point */
  11201. origin: Vector3;
  11202. /** direction */
  11203. direction: Vector3;
  11204. /** length of the ray */
  11205. length: number;
  11206. private static readonly TmpVector3;
  11207. private _tmpRay;
  11208. /**
  11209. * Creates a new ray
  11210. * @param origin origin point
  11211. * @param direction direction
  11212. * @param length length of the ray
  11213. */
  11214. constructor(
  11215. /** origin point */
  11216. origin: Vector3,
  11217. /** direction */
  11218. direction: Vector3,
  11219. /** length of the ray */
  11220. length?: number);
  11221. /**
  11222. * Checks if the ray intersects a box
  11223. * @param minimum bound of the box
  11224. * @param maximum bound of the box
  11225. * @param intersectionTreshold extra extend to be added to the box in all direction
  11226. * @returns if the box was hit
  11227. */
  11228. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11229. /**
  11230. * Checks if the ray intersects a box
  11231. * @param box the bounding box to check
  11232. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11233. * @returns if the box was hit
  11234. */
  11235. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11236. /**
  11237. * If the ray hits a sphere
  11238. * @param sphere the bounding sphere to check
  11239. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11240. * @returns true if it hits the sphere
  11241. */
  11242. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * If the ray hits a triange
  11245. * @param vertex0 triangle vertex
  11246. * @param vertex1 triangle vertex
  11247. * @param vertex2 triangle vertex
  11248. * @returns intersection information if hit
  11249. */
  11250. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11251. /**
  11252. * Checks if ray intersects a plane
  11253. * @param plane the plane to check
  11254. * @returns the distance away it was hit
  11255. */
  11256. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11257. /**
  11258. * Calculate the intercept of a ray on a given axis
  11259. * @param axis to check 'x' | 'y' | 'z'
  11260. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11261. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11262. */
  11263. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11264. /**
  11265. * Checks if ray intersects a mesh
  11266. * @param mesh the mesh to check
  11267. * @param fastCheck if only the bounding box should checked
  11268. * @returns picking info of the intersecton
  11269. */
  11270. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param meshes the meshes to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @param results array to store result in
  11276. * @returns Array of picking infos
  11277. */
  11278. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11279. private _comparePickingInfo;
  11280. private static smallnum;
  11281. private static rayl;
  11282. /**
  11283. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11284. * @param sega the first point of the segment to test the intersection against
  11285. * @param segb the second point of the segment to test the intersection against
  11286. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11287. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11288. */
  11289. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11290. /**
  11291. * Update the ray from viewport position
  11292. * @param x position
  11293. * @param y y position
  11294. * @param viewportWidth viewport width
  11295. * @param viewportHeight viewport height
  11296. * @param world world matrix
  11297. * @param view view matrix
  11298. * @param projection projection matrix
  11299. * @returns this ray updated
  11300. */
  11301. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Creates a ray with origin and direction of 0,0,0
  11304. * @returns the new ray
  11305. */
  11306. static Zero(): Ray;
  11307. /**
  11308. * Creates a new ray from screen space and viewport
  11309. * @param x position
  11310. * @param y y position
  11311. * @param viewportWidth viewport width
  11312. * @param viewportHeight viewport height
  11313. * @param world world matrix
  11314. * @param view view matrix
  11315. * @param projection projection matrix
  11316. * @returns new ray
  11317. */
  11318. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11319. /**
  11320. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11321. * transformed to the given world matrix.
  11322. * @param origin The origin point
  11323. * @param end The end point
  11324. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11325. * @returns the new ray
  11326. */
  11327. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11328. /**
  11329. * Transforms a ray by a matrix
  11330. * @param ray ray to transform
  11331. * @param matrix matrix to apply
  11332. * @returns the resulting new ray
  11333. */
  11334. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @param result ray to store result in
  11340. */
  11341. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11342. /**
  11343. * Unproject a ray from screen space to object space
  11344. * @param sourceX defines the screen space x coordinate to use
  11345. * @param sourceY defines the screen space y coordinate to use
  11346. * @param viewportWidth defines the current width of the viewport
  11347. * @param viewportHeight defines the current height of the viewport
  11348. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11349. * @param view defines the view matrix to use
  11350. * @param projection defines the projection matrix to use
  11351. */
  11352. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11353. }
  11354. /**
  11355. * Type used to define predicate used to select faces when a mesh intersection is detected
  11356. */
  11357. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11358. module "babylonjs/scene" {
  11359. interface Scene {
  11360. /** @hidden */
  11361. _tempPickingRay: Nullable<Ray>;
  11362. /** @hidden */
  11363. _cachedRayForTransform: Ray;
  11364. /** @hidden */
  11365. _pickWithRayInverseMatrix: Matrix;
  11366. /** @hidden */
  11367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11368. /** @hidden */
  11369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11370. }
  11371. }
  11372. }
  11373. declare module "babylonjs/sceneComponent" {
  11374. import { Scene } from "babylonjs/scene";
  11375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11377. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11378. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11382. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11383. import { AbstractScene } from "babylonjs/abstractScene";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. /**
  11386. * Groups all the scene component constants in one place to ease maintenance.
  11387. * @hidden
  11388. */
  11389. export class SceneComponentConstants {
  11390. static readonly NAME_EFFECTLAYER: string;
  11391. static readonly NAME_LAYER: string;
  11392. static readonly NAME_LENSFLARESYSTEM: string;
  11393. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11394. static readonly NAME_PARTICLESYSTEM: string;
  11395. static readonly NAME_GAMEPAD: string;
  11396. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11397. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11398. static readonly NAME_DEPTHRENDERER: string;
  11399. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11400. static readonly NAME_SPRITE: string;
  11401. static readonly NAME_OUTLINERENDERER: string;
  11402. static readonly NAME_PROCEDURALTEXTURE: string;
  11403. static readonly NAME_SHADOWGENERATOR: string;
  11404. static readonly NAME_OCTREE: string;
  11405. static readonly NAME_PHYSICSENGINE: string;
  11406. static readonly NAME_AUDIO: string;
  11407. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11408. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11409. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11410. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11411. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11412. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11413. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11414. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11415. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11416. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11417. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11418. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11419. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11420. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11421. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11422. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11423. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11424. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11425. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11426. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11427. static readonly STEP_AFTERRENDER_AUDIO: number;
  11428. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11429. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11430. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11431. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11432. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11433. static readonly STEP_POINTERMOVE_SPRITE: number;
  11434. static readonly STEP_POINTERDOWN_SPRITE: number;
  11435. static readonly STEP_POINTERUP_SPRITE: number;
  11436. }
  11437. /**
  11438. * This represents a scene component.
  11439. *
  11440. * This is used to decouple the dependency the scene is having on the different workloads like
  11441. * layers, post processes...
  11442. */
  11443. export interface ISceneComponent {
  11444. /**
  11445. * The name of the component. Each component must have a unique name.
  11446. */
  11447. name: string;
  11448. /**
  11449. * The scene the component belongs to.
  11450. */
  11451. scene: Scene;
  11452. /**
  11453. * Register the component to one instance of a scene.
  11454. */
  11455. register(): void;
  11456. /**
  11457. * Rebuilds the elements related to this component in case of
  11458. * context lost for instance.
  11459. */
  11460. rebuild(): void;
  11461. /**
  11462. * Disposes the component and the associated ressources.
  11463. */
  11464. dispose(): void;
  11465. }
  11466. /**
  11467. * This represents a SERIALIZABLE scene component.
  11468. *
  11469. * This extends Scene Component to add Serialization methods on top.
  11470. */
  11471. export interface ISceneSerializableComponent extends ISceneComponent {
  11472. /**
  11473. * Adds all the elements from the container to the scene
  11474. * @param container the container holding the elements
  11475. */
  11476. addFromContainer(container: AbstractScene): void;
  11477. /**
  11478. * Removes all the elements in the container from the scene
  11479. * @param container contains the elements to remove
  11480. * @param dispose if the removed element should be disposed (default: false)
  11481. */
  11482. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11483. /**
  11484. * Serializes the component data to the specified json object
  11485. * @param serializationObject The object to serialize to
  11486. */
  11487. serialize(serializationObject: any): void;
  11488. }
  11489. /**
  11490. * Strong typing of a Mesh related stage step action
  11491. */
  11492. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11493. /**
  11494. * Strong typing of a Evaluate Sub Mesh related stage step action
  11495. */
  11496. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11497. /**
  11498. * Strong typing of a Active Mesh related stage step action
  11499. */
  11500. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11501. /**
  11502. * Strong typing of a Camera related stage step action
  11503. */
  11504. export type CameraStageAction = (camera: Camera) => void;
  11505. /**
  11506. * Strong typing of a Camera Frame buffer related stage step action
  11507. */
  11508. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11509. /**
  11510. * Strong typing of a Render Target related stage step action
  11511. */
  11512. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11513. /**
  11514. * Strong typing of a RenderingGroup related stage step action
  11515. */
  11516. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11517. /**
  11518. * Strong typing of a Mesh Render related stage step action
  11519. */
  11520. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11521. /**
  11522. * Strong typing of a simple stage step action
  11523. */
  11524. export type SimpleStageAction = () => void;
  11525. /**
  11526. * Strong typing of a render target action.
  11527. */
  11528. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11529. /**
  11530. * Strong typing of a pointer move action.
  11531. */
  11532. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11533. /**
  11534. * Strong typing of a pointer up/down action.
  11535. */
  11536. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11537. /**
  11538. * Representation of a stage in the scene (Basically a list of ordered steps)
  11539. * @hidden
  11540. */
  11541. export class Stage<T extends Function> extends Array<{
  11542. index: number;
  11543. component: ISceneComponent;
  11544. action: T;
  11545. }> {
  11546. /**
  11547. * Hide ctor from the rest of the world.
  11548. * @param items The items to add.
  11549. */
  11550. private constructor();
  11551. /**
  11552. * Creates a new Stage.
  11553. * @returns A new instance of a Stage
  11554. */
  11555. static Create<T extends Function>(): Stage<T>;
  11556. /**
  11557. * Registers a step in an ordered way in the targeted stage.
  11558. * @param index Defines the position to register the step in
  11559. * @param component Defines the component attached to the step
  11560. * @param action Defines the action to launch during the step
  11561. */
  11562. registerStep(index: number, component: ISceneComponent, action: T): void;
  11563. /**
  11564. * Clears all the steps from the stage.
  11565. */
  11566. clear(): void;
  11567. }
  11568. }
  11569. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11570. import { Nullable } from "babylonjs/types";
  11571. import { Observable } from "babylonjs/Misc/observable";
  11572. import { Scene } from "babylonjs/scene";
  11573. import { Sprite } from "babylonjs/Sprites/sprite";
  11574. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11575. import { Ray } from "babylonjs/Culling/ray";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11578. import { ISceneComponent } from "babylonjs/sceneComponent";
  11579. module "babylonjs/scene" {
  11580. interface Scene {
  11581. /** @hidden */
  11582. _pointerOverSprite: Nullable<Sprite>;
  11583. /** @hidden */
  11584. _pickedDownSprite: Nullable<Sprite>;
  11585. /** @hidden */
  11586. _tempSpritePickingRay: Nullable<Ray>;
  11587. /**
  11588. * All of the sprite managers added to this scene
  11589. * @see http://doc.babylonjs.com/babylon101/sprites
  11590. */
  11591. spriteManagers: Array<ISpriteManager>;
  11592. /**
  11593. * An event triggered when sprites rendering is about to start
  11594. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11595. */
  11596. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11597. /**
  11598. * An event triggered when sprites rendering is done
  11599. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11600. */
  11601. onAfterSpritesRenderingObservable: Observable<Scene>;
  11602. /** @hidden */
  11603. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /** Launch a ray to try to pick a sprite in the scene
  11605. * @param x position on screen
  11606. * @param y position on screen
  11607. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11608. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11609. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11610. * @returns a PickingInfo
  11611. */
  11612. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11613. /** Use the given ray to pick a sprite in the scene
  11614. * @param ray The ray (in world space) to use to pick meshes
  11615. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11616. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11617. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11618. * @returns a PickingInfo
  11619. */
  11620. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11621. /** @hidden */
  11622. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11623. /** Launch a ray to try to pick sprites in the scene
  11624. * @param x position on screen
  11625. * @param y position on screen
  11626. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11627. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11628. * @returns a PickingInfo array
  11629. */
  11630. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11631. /** Use the given ray to pick sprites in the scene
  11632. * @param ray The ray (in world space) to use to pick meshes
  11633. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11634. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11635. * @returns a PickingInfo array
  11636. */
  11637. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11638. /**
  11639. * Force the sprite under the pointer
  11640. * @param sprite defines the sprite to use
  11641. */
  11642. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11643. /**
  11644. * Gets the sprite under the pointer
  11645. * @returns a Sprite or null if no sprite is under the pointer
  11646. */
  11647. getPointerOverSprite(): Nullable<Sprite>;
  11648. }
  11649. }
  11650. /**
  11651. * Defines the sprite scene component responsible to manage sprites
  11652. * in a given scene.
  11653. */
  11654. export class SpriteSceneComponent implements ISceneComponent {
  11655. /**
  11656. * The component name helpfull to identify the component in the list of scene components.
  11657. */
  11658. readonly name: string;
  11659. /**
  11660. * The scene the component belongs to.
  11661. */
  11662. scene: Scene;
  11663. /** @hidden */
  11664. private _spritePredicate;
  11665. /**
  11666. * Creates a new instance of the component for the given scene
  11667. * @param scene Defines the scene to register the component in
  11668. */
  11669. constructor(scene: Scene);
  11670. /**
  11671. * Registers the component in a given scene
  11672. */
  11673. register(): void;
  11674. /**
  11675. * Rebuilds the elements related to this component in case of
  11676. * context lost for instance.
  11677. */
  11678. rebuild(): void;
  11679. /**
  11680. * Disposes the component and the associated ressources.
  11681. */
  11682. dispose(): void;
  11683. private _pickSpriteButKeepRay;
  11684. private _pointerMove;
  11685. private _pointerDown;
  11686. private _pointerUp;
  11687. }
  11688. }
  11689. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11690. /** @hidden */
  11691. export var fogFragmentDeclaration: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11697. /** @hidden */
  11698. export var fogFragment: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module "babylonjs/Shaders/sprites.fragment" {
  11704. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11705. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11706. /** @hidden */
  11707. export var spritesPixelShader: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11713. /** @hidden */
  11714. export var fogVertexDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/sprites.vertex" {
  11720. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11721. /** @hidden */
  11722. export var spritesVertexShader: {
  11723. name: string;
  11724. shader: string;
  11725. };
  11726. }
  11727. declare module "babylonjs/Sprites/spriteManager" {
  11728. import { IDisposable, Scene } from "babylonjs/scene";
  11729. import { Nullable } from "babylonjs/types";
  11730. import { Observable } from "babylonjs/Misc/observable";
  11731. import { Sprite } from "babylonjs/Sprites/sprite";
  11732. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11733. import { Camera } from "babylonjs/Cameras/camera";
  11734. import { Texture } from "babylonjs/Materials/Textures/texture";
  11735. import "babylonjs/Shaders/sprites.fragment";
  11736. import "babylonjs/Shaders/sprites.vertex";
  11737. import { Ray } from "babylonjs/Culling/ray";
  11738. /**
  11739. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11740. */
  11741. export interface ISpriteManager extends IDisposable {
  11742. /**
  11743. * Restricts the camera to viewing objects with the same layerMask.
  11744. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11745. */
  11746. layerMask: number;
  11747. /**
  11748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11749. */
  11750. isPickable: boolean;
  11751. /**
  11752. * Specifies the rendering group id for this mesh (0 by default)
  11753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11754. */
  11755. renderingGroupId: number;
  11756. /**
  11757. * Defines the list of sprites managed by the manager.
  11758. */
  11759. sprites: Array<Sprite>;
  11760. /**
  11761. * Tests the intersection of a sprite with a specific ray.
  11762. * @param ray The ray we are sending to test the collision
  11763. * @param camera The camera space we are sending rays in
  11764. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11765. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11766. * @returns picking info or null.
  11767. */
  11768. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11769. /**
  11770. * Intersects the sprites with a ray
  11771. * @param ray defines the ray to intersect with
  11772. * @param camera defines the current active camera
  11773. * @param predicate defines a predicate used to select candidate sprites
  11774. * @returns null if no hit or a PickingInfo array
  11775. */
  11776. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11777. /**
  11778. * Renders the list of sprites on screen.
  11779. */
  11780. render(): void;
  11781. }
  11782. /**
  11783. * Class used to manage multiple sprites on the same spritesheet
  11784. * @see http://doc.babylonjs.com/babylon101/sprites
  11785. */
  11786. export class SpriteManager implements ISpriteManager {
  11787. /** defines the manager's name */
  11788. name: string;
  11789. /** Gets the list of sprites */
  11790. sprites: Sprite[];
  11791. /** Gets or sets the rendering group id (0 by default) */
  11792. renderingGroupId: number;
  11793. /** Gets or sets camera layer mask */
  11794. layerMask: number;
  11795. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11796. fogEnabled: boolean;
  11797. /** Gets or sets a boolean indicating if the sprites are pickable */
  11798. isPickable: boolean;
  11799. /** Defines the default width of a cell in the spritesheet */
  11800. cellWidth: number;
  11801. /** Defines the default height of a cell in the spritesheet */
  11802. cellHeight: number;
  11803. /** Associative array from JSON sprite data file */
  11804. private _cellData;
  11805. /** Array of sprite names from JSON sprite data file */
  11806. private _spriteMap;
  11807. /** True when packed cell data from JSON file is ready*/
  11808. private _packedAndReady;
  11809. /**
  11810. * An event triggered when the manager is disposed.
  11811. */
  11812. onDisposeObservable: Observable<SpriteManager>;
  11813. private _onDisposeObserver;
  11814. /**
  11815. * Callback called when the manager is disposed
  11816. */
  11817. onDispose: () => void;
  11818. private _capacity;
  11819. private _fromPacked;
  11820. private _spriteTexture;
  11821. private _epsilon;
  11822. private _scene;
  11823. private _vertexData;
  11824. private _buffer;
  11825. private _vertexBuffers;
  11826. private _indexBuffer;
  11827. private _effectBase;
  11828. private _effectFog;
  11829. /**
  11830. * Gets or sets the spritesheet texture
  11831. */
  11832. texture: Texture;
  11833. /**
  11834. * Creates a new sprite manager
  11835. * @param name defines the manager's name
  11836. * @param imgUrl defines the sprite sheet url
  11837. * @param capacity defines the maximum allowed number of sprites
  11838. * @param cellSize defines the size of a sprite cell
  11839. * @param scene defines the hosting scene
  11840. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11841. * @param samplingMode defines the smapling mode to use with spritesheet
  11842. * @param fromPacked set to false; do not alter
  11843. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11844. */
  11845. constructor(
  11846. /** defines the manager's name */
  11847. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11848. private _makePacked;
  11849. private _appendSpriteVertex;
  11850. /**
  11851. * Intersects the sprites with a ray
  11852. * @param ray defines the ray to intersect with
  11853. * @param camera defines the current active camera
  11854. * @param predicate defines a predicate used to select candidate sprites
  11855. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11856. * @returns null if no hit or a PickingInfo
  11857. */
  11858. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11859. /**
  11860. * Intersects the sprites with a ray
  11861. * @param ray defines the ray to intersect with
  11862. * @param camera defines the current active camera
  11863. * @param predicate defines a predicate used to select candidate sprites
  11864. * @returns null if no hit or a PickingInfo array
  11865. */
  11866. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11867. /**
  11868. * Render all child sprites
  11869. */
  11870. render(): void;
  11871. /**
  11872. * Release associated resources
  11873. */
  11874. dispose(): void;
  11875. }
  11876. }
  11877. declare module "babylonjs/Sprites/sprite" {
  11878. import { Vector3 } from "babylonjs/Maths/math.vector";
  11879. import { Nullable } from "babylonjs/types";
  11880. import { ActionManager } from "babylonjs/Actions/actionManager";
  11881. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11882. import { Color4 } from "babylonjs/Maths/math.color";
  11883. /**
  11884. * Class used to represent a sprite
  11885. * @see http://doc.babylonjs.com/babylon101/sprites
  11886. */
  11887. export class Sprite {
  11888. /** defines the name */
  11889. name: string;
  11890. /** Gets or sets the current world position */
  11891. position: Vector3;
  11892. /** Gets or sets the main color */
  11893. color: Color4;
  11894. /** Gets or sets the width */
  11895. width: number;
  11896. /** Gets or sets the height */
  11897. height: number;
  11898. /** Gets or sets rotation angle */
  11899. angle: number;
  11900. /** Gets or sets the cell index in the sprite sheet */
  11901. cellIndex: number;
  11902. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11903. cellRef: string;
  11904. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11905. invertU: number;
  11906. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11907. invertV: number;
  11908. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11909. disposeWhenFinishedAnimating: boolean;
  11910. /** Gets the list of attached animations */
  11911. animations: Animation[];
  11912. /** Gets or sets a boolean indicating if the sprite can be picked */
  11913. isPickable: boolean;
  11914. /**
  11915. * Gets or sets the associated action manager
  11916. */
  11917. actionManager: Nullable<ActionManager>;
  11918. private _animationStarted;
  11919. private _loopAnimation;
  11920. private _fromIndex;
  11921. private _toIndex;
  11922. private _delay;
  11923. private _direction;
  11924. private _manager;
  11925. private _time;
  11926. private _onAnimationEnd;
  11927. /**
  11928. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11929. */
  11930. isVisible: boolean;
  11931. /**
  11932. * Gets or sets the sprite size
  11933. */
  11934. size: number;
  11935. /**
  11936. * Creates a new Sprite
  11937. * @param name defines the name
  11938. * @param manager defines the manager
  11939. */
  11940. constructor(
  11941. /** defines the name */
  11942. name: string, manager: ISpriteManager);
  11943. /**
  11944. * Starts an animation
  11945. * @param from defines the initial key
  11946. * @param to defines the end key
  11947. * @param loop defines if the animation must loop
  11948. * @param delay defines the start delay (in ms)
  11949. * @param onAnimationEnd defines a callback to call when animation ends
  11950. */
  11951. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11952. /** Stops current animation (if any) */
  11953. stopAnimation(): void;
  11954. /** @hidden */
  11955. _animate(deltaTime: number): void;
  11956. /** Release associated resources */
  11957. dispose(): void;
  11958. }
  11959. }
  11960. declare module "babylonjs/Collisions/pickingInfo" {
  11961. import { Nullable } from "babylonjs/types";
  11962. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11964. import { Sprite } from "babylonjs/Sprites/sprite";
  11965. import { Ray } from "babylonjs/Culling/ray";
  11966. /**
  11967. * Information about the result of picking within a scene
  11968. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11969. */
  11970. export class PickingInfo {
  11971. /** @hidden */
  11972. _pickingUnavailable: boolean;
  11973. /**
  11974. * If the pick collided with an object
  11975. */
  11976. hit: boolean;
  11977. /**
  11978. * Distance away where the pick collided
  11979. */
  11980. distance: number;
  11981. /**
  11982. * The location of pick collision
  11983. */
  11984. pickedPoint: Nullable<Vector3>;
  11985. /**
  11986. * The mesh corresponding the the pick collision
  11987. */
  11988. pickedMesh: Nullable<AbstractMesh>;
  11989. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11990. bu: number;
  11991. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11992. bv: number;
  11993. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11994. faceId: number;
  11995. /** Id of the the submesh that was picked */
  11996. subMeshId: number;
  11997. /** If a sprite was picked, this will be the sprite the pick collided with */
  11998. pickedSprite: Nullable<Sprite>;
  11999. /**
  12000. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12001. */
  12002. originMesh: Nullable<AbstractMesh>;
  12003. /**
  12004. * The ray that was used to perform the picking.
  12005. */
  12006. ray: Nullable<Ray>;
  12007. /**
  12008. * Gets the normal correspodning to the face the pick collided with
  12009. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12010. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12011. * @returns The normal correspodning to the face the pick collided with
  12012. */
  12013. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12014. /**
  12015. * Gets the texture coordinates of where the pick occured
  12016. * @returns the vector containing the coordnates of the texture
  12017. */
  12018. getTextureCoordinates(): Nullable<Vector2>;
  12019. }
  12020. }
  12021. declare module "babylonjs/Events/pointerEvents" {
  12022. import { Nullable } from "babylonjs/types";
  12023. import { Vector2 } from "babylonjs/Maths/math.vector";
  12024. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12025. import { Ray } from "babylonjs/Culling/ray";
  12026. /**
  12027. * Gather the list of pointer event types as constants.
  12028. */
  12029. export class PointerEventTypes {
  12030. /**
  12031. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12032. */
  12033. static readonly POINTERDOWN: number;
  12034. /**
  12035. * The pointerup event is fired when a pointer is no longer active.
  12036. */
  12037. static readonly POINTERUP: number;
  12038. /**
  12039. * The pointermove event is fired when a pointer changes coordinates.
  12040. */
  12041. static readonly POINTERMOVE: number;
  12042. /**
  12043. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12044. */
  12045. static readonly POINTERWHEEL: number;
  12046. /**
  12047. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12048. */
  12049. static readonly POINTERPICK: number;
  12050. /**
  12051. * The pointertap event is fired when a the object has been touched and released without drag.
  12052. */
  12053. static readonly POINTERTAP: number;
  12054. /**
  12055. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12056. */
  12057. static readonly POINTERDOUBLETAP: number;
  12058. }
  12059. /**
  12060. * Base class of pointer info types.
  12061. */
  12062. export class PointerInfoBase {
  12063. /**
  12064. * Defines the type of event (PointerEventTypes)
  12065. */
  12066. type: number;
  12067. /**
  12068. * Defines the related dom event
  12069. */
  12070. event: PointerEvent | MouseWheelEvent;
  12071. /**
  12072. * Instantiates the base class of pointers info.
  12073. * @param type Defines the type of event (PointerEventTypes)
  12074. * @param event Defines the related dom event
  12075. */
  12076. constructor(
  12077. /**
  12078. * Defines the type of event (PointerEventTypes)
  12079. */
  12080. type: number,
  12081. /**
  12082. * Defines the related dom event
  12083. */
  12084. event: PointerEvent | MouseWheelEvent);
  12085. }
  12086. /**
  12087. * This class is used to store pointer related info for the onPrePointerObservable event.
  12088. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12089. */
  12090. export class PointerInfoPre extends PointerInfoBase {
  12091. /**
  12092. * Ray from a pointer if availible (eg. 6dof controller)
  12093. */
  12094. ray: Nullable<Ray>;
  12095. /**
  12096. * Defines the local position of the pointer on the canvas.
  12097. */
  12098. localPosition: Vector2;
  12099. /**
  12100. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12101. */
  12102. skipOnPointerObservable: boolean;
  12103. /**
  12104. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12105. * @param type Defines the type of event (PointerEventTypes)
  12106. * @param event Defines the related dom event
  12107. * @param localX Defines the local x coordinates of the pointer when the event occured
  12108. * @param localY Defines the local y coordinates of the pointer when the event occured
  12109. */
  12110. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12111. }
  12112. /**
  12113. * This type contains all the data related to a pointer event in Babylon.js.
  12114. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12115. */
  12116. export class PointerInfo extends PointerInfoBase {
  12117. /**
  12118. * Defines the picking info associated to the info (if any)\
  12119. */
  12120. pickInfo: Nullable<PickingInfo>;
  12121. /**
  12122. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12123. * @param type Defines the type of event (PointerEventTypes)
  12124. * @param event Defines the related dom event
  12125. * @param pickInfo Defines the picking info associated to the info (if any)\
  12126. */
  12127. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12128. /**
  12129. * Defines the picking info associated to the info (if any)\
  12130. */
  12131. pickInfo: Nullable<PickingInfo>);
  12132. }
  12133. /**
  12134. * Data relating to a touch event on the screen.
  12135. */
  12136. export interface PointerTouch {
  12137. /**
  12138. * X coordinate of touch.
  12139. */
  12140. x: number;
  12141. /**
  12142. * Y coordinate of touch.
  12143. */
  12144. y: number;
  12145. /**
  12146. * Id of touch. Unique for each finger.
  12147. */
  12148. pointerId: number;
  12149. /**
  12150. * Event type passed from DOM.
  12151. */
  12152. type: any;
  12153. }
  12154. }
  12155. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12156. import { Observable } from "babylonjs/Misc/observable";
  12157. import { Nullable } from "babylonjs/types";
  12158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12159. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12160. /**
  12161. * Manage the mouse inputs to control the movement of a free camera.
  12162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12163. */
  12164. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12165. /**
  12166. * Define if touch is enabled in the mouse input
  12167. */
  12168. touchEnabled: boolean;
  12169. /**
  12170. * Defines the camera the input is attached to.
  12171. */
  12172. camera: FreeCamera;
  12173. /**
  12174. * Defines the buttons associated with the input to handle camera move.
  12175. */
  12176. buttons: number[];
  12177. /**
  12178. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12179. */
  12180. angularSensibility: number;
  12181. private _pointerInput;
  12182. private _onMouseMove;
  12183. private _observer;
  12184. private previousPosition;
  12185. /**
  12186. * Observable for when a pointer move event occurs containing the move offset
  12187. */
  12188. onPointerMovedObservable: Observable<{
  12189. offsetX: number;
  12190. offsetY: number;
  12191. }>;
  12192. /**
  12193. * @hidden
  12194. * If the camera should be rotated automatically based on pointer movement
  12195. */
  12196. _allowCameraRotation: boolean;
  12197. /**
  12198. * Manage the mouse inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. * @param touchEnabled Defines if touch is enabled or not
  12201. */
  12202. constructor(
  12203. /**
  12204. * Define if touch is enabled in the mouse input
  12205. */
  12206. touchEnabled?: boolean);
  12207. /**
  12208. * Attach the input controls to a specific dom element to get the input from.
  12209. * @param element Defines the element the controls should be listened from
  12210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12211. */
  12212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12213. /**
  12214. * Called on JS contextmenu event.
  12215. * Override this method to provide functionality.
  12216. */
  12217. protected onContextMenu(evt: PointerEvent): void;
  12218. /**
  12219. * Detach the current controls from the specified dom element.
  12220. * @param element Defines the element to stop listening the inputs from
  12221. */
  12222. detachControl(element: Nullable<HTMLElement>): void;
  12223. /**
  12224. * Gets the class name of the current intput.
  12225. * @returns the class name
  12226. */
  12227. getClassName(): string;
  12228. /**
  12229. * Get the friendly name associated with the input class.
  12230. * @returns the input friendly name
  12231. */
  12232. getSimpleName(): string;
  12233. }
  12234. }
  12235. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12236. import { Nullable } from "babylonjs/types";
  12237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12239. /**
  12240. * Manage the touch inputs to control the movement of a free camera.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. */
  12243. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12244. /**
  12245. * Defines the camera the input is attached to.
  12246. */
  12247. camera: FreeCamera;
  12248. /**
  12249. * Defines the touch sensibility for rotation.
  12250. * The higher the faster.
  12251. */
  12252. touchAngularSensibility: number;
  12253. /**
  12254. * Defines the touch sensibility for move.
  12255. * The higher the faster.
  12256. */
  12257. touchMoveSensibility: number;
  12258. private _offsetX;
  12259. private _offsetY;
  12260. private _pointerPressed;
  12261. private _pointerInput;
  12262. private _observer;
  12263. private _onLostFocus;
  12264. /**
  12265. * Attach the input controls to a specific dom element to get the input from.
  12266. * @param element Defines the element the controls should be listened from
  12267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12268. */
  12269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12270. /**
  12271. * Detach the current controls from the specified dom element.
  12272. * @param element Defines the element to stop listening the inputs from
  12273. */
  12274. detachControl(element: Nullable<HTMLElement>): void;
  12275. /**
  12276. * Update the current camera state depending on the inputs that have been used this frame.
  12277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12278. */
  12279. checkInputs(): void;
  12280. /**
  12281. * Gets the class name of the current intput.
  12282. * @returns the class name
  12283. */
  12284. getClassName(): string;
  12285. /**
  12286. * Get the friendly name associated with the input class.
  12287. * @returns the input friendly name
  12288. */
  12289. getSimpleName(): string;
  12290. }
  12291. }
  12292. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12293. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12294. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12295. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12296. import { Nullable } from "babylonjs/types";
  12297. /**
  12298. * Default Inputs manager for the FreeCamera.
  12299. * It groups all the default supported inputs for ease of use.
  12300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12301. */
  12302. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12303. /**
  12304. * @hidden
  12305. */
  12306. _mouseInput: Nullable<FreeCameraMouseInput>;
  12307. /**
  12308. * Instantiates a new FreeCameraInputsManager.
  12309. * @param camera Defines the camera the inputs belong to
  12310. */
  12311. constructor(camera: FreeCamera);
  12312. /**
  12313. * Add keyboard input support to the input manager.
  12314. * @returns the current input manager
  12315. */
  12316. addKeyboard(): FreeCameraInputsManager;
  12317. /**
  12318. * Add mouse input support to the input manager.
  12319. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12320. * @returns the current input manager
  12321. */
  12322. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12323. /**
  12324. * Removes the mouse input support from the manager
  12325. * @returns the current input manager
  12326. */
  12327. removeMouse(): FreeCameraInputsManager;
  12328. /**
  12329. * Add touch input support to the input manager.
  12330. * @returns the current input manager
  12331. */
  12332. addTouch(): FreeCameraInputsManager;
  12333. /**
  12334. * Remove all attached input methods from a camera
  12335. */
  12336. clear(): void;
  12337. }
  12338. }
  12339. declare module "babylonjs/Cameras/freeCamera" {
  12340. import { Vector3 } from "babylonjs/Maths/math.vector";
  12341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12342. import { Scene } from "babylonjs/scene";
  12343. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12344. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12345. /**
  12346. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12347. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12349. */
  12350. export class FreeCamera extends TargetCamera {
  12351. /**
  12352. * Define the collision ellipsoid of the camera.
  12353. * This is helpful to simulate a camera body like the player body around the camera
  12354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12355. */
  12356. ellipsoid: Vector3;
  12357. /**
  12358. * Define an offset for the position of the ellipsoid around the camera.
  12359. * This can be helpful to determine the center of the body near the gravity center of the body
  12360. * instead of its head.
  12361. */
  12362. ellipsoidOffset: Vector3;
  12363. /**
  12364. * Enable or disable collisions of the camera with the rest of the scene objects.
  12365. */
  12366. checkCollisions: boolean;
  12367. /**
  12368. * Enable or disable gravity on the camera.
  12369. */
  12370. applyGravity: boolean;
  12371. /**
  12372. * Define the input manager associated to the camera.
  12373. */
  12374. inputs: FreeCameraInputsManager;
  12375. /**
  12376. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12377. * Higher values reduce sensitivity.
  12378. */
  12379. /**
  12380. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12381. * Higher values reduce sensitivity.
  12382. */
  12383. angularSensibility: number;
  12384. /**
  12385. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12386. */
  12387. keysUp: number[];
  12388. /**
  12389. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12390. */
  12391. keysDown: number[];
  12392. /**
  12393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12394. */
  12395. keysLeft: number[];
  12396. /**
  12397. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12398. */
  12399. keysRight: number[];
  12400. /**
  12401. * Event raised when the camera collide with a mesh in the scene.
  12402. */
  12403. onCollide: (collidedMesh: AbstractMesh) => void;
  12404. private _collider;
  12405. private _needMoveForGravity;
  12406. private _oldPosition;
  12407. private _diffPosition;
  12408. private _newPosition;
  12409. /** @hidden */
  12410. _localDirection: Vector3;
  12411. /** @hidden */
  12412. _transformedDirection: Vector3;
  12413. /**
  12414. * Instantiates a Free Camera.
  12415. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12416. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12417. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12418. * @param name Define the name of the camera in the scene
  12419. * @param position Define the start position of the camera in the scene
  12420. * @param scene Define the scene the camera belongs to
  12421. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12422. */
  12423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12424. /**
  12425. * Attached controls to the current camera.
  12426. * @param element Defines the element the controls should be listened from
  12427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12428. */
  12429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12430. /**
  12431. * Detach the current controls from the camera.
  12432. * The camera will stop reacting to inputs.
  12433. * @param element Defines the element to stop listening the inputs from
  12434. */
  12435. detachControl(element: HTMLElement): void;
  12436. private _collisionMask;
  12437. /**
  12438. * Define a collision mask to limit the list of object the camera can collide with
  12439. */
  12440. collisionMask: number;
  12441. /** @hidden */
  12442. _collideWithWorld(displacement: Vector3): void;
  12443. private _onCollisionPositionChange;
  12444. /** @hidden */
  12445. _checkInputs(): void;
  12446. /** @hidden */
  12447. _decideIfNeedsToMove(): boolean;
  12448. /** @hidden */
  12449. _updatePosition(): void;
  12450. /**
  12451. * Destroy the camera and release the current resources hold by it.
  12452. */
  12453. dispose(): void;
  12454. /**
  12455. * Gets the current object class name.
  12456. * @return the class name
  12457. */
  12458. getClassName(): string;
  12459. }
  12460. }
  12461. declare module "babylonjs/Gamepads/gamepad" {
  12462. import { Observable } from "babylonjs/Misc/observable";
  12463. /**
  12464. * Represents a gamepad control stick position
  12465. */
  12466. export class StickValues {
  12467. /**
  12468. * The x component of the control stick
  12469. */
  12470. x: number;
  12471. /**
  12472. * The y component of the control stick
  12473. */
  12474. y: number;
  12475. /**
  12476. * Initializes the gamepad x and y control stick values
  12477. * @param x The x component of the gamepad control stick value
  12478. * @param y The y component of the gamepad control stick value
  12479. */
  12480. constructor(
  12481. /**
  12482. * The x component of the control stick
  12483. */
  12484. x: number,
  12485. /**
  12486. * The y component of the control stick
  12487. */
  12488. y: number);
  12489. }
  12490. /**
  12491. * An interface which manages callbacks for gamepad button changes
  12492. */
  12493. export interface GamepadButtonChanges {
  12494. /**
  12495. * Called when a gamepad has been changed
  12496. */
  12497. changed: boolean;
  12498. /**
  12499. * Called when a gamepad press event has been triggered
  12500. */
  12501. pressChanged: boolean;
  12502. /**
  12503. * Called when a touch event has been triggered
  12504. */
  12505. touchChanged: boolean;
  12506. /**
  12507. * Called when a value has changed
  12508. */
  12509. valueChanged: boolean;
  12510. }
  12511. /**
  12512. * Represents a gamepad
  12513. */
  12514. export class Gamepad {
  12515. /**
  12516. * The id of the gamepad
  12517. */
  12518. id: string;
  12519. /**
  12520. * The index of the gamepad
  12521. */
  12522. index: number;
  12523. /**
  12524. * The browser gamepad
  12525. */
  12526. browserGamepad: any;
  12527. /**
  12528. * Specifies what type of gamepad this represents
  12529. */
  12530. type: number;
  12531. private _leftStick;
  12532. private _rightStick;
  12533. /** @hidden */
  12534. _isConnected: boolean;
  12535. private _leftStickAxisX;
  12536. private _leftStickAxisY;
  12537. private _rightStickAxisX;
  12538. private _rightStickAxisY;
  12539. /**
  12540. * Triggered when the left control stick has been changed
  12541. */
  12542. private _onleftstickchanged;
  12543. /**
  12544. * Triggered when the right control stick has been changed
  12545. */
  12546. private _onrightstickchanged;
  12547. /**
  12548. * Represents a gamepad controller
  12549. */
  12550. static GAMEPAD: number;
  12551. /**
  12552. * Represents a generic controller
  12553. */
  12554. static GENERIC: number;
  12555. /**
  12556. * Represents an XBox controller
  12557. */
  12558. static XBOX: number;
  12559. /**
  12560. * Represents a pose-enabled controller
  12561. */
  12562. static POSE_ENABLED: number;
  12563. /**
  12564. * Represents an Dual Shock controller
  12565. */
  12566. static DUALSHOCK: number;
  12567. /**
  12568. * Specifies whether the left control stick should be Y-inverted
  12569. */
  12570. protected _invertLeftStickY: boolean;
  12571. /**
  12572. * Specifies if the gamepad has been connected
  12573. */
  12574. readonly isConnected: boolean;
  12575. /**
  12576. * Initializes the gamepad
  12577. * @param id The id of the gamepad
  12578. * @param index The index of the gamepad
  12579. * @param browserGamepad The browser gamepad
  12580. * @param leftStickX The x component of the left joystick
  12581. * @param leftStickY The y component of the left joystick
  12582. * @param rightStickX The x component of the right joystick
  12583. * @param rightStickY The y component of the right joystick
  12584. */
  12585. constructor(
  12586. /**
  12587. * The id of the gamepad
  12588. */
  12589. id: string,
  12590. /**
  12591. * The index of the gamepad
  12592. */
  12593. index: number,
  12594. /**
  12595. * The browser gamepad
  12596. */
  12597. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12598. /**
  12599. * Callback triggered when the left joystick has changed
  12600. * @param callback
  12601. */
  12602. onleftstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Callback triggered when the right joystick has changed
  12605. * @param callback
  12606. */
  12607. onrightstickchanged(callback: (values: StickValues) => void): void;
  12608. /**
  12609. * Gets the left joystick
  12610. */
  12611. /**
  12612. * Sets the left joystick values
  12613. */
  12614. leftStick: StickValues;
  12615. /**
  12616. * Gets the right joystick
  12617. */
  12618. /**
  12619. * Sets the right joystick value
  12620. */
  12621. rightStick: StickValues;
  12622. /**
  12623. * Updates the gamepad joystick positions
  12624. */
  12625. update(): void;
  12626. /**
  12627. * Disposes the gamepad
  12628. */
  12629. dispose(): void;
  12630. }
  12631. /**
  12632. * Represents a generic gamepad
  12633. */
  12634. export class GenericPad extends Gamepad {
  12635. private _buttons;
  12636. private _onbuttondown;
  12637. private _onbuttonup;
  12638. /**
  12639. * Observable triggered when a button has been pressed
  12640. */
  12641. onButtonDownObservable: Observable<number>;
  12642. /**
  12643. * Observable triggered when a button has been released
  12644. */
  12645. onButtonUpObservable: Observable<number>;
  12646. /**
  12647. * Callback triggered when a button has been pressed
  12648. * @param callback Called when a button has been pressed
  12649. */
  12650. onbuttondown(callback: (buttonPressed: number) => void): void;
  12651. /**
  12652. * Callback triggered when a button has been released
  12653. * @param callback Called when a button has been released
  12654. */
  12655. onbuttonup(callback: (buttonReleased: number) => void): void;
  12656. /**
  12657. * Initializes the generic gamepad
  12658. * @param id The id of the generic gamepad
  12659. * @param index The index of the generic gamepad
  12660. * @param browserGamepad The browser gamepad
  12661. */
  12662. constructor(id: string, index: number, browserGamepad: any);
  12663. private _setButtonValue;
  12664. /**
  12665. * Updates the generic gamepad
  12666. */
  12667. update(): void;
  12668. /**
  12669. * Disposes the generic gamepad
  12670. */
  12671. dispose(): void;
  12672. }
  12673. }
  12674. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12675. import { Nullable } from "babylonjs/types";
  12676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12677. import { Scene } from "babylonjs/scene";
  12678. module "babylonjs/Engines/engine" {
  12679. interface Engine {
  12680. /**
  12681. * Creates a raw texture
  12682. * @param data defines the data to store in the texture
  12683. * @param width defines the width of the texture
  12684. * @param height defines the height of the texture
  12685. * @param format defines the format of the data
  12686. * @param generateMipMaps defines if the engine should generate the mip levels
  12687. * @param invertY defines if data must be stored with Y axis inverted
  12688. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12689. * @param compression defines the compression used (null by default)
  12690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12691. * @returns the raw texture inside an InternalTexture
  12692. */
  12693. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12694. /**
  12695. * Update a raw texture
  12696. * @param texture defines the texture to update
  12697. * @param data defines the data to store in the texture
  12698. * @param format defines the format of the data
  12699. * @param invertY defines if data must be stored with Y axis inverted
  12700. */
  12701. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12702. /**
  12703. * Update a raw texture
  12704. * @param texture defines the texture to update
  12705. * @param data defines the data to store in the texture
  12706. * @param format defines the format of the data
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param compression defines the compression used (null by default)
  12709. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12710. */
  12711. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12712. /**
  12713. * Creates a new raw cube texture
  12714. * @param data defines the array of data to use to create each face
  12715. * @param size defines the size of the textures
  12716. * @param format defines the format of the data
  12717. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12718. * @param generateMipMaps defines if the engine should generate the mip levels
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12721. * @param compression defines the compression used (null by default)
  12722. * @returns the cube texture as an InternalTexture
  12723. */
  12724. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12725. /**
  12726. * Update a raw cube texture
  12727. * @param texture defines the texture to udpdate
  12728. * @param data defines the data to store
  12729. * @param format defines the data format
  12730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12731. * @param invertY defines if data must be stored with Y axis inverted
  12732. */
  12733. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12734. /**
  12735. * Update a raw cube texture
  12736. * @param texture defines the texture to udpdate
  12737. * @param data defines the data to store
  12738. * @param format defines the data format
  12739. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12740. * @param invertY defines if data must be stored with Y axis inverted
  12741. * @param compression defines the compression used (null by default)
  12742. */
  12743. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12744. /**
  12745. * Update a raw cube texture
  12746. * @param texture defines the texture to udpdate
  12747. * @param data defines the data to store
  12748. * @param format defines the data format
  12749. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12750. * @param invertY defines if data must be stored with Y axis inverted
  12751. * @param compression defines the compression used (null by default)
  12752. * @param level defines which level of the texture to update
  12753. */
  12754. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12755. /**
  12756. * Creates a new raw cube texture from a specified url
  12757. * @param url defines the url where the data is located
  12758. * @param scene defines the current scene
  12759. * @param size defines the size of the textures
  12760. * @param format defines the format of the data
  12761. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12762. * @param noMipmap defines if the engine should avoid generating the mip levels
  12763. * @param callback defines a callback used to extract texture data from loaded data
  12764. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12765. * @param onLoad defines a callback called when texture is loaded
  12766. * @param onError defines a callback called if there is an error
  12767. * @returns the cube texture as an InternalTexture
  12768. */
  12769. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12770. /**
  12771. * Creates a new raw cube texture from a specified url
  12772. * @param url defines the url where the data is located
  12773. * @param scene defines the current scene
  12774. * @param size defines the size of the textures
  12775. * @param format defines the format of the data
  12776. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12777. * @param noMipmap defines if the engine should avoid generating the mip levels
  12778. * @param callback defines a callback used to extract texture data from loaded data
  12779. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12780. * @param onLoad defines a callback called when texture is loaded
  12781. * @param onError defines a callback called if there is an error
  12782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12783. * @param invertY defines if data must be stored with Y axis inverted
  12784. * @returns the cube texture as an InternalTexture
  12785. */
  12786. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12787. /**
  12788. * Creates a new raw 3D texture
  12789. * @param data defines the data used to create the texture
  12790. * @param width defines the width of the texture
  12791. * @param height defines the height of the texture
  12792. * @param depth defines the depth of the texture
  12793. * @param format defines the format of the texture
  12794. * @param generateMipMaps defines if the engine must generate mip levels
  12795. * @param invertY defines if data must be stored with Y axis inverted
  12796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12797. * @param compression defines the compressed used (can be null)
  12798. * @param textureType defines the compressed used (can be null)
  12799. * @returns a new raw 3D texture (stored in an InternalTexture)
  12800. */
  12801. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12802. /**
  12803. * Update a raw 3D texture
  12804. * @param texture defines the texture to update
  12805. * @param data defines the data to store
  12806. * @param format defines the data format
  12807. * @param invertY defines if data must be stored with Y axis inverted
  12808. */
  12809. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12810. /**
  12811. * Update a raw 3D texture
  12812. * @param texture defines the texture to update
  12813. * @param data defines the data to store
  12814. * @param format defines the data format
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param compression defines the used compression (can be null)
  12817. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12818. */
  12819. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12820. /**
  12821. * Creates a new raw 2D array texture
  12822. * @param data defines the data used to create the texture
  12823. * @param width defines the width of the texture
  12824. * @param height defines the height of the texture
  12825. * @param depth defines the number of layers of the texture
  12826. * @param format defines the format of the texture
  12827. * @param generateMipMaps defines if the engine must generate mip levels
  12828. * @param invertY defines if data must be stored with Y axis inverted
  12829. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12830. * @param compression defines the compressed used (can be null)
  12831. * @param textureType defines the compressed used (can be null)
  12832. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12833. */
  12834. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12835. /**
  12836. * Update a raw 2D array texture
  12837. * @param texture defines the texture to update
  12838. * @param data defines the data to store
  12839. * @param format defines the data format
  12840. * @param invertY defines if data must be stored with Y axis inverted
  12841. */
  12842. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12843. /**
  12844. * Update a raw 2D array texture
  12845. * @param texture defines the texture to update
  12846. * @param data defines the data to store
  12847. * @param format defines the data format
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param compression defines the used compression (can be null)
  12850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12851. */
  12852. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12853. }
  12854. }
  12855. }
  12856. declare module "babylonjs/Materials/Textures/rawTexture" {
  12857. import { Scene } from "babylonjs/scene";
  12858. import { Texture } from "babylonjs/Materials/Textures/texture";
  12859. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12860. /**
  12861. * Raw texture can help creating a texture directly from an array of data.
  12862. * This can be super useful if you either get the data from an uncompressed source or
  12863. * if you wish to create your texture pixel by pixel.
  12864. */
  12865. export class RawTexture extends Texture {
  12866. /**
  12867. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12868. */
  12869. format: number;
  12870. private _engine;
  12871. /**
  12872. * Instantiates a new RawTexture.
  12873. * Raw texture can help creating a texture directly from an array of data.
  12874. * This can be super useful if you either get the data from an uncompressed source or
  12875. * if you wish to create your texture pixel by pixel.
  12876. * @param data define the array of data to use to create the texture
  12877. * @param width define the width of the texture
  12878. * @param height define the height of the texture
  12879. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12880. * @param scene define the scene the texture belongs to
  12881. * @param generateMipMaps define whether mip maps should be generated or not
  12882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12884. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12885. */
  12886. constructor(data: ArrayBufferView, width: number, height: number,
  12887. /**
  12888. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12889. */
  12890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12891. /**
  12892. * Updates the texture underlying data.
  12893. * @param data Define the new data of the texture
  12894. */
  12895. update(data: ArrayBufferView): void;
  12896. /**
  12897. * Creates a luminance texture from some data.
  12898. * @param data Define the texture data
  12899. * @param width Define the width of the texture
  12900. * @param height Define the height of the texture
  12901. * @param scene Define the scene the texture belongs to
  12902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12905. * @returns the luminance texture
  12906. */
  12907. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12908. /**
  12909. * Creates a luminance alpha texture from some data.
  12910. * @param data Define the texture data
  12911. * @param width Define the width of the texture
  12912. * @param height Define the height of the texture
  12913. * @param scene Define the scene the texture belongs to
  12914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12917. * @returns the luminance alpha texture
  12918. */
  12919. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12920. /**
  12921. * Creates an alpha texture from some data.
  12922. * @param data Define the texture data
  12923. * @param width Define the width of the texture
  12924. * @param height Define the height of the texture
  12925. * @param scene Define the scene the texture belongs to
  12926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12929. * @returns the alpha texture
  12930. */
  12931. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12932. /**
  12933. * Creates a RGB texture from some data.
  12934. * @param data Define the texture data
  12935. * @param width Define the width of the texture
  12936. * @param height Define the height of the texture
  12937. * @param scene Define the scene the texture belongs to
  12938. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12939. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12940. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12941. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12942. * @returns the RGB alpha texture
  12943. */
  12944. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12945. /**
  12946. * Creates a RGBA texture from some data.
  12947. * @param data Define the texture data
  12948. * @param width Define the width of the texture
  12949. * @param height Define the height of the texture
  12950. * @param scene Define the scene the texture belongs to
  12951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12954. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12955. * @returns the RGBA texture
  12956. */
  12957. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12958. /**
  12959. * Creates a R texture from some data.
  12960. * @param data Define the texture data
  12961. * @param width Define the width of the texture
  12962. * @param height Define the height of the texture
  12963. * @param scene Define the scene the texture belongs to
  12964. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12965. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12966. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12967. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12968. * @returns the R texture
  12969. */
  12970. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12971. }
  12972. }
  12973. declare module "babylonjs/Maths/math.size" {
  12974. /**
  12975. * Interface for the size containing width and height
  12976. */
  12977. export interface ISize {
  12978. /**
  12979. * Width
  12980. */
  12981. width: number;
  12982. /**
  12983. * Heighht
  12984. */
  12985. height: number;
  12986. }
  12987. /**
  12988. * Size containing widht and height
  12989. */
  12990. export class Size implements ISize {
  12991. /**
  12992. * Width
  12993. */
  12994. width: number;
  12995. /**
  12996. * Height
  12997. */
  12998. height: number;
  12999. /**
  13000. * Creates a Size object from the given width and height (floats).
  13001. * @param width width of the new size
  13002. * @param height height of the new size
  13003. */
  13004. constructor(width: number, height: number);
  13005. /**
  13006. * Returns a string with the Size width and height
  13007. * @returns a string with the Size width and height
  13008. */
  13009. toString(): string;
  13010. /**
  13011. * "Size"
  13012. * @returns the string "Size"
  13013. */
  13014. getClassName(): string;
  13015. /**
  13016. * Returns the Size hash code.
  13017. * @returns a hash code for a unique width and height
  13018. */
  13019. getHashCode(): number;
  13020. /**
  13021. * Updates the current size from the given one.
  13022. * @param src the given size
  13023. */
  13024. copyFrom(src: Size): void;
  13025. /**
  13026. * Updates in place the current Size from the given floats.
  13027. * @param width width of the new size
  13028. * @param height height of the new size
  13029. * @returns the updated Size.
  13030. */
  13031. copyFromFloats(width: number, height: number): Size;
  13032. /**
  13033. * Updates in place the current Size from the given floats.
  13034. * @param width width to set
  13035. * @param height height to set
  13036. * @returns the updated Size.
  13037. */
  13038. set(width: number, height: number): Size;
  13039. /**
  13040. * Multiplies the width and height by numbers
  13041. * @param w factor to multiple the width by
  13042. * @param h factor to multiple the height by
  13043. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13044. */
  13045. multiplyByFloats(w: number, h: number): Size;
  13046. /**
  13047. * Clones the size
  13048. * @returns a new Size copied from the given one.
  13049. */
  13050. clone(): Size;
  13051. /**
  13052. * True if the current Size and the given one width and height are strictly equal.
  13053. * @param other the other size to compare against
  13054. * @returns True if the current Size and the given one width and height are strictly equal.
  13055. */
  13056. equals(other: Size): boolean;
  13057. /**
  13058. * The surface of the Size : width * height (float).
  13059. */
  13060. readonly surface: number;
  13061. /**
  13062. * Create a new size of zero
  13063. * @returns a new Size set to (0.0, 0.0)
  13064. */
  13065. static Zero(): Size;
  13066. /**
  13067. * Sums the width and height of two sizes
  13068. * @param otherSize size to add to this size
  13069. * @returns a new Size set as the addition result of the current Size and the given one.
  13070. */
  13071. add(otherSize: Size): Size;
  13072. /**
  13073. * Subtracts the width and height of two
  13074. * @param otherSize size to subtract to this size
  13075. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13076. */
  13077. subtract(otherSize: Size): Size;
  13078. /**
  13079. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13080. * @param start starting size to lerp between
  13081. * @param end end size to lerp between
  13082. * @param amount amount to lerp between the start and end values
  13083. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13084. */
  13085. static Lerp(start: Size, end: Size, amount: number): Size;
  13086. }
  13087. }
  13088. declare module "babylonjs/Animations/runtimeAnimation" {
  13089. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13090. import { Animatable } from "babylonjs/Animations/animatable";
  13091. import { Scene } from "babylonjs/scene";
  13092. /**
  13093. * Defines a runtime animation
  13094. */
  13095. export class RuntimeAnimation {
  13096. private _events;
  13097. /**
  13098. * The current frame of the runtime animation
  13099. */
  13100. private _currentFrame;
  13101. /**
  13102. * The animation used by the runtime animation
  13103. */
  13104. private _animation;
  13105. /**
  13106. * The target of the runtime animation
  13107. */
  13108. private _target;
  13109. /**
  13110. * The initiating animatable
  13111. */
  13112. private _host;
  13113. /**
  13114. * The original value of the runtime animation
  13115. */
  13116. private _originalValue;
  13117. /**
  13118. * The original blend value of the runtime animation
  13119. */
  13120. private _originalBlendValue;
  13121. /**
  13122. * The offsets cache of the runtime animation
  13123. */
  13124. private _offsetsCache;
  13125. /**
  13126. * The high limits cache of the runtime animation
  13127. */
  13128. private _highLimitsCache;
  13129. /**
  13130. * Specifies if the runtime animation has been stopped
  13131. */
  13132. private _stopped;
  13133. /**
  13134. * The blending factor of the runtime animation
  13135. */
  13136. private _blendingFactor;
  13137. /**
  13138. * The BabylonJS scene
  13139. */
  13140. private _scene;
  13141. /**
  13142. * The current value of the runtime animation
  13143. */
  13144. private _currentValue;
  13145. /** @hidden */
  13146. _animationState: _IAnimationState;
  13147. /**
  13148. * The active target of the runtime animation
  13149. */
  13150. private _activeTargets;
  13151. private _currentActiveTarget;
  13152. private _directTarget;
  13153. /**
  13154. * The target path of the runtime animation
  13155. */
  13156. private _targetPath;
  13157. /**
  13158. * The weight of the runtime animation
  13159. */
  13160. private _weight;
  13161. /**
  13162. * The ratio offset of the runtime animation
  13163. */
  13164. private _ratioOffset;
  13165. /**
  13166. * The previous delay of the runtime animation
  13167. */
  13168. private _previousDelay;
  13169. /**
  13170. * The previous ratio of the runtime animation
  13171. */
  13172. private _previousRatio;
  13173. private _enableBlending;
  13174. private _keys;
  13175. private _minFrame;
  13176. private _maxFrame;
  13177. private _minValue;
  13178. private _maxValue;
  13179. private _targetIsArray;
  13180. /**
  13181. * Gets the current frame of the runtime animation
  13182. */
  13183. readonly currentFrame: number;
  13184. /**
  13185. * Gets the weight of the runtime animation
  13186. */
  13187. readonly weight: number;
  13188. /**
  13189. * Gets the current value of the runtime animation
  13190. */
  13191. readonly currentValue: any;
  13192. /**
  13193. * Gets the target path of the runtime animation
  13194. */
  13195. readonly targetPath: string;
  13196. /**
  13197. * Gets the actual target of the runtime animation
  13198. */
  13199. readonly target: any;
  13200. /** @hidden */
  13201. _onLoop: () => void;
  13202. /**
  13203. * Create a new RuntimeAnimation object
  13204. * @param target defines the target of the animation
  13205. * @param animation defines the source animation object
  13206. * @param scene defines the hosting scene
  13207. * @param host defines the initiating Animatable
  13208. */
  13209. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13210. private _preparePath;
  13211. /**
  13212. * Gets the animation from the runtime animation
  13213. */
  13214. readonly animation: Animation;
  13215. /**
  13216. * Resets the runtime animation to the beginning
  13217. * @param restoreOriginal defines whether to restore the target property to the original value
  13218. */
  13219. reset(restoreOriginal?: boolean): void;
  13220. /**
  13221. * Specifies if the runtime animation is stopped
  13222. * @returns Boolean specifying if the runtime animation is stopped
  13223. */
  13224. isStopped(): boolean;
  13225. /**
  13226. * Disposes of the runtime animation
  13227. */
  13228. dispose(): void;
  13229. /**
  13230. * Apply the interpolated value to the target
  13231. * @param currentValue defines the value computed by the animation
  13232. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13233. */
  13234. setValue(currentValue: any, weight: number): void;
  13235. private _getOriginalValues;
  13236. private _setValue;
  13237. /**
  13238. * Gets the loop pmode of the runtime animation
  13239. * @returns Loop Mode
  13240. */
  13241. private _getCorrectLoopMode;
  13242. /**
  13243. * Move the current animation to a given frame
  13244. * @param frame defines the frame to move to
  13245. */
  13246. goToFrame(frame: number): void;
  13247. /**
  13248. * @hidden Internal use only
  13249. */
  13250. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13251. /**
  13252. * Execute the current animation
  13253. * @param delay defines the delay to add to the current frame
  13254. * @param from defines the lower bound of the animation range
  13255. * @param to defines the upper bound of the animation range
  13256. * @param loop defines if the current animation must loop
  13257. * @param speedRatio defines the current speed ratio
  13258. * @param weight defines the weight of the animation (default is -1 so no weight)
  13259. * @param onLoop optional callback called when animation loops
  13260. * @returns a boolean indicating if the animation is running
  13261. */
  13262. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13263. }
  13264. }
  13265. declare module "babylonjs/Animations/animatable" {
  13266. import { Animation } from "babylonjs/Animations/animation";
  13267. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Observable } from "babylonjs/Misc/observable";
  13270. import { Scene } from "babylonjs/scene";
  13271. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13272. import { Node } from "babylonjs/node";
  13273. /**
  13274. * Class used to store an actual running animation
  13275. */
  13276. export class Animatable {
  13277. /** defines the target object */
  13278. target: any;
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame: number;
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame: number;
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation: boolean;
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined;
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined;
  13289. private _localDelayOffset;
  13290. private _pausedDelay;
  13291. private _runtimeAnimations;
  13292. private _paused;
  13293. private _scene;
  13294. private _speedRatio;
  13295. private _weight;
  13296. private _syncRoot;
  13297. /**
  13298. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13299. * This will only apply for non looping animation (default is true)
  13300. */
  13301. disposeOnEnd: boolean;
  13302. /**
  13303. * Gets a boolean indicating if the animation has started
  13304. */
  13305. animationStarted: boolean;
  13306. /**
  13307. * Observer raised when the animation ends
  13308. */
  13309. onAnimationEndObservable: Observable<Animatable>;
  13310. /**
  13311. * Observer raised when the animation loops
  13312. */
  13313. onAnimationLoopObservable: Observable<Animatable>;
  13314. /**
  13315. * Gets the root Animatable used to synchronize and normalize animations
  13316. */
  13317. readonly syncRoot: Nullable<Animatable>;
  13318. /**
  13319. * Gets the current frame of the first RuntimeAnimation
  13320. * Used to synchronize Animatables
  13321. */
  13322. readonly masterFrame: number;
  13323. /**
  13324. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13325. */
  13326. weight: number;
  13327. /**
  13328. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13329. */
  13330. speedRatio: number;
  13331. /**
  13332. * Creates a new Animatable
  13333. * @param scene defines the hosting scene
  13334. * @param target defines the target object
  13335. * @param fromFrame defines the starting frame number (default is 0)
  13336. * @param toFrame defines the ending frame number (default is 100)
  13337. * @param loopAnimation defines if the animation must loop (default is false)
  13338. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13339. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13340. * @param animations defines a group of animation to add to the new Animatable
  13341. * @param onAnimationLoop defines a callback to call when animation loops
  13342. */
  13343. constructor(scene: Scene,
  13344. /** defines the target object */
  13345. target: any,
  13346. /** defines the starting frame number (default is 0) */
  13347. fromFrame?: number,
  13348. /** defines the ending frame number (default is 100) */
  13349. toFrame?: number,
  13350. /** defines if the animation must loop (default is false) */
  13351. loopAnimation?: boolean, speedRatio?: number,
  13352. /** defines a callback to call when animation ends if it is not looping */
  13353. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13354. /** defines a callback to call when animation loops */
  13355. onAnimationLoop?: (() => void) | null | undefined);
  13356. /**
  13357. * Synchronize and normalize current Animatable with a source Animatable
  13358. * This is useful when using animation weights and when animations are not of the same length
  13359. * @param root defines the root Animatable to synchronize with
  13360. * @returns the current Animatable
  13361. */
  13362. syncWith(root: Animatable): Animatable;
  13363. /**
  13364. * Gets the list of runtime animations
  13365. * @returns an array of RuntimeAnimation
  13366. */
  13367. getAnimations(): RuntimeAnimation[];
  13368. /**
  13369. * Adds more animations to the current animatable
  13370. * @param target defines the target of the animations
  13371. * @param animations defines the new animations to add
  13372. */
  13373. appendAnimations(target: any, animations: Animation[]): void;
  13374. /**
  13375. * Gets the source animation for a specific property
  13376. * @param property defines the propertyu to look for
  13377. * @returns null or the source animation for the given property
  13378. */
  13379. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13380. /**
  13381. * Gets the runtime animation for a specific property
  13382. * @param property defines the propertyu to look for
  13383. * @returns null or the runtime animation for the given property
  13384. */
  13385. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13386. /**
  13387. * Resets the animatable to its original state
  13388. */
  13389. reset(): void;
  13390. /**
  13391. * Allows the animatable to blend with current running animations
  13392. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13393. * @param blendingSpeed defines the blending speed to use
  13394. */
  13395. enableBlending(blendingSpeed: number): void;
  13396. /**
  13397. * Disable animation blending
  13398. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13399. */
  13400. disableBlending(): void;
  13401. /**
  13402. * Jump directly to a given frame
  13403. * @param frame defines the frame to jump to
  13404. */
  13405. goToFrame(frame: number): void;
  13406. /**
  13407. * Pause the animation
  13408. */
  13409. pause(): void;
  13410. /**
  13411. * Restart the animation
  13412. */
  13413. restart(): void;
  13414. private _raiseOnAnimationEnd;
  13415. /**
  13416. * Stop and delete the current animation
  13417. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13418. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13419. */
  13420. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13421. /**
  13422. * Wait asynchronously for the animation to end
  13423. * @returns a promise which will be fullfilled when the animation ends
  13424. */
  13425. waitAsync(): Promise<Animatable>;
  13426. /** @hidden */
  13427. _animate(delay: number): boolean;
  13428. }
  13429. module "babylonjs/scene" {
  13430. interface Scene {
  13431. /** @hidden */
  13432. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13433. /** @hidden */
  13434. _processLateAnimationBindingsForMatrices(holder: {
  13435. totalWeight: number;
  13436. animations: RuntimeAnimation[];
  13437. originalValue: Matrix;
  13438. }): any;
  13439. /** @hidden */
  13440. _processLateAnimationBindingsForQuaternions(holder: {
  13441. totalWeight: number;
  13442. animations: RuntimeAnimation[];
  13443. originalValue: Quaternion;
  13444. }, refQuaternion: Quaternion): Quaternion;
  13445. /** @hidden */
  13446. _processLateAnimationBindings(): void;
  13447. /**
  13448. * Will start the animation sequence of a given target
  13449. * @param target defines the target
  13450. * @param from defines from which frame should animation start
  13451. * @param to defines until which frame should animation run.
  13452. * @param weight defines the weight to apply to the animation (1.0 by default)
  13453. * @param loop defines if the animation loops
  13454. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13455. * @param onAnimationEnd defines the function to be executed when the animation ends
  13456. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13457. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13458. * @param onAnimationLoop defines the callback to call when an animation loops
  13459. * @returns the animatable object created for this animation
  13460. */
  13461. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13462. /**
  13463. * Will start the animation sequence of a given target
  13464. * @param target defines the target
  13465. * @param from defines from which frame should animation start
  13466. * @param to defines until which frame should animation run.
  13467. * @param loop defines if the animation loops
  13468. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13469. * @param onAnimationEnd defines the function to be executed when the animation ends
  13470. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13471. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13472. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13473. * @param onAnimationLoop defines the callback to call when an animation loops
  13474. * @returns the animatable object created for this animation
  13475. */
  13476. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13477. /**
  13478. * Will start the animation sequence of a given target and its hierarchy
  13479. * @param target defines the target
  13480. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13481. * @param from defines from which frame should animation start
  13482. * @param to defines until which frame should animation run.
  13483. * @param loop defines if the animation loops
  13484. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13485. * @param onAnimationEnd defines the function to be executed when the animation ends
  13486. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13487. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13488. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13489. * @param onAnimationLoop defines the callback to call when an animation loops
  13490. * @returns the list of created animatables
  13491. */
  13492. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13493. /**
  13494. * Begin a new animation on a given node
  13495. * @param target defines the target where the animation will take place
  13496. * @param animations defines the list of animations to start
  13497. * @param from defines the initial value
  13498. * @param to defines the final value
  13499. * @param loop defines if you want animation to loop (off by default)
  13500. * @param speedRatio defines the speed ratio to apply to all animations
  13501. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13502. * @param onAnimationLoop defines the callback to call when an animation loops
  13503. * @returns the list of created animatables
  13504. */
  13505. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13506. /**
  13507. * Begin a new animation on a given node and its hierarchy
  13508. * @param target defines the root node where the animation will take place
  13509. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13510. * @param animations defines the list of animations to start
  13511. * @param from defines the initial value
  13512. * @param to defines the final value
  13513. * @param loop defines if you want animation to loop (off by default)
  13514. * @param speedRatio defines the speed ratio to apply to all animations
  13515. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13516. * @param onAnimationLoop defines the callback to call when an animation loops
  13517. * @returns the list of animatables created for all nodes
  13518. */
  13519. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13520. /**
  13521. * Gets the animatable associated with a specific target
  13522. * @param target defines the target of the animatable
  13523. * @returns the required animatable if found
  13524. */
  13525. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13526. /**
  13527. * Gets all animatables associated with a given target
  13528. * @param target defines the target to look animatables for
  13529. * @returns an array of Animatables
  13530. */
  13531. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13532. /**
  13533. * Stops and removes all animations that have been applied to the scene
  13534. */
  13535. stopAllAnimations(): void;
  13536. /**
  13537. * Gets the current delta time used by animation engine
  13538. */
  13539. deltaTime: number;
  13540. }
  13541. }
  13542. module "babylonjs/Bones/bone" {
  13543. interface Bone {
  13544. /**
  13545. * Copy an animation range from another bone
  13546. * @param source defines the source bone
  13547. * @param rangeName defines the range name to copy
  13548. * @param frameOffset defines the frame offset
  13549. * @param rescaleAsRequired defines if rescaling must be applied if required
  13550. * @param skelDimensionsRatio defines the scaling ratio
  13551. * @returns true if operation was successful
  13552. */
  13553. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13554. }
  13555. }
  13556. }
  13557. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13558. /**
  13559. * Class used to override all child animations of a given target
  13560. */
  13561. export class AnimationPropertiesOverride {
  13562. /**
  13563. * Gets or sets a value indicating if animation blending must be used
  13564. */
  13565. enableBlending: boolean;
  13566. /**
  13567. * Gets or sets the blending speed to use when enableBlending is true
  13568. */
  13569. blendingSpeed: number;
  13570. /**
  13571. * Gets or sets the default loop mode to use
  13572. */
  13573. loopMode: number;
  13574. }
  13575. }
  13576. declare module "babylonjs/Bones/skeleton" {
  13577. import { Bone } from "babylonjs/Bones/bone";
  13578. import { Observable } from "babylonjs/Misc/observable";
  13579. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13580. import { Scene } from "babylonjs/scene";
  13581. import { Nullable } from "babylonjs/types";
  13582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13583. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13584. import { Animatable } from "babylonjs/Animations/animatable";
  13585. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13586. import { Animation } from "babylonjs/Animations/animation";
  13587. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13588. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13589. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13590. /**
  13591. * Class used to handle skinning animations
  13592. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13593. */
  13594. export class Skeleton implements IAnimatable {
  13595. /** defines the skeleton name */
  13596. name: string;
  13597. /** defines the skeleton Id */
  13598. id: string;
  13599. /**
  13600. * Defines the list of child bones
  13601. */
  13602. bones: Bone[];
  13603. /**
  13604. * Defines an estimate of the dimension of the skeleton at rest
  13605. */
  13606. dimensionsAtRest: Vector3;
  13607. /**
  13608. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13609. */
  13610. needInitialSkinMatrix: boolean;
  13611. /**
  13612. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13613. */
  13614. overrideMesh: Nullable<AbstractMesh>;
  13615. /**
  13616. * Gets the list of animations attached to this skeleton
  13617. */
  13618. animations: Array<Animation>;
  13619. private _scene;
  13620. private _isDirty;
  13621. private _transformMatrices;
  13622. private _transformMatrixTexture;
  13623. private _meshesWithPoseMatrix;
  13624. private _animatables;
  13625. private _identity;
  13626. private _synchronizedWithMesh;
  13627. private _ranges;
  13628. private _lastAbsoluteTransformsUpdateId;
  13629. private _canUseTextureForBones;
  13630. private _uniqueId;
  13631. /** @hidden */
  13632. _numBonesWithLinkedTransformNode: number;
  13633. /** @hidden */
  13634. _hasWaitingData: Nullable<boolean>;
  13635. /**
  13636. * Specifies if the skeleton should be serialized
  13637. */
  13638. doNotSerialize: boolean;
  13639. private _useTextureToStoreBoneMatrices;
  13640. /**
  13641. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13642. * Please note that this option is not available if the hardware does not support it
  13643. */
  13644. useTextureToStoreBoneMatrices: boolean;
  13645. private _animationPropertiesOverride;
  13646. /**
  13647. * Gets or sets the animation properties override
  13648. */
  13649. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * An observable triggered before computing the skeleton's matrices
  13657. */
  13658. onBeforeComputeObservable: Observable<Skeleton>;
  13659. /**
  13660. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13661. */
  13662. readonly isUsingTextureForMatrices: boolean;
  13663. /**
  13664. * Gets the unique ID of this skeleton
  13665. */
  13666. readonly uniqueId: number;
  13667. /**
  13668. * Creates a new skeleton
  13669. * @param name defines the skeleton name
  13670. * @param id defines the skeleton Id
  13671. * @param scene defines the hosting scene
  13672. */
  13673. constructor(
  13674. /** defines the skeleton name */
  13675. name: string,
  13676. /** defines the skeleton Id */
  13677. id: string, scene: Scene);
  13678. /**
  13679. * Gets the current object class name.
  13680. * @return the class name
  13681. */
  13682. getClassName(): string;
  13683. /**
  13684. * Returns an array containing the root bones
  13685. * @returns an array containing the root bones
  13686. */
  13687. getChildren(): Array<Bone>;
  13688. /**
  13689. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13690. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13691. * @returns a Float32Array containing matrices data
  13692. */
  13693. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13694. /**
  13695. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13696. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13697. * @returns a raw texture containing the data
  13698. */
  13699. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13700. /**
  13701. * Gets the current hosting scene
  13702. * @returns a scene object
  13703. */
  13704. getScene(): Scene;
  13705. /**
  13706. * Gets a string representing the current skeleton data
  13707. * @param fullDetails defines a boolean indicating if we want a verbose version
  13708. * @returns a string representing the current skeleton data
  13709. */
  13710. toString(fullDetails?: boolean): string;
  13711. /**
  13712. * Get bone's index searching by name
  13713. * @param name defines bone's name to search for
  13714. * @return the indice of the bone. Returns -1 if not found
  13715. */
  13716. getBoneIndexByName(name: string): number;
  13717. /**
  13718. * Creater a new animation range
  13719. * @param name defines the name of the range
  13720. * @param from defines the start key
  13721. * @param to defines the end key
  13722. */
  13723. createAnimationRange(name: string, from: number, to: number): void;
  13724. /**
  13725. * Delete a specific animation range
  13726. * @param name defines the name of the range
  13727. * @param deleteFrames defines if frames must be removed as well
  13728. */
  13729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13730. /**
  13731. * Gets a specific animation range
  13732. * @param name defines the name of the range to look for
  13733. * @returns the requested animation range or null if not found
  13734. */
  13735. getAnimationRange(name: string): Nullable<AnimationRange>;
  13736. /**
  13737. * Gets the list of all animation ranges defined on this skeleton
  13738. * @returns an array
  13739. */
  13740. getAnimationRanges(): Nullable<AnimationRange>[];
  13741. /**
  13742. * Copy animation range from a source skeleton.
  13743. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13744. * @param source defines the source skeleton
  13745. * @param name defines the name of the range to copy
  13746. * @param rescaleAsRequired defines if rescaling must be applied if required
  13747. * @returns true if operation was successful
  13748. */
  13749. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13750. /**
  13751. * Forces the skeleton to go to rest pose
  13752. */
  13753. returnToRest(): void;
  13754. private _getHighestAnimationFrame;
  13755. /**
  13756. * Begin a specific animation range
  13757. * @param name defines the name of the range to start
  13758. * @param loop defines if looping must be turned on (false by default)
  13759. * @param speedRatio defines the speed ratio to apply (1 by default)
  13760. * @param onAnimationEnd defines a callback which will be called when animation will end
  13761. * @returns a new animatable
  13762. */
  13763. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13764. /** @hidden */
  13765. _markAsDirty(): void;
  13766. /** @hidden */
  13767. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13768. /** @hidden */
  13769. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13770. private _computeTransformMatrices;
  13771. /**
  13772. * Build all resources required to render a skeleton
  13773. */
  13774. prepare(): void;
  13775. /**
  13776. * Gets the list of animatables currently running for this skeleton
  13777. * @returns an array of animatables
  13778. */
  13779. getAnimatables(): IAnimatable[];
  13780. /**
  13781. * Clone the current skeleton
  13782. * @param name defines the name of the new skeleton
  13783. * @param id defines the id of the new skeleton
  13784. * @returns the new skeleton
  13785. */
  13786. clone(name: string, id?: string): Skeleton;
  13787. /**
  13788. * Enable animation blending for this skeleton
  13789. * @param blendingSpeed defines the blending speed to apply
  13790. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13791. */
  13792. enableBlending(blendingSpeed?: number): void;
  13793. /**
  13794. * Releases all resources associated with the current skeleton
  13795. */
  13796. dispose(): void;
  13797. /**
  13798. * Serialize the skeleton in a JSON object
  13799. * @returns a JSON object
  13800. */
  13801. serialize(): any;
  13802. /**
  13803. * Creates a new skeleton from serialized data
  13804. * @param parsedSkeleton defines the serialized data
  13805. * @param scene defines the hosting scene
  13806. * @returns a new skeleton
  13807. */
  13808. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13809. /**
  13810. * Compute all node absolute transforms
  13811. * @param forceUpdate defines if computation must be done even if cache is up to date
  13812. */
  13813. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13814. /**
  13815. * Gets the root pose matrix
  13816. * @returns a matrix
  13817. */
  13818. getPoseMatrix(): Nullable<Matrix>;
  13819. /**
  13820. * Sorts bones per internal index
  13821. */
  13822. sortBones(): void;
  13823. private _sortBones;
  13824. }
  13825. }
  13826. declare module "babylonjs/Bones/bone" {
  13827. import { Skeleton } from "babylonjs/Bones/skeleton";
  13828. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13829. import { Nullable } from "babylonjs/types";
  13830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13831. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13832. import { Node } from "babylonjs/node";
  13833. import { Space } from "babylonjs/Maths/math.axis";
  13834. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13835. /**
  13836. * Class used to store bone information
  13837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13838. */
  13839. export class Bone extends Node {
  13840. /**
  13841. * defines the bone name
  13842. */
  13843. name: string;
  13844. private static _tmpVecs;
  13845. private static _tmpQuat;
  13846. private static _tmpMats;
  13847. /**
  13848. * Gets the list of child bones
  13849. */
  13850. children: Bone[];
  13851. /** Gets the animations associated with this bone */
  13852. animations: import("babylonjs/Animations/animation").Animation[];
  13853. /**
  13854. * Gets or sets bone length
  13855. */
  13856. length: number;
  13857. /**
  13858. * @hidden Internal only
  13859. * Set this value to map this bone to a different index in the transform matrices
  13860. * Set this value to -1 to exclude the bone from the transform matrices
  13861. */
  13862. _index: Nullable<number>;
  13863. private _skeleton;
  13864. private _localMatrix;
  13865. private _restPose;
  13866. private _baseMatrix;
  13867. private _absoluteTransform;
  13868. private _invertedAbsoluteTransform;
  13869. private _parent;
  13870. private _scalingDeterminant;
  13871. private _worldTransform;
  13872. private _localScaling;
  13873. private _localRotation;
  13874. private _localPosition;
  13875. private _needToDecompose;
  13876. private _needToCompose;
  13877. /** @hidden */
  13878. _linkedTransformNode: Nullable<TransformNode>;
  13879. /** @hidden */
  13880. _waitingTransformNodeId: Nullable<string>;
  13881. /** @hidden */
  13882. /** @hidden */
  13883. _matrix: Matrix;
  13884. /**
  13885. * Create a new bone
  13886. * @param name defines the bone name
  13887. * @param skeleton defines the parent skeleton
  13888. * @param parentBone defines the parent (can be null if the bone is the root)
  13889. * @param localMatrix defines the local matrix
  13890. * @param restPose defines the rest pose matrix
  13891. * @param baseMatrix defines the base matrix
  13892. * @param index defines index of the bone in the hiearchy
  13893. */
  13894. constructor(
  13895. /**
  13896. * defines the bone name
  13897. */
  13898. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13899. /**
  13900. * Gets the current object class name.
  13901. * @return the class name
  13902. */
  13903. getClassName(): string;
  13904. /**
  13905. * Gets the parent skeleton
  13906. * @returns a skeleton
  13907. */
  13908. getSkeleton(): Skeleton;
  13909. /**
  13910. * Gets parent bone
  13911. * @returns a bone or null if the bone is the root of the bone hierarchy
  13912. */
  13913. getParent(): Nullable<Bone>;
  13914. /**
  13915. * Returns an array containing the root bones
  13916. * @returns an array containing the root bones
  13917. */
  13918. getChildren(): Array<Bone>;
  13919. /**
  13920. * Gets the node index in matrix array generated for rendering
  13921. * @returns the node index
  13922. */
  13923. getIndex(): number;
  13924. /**
  13925. * Sets the parent bone
  13926. * @param parent defines the parent (can be null if the bone is the root)
  13927. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13928. */
  13929. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13930. /**
  13931. * Gets the local matrix
  13932. * @returns a matrix
  13933. */
  13934. getLocalMatrix(): Matrix;
  13935. /**
  13936. * Gets the base matrix (initial matrix which remains unchanged)
  13937. * @returns a matrix
  13938. */
  13939. getBaseMatrix(): Matrix;
  13940. /**
  13941. * Gets the rest pose matrix
  13942. * @returns a matrix
  13943. */
  13944. getRestPose(): Matrix;
  13945. /**
  13946. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13947. */
  13948. getWorldMatrix(): Matrix;
  13949. /**
  13950. * Sets the local matrix to rest pose matrix
  13951. */
  13952. returnToRest(): void;
  13953. /**
  13954. * Gets the inverse of the absolute transform matrix.
  13955. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13956. * @returns a matrix
  13957. */
  13958. getInvertedAbsoluteTransform(): Matrix;
  13959. /**
  13960. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13961. * @returns a matrix
  13962. */
  13963. getAbsoluteTransform(): Matrix;
  13964. /**
  13965. * Links with the given transform node.
  13966. * The local matrix of this bone is copied from the transform node every frame.
  13967. * @param transformNode defines the transform node to link to
  13968. */
  13969. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13970. /**
  13971. * Gets the node used to drive the bone's transformation
  13972. * @returns a transform node or null
  13973. */
  13974. getTransformNode(): Nullable<TransformNode>;
  13975. /** Gets or sets current position (in local space) */
  13976. position: Vector3;
  13977. /** Gets or sets current rotation (in local space) */
  13978. rotation: Vector3;
  13979. /** Gets or sets current rotation quaternion (in local space) */
  13980. rotationQuaternion: Quaternion;
  13981. /** Gets or sets current scaling (in local space) */
  13982. scaling: Vector3;
  13983. /**
  13984. * Gets the animation properties override
  13985. */
  13986. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13987. private _decompose;
  13988. private _compose;
  13989. /**
  13990. * Update the base and local matrices
  13991. * @param matrix defines the new base or local matrix
  13992. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13993. * @param updateLocalMatrix defines if the local matrix should be updated
  13994. */
  13995. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13996. /** @hidden */
  13997. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13998. /**
  13999. * Flag the bone as dirty (Forcing it to update everything)
  14000. */
  14001. markAsDirty(): void;
  14002. /** @hidden */
  14003. _markAsDirtyAndCompose(): void;
  14004. private _markAsDirtyAndDecompose;
  14005. /**
  14006. * Translate the bone in local or world space
  14007. * @param vec The amount to translate the bone
  14008. * @param space The space that the translation is in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. */
  14011. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14012. /**
  14013. * Set the postion of the bone in local or world space
  14014. * @param position The position to set the bone
  14015. * @param space The space that the position is in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. */
  14018. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14019. /**
  14020. * Set the absolute position of the bone (world space)
  14021. * @param position The position to set the bone
  14022. * @param mesh The mesh that this bone is attached to
  14023. */
  14024. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14025. /**
  14026. * Scale the bone on the x, y and z axes (in local space)
  14027. * @param x The amount to scale the bone on the x axis
  14028. * @param y The amount to scale the bone on the y axis
  14029. * @param z The amount to scale the bone on the z axis
  14030. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14031. */
  14032. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14033. /**
  14034. * Set the bone scaling in local space
  14035. * @param scale defines the scaling vector
  14036. */
  14037. setScale(scale: Vector3): void;
  14038. /**
  14039. * Gets the current scaling in local space
  14040. * @returns the current scaling vector
  14041. */
  14042. getScale(): Vector3;
  14043. /**
  14044. * Gets the current scaling in local space and stores it in a target vector
  14045. * @param result defines the target vector
  14046. */
  14047. getScaleToRef(result: Vector3): void;
  14048. /**
  14049. * Set the yaw, pitch, and roll of the bone in local or world space
  14050. * @param yaw The rotation of the bone on the y axis
  14051. * @param pitch The rotation of the bone on the x axis
  14052. * @param roll The rotation of the bone on the z axis
  14053. * @param space The space that the axes of rotation are in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. */
  14056. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14057. /**
  14058. * Add a rotation to the bone on an axis in local or world space
  14059. * @param axis The axis to rotate the bone on
  14060. * @param amount The amount to rotate the bone
  14061. * @param space The space that the axis is in
  14062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14063. */
  14064. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14065. /**
  14066. * Set the rotation of the bone to a particular axis angle in local or world space
  14067. * @param axis The axis to rotate the bone on
  14068. * @param angle The angle that the bone should be rotated to
  14069. * @param space The space that the axis is in
  14070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14071. */
  14072. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14073. /**
  14074. * Set the euler rotation of the bone in local of world space
  14075. * @param rotation The euler rotation that the bone should be set to
  14076. * @param space The space that the rotation is in
  14077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14078. */
  14079. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14080. /**
  14081. * Set the quaternion rotation of the bone in local of world space
  14082. * @param quat The quaternion rotation that the bone should be set to
  14083. * @param space The space that the rotation is in
  14084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14085. */
  14086. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14087. /**
  14088. * Set the rotation matrix of the bone in local of world space
  14089. * @param rotMat The rotation matrix that the bone should be set to
  14090. * @param space The space that the rotation is in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14094. private _rotateWithMatrix;
  14095. private _getNegativeRotationToRef;
  14096. /**
  14097. * Get the position of the bone in local or world space
  14098. * @param space The space that the returned position is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. * @returns The position of the bone
  14101. */
  14102. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14103. /**
  14104. * Copy the position of the bone to a vector3 in local or world space
  14105. * @param space The space that the returned position is in
  14106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14107. * @param result The vector3 to copy the position to
  14108. */
  14109. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14110. /**
  14111. * Get the absolute position of the bone (world space)
  14112. * @param mesh The mesh that this bone is attached to
  14113. * @returns The absolute position of the bone
  14114. */
  14115. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14116. /**
  14117. * Copy the absolute position of the bone (world space) to the result param
  14118. * @param mesh The mesh that this bone is attached to
  14119. * @param result The vector3 to copy the absolute position to
  14120. */
  14121. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14122. /**
  14123. * Compute the absolute transforms of this bone and its children
  14124. */
  14125. computeAbsoluteTransforms(): void;
  14126. /**
  14127. * Get the world direction from an axis that is in the local space of the bone
  14128. * @param localAxis The local direction that is used to compute the world direction
  14129. * @param mesh The mesh that this bone is attached to
  14130. * @returns The world direction
  14131. */
  14132. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14133. /**
  14134. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14135. * @param localAxis The local direction that is used to compute the world direction
  14136. * @param mesh The mesh that this bone is attached to
  14137. * @param result The vector3 that the world direction will be copied to
  14138. */
  14139. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14140. /**
  14141. * Get the euler rotation of the bone in local or world space
  14142. * @param space The space that the rotation should be in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @returns The euler rotation
  14145. */
  14146. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14147. /**
  14148. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14149. * @param space The space that the rotation should be in
  14150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14151. * @param result The vector3 that the rotation should be copied to
  14152. */
  14153. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14154. /**
  14155. * Get the quaternion rotation of the bone in either local or world space
  14156. * @param space The space that the rotation should be in
  14157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14158. * @returns The quaternion rotation
  14159. */
  14160. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14161. /**
  14162. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14163. * @param space The space that the rotation should be in
  14164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14165. * @param result The quaternion that the rotation should be copied to
  14166. */
  14167. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14168. /**
  14169. * Get the rotation matrix of the bone in local or world space
  14170. * @param space The space that the rotation should be in
  14171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14172. * @returns The rotation matrix
  14173. */
  14174. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14175. /**
  14176. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14177. * @param space The space that the rotation should be in
  14178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14179. * @param result The quaternion that the rotation should be copied to
  14180. */
  14181. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14182. /**
  14183. * Get the world position of a point that is in the local space of the bone
  14184. * @param position The local position
  14185. * @param mesh The mesh that this bone is attached to
  14186. * @returns The world position
  14187. */
  14188. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14189. /**
  14190. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14191. * @param position The local position
  14192. * @param mesh The mesh that this bone is attached to
  14193. * @param result The vector3 that the world position should be copied to
  14194. */
  14195. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14196. /**
  14197. * Get the local position of a point that is in world space
  14198. * @param position The world position
  14199. * @param mesh The mesh that this bone is attached to
  14200. * @returns The local position
  14201. */
  14202. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14203. /**
  14204. * Get the local position of a point that is in world space and copy it to the result param
  14205. * @param position The world position
  14206. * @param mesh The mesh that this bone is attached to
  14207. * @param result The vector3 that the local position should be copied to
  14208. */
  14209. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14210. }
  14211. }
  14212. declare module "babylonjs/Meshes/transformNode" {
  14213. import { DeepImmutable } from "babylonjs/types";
  14214. import { Observable } from "babylonjs/Misc/observable";
  14215. import { Nullable } from "babylonjs/types";
  14216. import { Camera } from "babylonjs/Cameras/camera";
  14217. import { Scene } from "babylonjs/scene";
  14218. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14219. import { Node } from "babylonjs/node";
  14220. import { Bone } from "babylonjs/Bones/bone";
  14221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14222. import { Space } from "babylonjs/Maths/math.axis";
  14223. /**
  14224. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14225. * @see https://doc.babylonjs.com/how_to/transformnode
  14226. */
  14227. export class TransformNode extends Node {
  14228. /**
  14229. * Object will not rotate to face the camera
  14230. */
  14231. static BILLBOARDMODE_NONE: number;
  14232. /**
  14233. * Object will rotate to face the camera but only on the x axis
  14234. */
  14235. static BILLBOARDMODE_X: number;
  14236. /**
  14237. * Object will rotate to face the camera but only on the y axis
  14238. */
  14239. static BILLBOARDMODE_Y: number;
  14240. /**
  14241. * Object will rotate to face the camera but only on the z axis
  14242. */
  14243. static BILLBOARDMODE_Z: number;
  14244. /**
  14245. * Object will rotate to face the camera
  14246. */
  14247. static BILLBOARDMODE_ALL: number;
  14248. /**
  14249. * Object will rotate to face the camera's position instead of orientation
  14250. */
  14251. static BILLBOARDMODE_USE_POSITION: number;
  14252. private _forward;
  14253. private _forwardInverted;
  14254. private _up;
  14255. private _right;
  14256. private _rightInverted;
  14257. private _position;
  14258. private _rotation;
  14259. private _rotationQuaternion;
  14260. protected _scaling: Vector3;
  14261. protected _isDirty: boolean;
  14262. private _transformToBoneReferal;
  14263. private _isAbsoluteSynced;
  14264. private _billboardMode;
  14265. /**
  14266. * Gets or sets the billboard mode. Default is 0.
  14267. *
  14268. * | Value | Type | Description |
  14269. * | --- | --- | --- |
  14270. * | 0 | BILLBOARDMODE_NONE | |
  14271. * | 1 | BILLBOARDMODE_X | |
  14272. * | 2 | BILLBOARDMODE_Y | |
  14273. * | 4 | BILLBOARDMODE_Z | |
  14274. * | 7 | BILLBOARDMODE_ALL | |
  14275. *
  14276. */
  14277. billboardMode: number;
  14278. private _preserveParentRotationForBillboard;
  14279. /**
  14280. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14281. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14282. */
  14283. preserveParentRotationForBillboard: boolean;
  14284. /**
  14285. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14286. */
  14287. scalingDeterminant: number;
  14288. private _infiniteDistance;
  14289. /**
  14290. * Gets or sets the distance of the object to max, often used by skybox
  14291. */
  14292. infiniteDistance: boolean;
  14293. /**
  14294. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14295. * By default the system will update normals to compensate
  14296. */
  14297. ignoreNonUniformScaling: boolean;
  14298. /**
  14299. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14300. */
  14301. reIntegrateRotationIntoRotationQuaternion: boolean;
  14302. /** @hidden */
  14303. _poseMatrix: Nullable<Matrix>;
  14304. /** @hidden */
  14305. _localMatrix: Matrix;
  14306. private _usePivotMatrix;
  14307. private _absolutePosition;
  14308. private _absoluteScaling;
  14309. private _absoluteRotationQuaternion;
  14310. private _pivotMatrix;
  14311. private _pivotMatrixInverse;
  14312. protected _postMultiplyPivotMatrix: boolean;
  14313. protected _isWorldMatrixFrozen: boolean;
  14314. /** @hidden */
  14315. _indexInSceneTransformNodesArray: number;
  14316. /**
  14317. * An event triggered after the world matrix is updated
  14318. */
  14319. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14320. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14321. /**
  14322. * Gets a string identifying the name of the class
  14323. * @returns "TransformNode" string
  14324. */
  14325. getClassName(): string;
  14326. /**
  14327. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14328. */
  14329. position: Vector3;
  14330. /**
  14331. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14332. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14333. */
  14334. rotation: Vector3;
  14335. /**
  14336. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14337. */
  14338. scaling: Vector3;
  14339. /**
  14340. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14341. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14342. */
  14343. rotationQuaternion: Nullable<Quaternion>;
  14344. /**
  14345. * The forward direction of that transform in world space.
  14346. */
  14347. readonly forward: Vector3;
  14348. /**
  14349. * The up direction of that transform in world space.
  14350. */
  14351. readonly up: Vector3;
  14352. /**
  14353. * The right direction of that transform in world space.
  14354. */
  14355. readonly right: Vector3;
  14356. /**
  14357. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14358. * @param matrix the matrix to copy the pose from
  14359. * @returns this TransformNode.
  14360. */
  14361. updatePoseMatrix(matrix: Matrix): TransformNode;
  14362. /**
  14363. * Returns the mesh Pose matrix.
  14364. * @returns the pose matrix
  14365. */
  14366. getPoseMatrix(): Matrix;
  14367. /** @hidden */
  14368. _isSynchronized(): boolean;
  14369. /** @hidden */
  14370. _initCache(): void;
  14371. /**
  14372. * Flag the transform node as dirty (Forcing it to update everything)
  14373. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14374. * @returns this transform node
  14375. */
  14376. markAsDirty(property: string): TransformNode;
  14377. /**
  14378. * Returns the current mesh absolute position.
  14379. * Returns a Vector3.
  14380. */
  14381. readonly absolutePosition: Vector3;
  14382. /**
  14383. * Returns the current mesh absolute scaling.
  14384. * Returns a Vector3.
  14385. */
  14386. readonly absoluteScaling: Vector3;
  14387. /**
  14388. * Returns the current mesh absolute rotation.
  14389. * Returns a Quaternion.
  14390. */
  14391. readonly absoluteRotationQuaternion: Quaternion;
  14392. /**
  14393. * Sets a new matrix to apply before all other transformation
  14394. * @param matrix defines the transform matrix
  14395. * @returns the current TransformNode
  14396. */
  14397. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14398. /**
  14399. * Sets a new pivot matrix to the current node
  14400. * @param matrix defines the new pivot matrix to use
  14401. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14402. * @returns the current TransformNode
  14403. */
  14404. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14405. /**
  14406. * Returns the mesh pivot matrix.
  14407. * Default : Identity.
  14408. * @returns the matrix
  14409. */
  14410. getPivotMatrix(): Matrix;
  14411. /**
  14412. * Instantiate (when possible) or clone that node with its hierarchy
  14413. * @param newParent defines the new parent to use for the instance (or clone)
  14414. * @param options defines options to configure how copy is done
  14415. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14416. * @returns an instance (or a clone) of the current node with its hiearchy
  14417. */
  14418. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14419. doNotInstantiate: boolean;
  14420. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14421. /**
  14422. * Prevents the World matrix to be computed any longer
  14423. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14424. * @returns the TransformNode.
  14425. */
  14426. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14427. /**
  14428. * Allows back the World matrix computation.
  14429. * @returns the TransformNode.
  14430. */
  14431. unfreezeWorldMatrix(): this;
  14432. /**
  14433. * True if the World matrix has been frozen.
  14434. */
  14435. readonly isWorldMatrixFrozen: boolean;
  14436. /**
  14437. * Retuns the mesh absolute position in the World.
  14438. * @returns a Vector3.
  14439. */
  14440. getAbsolutePosition(): Vector3;
  14441. /**
  14442. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14443. * @param absolutePosition the absolute position to set
  14444. * @returns the TransformNode.
  14445. */
  14446. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14447. /**
  14448. * Sets the mesh position in its local space.
  14449. * @param vector3 the position to set in localspace
  14450. * @returns the TransformNode.
  14451. */
  14452. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14453. /**
  14454. * Returns the mesh position in the local space from the current World matrix values.
  14455. * @returns a new Vector3.
  14456. */
  14457. getPositionExpressedInLocalSpace(): Vector3;
  14458. /**
  14459. * Translates the mesh along the passed Vector3 in its local space.
  14460. * @param vector3 the distance to translate in localspace
  14461. * @returns the TransformNode.
  14462. */
  14463. locallyTranslate(vector3: Vector3): TransformNode;
  14464. private static _lookAtVectorCache;
  14465. /**
  14466. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14467. * @param targetPoint the position (must be in same space as current mesh) to look at
  14468. * @param yawCor optional yaw (y-axis) correction in radians
  14469. * @param pitchCor optional pitch (x-axis) correction in radians
  14470. * @param rollCor optional roll (z-axis) correction in radians
  14471. * @param space the choosen space of the target
  14472. * @returns the TransformNode.
  14473. */
  14474. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14475. /**
  14476. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14477. * This Vector3 is expressed in the World space.
  14478. * @param localAxis axis to rotate
  14479. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14480. */
  14481. getDirection(localAxis: Vector3): Vector3;
  14482. /**
  14483. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14484. * localAxis is expressed in the mesh local space.
  14485. * result is computed in the Wordl space from the mesh World matrix.
  14486. * @param localAxis axis to rotate
  14487. * @param result the resulting transformnode
  14488. * @returns this TransformNode.
  14489. */
  14490. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14491. /**
  14492. * Sets this transform node rotation to the given local axis.
  14493. * @param localAxis the axis in local space
  14494. * @param yawCor optional yaw (y-axis) correction in radians
  14495. * @param pitchCor optional pitch (x-axis) correction in radians
  14496. * @param rollCor optional roll (z-axis) correction in radians
  14497. * @returns this TransformNode
  14498. */
  14499. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14500. /**
  14501. * Sets a new pivot point to the current node
  14502. * @param point defines the new pivot point to use
  14503. * @param space defines if the point is in world or local space (local by default)
  14504. * @returns the current TransformNode
  14505. */
  14506. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14507. /**
  14508. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14509. * @returns the pivot point
  14510. */
  14511. getPivotPoint(): Vector3;
  14512. /**
  14513. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14514. * @param result the vector3 to store the result
  14515. * @returns this TransformNode.
  14516. */
  14517. getPivotPointToRef(result: Vector3): TransformNode;
  14518. /**
  14519. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14520. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14521. */
  14522. getAbsolutePivotPoint(): Vector3;
  14523. /**
  14524. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14525. * @param result vector3 to store the result
  14526. * @returns this TransformNode.
  14527. */
  14528. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14529. /**
  14530. * Defines the passed node as the parent of the current node.
  14531. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14532. * @see https://doc.babylonjs.com/how_to/parenting
  14533. * @param node the node ot set as the parent
  14534. * @returns this TransformNode.
  14535. */
  14536. setParent(node: Nullable<Node>): TransformNode;
  14537. private _nonUniformScaling;
  14538. /**
  14539. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14540. */
  14541. readonly nonUniformScaling: boolean;
  14542. /** @hidden */
  14543. _updateNonUniformScalingState(value: boolean): boolean;
  14544. /**
  14545. * Attach the current TransformNode to another TransformNode associated with a bone
  14546. * @param bone Bone affecting the TransformNode
  14547. * @param affectedTransformNode TransformNode associated with the bone
  14548. * @returns this object
  14549. */
  14550. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14551. /**
  14552. * Detach the transform node if its associated with a bone
  14553. * @returns this object
  14554. */
  14555. detachFromBone(): TransformNode;
  14556. private static _rotationAxisCache;
  14557. /**
  14558. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14559. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14560. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14561. * The passed axis is also normalized.
  14562. * @param axis the axis to rotate around
  14563. * @param amount the amount to rotate in radians
  14564. * @param space Space to rotate in (Default: local)
  14565. * @returns the TransformNode.
  14566. */
  14567. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14568. /**
  14569. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14570. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14571. * The passed axis is also normalized. .
  14572. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14573. * @param point the point to rotate around
  14574. * @param axis the axis to rotate around
  14575. * @param amount the amount to rotate in radians
  14576. * @returns the TransformNode
  14577. */
  14578. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14579. /**
  14580. * Translates the mesh along the axis vector for the passed distance in the given space.
  14581. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14582. * @param axis the axis to translate in
  14583. * @param distance the distance to translate
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14588. /**
  14589. * Adds a rotation step to the mesh current rotation.
  14590. * x, y, z are Euler angles expressed in radians.
  14591. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14592. * This means this rotation is made in the mesh local space only.
  14593. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14594. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14595. * ```javascript
  14596. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14597. * ```
  14598. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14599. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14600. * @param x Rotation to add
  14601. * @param y Rotation to add
  14602. * @param z Rotation to add
  14603. * @returns the TransformNode.
  14604. */
  14605. addRotation(x: number, y: number, z: number): TransformNode;
  14606. /**
  14607. * @hidden
  14608. */
  14609. protected _getEffectiveParent(): Nullable<Node>;
  14610. /**
  14611. * Computes the world matrix of the node
  14612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14613. * @returns the world matrix
  14614. */
  14615. computeWorldMatrix(force?: boolean): Matrix;
  14616. protected _afterComputeWorldMatrix(): void;
  14617. /**
  14618. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14619. * @param func callback function to add
  14620. *
  14621. * @returns the TransformNode.
  14622. */
  14623. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14624. /**
  14625. * Removes a registered callback function.
  14626. * @param func callback function to remove
  14627. * @returns the TransformNode.
  14628. */
  14629. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14630. /**
  14631. * Gets the position of the current mesh in camera space
  14632. * @param camera defines the camera to use
  14633. * @returns a position
  14634. */
  14635. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14636. /**
  14637. * Returns the distance from the mesh to the active camera
  14638. * @param camera defines the camera to use
  14639. * @returns the distance
  14640. */
  14641. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14642. /**
  14643. * Clone the current transform node
  14644. * @param name Name of the new clone
  14645. * @param newParent New parent for the clone
  14646. * @param doNotCloneChildren Do not clone children hierarchy
  14647. * @returns the new transform node
  14648. */
  14649. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14650. /**
  14651. * Serializes the objects information.
  14652. * @param currentSerializationObject defines the object to serialize in
  14653. * @returns the serialized object
  14654. */
  14655. serialize(currentSerializationObject?: any): any;
  14656. /**
  14657. * Returns a new TransformNode object parsed from the source provided.
  14658. * @param parsedTransformNode is the source.
  14659. * @param scene the scne the object belongs to
  14660. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14661. * @returns a new TransformNode object parsed from the source provided.
  14662. */
  14663. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14664. /**
  14665. * Get all child-transformNodes of this node
  14666. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14667. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14668. * @returns an array of TransformNode
  14669. */
  14670. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14671. /**
  14672. * Releases resources associated with this transform node.
  14673. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14674. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14675. */
  14676. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14677. /**
  14678. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14679. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14680. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14681. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14682. * @returns the current mesh
  14683. */
  14684. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14685. private _syncAbsoluteScalingAndRotation;
  14686. }
  14687. }
  14688. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14689. import { Observable } from "babylonjs/Misc/observable";
  14690. import { Nullable } from "babylonjs/types";
  14691. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14694. import { Ray } from "babylonjs/Culling/ray";
  14695. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14696. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14697. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14698. /**
  14699. * Defines the types of pose enabled controllers that are supported
  14700. */
  14701. export enum PoseEnabledControllerType {
  14702. /**
  14703. * HTC Vive
  14704. */
  14705. VIVE = 0,
  14706. /**
  14707. * Oculus Rift
  14708. */
  14709. OCULUS = 1,
  14710. /**
  14711. * Windows mixed reality
  14712. */
  14713. WINDOWS = 2,
  14714. /**
  14715. * Samsung gear VR
  14716. */
  14717. GEAR_VR = 3,
  14718. /**
  14719. * Google Daydream
  14720. */
  14721. DAYDREAM = 4,
  14722. /**
  14723. * Generic
  14724. */
  14725. GENERIC = 5
  14726. }
  14727. /**
  14728. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14729. */
  14730. export interface MutableGamepadButton {
  14731. /**
  14732. * Value of the button/trigger
  14733. */
  14734. value: number;
  14735. /**
  14736. * If the button/trigger is currently touched
  14737. */
  14738. touched: boolean;
  14739. /**
  14740. * If the button/trigger is currently pressed
  14741. */
  14742. pressed: boolean;
  14743. }
  14744. /**
  14745. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14746. * @hidden
  14747. */
  14748. export interface ExtendedGamepadButton extends GamepadButton {
  14749. /**
  14750. * If the button/trigger is currently pressed
  14751. */
  14752. readonly pressed: boolean;
  14753. /**
  14754. * If the button/trigger is currently touched
  14755. */
  14756. readonly touched: boolean;
  14757. /**
  14758. * Value of the button/trigger
  14759. */
  14760. readonly value: number;
  14761. }
  14762. /** @hidden */
  14763. export interface _GamePadFactory {
  14764. /**
  14765. * Returns wether or not the current gamepad can be created for this type of controller.
  14766. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14767. * @returns true if it can be created, otherwise false
  14768. */
  14769. canCreate(gamepadInfo: any): boolean;
  14770. /**
  14771. * Creates a new instance of the Gamepad.
  14772. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14773. * @returns the new gamepad instance
  14774. */
  14775. create(gamepadInfo: any): Gamepad;
  14776. }
  14777. /**
  14778. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14779. */
  14780. export class PoseEnabledControllerHelper {
  14781. /** @hidden */
  14782. static _ControllerFactories: _GamePadFactory[];
  14783. /** @hidden */
  14784. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14785. /**
  14786. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14787. * @param vrGamepad the gamepad to initialized
  14788. * @returns a vr controller of the type the gamepad identified as
  14789. */
  14790. static InitiateController(vrGamepad: any): Gamepad;
  14791. }
  14792. /**
  14793. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14794. */
  14795. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14796. /**
  14797. * If the controller is used in a webXR session
  14798. */
  14799. isXR: boolean;
  14800. private _deviceRoomPosition;
  14801. private _deviceRoomRotationQuaternion;
  14802. /**
  14803. * The device position in babylon space
  14804. */
  14805. devicePosition: Vector3;
  14806. /**
  14807. * The device rotation in babylon space
  14808. */
  14809. deviceRotationQuaternion: Quaternion;
  14810. /**
  14811. * The scale factor of the device in babylon space
  14812. */
  14813. deviceScaleFactor: number;
  14814. /**
  14815. * (Likely devicePosition should be used instead) The device position in its room space
  14816. */
  14817. position: Vector3;
  14818. /**
  14819. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14820. */
  14821. rotationQuaternion: Quaternion;
  14822. /**
  14823. * The type of controller (Eg. Windows mixed reality)
  14824. */
  14825. controllerType: PoseEnabledControllerType;
  14826. protected _calculatedPosition: Vector3;
  14827. private _calculatedRotation;
  14828. /**
  14829. * The raw pose from the device
  14830. */
  14831. rawPose: DevicePose;
  14832. private _trackPosition;
  14833. private _maxRotationDistFromHeadset;
  14834. private _draggedRoomRotation;
  14835. /**
  14836. * @hidden
  14837. */
  14838. _disableTrackPosition(fixedPosition: Vector3): void;
  14839. /**
  14840. * Internal, the mesh attached to the controller
  14841. * @hidden
  14842. */
  14843. _mesh: Nullable<AbstractMesh>;
  14844. private _poseControlledCamera;
  14845. private _leftHandSystemQuaternion;
  14846. /**
  14847. * Internal, matrix used to convert room space to babylon space
  14848. * @hidden
  14849. */
  14850. _deviceToWorld: Matrix;
  14851. /**
  14852. * Node to be used when casting a ray from the controller
  14853. * @hidden
  14854. */
  14855. _pointingPoseNode: Nullable<TransformNode>;
  14856. /**
  14857. * Name of the child mesh that can be used to cast a ray from the controller
  14858. */
  14859. static readonly POINTING_POSE: string;
  14860. /**
  14861. * Creates a new PoseEnabledController from a gamepad
  14862. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14863. */
  14864. constructor(browserGamepad: any);
  14865. private _workingMatrix;
  14866. /**
  14867. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14868. */
  14869. update(): void;
  14870. /**
  14871. * Updates only the pose device and mesh without doing any button event checking
  14872. */
  14873. protected _updatePoseAndMesh(): void;
  14874. /**
  14875. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14876. * @param poseData raw pose fromthe device
  14877. */
  14878. updateFromDevice(poseData: DevicePose): void;
  14879. /**
  14880. * @hidden
  14881. */
  14882. _meshAttachedObservable: Observable<AbstractMesh>;
  14883. /**
  14884. * Attaches a mesh to the controller
  14885. * @param mesh the mesh to be attached
  14886. */
  14887. attachToMesh(mesh: AbstractMesh): void;
  14888. /**
  14889. * Attaches the controllers mesh to a camera
  14890. * @param camera the camera the mesh should be attached to
  14891. */
  14892. attachToPoseControlledCamera(camera: TargetCamera): void;
  14893. /**
  14894. * Disposes of the controller
  14895. */
  14896. dispose(): void;
  14897. /**
  14898. * The mesh that is attached to the controller
  14899. */
  14900. readonly mesh: Nullable<AbstractMesh>;
  14901. /**
  14902. * Gets the ray of the controller in the direction the controller is pointing
  14903. * @param length the length the resulting ray should be
  14904. * @returns a ray in the direction the controller is pointing
  14905. */
  14906. getForwardRay(length?: number): Ray;
  14907. }
  14908. }
  14909. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14910. import { Observable } from "babylonjs/Misc/observable";
  14911. import { Scene } from "babylonjs/scene";
  14912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14913. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14914. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14915. import { Nullable } from "babylonjs/types";
  14916. /**
  14917. * Defines the WebVRController object that represents controllers tracked in 3D space
  14918. */
  14919. export abstract class WebVRController extends PoseEnabledController {
  14920. /**
  14921. * Internal, the default controller model for the controller
  14922. */
  14923. protected _defaultModel: Nullable<AbstractMesh>;
  14924. /**
  14925. * Fired when the trigger state has changed
  14926. */
  14927. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14928. /**
  14929. * Fired when the main button state has changed
  14930. */
  14931. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14932. /**
  14933. * Fired when the secondary button state has changed
  14934. */
  14935. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14936. /**
  14937. * Fired when the pad state has changed
  14938. */
  14939. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14940. /**
  14941. * Fired when controllers stick values have changed
  14942. */
  14943. onPadValuesChangedObservable: Observable<StickValues>;
  14944. /**
  14945. * Array of button availible on the controller
  14946. */
  14947. protected _buttons: Array<MutableGamepadButton>;
  14948. private _onButtonStateChange;
  14949. /**
  14950. * Fired when a controller button's state has changed
  14951. * @param callback the callback containing the button that was modified
  14952. */
  14953. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14954. /**
  14955. * X and Y axis corresponding to the controllers joystick
  14956. */
  14957. pad: StickValues;
  14958. /**
  14959. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14960. */
  14961. hand: string;
  14962. /**
  14963. * The default controller model for the controller
  14964. */
  14965. readonly defaultModel: Nullable<AbstractMesh>;
  14966. /**
  14967. * Creates a new WebVRController from a gamepad
  14968. * @param vrGamepad the gamepad that the WebVRController should be created from
  14969. */
  14970. constructor(vrGamepad: any);
  14971. /**
  14972. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14973. */
  14974. update(): void;
  14975. /**
  14976. * Function to be called when a button is modified
  14977. */
  14978. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14979. /**
  14980. * Loads a mesh and attaches it to the controller
  14981. * @param scene the scene the mesh should be added to
  14982. * @param meshLoaded callback for when the mesh has been loaded
  14983. */
  14984. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14985. private _setButtonValue;
  14986. private _changes;
  14987. private _checkChanges;
  14988. /**
  14989. * Disposes of th webVRCOntroller
  14990. */
  14991. dispose(): void;
  14992. }
  14993. }
  14994. declare module "babylonjs/Lights/hemisphericLight" {
  14995. import { Nullable } from "babylonjs/types";
  14996. import { Scene } from "babylonjs/scene";
  14997. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14998. import { Color3 } from "babylonjs/Maths/math.color";
  14999. import { Effect } from "babylonjs/Materials/effect";
  15000. import { Light } from "babylonjs/Lights/light";
  15001. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15002. /**
  15003. * The HemisphericLight simulates the ambient environment light,
  15004. * so the passed direction is the light reflection direction, not the incoming direction.
  15005. */
  15006. export class HemisphericLight extends Light {
  15007. /**
  15008. * The groundColor is the light in the opposite direction to the one specified during creation.
  15009. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  15010. */
  15011. groundColor: Color3;
  15012. /**
  15013. * The light reflection direction, not the incoming direction.
  15014. */
  15015. direction: Vector3;
  15016. /**
  15017. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15018. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15019. * The HemisphericLight can't cast shadows.
  15020. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15021. * @param name The friendly name of the light
  15022. * @param direction The direction of the light reflection
  15023. * @param scene The scene the light belongs to
  15024. */
  15025. constructor(name: string, direction: Vector3, scene: Scene);
  15026. protected _buildUniformLayout(): void;
  15027. /**
  15028. * Returns the string "HemisphericLight".
  15029. * @return The class name
  15030. */
  15031. getClassName(): string;
  15032. /**
  15033. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15034. * Returns the updated direction.
  15035. * @param target The target the direction should point to
  15036. * @return The computed direction
  15037. */
  15038. setDirectionToTarget(target: Vector3): Vector3;
  15039. /**
  15040. * Returns the shadow generator associated to the light.
  15041. * @returns Always null for hemispheric lights because it does not support shadows.
  15042. */
  15043. getShadowGenerator(): Nullable<IShadowGenerator>;
  15044. /**
  15045. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15046. * @param effect The effect to update
  15047. * @param lightIndex The index of the light in the effect to update
  15048. * @returns The hemispheric light
  15049. */
  15050. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15051. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15052. /**
  15053. * Computes the world matrix of the node
  15054. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15055. * @param useWasUpdatedFlag defines a reserved property
  15056. * @returns the world matrix
  15057. */
  15058. computeWorldMatrix(): Matrix;
  15059. /**
  15060. * Returns the integer 3.
  15061. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15062. */
  15063. getTypeID(): number;
  15064. /**
  15065. * Prepares the list of defines specific to the light type.
  15066. * @param defines the list of defines
  15067. * @param lightIndex defines the index of the light for the effect
  15068. */
  15069. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15070. }
  15071. }
  15072. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15073. /** @hidden */
  15074. export var vrMultiviewToSingleviewPixelShader: {
  15075. name: string;
  15076. shader: string;
  15077. };
  15078. }
  15079. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15081. import { Scene } from "babylonjs/scene";
  15082. /**
  15083. * Renders to multiple views with a single draw call
  15084. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15085. */
  15086. export class MultiviewRenderTarget extends RenderTargetTexture {
  15087. /**
  15088. * Creates a multiview render target
  15089. * @param scene scene used with the render target
  15090. * @param size the size of the render target (used for each view)
  15091. */
  15092. constructor(scene: Scene, size?: number | {
  15093. width: number;
  15094. height: number;
  15095. } | {
  15096. ratio: number;
  15097. });
  15098. /**
  15099. * @hidden
  15100. * @param faceIndex the face index, if its a cube texture
  15101. */
  15102. _bindFrameBuffer(faceIndex?: number): void;
  15103. /**
  15104. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15105. * @returns the view count
  15106. */
  15107. getViewCount(): number;
  15108. }
  15109. }
  15110. declare module "babylonjs/Maths/math.frustum" {
  15111. import { Matrix } from "babylonjs/Maths/math.vector";
  15112. import { DeepImmutable } from "babylonjs/types";
  15113. import { Plane } from "babylonjs/Maths/math.plane";
  15114. /**
  15115. * Represents a camera frustum
  15116. */
  15117. export class Frustum {
  15118. /**
  15119. * Gets the planes representing the frustum
  15120. * @param transform matrix to be applied to the returned planes
  15121. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15122. */
  15123. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15124. /**
  15125. * Gets the near frustum plane transformed by the transform matrix
  15126. * @param transform transformation matrix to be applied to the resulting frustum plane
  15127. * @param frustumPlane the resuling frustum plane
  15128. */
  15129. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15130. /**
  15131. * Gets the far frustum plane transformed by the transform matrix
  15132. * @param transform transformation matrix to be applied to the resulting frustum plane
  15133. * @param frustumPlane the resuling frustum plane
  15134. */
  15135. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15136. /**
  15137. * Gets the left frustum plane transformed by the transform matrix
  15138. * @param transform transformation matrix to be applied to the resulting frustum plane
  15139. * @param frustumPlane the resuling frustum plane
  15140. */
  15141. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15142. /**
  15143. * Gets the right frustum plane transformed by the transform matrix
  15144. * @param transform transformation matrix to be applied to the resulting frustum plane
  15145. * @param frustumPlane the resuling frustum plane
  15146. */
  15147. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15148. /**
  15149. * Gets the top frustum plane transformed by the transform matrix
  15150. * @param transform transformation matrix to be applied to the resulting frustum plane
  15151. * @param frustumPlane the resuling frustum plane
  15152. */
  15153. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15154. /**
  15155. * Gets the bottom frustum plane transformed by the transform matrix
  15156. * @param transform transformation matrix to be applied to the resulting frustum plane
  15157. * @param frustumPlane the resuling frustum plane
  15158. */
  15159. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15160. /**
  15161. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15162. * @param transform transformation matrix to be applied to the resulting frustum planes
  15163. * @param frustumPlanes the resuling frustum planes
  15164. */
  15165. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15166. }
  15167. }
  15168. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15169. import { Camera } from "babylonjs/Cameras/camera";
  15170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15171. import { Nullable } from "babylonjs/types";
  15172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15173. import { Matrix } from "babylonjs/Maths/math.vector";
  15174. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /**
  15178. * Creates a new multiview render target
  15179. * @param width defines the width of the texture
  15180. * @param height defines the height of the texture
  15181. * @returns the created multiview texture
  15182. */
  15183. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15184. /**
  15185. * Binds a multiview framebuffer to be drawn to
  15186. * @param multiviewTexture texture to bind
  15187. */
  15188. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15189. }
  15190. }
  15191. module "babylonjs/Cameras/camera" {
  15192. interface Camera {
  15193. /**
  15194. * @hidden
  15195. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15196. */
  15197. _useMultiviewToSingleView: boolean;
  15198. /**
  15199. * @hidden
  15200. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15201. */
  15202. _multiviewTexture: Nullable<RenderTargetTexture>;
  15203. /**
  15204. * @hidden
  15205. * ensures the multiview texture of the camera exists and has the specified width/height
  15206. * @param width height to set on the multiview texture
  15207. * @param height width to set on the multiview texture
  15208. */
  15209. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15210. }
  15211. }
  15212. module "babylonjs/scene" {
  15213. interface Scene {
  15214. /** @hidden */
  15215. _transformMatrixR: Matrix;
  15216. /** @hidden */
  15217. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15218. /** @hidden */
  15219. _createMultiviewUbo(): void;
  15220. /** @hidden */
  15221. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15222. /** @hidden */
  15223. _renderMultiviewToSingleView(camera: Camera): void;
  15224. }
  15225. }
  15226. }
  15227. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15228. import { Camera } from "babylonjs/Cameras/camera";
  15229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15230. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15231. import "babylonjs/Engines/Extensions/engine.multiview";
  15232. /**
  15233. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15234. * This will not be used for webXR as it supports displaying texture arrays directly
  15235. */
  15236. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15237. /**
  15238. * Initializes a VRMultiviewToSingleview
  15239. * @param name name of the post process
  15240. * @param camera camera to be applied to
  15241. * @param scaleFactor scaling factor to the size of the output texture
  15242. */
  15243. constructor(name: string, camera: Camera, scaleFactor: number);
  15244. }
  15245. }
  15246. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15247. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15248. import { Nullable } from "babylonjs/types";
  15249. import { Size } from "babylonjs/Maths/math.size";
  15250. import { Observable } from "babylonjs/Misc/observable";
  15251. /**
  15252. * Interface used to define additional presentation attributes
  15253. */
  15254. export interface IVRPresentationAttributes {
  15255. /**
  15256. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15257. */
  15258. highRefreshRate: boolean;
  15259. /**
  15260. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15261. */
  15262. foveationLevel: number;
  15263. }
  15264. module "babylonjs/Engines/engine" {
  15265. interface Engine {
  15266. /** @hidden */
  15267. _vrDisplay: any;
  15268. /** @hidden */
  15269. _vrSupported: boolean;
  15270. /** @hidden */
  15271. _oldSize: Size;
  15272. /** @hidden */
  15273. _oldHardwareScaleFactor: number;
  15274. /** @hidden */
  15275. _vrExclusivePointerMode: boolean;
  15276. /** @hidden */
  15277. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15278. /** @hidden */
  15279. _onVRDisplayPointerRestricted: () => void;
  15280. /** @hidden */
  15281. _onVRDisplayPointerUnrestricted: () => void;
  15282. /** @hidden */
  15283. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15284. /** @hidden */
  15285. _onVrDisplayDisconnect: Nullable<() => void>;
  15286. /** @hidden */
  15287. _onVrDisplayPresentChange: Nullable<() => void>;
  15288. /**
  15289. * Observable signaled when VR display mode changes
  15290. */
  15291. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15292. /**
  15293. * Observable signaled when VR request present is complete
  15294. */
  15295. onVRRequestPresentComplete: Observable<boolean>;
  15296. /**
  15297. * Observable signaled when VR request present starts
  15298. */
  15299. onVRRequestPresentStart: Observable<Engine>;
  15300. /**
  15301. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15302. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15303. */
  15304. isInVRExclusivePointerMode: boolean;
  15305. /**
  15306. * Gets a boolean indicating if a webVR device was detected
  15307. * @returns true if a webVR device was detected
  15308. */
  15309. isVRDevicePresent(): boolean;
  15310. /**
  15311. * Gets the current webVR device
  15312. * @returns the current webVR device (or null)
  15313. */
  15314. getVRDevice(): any;
  15315. /**
  15316. * Initializes a webVR display and starts listening to display change events
  15317. * The onVRDisplayChangedObservable will be notified upon these changes
  15318. * @returns A promise containing a VRDisplay and if vr is supported
  15319. */
  15320. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15321. /** @hidden */
  15322. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15323. /**
  15324. * Gets or sets the presentation attributes used to configure VR rendering
  15325. */
  15326. vrPresentationAttributes?: IVRPresentationAttributes;
  15327. /**
  15328. * Call this function to switch to webVR mode
  15329. * Will do nothing if webVR is not supported or if there is no webVR device
  15330. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15331. */
  15332. enableVR(): void;
  15333. /** @hidden */
  15334. _onVRFullScreenTriggered(): void;
  15335. }
  15336. }
  15337. }
  15338. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15339. import { Nullable } from "babylonjs/types";
  15340. import { Observable } from "babylonjs/Misc/observable";
  15341. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15342. import { Scene } from "babylonjs/scene";
  15343. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15344. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15345. import { Node } from "babylonjs/node";
  15346. import { Ray } from "babylonjs/Culling/ray";
  15347. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15348. import "babylonjs/Engines/Extensions/engine.webVR";
  15349. /**
  15350. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15351. * IMPORTANT!! The data is right-hand data.
  15352. * @export
  15353. * @interface DevicePose
  15354. */
  15355. export interface DevicePose {
  15356. /**
  15357. * The position of the device, values in array are [x,y,z].
  15358. */
  15359. readonly position: Nullable<Float32Array>;
  15360. /**
  15361. * The linearVelocity of the device, values in array are [x,y,z].
  15362. */
  15363. readonly linearVelocity: Nullable<Float32Array>;
  15364. /**
  15365. * The linearAcceleration of the device, values in array are [x,y,z].
  15366. */
  15367. readonly linearAcceleration: Nullable<Float32Array>;
  15368. /**
  15369. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15370. */
  15371. readonly orientation: Nullable<Float32Array>;
  15372. /**
  15373. * The angularVelocity of the device, values in array are [x,y,z].
  15374. */
  15375. readonly angularVelocity: Nullable<Float32Array>;
  15376. /**
  15377. * The angularAcceleration of the device, values in array are [x,y,z].
  15378. */
  15379. readonly angularAcceleration: Nullable<Float32Array>;
  15380. }
  15381. /**
  15382. * Interface representing a pose controlled object in Babylon.
  15383. * A pose controlled object has both regular pose values as well as pose values
  15384. * from an external device such as a VR head mounted display
  15385. */
  15386. export interface PoseControlled {
  15387. /**
  15388. * The position of the object in babylon space.
  15389. */
  15390. position: Vector3;
  15391. /**
  15392. * The rotation quaternion of the object in babylon space.
  15393. */
  15394. rotationQuaternion: Quaternion;
  15395. /**
  15396. * The position of the device in babylon space.
  15397. */
  15398. devicePosition?: Vector3;
  15399. /**
  15400. * The rotation quaternion of the device in babylon space.
  15401. */
  15402. deviceRotationQuaternion: Quaternion;
  15403. /**
  15404. * The raw pose coming from the device.
  15405. */
  15406. rawPose: Nullable<DevicePose>;
  15407. /**
  15408. * The scale of the device to be used when translating from device space to babylon space.
  15409. */
  15410. deviceScaleFactor: number;
  15411. /**
  15412. * Updates the poseControlled values based on the input device pose.
  15413. * @param poseData the pose data to update the object with
  15414. */
  15415. updateFromDevice(poseData: DevicePose): void;
  15416. }
  15417. /**
  15418. * Set of options to customize the webVRCamera
  15419. */
  15420. export interface WebVROptions {
  15421. /**
  15422. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15423. */
  15424. trackPosition?: boolean;
  15425. /**
  15426. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15427. */
  15428. positionScale?: number;
  15429. /**
  15430. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15431. */
  15432. displayName?: string;
  15433. /**
  15434. * Should the native controller meshes be initialized. (default: true)
  15435. */
  15436. controllerMeshes?: boolean;
  15437. /**
  15438. * Creating a default HemiLight only on controllers. (default: true)
  15439. */
  15440. defaultLightingOnControllers?: boolean;
  15441. /**
  15442. * If you don't want to use the default VR button of the helper. (default: false)
  15443. */
  15444. useCustomVRButton?: boolean;
  15445. /**
  15446. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15447. */
  15448. customVRButton?: HTMLButtonElement;
  15449. /**
  15450. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15451. */
  15452. rayLength?: number;
  15453. /**
  15454. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15455. */
  15456. defaultHeight?: number;
  15457. /**
  15458. * If multiview should be used if availible (default: false)
  15459. */
  15460. useMultiview?: boolean;
  15461. }
  15462. /**
  15463. * This represents a WebVR camera.
  15464. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15465. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15466. */
  15467. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15468. private webVROptions;
  15469. /**
  15470. * @hidden
  15471. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15472. */
  15473. _vrDevice: any;
  15474. /**
  15475. * The rawPose of the vrDevice.
  15476. */
  15477. rawPose: Nullable<DevicePose>;
  15478. private _onVREnabled;
  15479. private _specsVersion;
  15480. private _attached;
  15481. private _frameData;
  15482. protected _descendants: Array<Node>;
  15483. private _deviceRoomPosition;
  15484. /** @hidden */
  15485. _deviceRoomRotationQuaternion: Quaternion;
  15486. private _standingMatrix;
  15487. /**
  15488. * Represents device position in babylon space.
  15489. */
  15490. devicePosition: Vector3;
  15491. /**
  15492. * Represents device rotation in babylon space.
  15493. */
  15494. deviceRotationQuaternion: Quaternion;
  15495. /**
  15496. * The scale of the device to be used when translating from device space to babylon space.
  15497. */
  15498. deviceScaleFactor: number;
  15499. private _deviceToWorld;
  15500. private _worldToDevice;
  15501. /**
  15502. * References to the webVR controllers for the vrDevice.
  15503. */
  15504. controllers: Array<WebVRController>;
  15505. /**
  15506. * Emits an event when a controller is attached.
  15507. */
  15508. onControllersAttachedObservable: Observable<WebVRController[]>;
  15509. /**
  15510. * Emits an event when a controller's mesh has been loaded;
  15511. */
  15512. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15513. /**
  15514. * Emits an event when the HMD's pose has been updated.
  15515. */
  15516. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15517. private _poseSet;
  15518. /**
  15519. * If the rig cameras be used as parent instead of this camera.
  15520. */
  15521. rigParenting: boolean;
  15522. private _lightOnControllers;
  15523. private _defaultHeight?;
  15524. /**
  15525. * Instantiates a WebVRFreeCamera.
  15526. * @param name The name of the WebVRFreeCamera
  15527. * @param position The starting anchor position for the camera
  15528. * @param scene The scene the camera belongs to
  15529. * @param webVROptions a set of customizable options for the webVRCamera
  15530. */
  15531. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15532. /**
  15533. * Gets the device distance from the ground in meters.
  15534. * @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.
  15535. */
  15536. deviceDistanceToRoomGround(): number;
  15537. /**
  15538. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15539. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15540. */
  15541. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15542. /**
  15543. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15544. * @returns A promise with a boolean set to if the standing matrix is supported.
  15545. */
  15546. useStandingMatrixAsync(): Promise<boolean>;
  15547. /**
  15548. * Disposes the camera
  15549. */
  15550. dispose(): void;
  15551. /**
  15552. * Gets a vrController by name.
  15553. * @param name The name of the controller to retreive
  15554. * @returns the controller matching the name specified or null if not found
  15555. */
  15556. getControllerByName(name: string): Nullable<WebVRController>;
  15557. private _leftController;
  15558. /**
  15559. * The controller corresponding to the users left hand.
  15560. */
  15561. readonly leftController: Nullable<WebVRController>;
  15562. private _rightController;
  15563. /**
  15564. * The controller corresponding to the users right hand.
  15565. */
  15566. readonly rightController: Nullable<WebVRController>;
  15567. /**
  15568. * Casts a ray forward from the vrCamera's gaze.
  15569. * @param length Length of the ray (default: 100)
  15570. * @returns the ray corresponding to the gaze
  15571. */
  15572. getForwardRay(length?: number): Ray;
  15573. /**
  15574. * @hidden
  15575. * Updates the camera based on device's frame data
  15576. */
  15577. _checkInputs(): void;
  15578. /**
  15579. * Updates the poseControlled values based on the input device pose.
  15580. * @param poseData Pose coming from the device
  15581. */
  15582. updateFromDevice(poseData: DevicePose): void;
  15583. private _htmlElementAttached;
  15584. private _detachIfAttached;
  15585. /**
  15586. * WebVR's attach control will start broadcasting frames to the device.
  15587. * Note that in certain browsers (chrome for example) this function must be called
  15588. * within a user-interaction callback. Example:
  15589. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15590. *
  15591. * @param element html element to attach the vrDevice to
  15592. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15593. */
  15594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15595. /**
  15596. * Detaches the camera from the html element and disables VR
  15597. *
  15598. * @param element html element to detach from
  15599. */
  15600. detachControl(element: HTMLElement): void;
  15601. /**
  15602. * @returns the name of this class
  15603. */
  15604. getClassName(): string;
  15605. /**
  15606. * Calls resetPose on the vrDisplay
  15607. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15608. */
  15609. resetToCurrentRotation(): void;
  15610. /**
  15611. * @hidden
  15612. * Updates the rig cameras (left and right eye)
  15613. */
  15614. _updateRigCameras(): void;
  15615. private _workingVector;
  15616. private _oneVector;
  15617. private _workingMatrix;
  15618. private updateCacheCalled;
  15619. private _correctPositionIfNotTrackPosition;
  15620. /**
  15621. * @hidden
  15622. * Updates the cached values of the camera
  15623. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15624. */
  15625. _updateCache(ignoreParentClass?: boolean): void;
  15626. /**
  15627. * @hidden
  15628. * Get current device position in babylon world
  15629. */
  15630. _computeDevicePosition(): void;
  15631. /**
  15632. * Updates the current device position and rotation in the babylon world
  15633. */
  15634. update(): void;
  15635. /**
  15636. * @hidden
  15637. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15638. * @returns an identity matrix
  15639. */
  15640. _getViewMatrix(): Matrix;
  15641. private _tmpMatrix;
  15642. /**
  15643. * This function is called by the two RIG cameras.
  15644. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15645. * @hidden
  15646. */
  15647. _getWebVRViewMatrix(): Matrix;
  15648. /** @hidden */
  15649. _getWebVRProjectionMatrix(): Matrix;
  15650. private _onGamepadConnectedObserver;
  15651. private _onGamepadDisconnectedObserver;
  15652. private _updateCacheWhenTrackingDisabledObserver;
  15653. /**
  15654. * Initializes the controllers and their meshes
  15655. */
  15656. initControllers(): void;
  15657. }
  15658. }
  15659. declare module "babylonjs/PostProcesses/postProcess" {
  15660. import { Nullable } from "babylonjs/types";
  15661. import { SmartArray } from "babylonjs/Misc/smartArray";
  15662. import { Observable } from "babylonjs/Misc/observable";
  15663. import { Vector2 } from "babylonjs/Maths/math.vector";
  15664. import { Camera } from "babylonjs/Cameras/camera";
  15665. import { Effect } from "babylonjs/Materials/effect";
  15666. import "babylonjs/Shaders/postprocess.vertex";
  15667. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15668. import { Engine } from "babylonjs/Engines/engine";
  15669. import { Color4 } from "babylonjs/Maths/math.color";
  15670. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15671. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15672. /**
  15673. * Size options for a post process
  15674. */
  15675. export type PostProcessOptions = {
  15676. width: number;
  15677. height: number;
  15678. };
  15679. /**
  15680. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15681. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15682. */
  15683. export class PostProcess {
  15684. /** Name of the PostProcess. */
  15685. name: string;
  15686. /**
  15687. * Gets or sets the unique id of the post process
  15688. */
  15689. uniqueId: number;
  15690. /**
  15691. * Width of the texture to apply the post process on
  15692. */
  15693. width: number;
  15694. /**
  15695. * Height of the texture to apply the post process on
  15696. */
  15697. height: number;
  15698. /**
  15699. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15700. * @hidden
  15701. */
  15702. _outputTexture: Nullable<InternalTexture>;
  15703. /**
  15704. * Sampling mode used by the shader
  15705. * See https://doc.babylonjs.com/classes/3.1/texture
  15706. */
  15707. renderTargetSamplingMode: number;
  15708. /**
  15709. * Clear color to use when screen clearing
  15710. */
  15711. clearColor: Color4;
  15712. /**
  15713. * If the buffer needs to be cleared before applying the post process. (default: true)
  15714. * Should be set to false if shader will overwrite all previous pixels.
  15715. */
  15716. autoClear: boolean;
  15717. /**
  15718. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15719. */
  15720. alphaMode: number;
  15721. /**
  15722. * Sets the setAlphaBlendConstants of the babylon engine
  15723. */
  15724. alphaConstants: Color4;
  15725. /**
  15726. * Animations to be used for the post processing
  15727. */
  15728. animations: import("babylonjs/Animations/animation").Animation[];
  15729. /**
  15730. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15731. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15732. */
  15733. enablePixelPerfectMode: boolean;
  15734. /**
  15735. * Force the postprocess to be applied without taking in account viewport
  15736. */
  15737. forceFullscreenViewport: boolean;
  15738. /**
  15739. * List of inspectable custom properties (used by the Inspector)
  15740. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15741. */
  15742. inspectableCustomProperties: IInspectable[];
  15743. /**
  15744. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15745. *
  15746. * | Value | Type | Description |
  15747. * | ----- | ----------------------------------- | ----------- |
  15748. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15749. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15750. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15751. *
  15752. */
  15753. scaleMode: number;
  15754. /**
  15755. * Force textures to be a power of two (default: false)
  15756. */
  15757. alwaysForcePOT: boolean;
  15758. private _samples;
  15759. /**
  15760. * Number of sample textures (default: 1)
  15761. */
  15762. samples: number;
  15763. /**
  15764. * Modify the scale of the post process to be the same as the viewport (default: false)
  15765. */
  15766. adaptScaleToCurrentViewport: boolean;
  15767. private _camera;
  15768. private _scene;
  15769. private _engine;
  15770. private _options;
  15771. private _reusable;
  15772. private _textureType;
  15773. /**
  15774. * Smart array of input and output textures for the post process.
  15775. * @hidden
  15776. */
  15777. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15778. /**
  15779. * The index in _textures that corresponds to the output texture.
  15780. * @hidden
  15781. */
  15782. _currentRenderTextureInd: number;
  15783. private _effect;
  15784. private _samplers;
  15785. private _fragmentUrl;
  15786. private _vertexUrl;
  15787. private _parameters;
  15788. private _scaleRatio;
  15789. protected _indexParameters: any;
  15790. private _shareOutputWithPostProcess;
  15791. private _texelSize;
  15792. private _forcedOutputTexture;
  15793. /**
  15794. * Returns the fragment url or shader name used in the post process.
  15795. * @returns the fragment url or name in the shader store.
  15796. */
  15797. getEffectName(): string;
  15798. /**
  15799. * An event triggered when the postprocess is activated.
  15800. */
  15801. onActivateObservable: Observable<Camera>;
  15802. private _onActivateObserver;
  15803. /**
  15804. * A function that is added to the onActivateObservable
  15805. */
  15806. onActivate: Nullable<(camera: Camera) => void>;
  15807. /**
  15808. * An event triggered when the postprocess changes its size.
  15809. */
  15810. onSizeChangedObservable: Observable<PostProcess>;
  15811. private _onSizeChangedObserver;
  15812. /**
  15813. * A function that is added to the onSizeChangedObservable
  15814. */
  15815. onSizeChanged: (postProcess: PostProcess) => void;
  15816. /**
  15817. * An event triggered when the postprocess applies its effect.
  15818. */
  15819. onApplyObservable: Observable<Effect>;
  15820. private _onApplyObserver;
  15821. /**
  15822. * A function that is added to the onApplyObservable
  15823. */
  15824. onApply: (effect: Effect) => void;
  15825. /**
  15826. * An event triggered before rendering the postprocess
  15827. */
  15828. onBeforeRenderObservable: Observable<Effect>;
  15829. private _onBeforeRenderObserver;
  15830. /**
  15831. * A function that is added to the onBeforeRenderObservable
  15832. */
  15833. onBeforeRender: (effect: Effect) => void;
  15834. /**
  15835. * An event triggered after rendering the postprocess
  15836. */
  15837. onAfterRenderObservable: Observable<Effect>;
  15838. private _onAfterRenderObserver;
  15839. /**
  15840. * A function that is added to the onAfterRenderObservable
  15841. */
  15842. onAfterRender: (efect: Effect) => void;
  15843. /**
  15844. * 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
  15845. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15846. */
  15847. inputTexture: InternalTexture;
  15848. /**
  15849. * Gets the camera which post process is applied to.
  15850. * @returns The camera the post process is applied to.
  15851. */
  15852. getCamera(): Camera;
  15853. /**
  15854. * Gets the texel size of the postprocess.
  15855. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15856. */
  15857. readonly texelSize: Vector2;
  15858. /**
  15859. * Creates a new instance PostProcess
  15860. * @param name The name of the PostProcess.
  15861. * @param fragmentUrl The url of the fragment shader to be used.
  15862. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15863. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15864. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15865. * @param camera The camera to apply the render pass to.
  15866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15867. * @param engine The engine which the post process will be applied. (default: current engine)
  15868. * @param reusable If the post process can be reused on the same frame. (default: false)
  15869. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15870. * @param textureType Type of textures used when performing the post process. (default: 0)
  15871. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15872. * @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
  15873. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15874. */
  15875. constructor(
  15876. /** Name of the PostProcess. */
  15877. 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);
  15878. /**
  15879. * Gets a string idenfifying the name of the class
  15880. * @returns "PostProcess" string
  15881. */
  15882. getClassName(): string;
  15883. /**
  15884. * Gets the engine which this post process belongs to.
  15885. * @returns The engine the post process was enabled with.
  15886. */
  15887. getEngine(): Engine;
  15888. /**
  15889. * The effect that is created when initializing the post process.
  15890. * @returns The created effect corresponding the the postprocess.
  15891. */
  15892. getEffect(): Effect;
  15893. /**
  15894. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15895. * @param postProcess The post process to share the output with.
  15896. * @returns This post process.
  15897. */
  15898. shareOutputWith(postProcess: PostProcess): PostProcess;
  15899. /**
  15900. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15901. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15902. */
  15903. useOwnOutput(): void;
  15904. /**
  15905. * Updates the effect with the current post process compile time values and recompiles the shader.
  15906. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15907. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15908. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15909. * @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
  15910. * @param onCompiled Called when the shader has been compiled.
  15911. * @param onError Called if there is an error when compiling a shader.
  15912. */
  15913. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15914. /**
  15915. * The post process is reusable if it can be used multiple times within one frame.
  15916. * @returns If the post process is reusable
  15917. */
  15918. isReusable(): boolean;
  15919. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15920. markTextureDirty(): void;
  15921. /**
  15922. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15923. * 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.
  15924. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15925. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15926. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15927. * @returns The target texture that was bound to be written to.
  15928. */
  15929. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15930. /**
  15931. * If the post process is supported.
  15932. */
  15933. readonly isSupported: boolean;
  15934. /**
  15935. * The aspect ratio of the output texture.
  15936. */
  15937. readonly aspectRatio: number;
  15938. /**
  15939. * Get a value indicating if the post-process is ready to be used
  15940. * @returns true if the post-process is ready (shader is compiled)
  15941. */
  15942. isReady(): boolean;
  15943. /**
  15944. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15945. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15946. */
  15947. apply(): Nullable<Effect>;
  15948. private _disposeTextures;
  15949. /**
  15950. * Disposes the post process.
  15951. * @param camera The camera to dispose the post process on.
  15952. */
  15953. dispose(camera?: Camera): void;
  15954. }
  15955. }
  15956. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15957. /** @hidden */
  15958. export var kernelBlurVaryingDeclaration: {
  15959. name: string;
  15960. shader: string;
  15961. };
  15962. }
  15963. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15964. /** @hidden */
  15965. export var kernelBlurFragment: {
  15966. name: string;
  15967. shader: string;
  15968. };
  15969. }
  15970. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15971. /** @hidden */
  15972. export var kernelBlurFragment2: {
  15973. name: string;
  15974. shader: string;
  15975. };
  15976. }
  15977. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15978. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15979. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15980. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15981. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15982. /** @hidden */
  15983. export var kernelBlurPixelShader: {
  15984. name: string;
  15985. shader: string;
  15986. };
  15987. }
  15988. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15989. /** @hidden */
  15990. export var kernelBlurVertex: {
  15991. name: string;
  15992. shader: string;
  15993. };
  15994. }
  15995. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15996. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15997. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15998. /** @hidden */
  15999. export var kernelBlurVertexShader: {
  16000. name: string;
  16001. shader: string;
  16002. };
  16003. }
  16004. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16005. import { Vector2 } from "babylonjs/Maths/math.vector";
  16006. import { Nullable } from "babylonjs/types";
  16007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16008. import { Camera } from "babylonjs/Cameras/camera";
  16009. import { Effect } from "babylonjs/Materials/effect";
  16010. import { Engine } from "babylonjs/Engines/engine";
  16011. import "babylonjs/Shaders/kernelBlur.fragment";
  16012. import "babylonjs/Shaders/kernelBlur.vertex";
  16013. /**
  16014. * The Blur Post Process which blurs an image based on a kernel and direction.
  16015. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16016. */
  16017. export class BlurPostProcess extends PostProcess {
  16018. /** The direction in which to blur the image. */
  16019. direction: Vector2;
  16020. private blockCompilation;
  16021. protected _kernel: number;
  16022. protected _idealKernel: number;
  16023. protected _packedFloat: boolean;
  16024. private _staticDefines;
  16025. /**
  16026. * Sets the length in pixels of the blur sample region
  16027. */
  16028. /**
  16029. * Gets the length in pixels of the blur sample region
  16030. */
  16031. kernel: number;
  16032. /**
  16033. * Sets wether or not the blur needs to unpack/repack floats
  16034. */
  16035. /**
  16036. * Gets wether or not the blur is unpacking/repacking floats
  16037. */
  16038. packedFloat: boolean;
  16039. /**
  16040. * Creates a new instance BlurPostProcess
  16041. * @param name The name of the effect.
  16042. * @param direction The direction in which to blur the image.
  16043. * @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.
  16044. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16045. * @param camera The camera to apply the render pass to.
  16046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16047. * @param engine The engine which the post process will be applied. (default: current engine)
  16048. * @param reusable If the post process can be reused on the same frame. (default: false)
  16049. * @param textureType Type of textures used when performing the post process. (default: 0)
  16050. * @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)
  16051. */
  16052. constructor(name: string,
  16053. /** The direction in which to blur the image. */
  16054. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16055. /**
  16056. * Updates the effect with the current post process compile time values and recompiles the shader.
  16057. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16058. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16059. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16060. * @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
  16061. * @param onCompiled Called when the shader has been compiled.
  16062. * @param onError Called if there is an error when compiling a shader.
  16063. */
  16064. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16065. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16066. /**
  16067. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16068. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16069. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16070. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16071. * The gaps between physical kernels are compensated for in the weighting of the samples
  16072. * @param idealKernel Ideal blur kernel.
  16073. * @return Nearest best kernel.
  16074. */
  16075. protected _nearestBestKernel(idealKernel: number): number;
  16076. /**
  16077. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16078. * @param x The point on the Gaussian distribution to sample.
  16079. * @return the value of the Gaussian function at x.
  16080. */
  16081. protected _gaussianWeight(x: number): number;
  16082. /**
  16083. * Generates a string that can be used as a floating point number in GLSL.
  16084. * @param x Value to print.
  16085. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16086. * @return GLSL float string.
  16087. */
  16088. protected _glslFloat(x: number, decimalFigures?: number): string;
  16089. }
  16090. }
  16091. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16092. import { Scene } from "babylonjs/scene";
  16093. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16094. import { Plane } from "babylonjs/Maths/math.plane";
  16095. /**
  16096. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16097. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16098. * You can then easily use it as a reflectionTexture on a flat surface.
  16099. * In case the surface is not a plane, please consider relying on reflection probes.
  16100. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16101. */
  16102. export class MirrorTexture extends RenderTargetTexture {
  16103. private scene;
  16104. /**
  16105. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16106. * 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.
  16107. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16108. */
  16109. mirrorPlane: Plane;
  16110. /**
  16111. * Define the blur ratio used to blur the reflection if needed.
  16112. */
  16113. blurRatio: number;
  16114. /**
  16115. * Define the adaptive blur kernel used to blur the reflection if needed.
  16116. * This will autocompute the closest best match for the `blurKernel`
  16117. */
  16118. adaptiveBlurKernel: number;
  16119. /**
  16120. * Define the blur kernel used to blur the reflection if needed.
  16121. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16122. */
  16123. blurKernel: number;
  16124. /**
  16125. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16126. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16127. */
  16128. blurKernelX: number;
  16129. /**
  16130. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16131. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16132. */
  16133. blurKernelY: number;
  16134. private _autoComputeBlurKernel;
  16135. protected _onRatioRescale(): void;
  16136. private _updateGammaSpace;
  16137. private _imageProcessingConfigChangeObserver;
  16138. private _transformMatrix;
  16139. private _mirrorMatrix;
  16140. private _savedViewMatrix;
  16141. private _blurX;
  16142. private _blurY;
  16143. private _adaptiveBlurKernel;
  16144. private _blurKernelX;
  16145. private _blurKernelY;
  16146. private _blurRatio;
  16147. /**
  16148. * Instantiates a Mirror Texture.
  16149. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16150. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16151. * You can then easily use it as a reflectionTexture on a flat surface.
  16152. * In case the surface is not a plane, please consider relying on reflection probes.
  16153. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16154. * @param name
  16155. * @param size
  16156. * @param scene
  16157. * @param generateMipMaps
  16158. * @param type
  16159. * @param samplingMode
  16160. * @param generateDepthBuffer
  16161. */
  16162. constructor(name: string, size: number | {
  16163. width: number;
  16164. height: number;
  16165. } | {
  16166. ratio: number;
  16167. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16168. private _preparePostProcesses;
  16169. /**
  16170. * Clone the mirror texture.
  16171. * @returns the cloned texture
  16172. */
  16173. clone(): MirrorTexture;
  16174. /**
  16175. * Serialize the texture to a JSON representation you could use in Parse later on
  16176. * @returns the serialized JSON representation
  16177. */
  16178. serialize(): any;
  16179. /**
  16180. * Dispose the texture and release its associated resources.
  16181. */
  16182. dispose(): void;
  16183. }
  16184. }
  16185. declare module "babylonjs/Materials/Textures/texture" {
  16186. import { Observable } from "babylonjs/Misc/observable";
  16187. import { Nullable } from "babylonjs/types";
  16188. import { Matrix } from "babylonjs/Maths/math.vector";
  16189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16190. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16191. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16192. import { Scene } from "babylonjs/scene";
  16193. /**
  16194. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16195. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16196. */
  16197. export class Texture extends BaseTexture {
  16198. /**
  16199. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16200. */
  16201. static SerializeBuffers: boolean;
  16202. /** @hidden */
  16203. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16204. /** @hidden */
  16205. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16206. /** @hidden */
  16207. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16208. /** nearest is mag = nearest and min = nearest and mip = linear */
  16209. static readonly NEAREST_SAMPLINGMODE: number;
  16210. /** nearest is mag = nearest and min = nearest and mip = linear */
  16211. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16212. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16213. static readonly BILINEAR_SAMPLINGMODE: number;
  16214. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16215. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16216. /** Trilinear is mag = linear and min = linear and mip = linear */
  16217. static readonly TRILINEAR_SAMPLINGMODE: number;
  16218. /** Trilinear is mag = linear and min = linear and mip = linear */
  16219. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16220. /** mag = nearest and min = nearest and mip = nearest */
  16221. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16222. /** mag = nearest and min = linear and mip = nearest */
  16223. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16224. /** mag = nearest and min = linear and mip = linear */
  16225. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16226. /** mag = nearest and min = linear and mip = none */
  16227. static readonly NEAREST_LINEAR: number;
  16228. /** mag = nearest and min = nearest and mip = none */
  16229. static readonly NEAREST_NEAREST: number;
  16230. /** mag = linear and min = nearest and mip = nearest */
  16231. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16232. /** mag = linear and min = nearest and mip = linear */
  16233. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16234. /** mag = linear and min = linear and mip = none */
  16235. static readonly LINEAR_LINEAR: number;
  16236. /** mag = linear and min = nearest and mip = none */
  16237. static readonly LINEAR_NEAREST: number;
  16238. /** Explicit coordinates mode */
  16239. static readonly EXPLICIT_MODE: number;
  16240. /** Spherical coordinates mode */
  16241. static readonly SPHERICAL_MODE: number;
  16242. /** Planar coordinates mode */
  16243. static readonly PLANAR_MODE: number;
  16244. /** Cubic coordinates mode */
  16245. static readonly CUBIC_MODE: number;
  16246. /** Projection coordinates mode */
  16247. static readonly PROJECTION_MODE: number;
  16248. /** Inverse Cubic coordinates mode */
  16249. static readonly SKYBOX_MODE: number;
  16250. /** Inverse Cubic coordinates mode */
  16251. static readonly INVCUBIC_MODE: number;
  16252. /** Equirectangular coordinates mode */
  16253. static readonly EQUIRECTANGULAR_MODE: number;
  16254. /** Equirectangular Fixed coordinates mode */
  16255. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16256. /** Equirectangular Fixed Mirrored coordinates mode */
  16257. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16258. /** Texture is not repeating outside of 0..1 UVs */
  16259. static readonly CLAMP_ADDRESSMODE: number;
  16260. /** Texture is repeating outside of 0..1 UVs */
  16261. static readonly WRAP_ADDRESSMODE: number;
  16262. /** Texture is repeating and mirrored */
  16263. static readonly MIRROR_ADDRESSMODE: number;
  16264. /**
  16265. * 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
  16266. */
  16267. static UseSerializedUrlIfAny: boolean;
  16268. /**
  16269. * Define the url of the texture.
  16270. */
  16271. url: Nullable<string>;
  16272. /**
  16273. * Define an offset on the texture to offset the u coordinates of the UVs
  16274. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16275. */
  16276. uOffset: number;
  16277. /**
  16278. * Define an offset on the texture to offset the v coordinates of the UVs
  16279. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16280. */
  16281. vOffset: number;
  16282. /**
  16283. * Define an offset on the texture to scale the u coordinates of the UVs
  16284. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16285. */
  16286. uScale: number;
  16287. /**
  16288. * Define an offset on the texture to scale the v coordinates of the UVs
  16289. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16290. */
  16291. vScale: number;
  16292. /**
  16293. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16294. * @see http://doc.babylonjs.com/how_to/more_materials
  16295. */
  16296. uAng: number;
  16297. /**
  16298. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16299. * @see http://doc.babylonjs.com/how_to/more_materials
  16300. */
  16301. vAng: number;
  16302. /**
  16303. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16304. * @see http://doc.babylonjs.com/how_to/more_materials
  16305. */
  16306. wAng: number;
  16307. /**
  16308. * Defines the center of rotation (U)
  16309. */
  16310. uRotationCenter: number;
  16311. /**
  16312. * Defines the center of rotation (V)
  16313. */
  16314. vRotationCenter: number;
  16315. /**
  16316. * Defines the center of rotation (W)
  16317. */
  16318. wRotationCenter: number;
  16319. /**
  16320. * Are mip maps generated for this texture or not.
  16321. */
  16322. readonly noMipmap: boolean;
  16323. /**
  16324. * List of inspectable custom properties (used by the Inspector)
  16325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16326. */
  16327. inspectableCustomProperties: Nullable<IInspectable[]>;
  16328. private _noMipmap;
  16329. /** @hidden */
  16330. _invertY: boolean;
  16331. private _rowGenerationMatrix;
  16332. private _cachedTextureMatrix;
  16333. private _projectionModeMatrix;
  16334. private _t0;
  16335. private _t1;
  16336. private _t2;
  16337. private _cachedUOffset;
  16338. private _cachedVOffset;
  16339. private _cachedUScale;
  16340. private _cachedVScale;
  16341. private _cachedUAng;
  16342. private _cachedVAng;
  16343. private _cachedWAng;
  16344. private _cachedProjectionMatrixId;
  16345. private _cachedCoordinatesMode;
  16346. /** @hidden */
  16347. protected _initialSamplingMode: number;
  16348. /** @hidden */
  16349. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16350. private _deleteBuffer;
  16351. protected _format: Nullable<number>;
  16352. private _delayedOnLoad;
  16353. private _delayedOnError;
  16354. private _mimeType?;
  16355. /**
  16356. * Observable triggered once the texture has been loaded.
  16357. */
  16358. onLoadObservable: Observable<Texture>;
  16359. protected _isBlocking: boolean;
  16360. /**
  16361. * Is the texture preventing material to render while loading.
  16362. * If false, a default texture will be used instead of the loading one during the preparation step.
  16363. */
  16364. isBlocking: boolean;
  16365. /**
  16366. * Get the current sampling mode associated with the texture.
  16367. */
  16368. readonly samplingMode: number;
  16369. /**
  16370. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16371. */
  16372. readonly invertY: boolean;
  16373. /**
  16374. * Instantiates a new texture.
  16375. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16376. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16377. * @param url defines the url of the picture to load as a texture
  16378. * @param scene defines the scene or engine the texture will belong to
  16379. * @param noMipmap defines if the texture will require mip maps or not
  16380. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16381. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16382. * @param onLoad defines a callback triggered when the texture has been loaded
  16383. * @param onError defines a callback triggered when an error occurred during the loading session
  16384. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16385. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16386. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16387. * @param mimeType defines an optional mime type information
  16388. */
  16389. 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);
  16390. /**
  16391. * Update the url (and optional buffer) of this texture if url was null during construction.
  16392. * @param url the url of the texture
  16393. * @param buffer the buffer of the texture (defaults to null)
  16394. * @param onLoad callback called when the texture is loaded (defaults to null)
  16395. */
  16396. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16397. /**
  16398. * Finish the loading sequence of a texture flagged as delayed load.
  16399. * @hidden
  16400. */
  16401. delayLoad(): void;
  16402. private _prepareRowForTextureGeneration;
  16403. /**
  16404. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16405. * @returns the transform matrix of the texture.
  16406. */
  16407. getTextureMatrix(): Matrix;
  16408. /**
  16409. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16410. * @returns The reflection texture transform
  16411. */
  16412. getReflectionTextureMatrix(): Matrix;
  16413. /**
  16414. * Clones the texture.
  16415. * @returns the cloned texture
  16416. */
  16417. clone(): Texture;
  16418. /**
  16419. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16420. * @returns The JSON representation of the texture
  16421. */
  16422. serialize(): any;
  16423. /**
  16424. * Get the current class name of the texture useful for serialization or dynamic coding.
  16425. * @returns "Texture"
  16426. */
  16427. getClassName(): string;
  16428. /**
  16429. * Dispose the texture and release its associated resources.
  16430. */
  16431. dispose(): void;
  16432. /**
  16433. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16434. * @param parsedTexture Define the JSON representation of the texture
  16435. * @param scene Define the scene the parsed texture should be instantiated in
  16436. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16437. * @returns The parsed texture if successful
  16438. */
  16439. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16440. /**
  16441. * Creates a texture from its base 64 representation.
  16442. * @param data Define the base64 payload without the data: prefix
  16443. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16444. * @param scene Define the scene the texture should belong to
  16445. * @param noMipmap Forces the texture to not create mip map information if true
  16446. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16447. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16448. * @param onLoad define a callback triggered when the texture has been loaded
  16449. * @param onError define a callback triggered when an error occurred during the loading session
  16450. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16451. * @returns the created texture
  16452. */
  16453. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16454. /**
  16455. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16456. * @param data Define the base64 payload without the data: prefix
  16457. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16458. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16459. * @param scene Define the scene the texture should belong to
  16460. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16461. * @param noMipmap Forces the texture to not create mip map information if true
  16462. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16463. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16464. * @param onLoad define a callback triggered when the texture has been loaded
  16465. * @param onError define a callback triggered when an error occurred during the loading session
  16466. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16467. * @returns the created texture
  16468. */
  16469. 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;
  16470. }
  16471. }
  16472. declare module "babylonjs/PostProcesses/postProcessManager" {
  16473. import { Nullable } from "babylonjs/types";
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16476. import { Scene } from "babylonjs/scene";
  16477. /**
  16478. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16479. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16480. */
  16481. export class PostProcessManager {
  16482. private _scene;
  16483. private _indexBuffer;
  16484. private _vertexBuffers;
  16485. /**
  16486. * Creates a new instance PostProcess
  16487. * @param scene The scene that the post process is associated with.
  16488. */
  16489. constructor(scene: Scene);
  16490. private _prepareBuffers;
  16491. private _buildIndexBuffer;
  16492. /**
  16493. * Rebuilds the vertex buffers of the manager.
  16494. * @hidden
  16495. */
  16496. _rebuild(): void;
  16497. /**
  16498. * Prepares a frame to be run through a post process.
  16499. * @param sourceTexture The input texture to the post procesess. (default: null)
  16500. * @param postProcesses An array of post processes to be run. (default: null)
  16501. * @returns True if the post processes were able to be run.
  16502. * @hidden
  16503. */
  16504. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16505. /**
  16506. * Manually render a set of post processes to a texture.
  16507. * @param postProcesses An array of post processes to be run.
  16508. * @param targetTexture The target texture to render to.
  16509. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16510. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16511. * @param lodLevel defines which lod of the texture to render to
  16512. */
  16513. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16514. /**
  16515. * Finalize the result of the output of the postprocesses.
  16516. * @param doNotPresent If true the result will not be displayed to the screen.
  16517. * @param targetTexture The target texture to render to.
  16518. * @param faceIndex The index of the face to bind the target texture to.
  16519. * @param postProcesses The array of post processes to render.
  16520. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16521. * @hidden
  16522. */
  16523. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16524. /**
  16525. * Disposes of the post process manager.
  16526. */
  16527. dispose(): void;
  16528. }
  16529. }
  16530. declare module "babylonjs/Misc/gradients" {
  16531. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16532. /** Interface used by value gradients (color, factor, ...) */
  16533. export interface IValueGradient {
  16534. /**
  16535. * Gets or sets the gradient value (between 0 and 1)
  16536. */
  16537. gradient: number;
  16538. }
  16539. /** Class used to store color4 gradient */
  16540. export class ColorGradient implements IValueGradient {
  16541. /**
  16542. * Gets or sets the gradient value (between 0 and 1)
  16543. */
  16544. gradient: number;
  16545. /**
  16546. * Gets or sets first associated color
  16547. */
  16548. color1: Color4;
  16549. /**
  16550. * Gets or sets second associated color
  16551. */
  16552. color2?: Color4;
  16553. /**
  16554. * Will get a color picked randomly between color1 and color2.
  16555. * If color2 is undefined then color1 will be used
  16556. * @param result defines the target Color4 to store the result in
  16557. */
  16558. getColorToRef(result: Color4): void;
  16559. }
  16560. /** Class used to store color 3 gradient */
  16561. export class Color3Gradient implements IValueGradient {
  16562. /**
  16563. * Gets or sets the gradient value (between 0 and 1)
  16564. */
  16565. gradient: number;
  16566. /**
  16567. * Gets or sets the associated color
  16568. */
  16569. color: Color3;
  16570. }
  16571. /** Class used to store factor gradient */
  16572. export class FactorGradient implements IValueGradient {
  16573. /**
  16574. * Gets or sets the gradient value (between 0 and 1)
  16575. */
  16576. gradient: number;
  16577. /**
  16578. * Gets or sets first associated factor
  16579. */
  16580. factor1: number;
  16581. /**
  16582. * Gets or sets second associated factor
  16583. */
  16584. factor2?: number;
  16585. /**
  16586. * Will get a number picked randomly between factor1 and factor2.
  16587. * If factor2 is undefined then factor1 will be used
  16588. * @returns the picked number
  16589. */
  16590. getFactor(): number;
  16591. }
  16592. /**
  16593. * Helper used to simplify some generic gradient tasks
  16594. */
  16595. export class GradientHelper {
  16596. /**
  16597. * Gets the current gradient from an array of IValueGradient
  16598. * @param ratio defines the current ratio to get
  16599. * @param gradients defines the array of IValueGradient
  16600. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16601. */
  16602. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16603. }
  16604. }
  16605. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16607. import { Nullable } from "babylonjs/types";
  16608. module "babylonjs/Engines/thinEngine" {
  16609. interface ThinEngine {
  16610. /**
  16611. * Creates a dynamic texture
  16612. * @param width defines the width of the texture
  16613. * @param height defines the height of the texture
  16614. * @param generateMipMaps defines if the engine should generate the mip levels
  16615. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16616. * @returns the dynamic texture inside an InternalTexture
  16617. */
  16618. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16619. /**
  16620. * Update the content of a dynamic texture
  16621. * @param texture defines the texture to update
  16622. * @param canvas defines the canvas containing the source
  16623. * @param invertY defines if data must be stored with Y axis inverted
  16624. * @param premulAlpha defines if alpha is stored as premultiplied
  16625. * @param format defines the format of the data
  16626. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16627. */
  16628. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16629. }
  16630. }
  16631. }
  16632. declare module "babylonjs/Misc/canvasGenerator" {
  16633. /**
  16634. * Helper class used to generate a canvas to manipulate images
  16635. */
  16636. export class CanvasGenerator {
  16637. /**
  16638. * Create a new canvas (or offscreen canvas depending on the context)
  16639. * @param width defines the expected width
  16640. * @param height defines the expected height
  16641. * @return a new canvas or offscreen canvas
  16642. */
  16643. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16644. }
  16645. }
  16646. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16647. import { Scene } from "babylonjs/scene";
  16648. import { Texture } from "babylonjs/Materials/Textures/texture";
  16649. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16650. /**
  16651. * A class extending Texture allowing drawing on a texture
  16652. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16653. */
  16654. export class DynamicTexture extends Texture {
  16655. private _generateMipMaps;
  16656. private _canvas;
  16657. private _context;
  16658. private _engine;
  16659. /**
  16660. * Creates a DynamicTexture
  16661. * @param name defines the name of the texture
  16662. * @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
  16663. * @param scene defines the scene where you want the texture
  16664. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16665. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16666. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16667. */
  16668. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16669. /**
  16670. * Get the current class name of the texture useful for serialization or dynamic coding.
  16671. * @returns "DynamicTexture"
  16672. */
  16673. getClassName(): string;
  16674. /**
  16675. * Gets the current state of canRescale
  16676. */
  16677. readonly canRescale: boolean;
  16678. private _recreate;
  16679. /**
  16680. * Scales the texture
  16681. * @param ratio the scale factor to apply to both width and height
  16682. */
  16683. scale(ratio: number): void;
  16684. /**
  16685. * Resizes the texture
  16686. * @param width the new width
  16687. * @param height the new height
  16688. */
  16689. scaleTo(width: number, height: number): void;
  16690. /**
  16691. * Gets the context of the canvas used by the texture
  16692. * @returns the canvas context of the dynamic texture
  16693. */
  16694. getContext(): CanvasRenderingContext2D;
  16695. /**
  16696. * Clears the texture
  16697. */
  16698. clear(): void;
  16699. /**
  16700. * Updates the texture
  16701. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16702. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16703. */
  16704. update(invertY?: boolean, premulAlpha?: boolean): void;
  16705. /**
  16706. * Draws text onto the texture
  16707. * @param text defines the text to be drawn
  16708. * @param x defines the placement of the text from the left
  16709. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16710. * @param font defines the font to be used with font-style, font-size, font-name
  16711. * @param color defines the color used for the text
  16712. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16713. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16714. * @param update defines whether texture is immediately update (default is true)
  16715. */
  16716. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16717. /**
  16718. * Clones the texture
  16719. * @returns the clone of the texture.
  16720. */
  16721. clone(): DynamicTexture;
  16722. /**
  16723. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16724. * @returns a serialized dynamic texture object
  16725. */
  16726. serialize(): any;
  16727. /** @hidden */
  16728. _rebuild(): void;
  16729. }
  16730. }
  16731. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16732. import { Scene } from "babylonjs/scene";
  16733. import { ISceneComponent } from "babylonjs/sceneComponent";
  16734. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16735. module "babylonjs/abstractScene" {
  16736. interface AbstractScene {
  16737. /**
  16738. * The list of procedural textures added to the scene
  16739. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16740. */
  16741. proceduralTextures: Array<ProceduralTexture>;
  16742. }
  16743. }
  16744. /**
  16745. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16746. * in a given scene.
  16747. */
  16748. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16749. /**
  16750. * The component name helpfull to identify the component in the list of scene components.
  16751. */
  16752. readonly name: string;
  16753. /**
  16754. * The scene the component belongs to.
  16755. */
  16756. scene: Scene;
  16757. /**
  16758. * Creates a new instance of the component for the given scene
  16759. * @param scene Defines the scene to register the component in
  16760. */
  16761. constructor(scene: Scene);
  16762. /**
  16763. * Registers the component in a given scene
  16764. */
  16765. register(): void;
  16766. /**
  16767. * Rebuilds the elements related to this component in case of
  16768. * context lost for instance.
  16769. */
  16770. rebuild(): void;
  16771. /**
  16772. * Disposes the component and the associated ressources.
  16773. */
  16774. dispose(): void;
  16775. private _beforeClear;
  16776. }
  16777. }
  16778. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16780. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16781. module "babylonjs/Engines/thinEngine" {
  16782. interface ThinEngine {
  16783. /**
  16784. * Creates a new render target cube texture
  16785. * @param size defines the size of the texture
  16786. * @param options defines the options used to create the texture
  16787. * @returns a new render target cube texture stored in an InternalTexture
  16788. */
  16789. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16790. }
  16791. }
  16792. }
  16793. declare module "babylonjs/Shaders/procedural.vertex" {
  16794. /** @hidden */
  16795. export var proceduralVertexShader: {
  16796. name: string;
  16797. shader: string;
  16798. };
  16799. }
  16800. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16801. import { Observable } from "babylonjs/Misc/observable";
  16802. import { Nullable } from "babylonjs/types";
  16803. import { Scene } from "babylonjs/scene";
  16804. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16805. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16806. import { Effect } from "babylonjs/Materials/effect";
  16807. import { Texture } from "babylonjs/Materials/Textures/texture";
  16808. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16809. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16810. import "babylonjs/Shaders/procedural.vertex";
  16811. /**
  16812. * 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.
  16813. * This is the base class of any Procedural texture and contains most of the shareable code.
  16814. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16815. */
  16816. export class ProceduralTexture extends Texture {
  16817. isCube: boolean;
  16818. /**
  16819. * Define if the texture is enabled or not (disabled texture will not render)
  16820. */
  16821. isEnabled: boolean;
  16822. /**
  16823. * Define if the texture must be cleared before rendering (default is true)
  16824. */
  16825. autoClear: boolean;
  16826. /**
  16827. * Callback called when the texture is generated
  16828. */
  16829. onGenerated: () => void;
  16830. /**
  16831. * Event raised when the texture is generated
  16832. */
  16833. onGeneratedObservable: Observable<ProceduralTexture>;
  16834. /** @hidden */
  16835. _generateMipMaps: boolean;
  16836. /** @hidden **/
  16837. _effect: Effect;
  16838. /** @hidden */
  16839. _textures: {
  16840. [key: string]: Texture;
  16841. };
  16842. private _size;
  16843. private _currentRefreshId;
  16844. private _refreshRate;
  16845. private _vertexBuffers;
  16846. private _indexBuffer;
  16847. private _uniforms;
  16848. private _samplers;
  16849. private _fragment;
  16850. private _floats;
  16851. private _ints;
  16852. private _floatsArrays;
  16853. private _colors3;
  16854. private _colors4;
  16855. private _vectors2;
  16856. private _vectors3;
  16857. private _matrices;
  16858. private _fallbackTexture;
  16859. private _fallbackTextureUsed;
  16860. private _engine;
  16861. private _cachedDefines;
  16862. private _contentUpdateId;
  16863. private _contentData;
  16864. /**
  16865. * Instantiates a new procedural texture.
  16866. * 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.
  16867. * This is the base class of any Procedural texture and contains most of the shareable code.
  16868. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16869. * @param name Define the name of the texture
  16870. * @param size Define the size of the texture to create
  16871. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16872. * @param scene Define the scene the texture belongs to
  16873. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16874. * @param generateMipMaps Define if the texture should creates mip maps or not
  16875. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16876. */
  16877. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16878. /**
  16879. * The effect that is created when initializing the post process.
  16880. * @returns The created effect corresponding the the postprocess.
  16881. */
  16882. getEffect(): Effect;
  16883. /**
  16884. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16885. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16886. */
  16887. getContent(): Nullable<ArrayBufferView>;
  16888. private _createIndexBuffer;
  16889. /** @hidden */
  16890. _rebuild(): void;
  16891. /**
  16892. * Resets the texture in order to recreate its associated resources.
  16893. * This can be called in case of context loss
  16894. */
  16895. reset(): void;
  16896. protected _getDefines(): string;
  16897. /**
  16898. * Is the texture ready to be used ? (rendered at least once)
  16899. * @returns true if ready, otherwise, false.
  16900. */
  16901. isReady(): boolean;
  16902. /**
  16903. * Resets the refresh counter of the texture and start bak from scratch.
  16904. * Could be useful to regenerate the texture if it is setup to render only once.
  16905. */
  16906. resetRefreshCounter(): void;
  16907. /**
  16908. * Set the fragment shader to use in order to render the texture.
  16909. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16910. */
  16911. setFragment(fragment: any): void;
  16912. /**
  16913. * Define the refresh rate of the texture or the rendering frequency.
  16914. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16915. */
  16916. refreshRate: number;
  16917. /** @hidden */
  16918. _shouldRender(): boolean;
  16919. /**
  16920. * Get the size the texture is rendering at.
  16921. * @returns the size (texture is always squared)
  16922. */
  16923. getRenderSize(): number;
  16924. /**
  16925. * Resize the texture to new value.
  16926. * @param size Define the new size the texture should have
  16927. * @param generateMipMaps Define whether the new texture should create mip maps
  16928. */
  16929. resize(size: number, generateMipMaps: boolean): void;
  16930. private _checkUniform;
  16931. /**
  16932. * Set a texture in the shader program used to render.
  16933. * @param name Define the name of the uniform samplers as defined in the shader
  16934. * @param texture Define the texture to bind to this sampler
  16935. * @return the texture itself allowing "fluent" like uniform updates
  16936. */
  16937. setTexture(name: string, texture: Texture): ProceduralTexture;
  16938. /**
  16939. * Set a float in the shader.
  16940. * @param name Define the name of the uniform as defined in the shader
  16941. * @param value Define the value to give to the uniform
  16942. * @return the texture itself allowing "fluent" like uniform updates
  16943. */
  16944. setFloat(name: string, value: number): ProceduralTexture;
  16945. /**
  16946. * Set a int in the shader.
  16947. * @param name Define the name of the uniform as defined in the shader
  16948. * @param value Define the value to give to the uniform
  16949. * @return the texture itself allowing "fluent" like uniform updates
  16950. */
  16951. setInt(name: string, value: number): ProceduralTexture;
  16952. /**
  16953. * Set an array of floats in the shader.
  16954. * @param name Define the name of the uniform as defined in the shader
  16955. * @param value Define the value to give to the uniform
  16956. * @return the texture itself allowing "fluent" like uniform updates
  16957. */
  16958. setFloats(name: string, value: number[]): ProceduralTexture;
  16959. /**
  16960. * Set a vec3 in the shader from a Color3.
  16961. * @param name Define the name of the uniform as defined in the shader
  16962. * @param value Define the value to give to the uniform
  16963. * @return the texture itself allowing "fluent" like uniform updates
  16964. */
  16965. setColor3(name: string, value: Color3): ProceduralTexture;
  16966. /**
  16967. * Set a vec4 in the shader from a Color4.
  16968. * @param name Define the name of the uniform as defined in the shader
  16969. * @param value Define the value to give to the uniform
  16970. * @return the texture itself allowing "fluent" like uniform updates
  16971. */
  16972. setColor4(name: string, value: Color4): ProceduralTexture;
  16973. /**
  16974. * Set a vec2 in the shader from a Vector2.
  16975. * @param name Define the name of the uniform as defined in the shader
  16976. * @param value Define the value to give to the uniform
  16977. * @return the texture itself allowing "fluent" like uniform updates
  16978. */
  16979. setVector2(name: string, value: Vector2): ProceduralTexture;
  16980. /**
  16981. * Set a vec3 in the shader from a Vector3.
  16982. * @param name Define the name of the uniform as defined in the shader
  16983. * @param value Define the value to give to the uniform
  16984. * @return the texture itself allowing "fluent" like uniform updates
  16985. */
  16986. setVector3(name: string, value: Vector3): ProceduralTexture;
  16987. /**
  16988. * Set a mat4 in the shader from a MAtrix.
  16989. * @param name Define the name of the uniform as defined in the shader
  16990. * @param value Define the value to give to the uniform
  16991. * @return the texture itself allowing "fluent" like uniform updates
  16992. */
  16993. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16994. /**
  16995. * Render the texture to its associated render target.
  16996. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16997. */
  16998. render(useCameraPostProcess?: boolean): void;
  16999. /**
  17000. * Clone the texture.
  17001. * @returns the cloned texture
  17002. */
  17003. clone(): ProceduralTexture;
  17004. /**
  17005. * Dispose the texture and release its asoociated resources.
  17006. */
  17007. dispose(): void;
  17008. }
  17009. }
  17010. declare module "babylonjs/Particles/baseParticleSystem" {
  17011. import { Nullable } from "babylonjs/types";
  17012. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17014. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17015. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17016. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17017. import { Scene } from "babylonjs/scene";
  17018. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17019. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17020. import { Texture } from "babylonjs/Materials/Textures/texture";
  17021. import { Color4 } from "babylonjs/Maths/math.color";
  17022. import { Animation } from "babylonjs/Animations/animation";
  17023. /**
  17024. * This represents the base class for particle system in Babylon.
  17025. * 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.
  17026. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17027. * @example https://doc.babylonjs.com/babylon101/particles
  17028. */
  17029. export class BaseParticleSystem {
  17030. /**
  17031. * Source color is added to the destination color without alpha affecting the result
  17032. */
  17033. static BLENDMODE_ONEONE: number;
  17034. /**
  17035. * Blend current color and particle color using particle’s alpha
  17036. */
  17037. static BLENDMODE_STANDARD: number;
  17038. /**
  17039. * Add current color and particle color multiplied by particle’s alpha
  17040. */
  17041. static BLENDMODE_ADD: number;
  17042. /**
  17043. * Multiply current color with particle color
  17044. */
  17045. static BLENDMODE_MULTIPLY: number;
  17046. /**
  17047. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17048. */
  17049. static BLENDMODE_MULTIPLYADD: number;
  17050. /**
  17051. * List of animations used by the particle system.
  17052. */
  17053. animations: Animation[];
  17054. /**
  17055. * The id of the Particle system.
  17056. */
  17057. id: string;
  17058. /**
  17059. * The friendly name of the Particle system.
  17060. */
  17061. name: string;
  17062. /**
  17063. * The rendering group used by the Particle system to chose when to render.
  17064. */
  17065. renderingGroupId: number;
  17066. /**
  17067. * The emitter represents the Mesh or position we are attaching the particle system to.
  17068. */
  17069. emitter: Nullable<AbstractMesh | Vector3>;
  17070. /**
  17071. * The maximum number of particles to emit per frame
  17072. */
  17073. emitRate: number;
  17074. /**
  17075. * If you want to launch only a few particles at once, that can be done, as well.
  17076. */
  17077. manualEmitCount: number;
  17078. /**
  17079. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17080. */
  17081. updateSpeed: number;
  17082. /**
  17083. * The amount of time the particle system is running (depends of the overall update speed).
  17084. */
  17085. targetStopDuration: number;
  17086. /**
  17087. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17088. */
  17089. disposeOnStop: boolean;
  17090. /**
  17091. * Minimum power of emitting particles.
  17092. */
  17093. minEmitPower: number;
  17094. /**
  17095. * Maximum power of emitting particles.
  17096. */
  17097. maxEmitPower: number;
  17098. /**
  17099. * Minimum life time of emitting particles.
  17100. */
  17101. minLifeTime: number;
  17102. /**
  17103. * Maximum life time of emitting particles.
  17104. */
  17105. maxLifeTime: number;
  17106. /**
  17107. * Minimum Size of emitting particles.
  17108. */
  17109. minSize: number;
  17110. /**
  17111. * Maximum Size of emitting particles.
  17112. */
  17113. maxSize: number;
  17114. /**
  17115. * Minimum scale of emitting particles on X axis.
  17116. */
  17117. minScaleX: number;
  17118. /**
  17119. * Maximum scale of emitting particles on X axis.
  17120. */
  17121. maxScaleX: number;
  17122. /**
  17123. * Minimum scale of emitting particles on Y axis.
  17124. */
  17125. minScaleY: number;
  17126. /**
  17127. * Maximum scale of emitting particles on Y axis.
  17128. */
  17129. maxScaleY: number;
  17130. /**
  17131. * Gets or sets the minimal initial rotation in radians.
  17132. */
  17133. minInitialRotation: number;
  17134. /**
  17135. * Gets or sets the maximal initial rotation in radians.
  17136. */
  17137. maxInitialRotation: number;
  17138. /**
  17139. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17140. */
  17141. minAngularSpeed: number;
  17142. /**
  17143. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17144. */
  17145. maxAngularSpeed: number;
  17146. /**
  17147. * The texture used to render each particle. (this can be a spritesheet)
  17148. */
  17149. particleTexture: Nullable<Texture>;
  17150. /**
  17151. * The layer mask we are rendering the particles through.
  17152. */
  17153. layerMask: number;
  17154. /**
  17155. * This can help using your own shader to render the particle system.
  17156. * The according effect will be created
  17157. */
  17158. customShader: any;
  17159. /**
  17160. * By default particle system starts as soon as they are created. This prevents the
  17161. * automatic start to happen and let you decide when to start emitting particles.
  17162. */
  17163. preventAutoStart: boolean;
  17164. private _noiseTexture;
  17165. /**
  17166. * Gets or sets a texture used to add random noise to particle positions
  17167. */
  17168. noiseTexture: Nullable<ProceduralTexture>;
  17169. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17170. noiseStrength: Vector3;
  17171. /**
  17172. * Callback triggered when the particle animation is ending.
  17173. */
  17174. onAnimationEnd: Nullable<() => void>;
  17175. /**
  17176. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17177. */
  17178. blendMode: number;
  17179. /**
  17180. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17181. * to override the particles.
  17182. */
  17183. forceDepthWrite: boolean;
  17184. /** 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 */
  17185. preWarmCycles: number;
  17186. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17187. preWarmStepOffset: number;
  17188. /**
  17189. * 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)
  17190. */
  17191. spriteCellChangeSpeed: number;
  17192. /**
  17193. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17194. */
  17195. startSpriteCellID: number;
  17196. /**
  17197. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17198. */
  17199. endSpriteCellID: number;
  17200. /**
  17201. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17202. */
  17203. spriteCellWidth: number;
  17204. /**
  17205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17206. */
  17207. spriteCellHeight: number;
  17208. /**
  17209. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17210. */
  17211. spriteRandomStartCell: boolean;
  17212. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17213. translationPivot: Vector2;
  17214. /** @hidden */
  17215. protected _isAnimationSheetEnabled: boolean;
  17216. /**
  17217. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17218. */
  17219. beginAnimationOnStart: boolean;
  17220. /**
  17221. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17222. */
  17223. beginAnimationFrom: number;
  17224. /**
  17225. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17226. */
  17227. beginAnimationTo: number;
  17228. /**
  17229. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17230. */
  17231. beginAnimationLoop: boolean;
  17232. /**
  17233. * Gets or sets a world offset applied to all particles
  17234. */
  17235. worldOffset: Vector3;
  17236. /**
  17237. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17238. */
  17239. isAnimationSheetEnabled: boolean;
  17240. /**
  17241. * Get hosting scene
  17242. * @returns the scene
  17243. */
  17244. getScene(): Scene;
  17245. /**
  17246. * You can use gravity if you want to give an orientation to your particles.
  17247. */
  17248. gravity: Vector3;
  17249. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17250. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17251. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17252. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17253. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17254. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17255. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17256. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17257. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17258. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17259. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17260. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17261. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17262. /**
  17263. * Defines the delay in milliseconds before starting the system (0 by default)
  17264. */
  17265. startDelay: number;
  17266. /**
  17267. * Gets the current list of drag gradients.
  17268. * You must use addDragGradient and removeDragGradient to udpate this list
  17269. * @returns the list of drag gradients
  17270. */
  17271. getDragGradients(): Nullable<Array<FactorGradient>>;
  17272. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17273. limitVelocityDamping: number;
  17274. /**
  17275. * Gets the current list of limit velocity gradients.
  17276. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17277. * @returns the list of limit velocity gradients
  17278. */
  17279. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17280. /**
  17281. * Gets the current list of color gradients.
  17282. * You must use addColorGradient and removeColorGradient to udpate this list
  17283. * @returns the list of color gradients
  17284. */
  17285. getColorGradients(): Nullable<Array<ColorGradient>>;
  17286. /**
  17287. * Gets the current list of size gradients.
  17288. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17289. * @returns the list of size gradients
  17290. */
  17291. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17292. /**
  17293. * Gets the current list of color remap gradients.
  17294. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17295. * @returns the list of color remap gradients
  17296. */
  17297. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17298. /**
  17299. * Gets the current list of alpha remap gradients.
  17300. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17301. * @returns the list of alpha remap gradients
  17302. */
  17303. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17304. /**
  17305. * Gets the current list of life time gradients.
  17306. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17307. * @returns the list of life time gradients
  17308. */
  17309. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17310. /**
  17311. * Gets the current list of angular speed gradients.
  17312. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17313. * @returns the list of angular speed gradients
  17314. */
  17315. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17316. /**
  17317. * Gets the current list of velocity gradients.
  17318. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17319. * @returns the list of velocity gradients
  17320. */
  17321. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17322. /**
  17323. * Gets the current list of start size gradients.
  17324. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17325. * @returns the list of start size gradients
  17326. */
  17327. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17328. /**
  17329. * Gets the current list of emit rate gradients.
  17330. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17331. * @returns the list of emit rate gradients
  17332. */
  17333. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17334. /**
  17335. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17336. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17337. */
  17338. direction1: Vector3;
  17339. /**
  17340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17341. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17342. */
  17343. direction2: Vector3;
  17344. /**
  17345. * 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.
  17346. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17347. */
  17348. minEmitBox: Vector3;
  17349. /**
  17350. * 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.
  17351. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17352. */
  17353. maxEmitBox: Vector3;
  17354. /**
  17355. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17356. */
  17357. color1: Color4;
  17358. /**
  17359. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17360. */
  17361. color2: Color4;
  17362. /**
  17363. * Color the particle will have at the end of its lifetime
  17364. */
  17365. colorDead: Color4;
  17366. /**
  17367. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17368. */
  17369. textureMask: Color4;
  17370. /**
  17371. * The particle emitter type defines the emitter used by the particle system.
  17372. * It can be for example box, sphere, or cone...
  17373. */
  17374. particleEmitterType: IParticleEmitterType;
  17375. /** @hidden */
  17376. _isSubEmitter: boolean;
  17377. /**
  17378. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17379. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17380. */
  17381. billboardMode: number;
  17382. protected _isBillboardBased: boolean;
  17383. /**
  17384. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17385. */
  17386. isBillboardBased: boolean;
  17387. /**
  17388. * The scene the particle system belongs to.
  17389. */
  17390. protected _scene: Scene;
  17391. /**
  17392. * Local cache of defines for image processing.
  17393. */
  17394. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17395. /**
  17396. * Default configuration related to image processing available in the standard Material.
  17397. */
  17398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17399. /**
  17400. * Gets the image processing configuration used either in this material.
  17401. */
  17402. /**
  17403. * Sets the Default image processing configuration used either in the this material.
  17404. *
  17405. * If sets to null, the scene one is in use.
  17406. */
  17407. imageProcessingConfiguration: ImageProcessingConfiguration;
  17408. /**
  17409. * Attaches a new image processing configuration to the Standard Material.
  17410. * @param configuration
  17411. */
  17412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17413. /** @hidden */
  17414. protected _reset(): void;
  17415. /** @hidden */
  17416. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17417. /**
  17418. * Instantiates a particle system.
  17419. * 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.
  17420. * @param name The name of the particle system
  17421. */
  17422. constructor(name: string);
  17423. /**
  17424. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17427. * @returns the emitter
  17428. */
  17429. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17430. /**
  17431. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17432. * @param radius The radius of the hemisphere to emit from
  17433. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17434. * @returns the emitter
  17435. */
  17436. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17437. /**
  17438. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17439. * @param radius The radius of the sphere to emit from
  17440. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17441. * @returns the emitter
  17442. */
  17443. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17444. /**
  17445. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17446. * @param radius The radius of the sphere to emit from
  17447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17449. * @returns the emitter
  17450. */
  17451. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17452. /**
  17453. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17454. * @param radius The radius of the emission cylinder
  17455. * @param height The height of the emission cylinder
  17456. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17457. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17458. * @returns the emitter
  17459. */
  17460. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17461. /**
  17462. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17463. * @param radius The radius of the cylinder to emit from
  17464. * @param height The height of the emission cylinder
  17465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17468. * @returns the emitter
  17469. */
  17470. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17471. /**
  17472. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17473. * @param radius The radius of the cone to emit from
  17474. * @param angle The base angle of the cone
  17475. * @returns the emitter
  17476. */
  17477. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17478. /**
  17479. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17482. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17483. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17484. * @returns the emitter
  17485. */
  17486. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17487. }
  17488. }
  17489. declare module "babylonjs/Particles/subEmitter" {
  17490. import { Scene } from "babylonjs/scene";
  17491. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17492. /**
  17493. * Type of sub emitter
  17494. */
  17495. export enum SubEmitterType {
  17496. /**
  17497. * Attached to the particle over it's lifetime
  17498. */
  17499. ATTACHED = 0,
  17500. /**
  17501. * Created when the particle dies
  17502. */
  17503. END = 1
  17504. }
  17505. /**
  17506. * Sub emitter class used to emit particles from an existing particle
  17507. */
  17508. export class SubEmitter {
  17509. /**
  17510. * the particle system to be used by the sub emitter
  17511. */
  17512. particleSystem: ParticleSystem;
  17513. /**
  17514. * Type of the submitter (Default: END)
  17515. */
  17516. type: SubEmitterType;
  17517. /**
  17518. * 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)
  17519. * Note: This only is supported when using an emitter of type Mesh
  17520. */
  17521. inheritDirection: boolean;
  17522. /**
  17523. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17524. */
  17525. inheritedVelocityAmount: number;
  17526. /**
  17527. * Creates a sub emitter
  17528. * @param particleSystem the particle system to be used by the sub emitter
  17529. */
  17530. constructor(
  17531. /**
  17532. * the particle system to be used by the sub emitter
  17533. */
  17534. particleSystem: ParticleSystem);
  17535. /**
  17536. * Clones the sub emitter
  17537. * @returns the cloned sub emitter
  17538. */
  17539. clone(): SubEmitter;
  17540. /**
  17541. * Serialize current object to a JSON object
  17542. * @returns the serialized object
  17543. */
  17544. serialize(): any;
  17545. /** @hidden */
  17546. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17547. /**
  17548. * Creates a new SubEmitter from a serialized JSON version
  17549. * @param serializationObject defines the JSON object to read from
  17550. * @param scene defines the hosting scene
  17551. * @param rootUrl defines the rootUrl for data loading
  17552. * @returns a new SubEmitter
  17553. */
  17554. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17555. /** Release associated resources */
  17556. dispose(): void;
  17557. }
  17558. }
  17559. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17560. /** @hidden */
  17561. export var clipPlaneFragmentDeclaration: {
  17562. name: string;
  17563. shader: string;
  17564. };
  17565. }
  17566. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17567. /** @hidden */
  17568. export var imageProcessingDeclaration: {
  17569. name: string;
  17570. shader: string;
  17571. };
  17572. }
  17573. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17574. /** @hidden */
  17575. export var imageProcessingFunctions: {
  17576. name: string;
  17577. shader: string;
  17578. };
  17579. }
  17580. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17581. /** @hidden */
  17582. export var clipPlaneFragment: {
  17583. name: string;
  17584. shader: string;
  17585. };
  17586. }
  17587. declare module "babylonjs/Shaders/particles.fragment" {
  17588. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17589. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17591. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17592. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17593. /** @hidden */
  17594. export var particlesPixelShader: {
  17595. name: string;
  17596. shader: string;
  17597. };
  17598. }
  17599. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17600. /** @hidden */
  17601. export var clipPlaneVertexDeclaration: {
  17602. name: string;
  17603. shader: string;
  17604. };
  17605. }
  17606. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17607. /** @hidden */
  17608. export var clipPlaneVertex: {
  17609. name: string;
  17610. shader: string;
  17611. };
  17612. }
  17613. declare module "babylonjs/Shaders/particles.vertex" {
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17616. /** @hidden */
  17617. export var particlesVertexShader: {
  17618. name: string;
  17619. shader: string;
  17620. };
  17621. }
  17622. declare module "babylonjs/Particles/particleSystem" {
  17623. import { Nullable } from "babylonjs/types";
  17624. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17625. import { Observable } from "babylonjs/Misc/observable";
  17626. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17627. import { Effect } from "babylonjs/Materials/effect";
  17628. import { Scene, IDisposable } from "babylonjs/scene";
  17629. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17630. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17631. import { Particle } from "babylonjs/Particles/particle";
  17632. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17633. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17634. import "babylonjs/Shaders/particles.fragment";
  17635. import "babylonjs/Shaders/particles.vertex";
  17636. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17637. /**
  17638. * This represents a particle system in Babylon.
  17639. * 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.
  17640. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17641. * @example https://doc.babylonjs.com/babylon101/particles
  17642. */
  17643. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17644. /**
  17645. * Billboard mode will only apply to Y axis
  17646. */
  17647. static readonly BILLBOARDMODE_Y: number;
  17648. /**
  17649. * Billboard mode will apply to all axes
  17650. */
  17651. static readonly BILLBOARDMODE_ALL: number;
  17652. /**
  17653. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17654. */
  17655. static readonly BILLBOARDMODE_STRETCHED: number;
  17656. /**
  17657. * This function can be defined to provide custom update for active particles.
  17658. * This function will be called instead of regular update (age, position, color, etc.).
  17659. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17660. */
  17661. updateFunction: (particles: Particle[]) => void;
  17662. private _emitterWorldMatrix;
  17663. /**
  17664. * This function can be defined to specify initial direction for every new particle.
  17665. * It by default use the emitterType defined function
  17666. */
  17667. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17668. /**
  17669. * This function can be defined to specify initial position for every new particle.
  17670. * It by default use the emitterType defined function
  17671. */
  17672. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17673. /**
  17674. * @hidden
  17675. */
  17676. _inheritedVelocityOffset: Vector3;
  17677. /**
  17678. * An event triggered when the system is disposed
  17679. */
  17680. onDisposeObservable: Observable<ParticleSystem>;
  17681. private _onDisposeObserver;
  17682. /**
  17683. * Sets a callback that will be triggered when the system is disposed
  17684. */
  17685. onDispose: () => void;
  17686. private _particles;
  17687. private _epsilon;
  17688. private _capacity;
  17689. private _stockParticles;
  17690. private _newPartsExcess;
  17691. private _vertexData;
  17692. private _vertexBuffer;
  17693. private _vertexBuffers;
  17694. private _spriteBuffer;
  17695. private _indexBuffer;
  17696. private _effect;
  17697. private _customEffect;
  17698. private _cachedDefines;
  17699. private _scaledColorStep;
  17700. private _colorDiff;
  17701. private _scaledDirection;
  17702. private _scaledGravity;
  17703. private _currentRenderId;
  17704. private _alive;
  17705. private _useInstancing;
  17706. private _started;
  17707. private _stopped;
  17708. private _actualFrame;
  17709. private _scaledUpdateSpeed;
  17710. private _vertexBufferSize;
  17711. /** @hidden */
  17712. _currentEmitRateGradient: Nullable<FactorGradient>;
  17713. /** @hidden */
  17714. _currentEmitRate1: number;
  17715. /** @hidden */
  17716. _currentEmitRate2: number;
  17717. /** @hidden */
  17718. _currentStartSizeGradient: Nullable<FactorGradient>;
  17719. /** @hidden */
  17720. _currentStartSize1: number;
  17721. /** @hidden */
  17722. _currentStartSize2: number;
  17723. private readonly _rawTextureWidth;
  17724. private _rampGradientsTexture;
  17725. private _useRampGradients;
  17726. /** Gets or sets a boolean indicating that ramp gradients must be used
  17727. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17728. */
  17729. useRampGradients: boolean;
  17730. /**
  17731. * 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.
  17732. * 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: [])
  17733. */
  17734. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17735. private _subEmitters;
  17736. /**
  17737. * @hidden
  17738. * If the particle systems emitter should be disposed when the particle system is disposed
  17739. */
  17740. _disposeEmitterOnDispose: boolean;
  17741. /**
  17742. * The current active Sub-systems, this property is used by the root particle system only.
  17743. */
  17744. activeSubSystems: Array<ParticleSystem>;
  17745. private _rootParticleSystem;
  17746. /**
  17747. * Gets the current list of active particles
  17748. */
  17749. readonly particles: Particle[];
  17750. /**
  17751. * Returns the string "ParticleSystem"
  17752. * @returns a string containing the class name
  17753. */
  17754. getClassName(): string;
  17755. /**
  17756. * Instantiates a particle system.
  17757. * 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.
  17758. * @param name The name of the particle system
  17759. * @param capacity The max number of particles alive at the same time
  17760. * @param scene The scene the particle system belongs to
  17761. * @param customEffect a custom effect used to change the way particles are rendered by default
  17762. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17763. * @param epsilon Offset used to render the particles
  17764. */
  17765. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17766. private _addFactorGradient;
  17767. private _removeFactorGradient;
  17768. /**
  17769. * Adds a new life time gradient
  17770. * @param gradient defines the gradient to use (between 0 and 1)
  17771. * @param factor defines the life time factor to affect to the specified gradient
  17772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17773. * @returns the current particle system
  17774. */
  17775. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17776. /**
  17777. * Remove a specific life time gradient
  17778. * @param gradient defines the gradient to remove
  17779. * @returns the current particle system
  17780. */
  17781. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17782. /**
  17783. * Adds a new size gradient
  17784. * @param gradient defines the gradient to use (between 0 and 1)
  17785. * @param factor defines the size factor to affect to the specified gradient
  17786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17787. * @returns the current particle system
  17788. */
  17789. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17790. /**
  17791. * Remove a specific size gradient
  17792. * @param gradient defines the gradient to remove
  17793. * @returns the current particle system
  17794. */
  17795. removeSizeGradient(gradient: number): IParticleSystem;
  17796. /**
  17797. * Adds a new color remap gradient
  17798. * @param gradient defines the gradient to use (between 0 and 1)
  17799. * @param min defines the color remap minimal range
  17800. * @param max defines the color remap maximal range
  17801. * @returns the current particle system
  17802. */
  17803. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17804. /**
  17805. * Remove a specific color remap gradient
  17806. * @param gradient defines the gradient to remove
  17807. * @returns the current particle system
  17808. */
  17809. removeColorRemapGradient(gradient: number): IParticleSystem;
  17810. /**
  17811. * Adds a new alpha remap gradient
  17812. * @param gradient defines the gradient to use (between 0 and 1)
  17813. * @param min defines the alpha remap minimal range
  17814. * @param max defines the alpha remap maximal range
  17815. * @returns the current particle system
  17816. */
  17817. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17818. /**
  17819. * Remove a specific alpha remap gradient
  17820. * @param gradient defines the gradient to remove
  17821. * @returns the current particle system
  17822. */
  17823. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17824. /**
  17825. * Adds a new angular speed gradient
  17826. * @param gradient defines the gradient to use (between 0 and 1)
  17827. * @param factor defines the angular speed to affect to the specified gradient
  17828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17829. * @returns the current particle system
  17830. */
  17831. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17832. /**
  17833. * Remove a specific angular speed gradient
  17834. * @param gradient defines the gradient to remove
  17835. * @returns the current particle system
  17836. */
  17837. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17838. /**
  17839. * Adds a new velocity gradient
  17840. * @param gradient defines the gradient to use (between 0 and 1)
  17841. * @param factor defines the velocity to affect to the specified gradient
  17842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17843. * @returns the current particle system
  17844. */
  17845. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17846. /**
  17847. * Remove a specific velocity gradient
  17848. * @param gradient defines the gradient to remove
  17849. * @returns the current particle system
  17850. */
  17851. removeVelocityGradient(gradient: number): IParticleSystem;
  17852. /**
  17853. * Adds a new limit velocity gradient
  17854. * @param gradient defines the gradient to use (between 0 and 1)
  17855. * @param factor defines the limit velocity value to affect to the specified gradient
  17856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17857. * @returns the current particle system
  17858. */
  17859. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17860. /**
  17861. * Remove a specific limit velocity gradient
  17862. * @param gradient defines the gradient to remove
  17863. * @returns the current particle system
  17864. */
  17865. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17866. /**
  17867. * Adds a new drag gradient
  17868. * @param gradient defines the gradient to use (between 0 and 1)
  17869. * @param factor defines the drag value to affect to the specified gradient
  17870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17871. * @returns the current particle system
  17872. */
  17873. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17874. /**
  17875. * Remove a specific drag gradient
  17876. * @param gradient defines the gradient to remove
  17877. * @returns the current particle system
  17878. */
  17879. removeDragGradient(gradient: number): IParticleSystem;
  17880. /**
  17881. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17882. * @param gradient defines the gradient to use (between 0 and 1)
  17883. * @param factor defines the emit rate value to affect to the specified gradient
  17884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17885. * @returns the current particle system
  17886. */
  17887. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17888. /**
  17889. * Remove a specific emit rate gradient
  17890. * @param gradient defines the gradient to remove
  17891. * @returns the current particle system
  17892. */
  17893. removeEmitRateGradient(gradient: number): IParticleSystem;
  17894. /**
  17895. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17896. * @param gradient defines the gradient to use (between 0 and 1)
  17897. * @param factor defines the start size value to affect to the specified gradient
  17898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17899. * @returns the current particle system
  17900. */
  17901. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17902. /**
  17903. * Remove a specific start size gradient
  17904. * @param gradient defines the gradient to remove
  17905. * @returns the current particle system
  17906. */
  17907. removeStartSizeGradient(gradient: number): IParticleSystem;
  17908. private _createRampGradientTexture;
  17909. /**
  17910. * Gets the current list of ramp gradients.
  17911. * You must use addRampGradient and removeRampGradient to udpate this list
  17912. * @returns the list of ramp gradients
  17913. */
  17914. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17915. /**
  17916. * Adds a new ramp gradient used to remap particle colors
  17917. * @param gradient defines the gradient to use (between 0 and 1)
  17918. * @param color defines the color to affect to the specified gradient
  17919. * @returns the current particle system
  17920. */
  17921. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17922. /**
  17923. * Remove a specific ramp gradient
  17924. * @param gradient defines the gradient to remove
  17925. * @returns the current particle system
  17926. */
  17927. removeRampGradient(gradient: number): ParticleSystem;
  17928. /**
  17929. * Adds a new color gradient
  17930. * @param gradient defines the gradient to use (between 0 and 1)
  17931. * @param color1 defines the color to affect to the specified gradient
  17932. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17933. * @returns this particle system
  17934. */
  17935. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17936. /**
  17937. * Remove a specific color gradient
  17938. * @param gradient defines the gradient to remove
  17939. * @returns this particle system
  17940. */
  17941. removeColorGradient(gradient: number): IParticleSystem;
  17942. private _fetchR;
  17943. protected _reset(): void;
  17944. private _resetEffect;
  17945. private _createVertexBuffers;
  17946. private _createIndexBuffer;
  17947. /**
  17948. * Gets the maximum number of particles active at the same time.
  17949. * @returns The max number of active particles.
  17950. */
  17951. getCapacity(): number;
  17952. /**
  17953. * Gets whether there are still active particles in the system.
  17954. * @returns True if it is alive, otherwise false.
  17955. */
  17956. isAlive(): boolean;
  17957. /**
  17958. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17959. * @returns True if it has been started, otherwise false.
  17960. */
  17961. isStarted(): boolean;
  17962. private _prepareSubEmitterInternalArray;
  17963. /**
  17964. * Starts the particle system and begins to emit
  17965. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17966. */
  17967. start(delay?: number): void;
  17968. /**
  17969. * Stops the particle system.
  17970. * @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.
  17971. */
  17972. stop(stopSubEmitters?: boolean): void;
  17973. /**
  17974. * Remove all active particles
  17975. */
  17976. reset(): void;
  17977. /**
  17978. * @hidden (for internal use only)
  17979. */
  17980. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17981. /**
  17982. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17983. * Its lifetime will start back at 0.
  17984. */
  17985. recycleParticle: (particle: Particle) => void;
  17986. private _stopSubEmitters;
  17987. private _createParticle;
  17988. private _removeFromRoot;
  17989. private _emitFromParticle;
  17990. private _update;
  17991. /** @hidden */
  17992. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17993. /** @hidden */
  17994. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17995. /** @hidden */
  17996. private _getEffect;
  17997. /**
  17998. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17999. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18000. */
  18001. animate(preWarmOnly?: boolean): void;
  18002. private _appendParticleVertices;
  18003. /**
  18004. * Rebuilds the particle system.
  18005. */
  18006. rebuild(): void;
  18007. /**
  18008. * Is this system ready to be used/rendered
  18009. * @return true if the system is ready
  18010. */
  18011. isReady(): boolean;
  18012. private _render;
  18013. /**
  18014. * Renders the particle system in its current state.
  18015. * @returns the current number of particles
  18016. */
  18017. render(): number;
  18018. /**
  18019. * Disposes the particle system and free the associated resources
  18020. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18021. */
  18022. dispose(disposeTexture?: boolean): void;
  18023. /**
  18024. * Clones the particle system.
  18025. * @param name The name of the cloned object
  18026. * @param newEmitter The new emitter to use
  18027. * @returns the cloned particle system
  18028. */
  18029. clone(name: string, newEmitter: any): ParticleSystem;
  18030. /**
  18031. * Serializes the particle system to a JSON object.
  18032. * @returns the JSON object
  18033. */
  18034. serialize(): any;
  18035. /** @hidden */
  18036. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18037. /** @hidden */
  18038. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18039. /**
  18040. * Parses a JSON object to create a particle system.
  18041. * @param parsedParticleSystem The JSON object to parse
  18042. * @param scene The scene to create the particle system in
  18043. * @param rootUrl The root url to use to load external dependencies like texture
  18044. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18045. * @returns the Parsed particle system
  18046. */
  18047. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18048. }
  18049. }
  18050. declare module "babylonjs/Particles/particle" {
  18051. import { Nullable } from "babylonjs/types";
  18052. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18053. import { Color4 } from "babylonjs/Maths/math.color";
  18054. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18055. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18056. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18057. /**
  18058. * A particle represents one of the element emitted by a particle system.
  18059. * This is mainly define by its coordinates, direction, velocity and age.
  18060. */
  18061. export class Particle {
  18062. /**
  18063. * The particle system the particle belongs to.
  18064. */
  18065. particleSystem: ParticleSystem;
  18066. private static _Count;
  18067. /**
  18068. * Unique ID of the particle
  18069. */
  18070. id: number;
  18071. /**
  18072. * The world position of the particle in the scene.
  18073. */
  18074. position: Vector3;
  18075. /**
  18076. * The world direction of the particle in the scene.
  18077. */
  18078. direction: Vector3;
  18079. /**
  18080. * The color of the particle.
  18081. */
  18082. color: Color4;
  18083. /**
  18084. * The color change of the particle per step.
  18085. */
  18086. colorStep: Color4;
  18087. /**
  18088. * Defines how long will the life of the particle be.
  18089. */
  18090. lifeTime: number;
  18091. /**
  18092. * The current age of the particle.
  18093. */
  18094. age: number;
  18095. /**
  18096. * The current size of the particle.
  18097. */
  18098. size: number;
  18099. /**
  18100. * The current scale of the particle.
  18101. */
  18102. scale: Vector2;
  18103. /**
  18104. * The current angle of the particle.
  18105. */
  18106. angle: number;
  18107. /**
  18108. * Defines how fast is the angle changing.
  18109. */
  18110. angularSpeed: number;
  18111. /**
  18112. * Defines the cell index used by the particle to be rendered from a sprite.
  18113. */
  18114. cellIndex: number;
  18115. /**
  18116. * The information required to support color remapping
  18117. */
  18118. remapData: Vector4;
  18119. /** @hidden */
  18120. _randomCellOffset?: number;
  18121. /** @hidden */
  18122. _initialDirection: Nullable<Vector3>;
  18123. /** @hidden */
  18124. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18125. /** @hidden */
  18126. _initialStartSpriteCellID: number;
  18127. /** @hidden */
  18128. _initialEndSpriteCellID: number;
  18129. /** @hidden */
  18130. _currentColorGradient: Nullable<ColorGradient>;
  18131. /** @hidden */
  18132. _currentColor1: Color4;
  18133. /** @hidden */
  18134. _currentColor2: Color4;
  18135. /** @hidden */
  18136. _currentSizeGradient: Nullable<FactorGradient>;
  18137. /** @hidden */
  18138. _currentSize1: number;
  18139. /** @hidden */
  18140. _currentSize2: number;
  18141. /** @hidden */
  18142. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18143. /** @hidden */
  18144. _currentAngularSpeed1: number;
  18145. /** @hidden */
  18146. _currentAngularSpeed2: number;
  18147. /** @hidden */
  18148. _currentVelocityGradient: Nullable<FactorGradient>;
  18149. /** @hidden */
  18150. _currentVelocity1: number;
  18151. /** @hidden */
  18152. _currentVelocity2: number;
  18153. /** @hidden */
  18154. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18155. /** @hidden */
  18156. _currentLimitVelocity1: number;
  18157. /** @hidden */
  18158. _currentLimitVelocity2: number;
  18159. /** @hidden */
  18160. _currentDragGradient: Nullable<FactorGradient>;
  18161. /** @hidden */
  18162. _currentDrag1: number;
  18163. /** @hidden */
  18164. _currentDrag2: number;
  18165. /** @hidden */
  18166. _randomNoiseCoordinates1: Vector3;
  18167. /** @hidden */
  18168. _randomNoiseCoordinates2: Vector3;
  18169. /**
  18170. * Creates a new instance Particle
  18171. * @param particleSystem the particle system the particle belongs to
  18172. */
  18173. constructor(
  18174. /**
  18175. * The particle system the particle belongs to.
  18176. */
  18177. particleSystem: ParticleSystem);
  18178. private updateCellInfoFromSystem;
  18179. /**
  18180. * Defines how the sprite cell index is updated for the particle
  18181. */
  18182. updateCellIndex(): void;
  18183. /** @hidden */
  18184. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18185. /** @hidden */
  18186. _inheritParticleInfoToSubEmitters(): void;
  18187. /** @hidden */
  18188. _reset(): void;
  18189. /**
  18190. * Copy the properties of particle to another one.
  18191. * @param other the particle to copy the information to.
  18192. */
  18193. copyTo(other: Particle): void;
  18194. }
  18195. }
  18196. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18197. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18198. import { Effect } from "babylonjs/Materials/effect";
  18199. import { Particle } from "babylonjs/Particles/particle";
  18200. /**
  18201. * Particle emitter represents a volume emitting particles.
  18202. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18203. */
  18204. export interface IParticleEmitterType {
  18205. /**
  18206. * Called by the particle System when the direction is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param directionToUpdate is the direction vector to update with the result
  18209. * @param particle is the particle we are computed the direction for
  18210. */
  18211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Called by the particle System when the position is computed for the created particle.
  18214. * @param worldMatrix is the world matrix of the particle system
  18215. * @param positionToUpdate is the position vector to update with the result
  18216. * @param particle is the particle we are computed the position for
  18217. */
  18218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18219. /**
  18220. * Clones the current emitter and returns a copy of it
  18221. * @returns the new emitter
  18222. */
  18223. clone(): IParticleEmitterType;
  18224. /**
  18225. * Called by the GPUParticleSystem to setup the update shader
  18226. * @param effect defines the update shader
  18227. */
  18228. applyToShader(effect: Effect): void;
  18229. /**
  18230. * Returns a string to use to update the GPU particles update shader
  18231. * @returns the effect defines string
  18232. */
  18233. getEffectDefines(): string;
  18234. /**
  18235. * Returns a string representing the class name
  18236. * @returns a string containing the class name
  18237. */
  18238. getClassName(): string;
  18239. /**
  18240. * Serializes the particle system to a JSON object.
  18241. * @returns the JSON object
  18242. */
  18243. serialize(): any;
  18244. /**
  18245. * Parse properties from a JSON object
  18246. * @param serializationObject defines the JSON object
  18247. */
  18248. parse(serializationObject: any): void;
  18249. }
  18250. }
  18251. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18252. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18253. import { Effect } from "babylonjs/Materials/effect";
  18254. import { Particle } from "babylonjs/Particles/particle";
  18255. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18256. /**
  18257. * Particle emitter emitting particles from the inside of a box.
  18258. * It emits the particles randomly between 2 given directions.
  18259. */
  18260. export class BoxParticleEmitter implements IParticleEmitterType {
  18261. /**
  18262. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18263. */
  18264. direction1: Vector3;
  18265. /**
  18266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18267. */
  18268. direction2: Vector3;
  18269. /**
  18270. * 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.
  18271. */
  18272. minEmitBox: Vector3;
  18273. /**
  18274. * 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.
  18275. */
  18276. maxEmitBox: Vector3;
  18277. /**
  18278. * Creates a new instance BoxParticleEmitter
  18279. */
  18280. constructor();
  18281. /**
  18282. * Called by the particle System when the direction is computed for the created particle.
  18283. * @param worldMatrix is the world matrix of the particle system
  18284. * @param directionToUpdate is the direction vector to update with the result
  18285. * @param particle is the particle we are computed the direction for
  18286. */
  18287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18288. /**
  18289. * Called by the particle System when the position is computed for the created particle.
  18290. * @param worldMatrix is the world matrix of the particle system
  18291. * @param positionToUpdate is the position vector to update with the result
  18292. * @param particle is the particle we are computed the position for
  18293. */
  18294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18295. /**
  18296. * Clones the current emitter and returns a copy of it
  18297. * @returns the new emitter
  18298. */
  18299. clone(): BoxParticleEmitter;
  18300. /**
  18301. * Called by the GPUParticleSystem to setup the update shader
  18302. * @param effect defines the update shader
  18303. */
  18304. applyToShader(effect: Effect): void;
  18305. /**
  18306. * Returns a string to use to update the GPU particles update shader
  18307. * @returns a string containng the defines string
  18308. */
  18309. getEffectDefines(): string;
  18310. /**
  18311. * Returns the string "BoxParticleEmitter"
  18312. * @returns a string containing the class name
  18313. */
  18314. getClassName(): string;
  18315. /**
  18316. * Serializes the particle system to a JSON object.
  18317. * @returns the JSON object
  18318. */
  18319. serialize(): any;
  18320. /**
  18321. * Parse properties from a JSON object
  18322. * @param serializationObject defines the JSON object
  18323. */
  18324. parse(serializationObject: any): void;
  18325. }
  18326. }
  18327. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18328. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18329. import { Effect } from "babylonjs/Materials/effect";
  18330. import { Particle } from "babylonjs/Particles/particle";
  18331. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18332. /**
  18333. * Particle emitter emitting particles from the inside of a cone.
  18334. * It emits the particles alongside the cone volume from the base to the particle.
  18335. * The emission direction might be randomized.
  18336. */
  18337. export class ConeParticleEmitter implements IParticleEmitterType {
  18338. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18339. directionRandomizer: number;
  18340. private _radius;
  18341. private _angle;
  18342. private _height;
  18343. /**
  18344. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18345. */
  18346. radiusRange: number;
  18347. /**
  18348. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18349. */
  18350. heightRange: number;
  18351. /**
  18352. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18353. */
  18354. emitFromSpawnPointOnly: boolean;
  18355. /**
  18356. * Gets or sets the radius of the emission cone
  18357. */
  18358. radius: number;
  18359. /**
  18360. * Gets or sets the angle of the emission cone
  18361. */
  18362. angle: number;
  18363. private _buildHeight;
  18364. /**
  18365. * Creates a new instance ConeParticleEmitter
  18366. * @param radius the radius of the emission cone (1 by default)
  18367. * @param angle the cone base angle (PI by default)
  18368. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18369. */
  18370. constructor(radius?: number, angle?: number,
  18371. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18372. directionRandomizer?: number);
  18373. /**
  18374. * Called by the particle System when the direction is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param directionToUpdate is the direction vector to update with the result
  18377. * @param particle is the particle we are computed the direction for
  18378. */
  18379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Called by the particle System when the position is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param positionToUpdate is the position vector to update with the result
  18384. * @param particle is the particle we are computed the position for
  18385. */
  18386. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Clones the current emitter and returns a copy of it
  18389. * @returns the new emitter
  18390. */
  18391. clone(): ConeParticleEmitter;
  18392. /**
  18393. * Called by the GPUParticleSystem to setup the update shader
  18394. * @param effect defines the update shader
  18395. */
  18396. applyToShader(effect: Effect): void;
  18397. /**
  18398. * Returns a string to use to update the GPU particles update shader
  18399. * @returns a string containng the defines string
  18400. */
  18401. getEffectDefines(): string;
  18402. /**
  18403. * Returns the string "ConeParticleEmitter"
  18404. * @returns a string containing the class name
  18405. */
  18406. getClassName(): string;
  18407. /**
  18408. * Serializes the particle system to a JSON object.
  18409. * @returns the JSON object
  18410. */
  18411. serialize(): any;
  18412. /**
  18413. * Parse properties from a JSON object
  18414. * @param serializationObject defines the JSON object
  18415. */
  18416. parse(serializationObject: any): void;
  18417. }
  18418. }
  18419. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18420. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18421. import { Effect } from "babylonjs/Materials/effect";
  18422. import { Particle } from "babylonjs/Particles/particle";
  18423. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18424. /**
  18425. * Particle emitter emitting particles from the inside of a cylinder.
  18426. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18427. */
  18428. export class CylinderParticleEmitter implements IParticleEmitterType {
  18429. /**
  18430. * The radius of the emission cylinder.
  18431. */
  18432. radius: number;
  18433. /**
  18434. * The height of the emission cylinder.
  18435. */
  18436. height: number;
  18437. /**
  18438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18439. */
  18440. radiusRange: number;
  18441. /**
  18442. * How much to randomize the particle direction [0-1].
  18443. */
  18444. directionRandomizer: number;
  18445. /**
  18446. * Creates a new instance CylinderParticleEmitter
  18447. * @param radius the radius of the emission cylinder (1 by default)
  18448. * @param height the height of the emission cylinder (1 by default)
  18449. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18450. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18451. */
  18452. constructor(
  18453. /**
  18454. * The radius of the emission cylinder.
  18455. */
  18456. radius?: number,
  18457. /**
  18458. * The height of the emission cylinder.
  18459. */
  18460. height?: number,
  18461. /**
  18462. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18463. */
  18464. radiusRange?: number,
  18465. /**
  18466. * How much to randomize the particle direction [0-1].
  18467. */
  18468. directionRandomizer?: number);
  18469. /**
  18470. * Called by the particle System when the direction is computed for the created particle.
  18471. * @param worldMatrix is the world matrix of the particle system
  18472. * @param directionToUpdate is the direction vector to update with the result
  18473. * @param particle is the particle we are computed the direction for
  18474. */
  18475. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18476. /**
  18477. * Called by the particle System when the position is computed for the created particle.
  18478. * @param worldMatrix is the world matrix of the particle system
  18479. * @param positionToUpdate is the position vector to update with the result
  18480. * @param particle is the particle we are computed the position for
  18481. */
  18482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18483. /**
  18484. * Clones the current emitter and returns a copy of it
  18485. * @returns the new emitter
  18486. */
  18487. clone(): CylinderParticleEmitter;
  18488. /**
  18489. * Called by the GPUParticleSystem to setup the update shader
  18490. * @param effect defines the update shader
  18491. */
  18492. applyToShader(effect: Effect): void;
  18493. /**
  18494. * Returns a string to use to update the GPU particles update shader
  18495. * @returns a string containng the defines string
  18496. */
  18497. getEffectDefines(): string;
  18498. /**
  18499. * Returns the string "CylinderParticleEmitter"
  18500. * @returns a string containing the class name
  18501. */
  18502. getClassName(): string;
  18503. /**
  18504. * Serializes the particle system to a JSON object.
  18505. * @returns the JSON object
  18506. */
  18507. serialize(): any;
  18508. /**
  18509. * Parse properties from a JSON object
  18510. * @param serializationObject defines the JSON object
  18511. */
  18512. parse(serializationObject: any): void;
  18513. }
  18514. /**
  18515. * Particle emitter emitting particles from the inside of a cylinder.
  18516. * It emits the particles randomly between two vectors.
  18517. */
  18518. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18519. /**
  18520. * The min limit of the emission direction.
  18521. */
  18522. direction1: Vector3;
  18523. /**
  18524. * The max limit of the emission direction.
  18525. */
  18526. direction2: Vector3;
  18527. /**
  18528. * Creates a new instance CylinderDirectedParticleEmitter
  18529. * @param radius the radius of the emission cylinder (1 by default)
  18530. * @param height the height of the emission cylinder (1 by default)
  18531. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18532. * @param direction1 the min limit of the emission direction (up vector by default)
  18533. * @param direction2 the max limit of the emission direction (up vector by default)
  18534. */
  18535. constructor(radius?: number, height?: number, radiusRange?: number,
  18536. /**
  18537. * The min limit of the emission direction.
  18538. */
  18539. direction1?: Vector3,
  18540. /**
  18541. * The max limit of the emission direction.
  18542. */
  18543. direction2?: Vector3);
  18544. /**
  18545. * Called by the particle System when the direction is computed for the created particle.
  18546. * @param worldMatrix is the world matrix of the particle system
  18547. * @param directionToUpdate is the direction vector to update with the result
  18548. * @param particle is the particle we are computed the direction for
  18549. */
  18550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18551. /**
  18552. * Clones the current emitter and returns a copy of it
  18553. * @returns the new emitter
  18554. */
  18555. clone(): CylinderDirectedParticleEmitter;
  18556. /**
  18557. * Called by the GPUParticleSystem to setup the update shader
  18558. * @param effect defines the update shader
  18559. */
  18560. applyToShader(effect: Effect): void;
  18561. /**
  18562. * Returns a string to use to update the GPU particles update shader
  18563. * @returns a string containng the defines string
  18564. */
  18565. getEffectDefines(): string;
  18566. /**
  18567. * Returns the string "CylinderDirectedParticleEmitter"
  18568. * @returns a string containing the class name
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * Serializes the particle system to a JSON object.
  18573. * @returns the JSON object
  18574. */
  18575. serialize(): any;
  18576. /**
  18577. * Parse properties from a JSON object
  18578. * @param serializationObject defines the JSON object
  18579. */
  18580. parse(serializationObject: any): void;
  18581. }
  18582. }
  18583. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18585. import { Effect } from "babylonjs/Materials/effect";
  18586. import { Particle } from "babylonjs/Particles/particle";
  18587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18588. /**
  18589. * Particle emitter emitting particles from the inside of a hemisphere.
  18590. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18591. */
  18592. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18593. /**
  18594. * The radius of the emission hemisphere.
  18595. */
  18596. radius: number;
  18597. /**
  18598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18599. */
  18600. radiusRange: number;
  18601. /**
  18602. * How much to randomize the particle direction [0-1].
  18603. */
  18604. directionRandomizer: number;
  18605. /**
  18606. * Creates a new instance HemisphericParticleEmitter
  18607. * @param radius the radius of the emission hemisphere (1 by default)
  18608. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18610. */
  18611. constructor(
  18612. /**
  18613. * The radius of the emission hemisphere.
  18614. */
  18615. radius?: number,
  18616. /**
  18617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18618. */
  18619. radiusRange?: number,
  18620. /**
  18621. * How much to randomize the particle direction [0-1].
  18622. */
  18623. directionRandomizer?: number);
  18624. /**
  18625. * Called by the particle System when the direction is computed for the created particle.
  18626. * @param worldMatrix is the world matrix of the particle system
  18627. * @param directionToUpdate is the direction vector to update with the result
  18628. * @param particle is the particle we are computed the direction for
  18629. */
  18630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18631. /**
  18632. * Called by the particle System when the position is computed for the created particle.
  18633. * @param worldMatrix is the world matrix of the particle system
  18634. * @param positionToUpdate is the position vector to update with the result
  18635. * @param particle is the particle we are computed the position for
  18636. */
  18637. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18638. /**
  18639. * Clones the current emitter and returns a copy of it
  18640. * @returns the new emitter
  18641. */
  18642. clone(): HemisphericParticleEmitter;
  18643. /**
  18644. * Called by the GPUParticleSystem to setup the update shader
  18645. * @param effect defines the update shader
  18646. */
  18647. applyToShader(effect: Effect): void;
  18648. /**
  18649. * Returns a string to use to update the GPU particles update shader
  18650. * @returns a string containng the defines string
  18651. */
  18652. getEffectDefines(): string;
  18653. /**
  18654. * Returns the string "HemisphericParticleEmitter"
  18655. * @returns a string containing the class name
  18656. */
  18657. getClassName(): string;
  18658. /**
  18659. * Serializes the particle system to a JSON object.
  18660. * @returns the JSON object
  18661. */
  18662. serialize(): any;
  18663. /**
  18664. * Parse properties from a JSON object
  18665. * @param serializationObject defines the JSON object
  18666. */
  18667. parse(serializationObject: any): void;
  18668. }
  18669. }
  18670. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18671. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18672. import { Effect } from "babylonjs/Materials/effect";
  18673. import { Particle } from "babylonjs/Particles/particle";
  18674. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18675. /**
  18676. * Particle emitter emitting particles from a point.
  18677. * It emits the particles randomly between 2 given directions.
  18678. */
  18679. export class PointParticleEmitter implements IParticleEmitterType {
  18680. /**
  18681. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18682. */
  18683. direction1: Vector3;
  18684. /**
  18685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18686. */
  18687. direction2: Vector3;
  18688. /**
  18689. * Creates a new instance PointParticleEmitter
  18690. */
  18691. constructor();
  18692. /**
  18693. * Called by the particle System when the direction is computed for the created particle.
  18694. * @param worldMatrix is the world matrix of the particle system
  18695. * @param directionToUpdate is the direction vector to update with the result
  18696. * @param particle is the particle we are computed the direction for
  18697. */
  18698. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18699. /**
  18700. * Called by the particle System when the position is computed for the created particle.
  18701. * @param worldMatrix is the world matrix of the particle system
  18702. * @param positionToUpdate is the position vector to update with the result
  18703. * @param particle is the particle we are computed the position for
  18704. */
  18705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18706. /**
  18707. * Clones the current emitter and returns a copy of it
  18708. * @returns the new emitter
  18709. */
  18710. clone(): PointParticleEmitter;
  18711. /**
  18712. * Called by the GPUParticleSystem to setup the update shader
  18713. * @param effect defines the update shader
  18714. */
  18715. applyToShader(effect: Effect): void;
  18716. /**
  18717. * Returns a string to use to update the GPU particles update shader
  18718. * @returns a string containng the defines string
  18719. */
  18720. getEffectDefines(): string;
  18721. /**
  18722. * Returns the string "PointParticleEmitter"
  18723. * @returns a string containing the class name
  18724. */
  18725. getClassName(): string;
  18726. /**
  18727. * Serializes the particle system to a JSON object.
  18728. * @returns the JSON object
  18729. */
  18730. serialize(): any;
  18731. /**
  18732. * Parse properties from a JSON object
  18733. * @param serializationObject defines the JSON object
  18734. */
  18735. parse(serializationObject: any): void;
  18736. }
  18737. }
  18738. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18740. import { Effect } from "babylonjs/Materials/effect";
  18741. import { Particle } from "babylonjs/Particles/particle";
  18742. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18743. /**
  18744. * Particle emitter emitting particles from the inside of a sphere.
  18745. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18746. */
  18747. export class SphereParticleEmitter implements IParticleEmitterType {
  18748. /**
  18749. * The radius of the emission sphere.
  18750. */
  18751. radius: number;
  18752. /**
  18753. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18754. */
  18755. radiusRange: number;
  18756. /**
  18757. * How much to randomize the particle direction [0-1].
  18758. */
  18759. directionRandomizer: number;
  18760. /**
  18761. * Creates a new instance SphereParticleEmitter
  18762. * @param radius the radius of the emission sphere (1 by default)
  18763. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18764. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18765. */
  18766. constructor(
  18767. /**
  18768. * The radius of the emission sphere.
  18769. */
  18770. radius?: number,
  18771. /**
  18772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18773. */
  18774. radiusRange?: number,
  18775. /**
  18776. * How much to randomize the particle direction [0-1].
  18777. */
  18778. directionRandomizer?: number);
  18779. /**
  18780. * Called by the particle System when the direction is computed for the created particle.
  18781. * @param worldMatrix is the world matrix of the particle system
  18782. * @param directionToUpdate is the direction vector to update with the result
  18783. * @param particle is the particle we are computed the direction for
  18784. */
  18785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18786. /**
  18787. * Called by the particle System when the position is computed for the created particle.
  18788. * @param worldMatrix is the world matrix of the particle system
  18789. * @param positionToUpdate is the position vector to update with the result
  18790. * @param particle is the particle we are computed the position for
  18791. */
  18792. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18793. /**
  18794. * Clones the current emitter and returns a copy of it
  18795. * @returns the new emitter
  18796. */
  18797. clone(): SphereParticleEmitter;
  18798. /**
  18799. * Called by the GPUParticleSystem to setup the update shader
  18800. * @param effect defines the update shader
  18801. */
  18802. applyToShader(effect: Effect): void;
  18803. /**
  18804. * Returns a string to use to update the GPU particles update shader
  18805. * @returns a string containng the defines string
  18806. */
  18807. getEffectDefines(): string;
  18808. /**
  18809. * Returns the string "SphereParticleEmitter"
  18810. * @returns a string containing the class name
  18811. */
  18812. getClassName(): string;
  18813. /**
  18814. * Serializes the particle system to a JSON object.
  18815. * @returns the JSON object
  18816. */
  18817. serialize(): any;
  18818. /**
  18819. * Parse properties from a JSON object
  18820. * @param serializationObject defines the JSON object
  18821. */
  18822. parse(serializationObject: any): void;
  18823. }
  18824. /**
  18825. * Particle emitter emitting particles from the inside of a sphere.
  18826. * It emits the particles randomly between two vectors.
  18827. */
  18828. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18829. /**
  18830. * The min limit of the emission direction.
  18831. */
  18832. direction1: Vector3;
  18833. /**
  18834. * The max limit of the emission direction.
  18835. */
  18836. direction2: Vector3;
  18837. /**
  18838. * Creates a new instance SphereDirectedParticleEmitter
  18839. * @param radius the radius of the emission sphere (1 by default)
  18840. * @param direction1 the min limit of the emission direction (up vector by default)
  18841. * @param direction2 the max limit of the emission direction (up vector by default)
  18842. */
  18843. constructor(radius?: number,
  18844. /**
  18845. * The min limit of the emission direction.
  18846. */
  18847. direction1?: Vector3,
  18848. /**
  18849. * The max limit of the emission direction.
  18850. */
  18851. direction2?: Vector3);
  18852. /**
  18853. * Called by the particle System when the direction is computed for the created particle.
  18854. * @param worldMatrix is the world matrix of the particle system
  18855. * @param directionToUpdate is the direction vector to update with the result
  18856. * @param particle is the particle we are computed the direction for
  18857. */
  18858. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18859. /**
  18860. * Clones the current emitter and returns a copy of it
  18861. * @returns the new emitter
  18862. */
  18863. clone(): SphereDirectedParticleEmitter;
  18864. /**
  18865. * Called by the GPUParticleSystem to setup the update shader
  18866. * @param effect defines the update shader
  18867. */
  18868. applyToShader(effect: Effect): void;
  18869. /**
  18870. * Returns a string to use to update the GPU particles update shader
  18871. * @returns a string containng the defines string
  18872. */
  18873. getEffectDefines(): string;
  18874. /**
  18875. * Returns the string "SphereDirectedParticleEmitter"
  18876. * @returns a string containing the class name
  18877. */
  18878. getClassName(): string;
  18879. /**
  18880. * Serializes the particle system to a JSON object.
  18881. * @returns the JSON object
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Parse properties from a JSON object
  18886. * @param serializationObject defines the JSON object
  18887. */
  18888. parse(serializationObject: any): void;
  18889. }
  18890. }
  18891. declare module "babylonjs/Particles/EmitterTypes/index" {
  18892. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18893. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18894. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18895. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18896. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18897. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18898. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18899. }
  18900. declare module "babylonjs/Particles/IParticleSystem" {
  18901. import { Nullable } from "babylonjs/types";
  18902. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18903. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18906. import { Texture } from "babylonjs/Materials/Textures/texture";
  18907. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18908. import { Scene } from "babylonjs/scene";
  18909. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18910. import { Animation } from "babylonjs/Animations/animation";
  18911. /**
  18912. * Interface representing a particle system in Babylon.js.
  18913. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18914. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18915. */
  18916. export interface IParticleSystem {
  18917. /**
  18918. * List of animations used by the particle system.
  18919. */
  18920. animations: Animation[];
  18921. /**
  18922. * The id of the Particle system.
  18923. */
  18924. id: string;
  18925. /**
  18926. * The name of the Particle system.
  18927. */
  18928. name: string;
  18929. /**
  18930. * The emitter represents the Mesh or position we are attaching the particle system to.
  18931. */
  18932. emitter: Nullable<AbstractMesh | Vector3>;
  18933. /**
  18934. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18935. */
  18936. isBillboardBased: boolean;
  18937. /**
  18938. * The rendering group used by the Particle system to chose when to render.
  18939. */
  18940. renderingGroupId: number;
  18941. /**
  18942. * The layer mask we are rendering the particles through.
  18943. */
  18944. layerMask: number;
  18945. /**
  18946. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18947. */
  18948. updateSpeed: number;
  18949. /**
  18950. * The amount of time the particle system is running (depends of the overall update speed).
  18951. */
  18952. targetStopDuration: number;
  18953. /**
  18954. * The texture used to render each particle. (this can be a spritesheet)
  18955. */
  18956. particleTexture: Nullable<Texture>;
  18957. /**
  18958. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18959. */
  18960. blendMode: number;
  18961. /**
  18962. * Minimum life time of emitting particles.
  18963. */
  18964. minLifeTime: number;
  18965. /**
  18966. * Maximum life time of emitting particles.
  18967. */
  18968. maxLifeTime: number;
  18969. /**
  18970. * Minimum Size of emitting particles.
  18971. */
  18972. minSize: number;
  18973. /**
  18974. * Maximum Size of emitting particles.
  18975. */
  18976. maxSize: number;
  18977. /**
  18978. * Minimum scale of emitting particles on X axis.
  18979. */
  18980. minScaleX: number;
  18981. /**
  18982. * Maximum scale of emitting particles on X axis.
  18983. */
  18984. maxScaleX: number;
  18985. /**
  18986. * Minimum scale of emitting particles on Y axis.
  18987. */
  18988. minScaleY: number;
  18989. /**
  18990. * Maximum scale of emitting particles on Y axis.
  18991. */
  18992. maxScaleY: number;
  18993. /**
  18994. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18995. */
  18996. color1: Color4;
  18997. /**
  18998. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18999. */
  19000. color2: Color4;
  19001. /**
  19002. * Color the particle will have at the end of its lifetime.
  19003. */
  19004. colorDead: Color4;
  19005. /**
  19006. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19007. */
  19008. emitRate: number;
  19009. /**
  19010. * You can use gravity if you want to give an orientation to your particles.
  19011. */
  19012. gravity: Vector3;
  19013. /**
  19014. * Minimum power of emitting particles.
  19015. */
  19016. minEmitPower: number;
  19017. /**
  19018. * Maximum power of emitting particles.
  19019. */
  19020. maxEmitPower: number;
  19021. /**
  19022. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19023. */
  19024. minAngularSpeed: number;
  19025. /**
  19026. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19027. */
  19028. maxAngularSpeed: number;
  19029. /**
  19030. * Gets or sets the minimal initial rotation in radians.
  19031. */
  19032. minInitialRotation: number;
  19033. /**
  19034. * Gets or sets the maximal initial rotation in radians.
  19035. */
  19036. maxInitialRotation: number;
  19037. /**
  19038. * The particle emitter type defines the emitter used by the particle system.
  19039. * It can be for example box, sphere, or cone...
  19040. */
  19041. particleEmitterType: Nullable<IParticleEmitterType>;
  19042. /**
  19043. * Defines the delay in milliseconds before starting the system (0 by default)
  19044. */
  19045. startDelay: number;
  19046. /**
  19047. * 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
  19048. */
  19049. preWarmCycles: number;
  19050. /**
  19051. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19052. */
  19053. preWarmStepOffset: number;
  19054. /**
  19055. * 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)
  19056. */
  19057. spriteCellChangeSpeed: number;
  19058. /**
  19059. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19060. */
  19061. startSpriteCellID: number;
  19062. /**
  19063. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19064. */
  19065. endSpriteCellID: number;
  19066. /**
  19067. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19068. */
  19069. spriteCellWidth: number;
  19070. /**
  19071. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19072. */
  19073. spriteCellHeight: number;
  19074. /**
  19075. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19076. */
  19077. spriteRandomStartCell: boolean;
  19078. /**
  19079. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19080. */
  19081. isAnimationSheetEnabled: boolean;
  19082. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19083. translationPivot: Vector2;
  19084. /**
  19085. * Gets or sets a texture used to add random noise to particle positions
  19086. */
  19087. noiseTexture: Nullable<BaseTexture>;
  19088. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19089. noiseStrength: Vector3;
  19090. /**
  19091. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19092. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19093. */
  19094. billboardMode: number;
  19095. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19096. limitVelocityDamping: number;
  19097. /**
  19098. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19099. */
  19100. beginAnimationOnStart: boolean;
  19101. /**
  19102. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19103. */
  19104. beginAnimationFrom: number;
  19105. /**
  19106. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19107. */
  19108. beginAnimationTo: number;
  19109. /**
  19110. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19111. */
  19112. beginAnimationLoop: boolean;
  19113. /**
  19114. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19115. */
  19116. disposeOnStop: boolean;
  19117. /**
  19118. * Gets the maximum number of particles active at the same time.
  19119. * @returns The max number of active particles.
  19120. */
  19121. getCapacity(): number;
  19122. /**
  19123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19124. * @returns True if it has been started, otherwise false.
  19125. */
  19126. isStarted(): boolean;
  19127. /**
  19128. * Animates the particle system for this frame.
  19129. */
  19130. animate(): void;
  19131. /**
  19132. * Renders the particle system in its current state.
  19133. * @returns the current number of particles
  19134. */
  19135. render(): number;
  19136. /**
  19137. * Dispose the particle system and frees its associated resources.
  19138. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19139. */
  19140. dispose(disposeTexture?: boolean): void;
  19141. /**
  19142. * Clones the particle system.
  19143. * @param name The name of the cloned object
  19144. * @param newEmitter The new emitter to use
  19145. * @returns the cloned particle system
  19146. */
  19147. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19148. /**
  19149. * Serializes the particle system to a JSON object.
  19150. * @returns the JSON object
  19151. */
  19152. serialize(): any;
  19153. /**
  19154. * Rebuild the particle system
  19155. */
  19156. rebuild(): void;
  19157. /**
  19158. * Starts the particle system and begins to emit
  19159. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19160. */
  19161. start(delay?: number): void;
  19162. /**
  19163. * Stops the particle system.
  19164. */
  19165. stop(): void;
  19166. /**
  19167. * Remove all active particles
  19168. */
  19169. reset(): void;
  19170. /**
  19171. * Is this system ready to be used/rendered
  19172. * @return true if the system is ready
  19173. */
  19174. isReady(): boolean;
  19175. /**
  19176. * Adds a new color gradient
  19177. * @param gradient defines the gradient to use (between 0 and 1)
  19178. * @param color1 defines the color to affect to the specified gradient
  19179. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19180. * @returns the current particle system
  19181. */
  19182. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19183. /**
  19184. * Remove a specific color gradient
  19185. * @param gradient defines the gradient to remove
  19186. * @returns the current particle system
  19187. */
  19188. removeColorGradient(gradient: number): IParticleSystem;
  19189. /**
  19190. * Adds a new size gradient
  19191. * @param gradient defines the gradient to use (between 0 and 1)
  19192. * @param factor defines the size factor to affect to the specified gradient
  19193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19194. * @returns the current particle system
  19195. */
  19196. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19197. /**
  19198. * Remove a specific size gradient
  19199. * @param gradient defines the gradient to remove
  19200. * @returns the current particle system
  19201. */
  19202. removeSizeGradient(gradient: number): IParticleSystem;
  19203. /**
  19204. * Gets the current list of color gradients.
  19205. * You must use addColorGradient and removeColorGradient to udpate this list
  19206. * @returns the list of color gradients
  19207. */
  19208. getColorGradients(): Nullable<Array<ColorGradient>>;
  19209. /**
  19210. * Gets the current list of size gradients.
  19211. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19212. * @returns the list of size gradients
  19213. */
  19214. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19215. /**
  19216. * Gets the current list of angular speed gradients.
  19217. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19218. * @returns the list of angular speed gradients
  19219. */
  19220. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19221. /**
  19222. * Adds a new angular speed gradient
  19223. * @param gradient defines the gradient to use (between 0 and 1)
  19224. * @param factor defines the angular speed to affect to the specified gradient
  19225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19226. * @returns the current particle system
  19227. */
  19228. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19229. /**
  19230. * Remove a specific angular speed gradient
  19231. * @param gradient defines the gradient to remove
  19232. * @returns the current particle system
  19233. */
  19234. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19235. /**
  19236. * Gets the current list of velocity gradients.
  19237. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19238. * @returns the list of velocity gradients
  19239. */
  19240. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19241. /**
  19242. * Adds a new velocity gradient
  19243. * @param gradient defines the gradient to use (between 0 and 1)
  19244. * @param factor defines the velocity to affect to the specified gradient
  19245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19246. * @returns the current particle system
  19247. */
  19248. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19249. /**
  19250. * Remove a specific velocity gradient
  19251. * @param gradient defines the gradient to remove
  19252. * @returns the current particle system
  19253. */
  19254. removeVelocityGradient(gradient: number): IParticleSystem;
  19255. /**
  19256. * Gets the current list of limit velocity gradients.
  19257. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19258. * @returns the list of limit velocity gradients
  19259. */
  19260. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19261. /**
  19262. * Adds a new limit velocity gradient
  19263. * @param gradient defines the gradient to use (between 0 and 1)
  19264. * @param factor defines the limit velocity to affect to the specified gradient
  19265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19266. * @returns the current particle system
  19267. */
  19268. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19269. /**
  19270. * Remove a specific limit velocity gradient
  19271. * @param gradient defines the gradient to remove
  19272. * @returns the current particle system
  19273. */
  19274. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19275. /**
  19276. * Adds a new drag gradient
  19277. * @param gradient defines the gradient to use (between 0 and 1)
  19278. * @param factor defines the drag to affect to the specified gradient
  19279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19280. * @returns the current particle system
  19281. */
  19282. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19283. /**
  19284. * Remove a specific drag gradient
  19285. * @param gradient defines the gradient to remove
  19286. * @returns the current particle system
  19287. */
  19288. removeDragGradient(gradient: number): IParticleSystem;
  19289. /**
  19290. * Gets the current list of drag gradients.
  19291. * You must use addDragGradient and removeDragGradient to udpate this list
  19292. * @returns the list of drag gradients
  19293. */
  19294. getDragGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19297. * @param gradient defines the gradient to use (between 0 and 1)
  19298. * @param factor defines the emit rate to affect to the specified gradient
  19299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19300. * @returns the current particle system
  19301. */
  19302. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19303. /**
  19304. * Remove a specific emit rate gradient
  19305. * @param gradient defines the gradient to remove
  19306. * @returns the current particle system
  19307. */
  19308. removeEmitRateGradient(gradient: number): IParticleSystem;
  19309. /**
  19310. * Gets the current list of emit rate gradients.
  19311. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19312. * @returns the list of emit rate gradients
  19313. */
  19314. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19315. /**
  19316. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19317. * @param gradient defines the gradient to use (between 0 and 1)
  19318. * @param factor defines the start size to affect to the specified gradient
  19319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19320. * @returns the current particle system
  19321. */
  19322. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19323. /**
  19324. * Remove a specific start size gradient
  19325. * @param gradient defines the gradient to remove
  19326. * @returns the current particle system
  19327. */
  19328. removeStartSizeGradient(gradient: number): IParticleSystem;
  19329. /**
  19330. * Gets the current list of start size gradients.
  19331. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19332. * @returns the list of start size gradients
  19333. */
  19334. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19335. /**
  19336. * Adds a new life time gradient
  19337. * @param gradient defines the gradient to use (between 0 and 1)
  19338. * @param factor defines the life time factor to affect to the specified gradient
  19339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19340. * @returns the current particle system
  19341. */
  19342. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19343. /**
  19344. * Remove a specific life time gradient
  19345. * @param gradient defines the gradient to remove
  19346. * @returns the current particle system
  19347. */
  19348. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19349. /**
  19350. * Gets the current list of life time gradients.
  19351. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19352. * @returns the list of life time gradients
  19353. */
  19354. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19355. /**
  19356. * Gets the current list of color gradients.
  19357. * You must use addColorGradient and removeColorGradient to udpate this list
  19358. * @returns the list of color gradients
  19359. */
  19360. getColorGradients(): Nullable<Array<ColorGradient>>;
  19361. /**
  19362. * Adds a new ramp gradient used to remap particle colors
  19363. * @param gradient defines the gradient to use (between 0 and 1)
  19364. * @param color defines the color to affect to the specified gradient
  19365. * @returns the current particle system
  19366. */
  19367. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19368. /**
  19369. * Gets the current list of ramp gradients.
  19370. * You must use addRampGradient and removeRampGradient to udpate this list
  19371. * @returns the list of ramp gradients
  19372. */
  19373. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19374. /** Gets or sets a boolean indicating that ramp gradients must be used
  19375. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19376. */
  19377. useRampGradients: boolean;
  19378. /**
  19379. * Adds a new color remap gradient
  19380. * @param gradient defines the gradient to use (between 0 and 1)
  19381. * @param min defines the color remap minimal range
  19382. * @param max defines the color remap maximal range
  19383. * @returns the current particle system
  19384. */
  19385. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19386. /**
  19387. * Gets the current list of color remap gradients.
  19388. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19389. * @returns the list of color remap gradients
  19390. */
  19391. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19392. /**
  19393. * Adds a new alpha remap gradient
  19394. * @param gradient defines the gradient to use (between 0 and 1)
  19395. * @param min defines the alpha remap minimal range
  19396. * @param max defines the alpha remap maximal range
  19397. * @returns the current particle system
  19398. */
  19399. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19400. /**
  19401. * Gets the current list of alpha remap gradients.
  19402. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19403. * @returns the list of alpha remap gradients
  19404. */
  19405. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19406. /**
  19407. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19410. * @returns the emitter
  19411. */
  19412. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19413. /**
  19414. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19415. * @param radius The radius of the hemisphere to emit from
  19416. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19417. * @returns the emitter
  19418. */
  19419. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19420. /**
  19421. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19422. * @param radius The radius of the sphere to emit from
  19423. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19424. * @returns the emitter
  19425. */
  19426. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19427. /**
  19428. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19429. * @param radius The radius of the sphere to emit from
  19430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19432. * @returns the emitter
  19433. */
  19434. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19435. /**
  19436. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19437. * @param radius The radius of the emission cylinder
  19438. * @param height The height of the emission cylinder
  19439. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19440. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19441. * @returns the emitter
  19442. */
  19443. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19444. /**
  19445. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19446. * @param radius The radius of the cylinder to emit from
  19447. * @param height The height of the emission cylinder
  19448. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19451. * @returns the emitter
  19452. */
  19453. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19454. /**
  19455. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19456. * @param radius The radius of the cone to emit from
  19457. * @param angle The base angle of the cone
  19458. * @returns the emitter
  19459. */
  19460. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19461. /**
  19462. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19465. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19466. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19467. * @returns the emitter
  19468. */
  19469. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19470. /**
  19471. * Get hosting scene
  19472. * @returns the scene
  19473. */
  19474. getScene(): Scene;
  19475. }
  19476. }
  19477. declare module "babylonjs/Meshes/instancedMesh" {
  19478. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19479. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19480. import { Camera } from "babylonjs/Cameras/camera";
  19481. import { Node } from "babylonjs/node";
  19482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19483. import { Mesh } from "babylonjs/Meshes/mesh";
  19484. import { Material } from "babylonjs/Materials/material";
  19485. import { Skeleton } from "babylonjs/Bones/skeleton";
  19486. import { Light } from "babylonjs/Lights/light";
  19487. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19488. /**
  19489. * Creates an instance based on a source mesh.
  19490. */
  19491. export class InstancedMesh extends AbstractMesh {
  19492. private _sourceMesh;
  19493. private _currentLOD;
  19494. /** @hidden */
  19495. _indexInSourceMeshInstanceArray: number;
  19496. constructor(name: string, source: Mesh);
  19497. /**
  19498. * Returns the string "InstancedMesh".
  19499. */
  19500. getClassName(): string;
  19501. /** Gets the list of lights affecting that mesh */
  19502. readonly lightSources: Light[];
  19503. _resyncLightSources(): void;
  19504. _resyncLighSource(light: Light): void;
  19505. _removeLightSource(light: Light, dispose: boolean): void;
  19506. /**
  19507. * If the source mesh receives shadows
  19508. */
  19509. readonly receiveShadows: boolean;
  19510. /**
  19511. * The material of the source mesh
  19512. */
  19513. readonly material: Nullable<Material>;
  19514. /**
  19515. * Visibility of the source mesh
  19516. */
  19517. readonly visibility: number;
  19518. /**
  19519. * Skeleton of the source mesh
  19520. */
  19521. readonly skeleton: Nullable<Skeleton>;
  19522. /**
  19523. * Rendering ground id of the source mesh
  19524. */
  19525. renderingGroupId: number;
  19526. /**
  19527. * Returns the total number of vertices (integer).
  19528. */
  19529. getTotalVertices(): number;
  19530. /**
  19531. * Returns a positive integer : the total number of indices in this mesh geometry.
  19532. * @returns the numner of indices or zero if the mesh has no geometry.
  19533. */
  19534. getTotalIndices(): number;
  19535. /**
  19536. * The source mesh of the instance
  19537. */
  19538. readonly sourceMesh: Mesh;
  19539. /**
  19540. * Is this node ready to be used/rendered
  19541. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19542. * @return {boolean} is it ready
  19543. */
  19544. isReady(completeCheck?: boolean): boolean;
  19545. /**
  19546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19547. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19548. * @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.
  19549. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19550. */
  19551. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19552. /**
  19553. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19554. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19555. * The `data` are either a numeric array either a Float32Array.
  19556. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19557. * 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).
  19558. * Note that a new underlying VertexBuffer object is created each call.
  19559. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19560. *
  19561. * Possible `kind` values :
  19562. * - VertexBuffer.PositionKind
  19563. * - VertexBuffer.UVKind
  19564. * - VertexBuffer.UV2Kind
  19565. * - VertexBuffer.UV3Kind
  19566. * - VertexBuffer.UV4Kind
  19567. * - VertexBuffer.UV5Kind
  19568. * - VertexBuffer.UV6Kind
  19569. * - VertexBuffer.ColorKind
  19570. * - VertexBuffer.MatricesIndicesKind
  19571. * - VertexBuffer.MatricesIndicesExtraKind
  19572. * - VertexBuffer.MatricesWeightsKind
  19573. * - VertexBuffer.MatricesWeightsExtraKind
  19574. *
  19575. * Returns the Mesh.
  19576. */
  19577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19578. /**
  19579. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19580. * If the mesh has no geometry, it is simply returned as it is.
  19581. * The `data` are either a numeric array either a Float32Array.
  19582. * No new underlying VertexBuffer object is created.
  19583. * 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.
  19584. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19585. *
  19586. * Possible `kind` values :
  19587. * - VertexBuffer.PositionKind
  19588. * - VertexBuffer.UVKind
  19589. * - VertexBuffer.UV2Kind
  19590. * - VertexBuffer.UV3Kind
  19591. * - VertexBuffer.UV4Kind
  19592. * - VertexBuffer.UV5Kind
  19593. * - VertexBuffer.UV6Kind
  19594. * - VertexBuffer.ColorKind
  19595. * - VertexBuffer.MatricesIndicesKind
  19596. * - VertexBuffer.MatricesIndicesExtraKind
  19597. * - VertexBuffer.MatricesWeightsKind
  19598. * - VertexBuffer.MatricesWeightsExtraKind
  19599. *
  19600. * Returns the Mesh.
  19601. */
  19602. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19603. /**
  19604. * Sets the mesh indices.
  19605. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19606. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19607. * This method creates a new index buffer each call.
  19608. * Returns the Mesh.
  19609. */
  19610. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19611. /**
  19612. * Boolean : True if the mesh owns the requested kind of data.
  19613. */
  19614. isVerticesDataPresent(kind: string): boolean;
  19615. /**
  19616. * Returns an array of indices (IndicesArray).
  19617. */
  19618. getIndices(): Nullable<IndicesArray>;
  19619. readonly _positions: Nullable<Vector3[]>;
  19620. /**
  19621. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19622. * This means the mesh underlying bounding box and sphere are recomputed.
  19623. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19624. * @returns the current mesh
  19625. */
  19626. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19627. /** @hidden */
  19628. _preActivate(): InstancedMesh;
  19629. /** @hidden */
  19630. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19631. /** @hidden */
  19632. _postActivate(): void;
  19633. getWorldMatrix(): Matrix;
  19634. readonly isAnInstance: boolean;
  19635. /**
  19636. * Returns the current associated LOD AbstractMesh.
  19637. */
  19638. getLOD(camera: Camera): AbstractMesh;
  19639. /** @hidden */
  19640. _syncSubMeshes(): InstancedMesh;
  19641. /** @hidden */
  19642. _generatePointsArray(): boolean;
  19643. /**
  19644. * Creates a new InstancedMesh from the current mesh.
  19645. * - name (string) : the cloned mesh name
  19646. * - newParent (optional Node) : the optional Node to parent the clone to.
  19647. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19648. *
  19649. * Returns the clone.
  19650. */
  19651. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19652. /**
  19653. * Disposes the InstancedMesh.
  19654. * Returns nothing.
  19655. */
  19656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19657. }
  19658. module "babylonjs/Meshes/mesh" {
  19659. interface Mesh {
  19660. /**
  19661. * Register a custom buffer that will be instanced
  19662. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19663. * @param kind defines the buffer kind
  19664. * @param stride defines the stride in floats
  19665. */
  19666. registerInstancedBuffer(kind: string, stride: number): void;
  19667. /** @hidden */
  19668. _userInstancedBuffersStorage: {
  19669. data: {
  19670. [key: string]: Float32Array;
  19671. };
  19672. sizes: {
  19673. [key: string]: number;
  19674. };
  19675. vertexBuffers: {
  19676. [key: string]: Nullable<VertexBuffer>;
  19677. };
  19678. strides: {
  19679. [key: string]: number;
  19680. };
  19681. };
  19682. }
  19683. }
  19684. module "babylonjs/Meshes/abstractMesh" {
  19685. interface AbstractMesh {
  19686. /**
  19687. * Object used to store instanced buffers defined by user
  19688. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19689. */
  19690. instancedBuffers: {
  19691. [key: string]: any;
  19692. };
  19693. }
  19694. }
  19695. }
  19696. declare module "babylonjs/Materials/shaderMaterial" {
  19697. import { Scene } from "babylonjs/scene";
  19698. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19700. import { Mesh } from "babylonjs/Meshes/mesh";
  19701. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19703. import { Texture } from "babylonjs/Materials/Textures/texture";
  19704. import { Material } from "babylonjs/Materials/material";
  19705. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19706. /**
  19707. * Defines the options associated with the creation of a shader material.
  19708. */
  19709. export interface IShaderMaterialOptions {
  19710. /**
  19711. * Does the material work in alpha blend mode
  19712. */
  19713. needAlphaBlending: boolean;
  19714. /**
  19715. * Does the material work in alpha test mode
  19716. */
  19717. needAlphaTesting: boolean;
  19718. /**
  19719. * The list of attribute names used in the shader
  19720. */
  19721. attributes: string[];
  19722. /**
  19723. * The list of unifrom names used in the shader
  19724. */
  19725. uniforms: string[];
  19726. /**
  19727. * The list of UBO names used in the shader
  19728. */
  19729. uniformBuffers: string[];
  19730. /**
  19731. * The list of sampler names used in the shader
  19732. */
  19733. samplers: string[];
  19734. /**
  19735. * The list of defines used in the shader
  19736. */
  19737. defines: string[];
  19738. }
  19739. /**
  19740. * 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.
  19741. *
  19742. * This returned material effects how the mesh will look based on the code in the shaders.
  19743. *
  19744. * @see http://doc.babylonjs.com/how_to/shader_material
  19745. */
  19746. export class ShaderMaterial extends Material {
  19747. private _shaderPath;
  19748. private _options;
  19749. private _textures;
  19750. private _textureArrays;
  19751. private _floats;
  19752. private _ints;
  19753. private _floatsArrays;
  19754. private _colors3;
  19755. private _colors3Arrays;
  19756. private _colors4;
  19757. private _colors4Arrays;
  19758. private _vectors2;
  19759. private _vectors3;
  19760. private _vectors4;
  19761. private _matrices;
  19762. private _matrixArrays;
  19763. private _matrices3x3;
  19764. private _matrices2x2;
  19765. private _vectors2Arrays;
  19766. private _vectors3Arrays;
  19767. private _vectors4Arrays;
  19768. private _cachedWorldViewMatrix;
  19769. private _cachedWorldViewProjectionMatrix;
  19770. private _renderId;
  19771. private _multiview;
  19772. /**
  19773. * Instantiate a new shader material.
  19774. * 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.
  19775. * This returned material effects how the mesh will look based on the code in the shaders.
  19776. * @see http://doc.babylonjs.com/how_to/shader_material
  19777. * @param name Define the name of the material in the scene
  19778. * @param scene Define the scene the material belongs to
  19779. * @param shaderPath Defines the route to the shader code in one of three ways:
  19780. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19781. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19782. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19783. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19784. * @param options Define the options used to create the shader
  19785. */
  19786. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19787. /**
  19788. * Gets the shader path used to define the shader code
  19789. * It can be modified to trigger a new compilation
  19790. */
  19791. /**
  19792. * Sets the shader path used to define the shader code
  19793. * It can be modified to trigger a new compilation
  19794. */
  19795. shaderPath: any;
  19796. /**
  19797. * Gets the options used to compile the shader.
  19798. * They can be modified to trigger a new compilation
  19799. */
  19800. readonly options: IShaderMaterialOptions;
  19801. /**
  19802. * Gets the current class name of the material e.g. "ShaderMaterial"
  19803. * Mainly use in serialization.
  19804. * @returns the class name
  19805. */
  19806. getClassName(): string;
  19807. /**
  19808. * Specifies if the material will require alpha blending
  19809. * @returns a boolean specifying if alpha blending is needed
  19810. */
  19811. needAlphaBlending(): boolean;
  19812. /**
  19813. * Specifies if this material should be rendered in alpha test mode
  19814. * @returns a boolean specifying if an alpha test is needed.
  19815. */
  19816. needAlphaTesting(): boolean;
  19817. private _checkUniform;
  19818. /**
  19819. * Set a texture in the shader.
  19820. * @param name Define the name of the uniform samplers as defined in the shader
  19821. * @param texture Define the texture to bind to this sampler
  19822. * @return the material itself allowing "fluent" like uniform updates
  19823. */
  19824. setTexture(name: string, texture: Texture): ShaderMaterial;
  19825. /**
  19826. * Set a texture array in the shader.
  19827. * @param name Define the name of the uniform sampler array as defined in the shader
  19828. * @param textures Define the list of textures to bind to this sampler
  19829. * @return the material itself allowing "fluent" like uniform updates
  19830. */
  19831. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19832. /**
  19833. * Set a float in the shader.
  19834. * @param name Define the name of the uniform as defined in the shader
  19835. * @param value Define the value to give to the uniform
  19836. * @return the material itself allowing "fluent" like uniform updates
  19837. */
  19838. setFloat(name: string, value: number): ShaderMaterial;
  19839. /**
  19840. * Set a int in the shader.
  19841. * @param name Define the name of the uniform as defined in the shader
  19842. * @param value Define the value to give to the uniform
  19843. * @return the material itself allowing "fluent" like uniform updates
  19844. */
  19845. setInt(name: string, value: number): ShaderMaterial;
  19846. /**
  19847. * Set an array of floats in the shader.
  19848. * @param name Define the name of the uniform as defined in the shader
  19849. * @param value Define the value to give to the uniform
  19850. * @return the material itself allowing "fluent" like uniform updates
  19851. */
  19852. setFloats(name: string, value: number[]): ShaderMaterial;
  19853. /**
  19854. * Set a vec3 in the shader from a Color3.
  19855. * @param name Define the name of the uniform as defined in the shader
  19856. * @param value Define the value to give to the uniform
  19857. * @return the material itself allowing "fluent" like uniform updates
  19858. */
  19859. setColor3(name: string, value: Color3): ShaderMaterial;
  19860. /**
  19861. * Set a vec3 array in the shader from a Color3 array.
  19862. * @param name Define the name of the uniform as defined in the shader
  19863. * @param value Define the value to give to the uniform
  19864. * @return the material itself allowing "fluent" like uniform updates
  19865. */
  19866. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19867. /**
  19868. * Set a vec4 in the shader from a Color4.
  19869. * @param name Define the name of the uniform as defined in the shader
  19870. * @param value Define the value to give to the uniform
  19871. * @return the material itself allowing "fluent" like uniform updates
  19872. */
  19873. setColor4(name: string, value: Color4): ShaderMaterial;
  19874. /**
  19875. * Set a vec4 array in the shader from a Color4 array.
  19876. * @param name Define the name of the uniform as defined in the shader
  19877. * @param value Define the value to give to the uniform
  19878. * @return the material itself allowing "fluent" like uniform updates
  19879. */
  19880. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19881. /**
  19882. * Set a vec2 in the shader from a Vector2.
  19883. * @param name Define the name of the uniform as defined in the shader
  19884. * @param value Define the value to give to the uniform
  19885. * @return the material itself allowing "fluent" like uniform updates
  19886. */
  19887. setVector2(name: string, value: Vector2): ShaderMaterial;
  19888. /**
  19889. * Set a vec3 in the shader from a Vector3.
  19890. * @param name Define the name of the uniform as defined in the shader
  19891. * @param value Define the value to give to the uniform
  19892. * @return the material itself allowing "fluent" like uniform updates
  19893. */
  19894. setVector3(name: string, value: Vector3): ShaderMaterial;
  19895. /**
  19896. * Set a vec4 in the shader from a Vector4.
  19897. * @param name Define the name of the uniform as defined in the shader
  19898. * @param value Define the value to give to the uniform
  19899. * @return the material itself allowing "fluent" like uniform updates
  19900. */
  19901. setVector4(name: string, value: Vector4): ShaderMaterial;
  19902. /**
  19903. * Set a mat4 in the shader from a Matrix.
  19904. * @param name Define the name of the uniform as defined in the shader
  19905. * @param value Define the value to give to the uniform
  19906. * @return the material itself allowing "fluent" like uniform updates
  19907. */
  19908. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19909. /**
  19910. * Set a float32Array in the shader from a matrix array.
  19911. * @param name Define the name of the uniform as defined in the shader
  19912. * @param value Define the value to give to the uniform
  19913. * @return the material itself allowing "fluent" like uniform updates
  19914. */
  19915. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19916. /**
  19917. * Set a mat3 in the shader from a Float32Array.
  19918. * @param name Define the name of the uniform as defined in the shader
  19919. * @param value Define the value to give to the uniform
  19920. * @return the material itself allowing "fluent" like uniform updates
  19921. */
  19922. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19923. /**
  19924. * Set a mat2 in the shader from a Float32Array.
  19925. * @param name Define the name of the uniform as defined in the shader
  19926. * @param value Define the value to give to the uniform
  19927. * @return the material itself allowing "fluent" like uniform updates
  19928. */
  19929. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19930. /**
  19931. * Set a vec2 array in the shader from a number array.
  19932. * @param name Define the name of the uniform as defined in the shader
  19933. * @param value Define the value to give to the uniform
  19934. * @return the material itself allowing "fluent" like uniform updates
  19935. */
  19936. setArray2(name: string, value: number[]): ShaderMaterial;
  19937. /**
  19938. * Set a vec3 array in the shader from a number array.
  19939. * @param name Define the name of the uniform as defined in the shader
  19940. * @param value Define the value to give to the uniform
  19941. * @return the material itself allowing "fluent" like uniform updates
  19942. */
  19943. setArray3(name: string, value: number[]): ShaderMaterial;
  19944. /**
  19945. * Set a vec4 array in the shader from a number array.
  19946. * @param name Define the name of the uniform as defined in the shader
  19947. * @param value Define the value to give to the uniform
  19948. * @return the material itself allowing "fluent" like uniform updates
  19949. */
  19950. setArray4(name: string, value: number[]): ShaderMaterial;
  19951. private _checkCache;
  19952. /**
  19953. * Specifies that the submesh is ready to be used
  19954. * @param mesh defines the mesh to check
  19955. * @param subMesh defines which submesh to check
  19956. * @param useInstances specifies that instances should be used
  19957. * @returns a boolean indicating that the submesh is ready or not
  19958. */
  19959. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19960. /**
  19961. * Checks if the material is ready to render the requested mesh
  19962. * @param mesh Define the mesh to render
  19963. * @param useInstances Define whether or not the material is used with instances
  19964. * @returns true if ready, otherwise false
  19965. */
  19966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19967. /**
  19968. * Binds the world matrix to the material
  19969. * @param world defines the world transformation matrix
  19970. */
  19971. bindOnlyWorldMatrix(world: Matrix): void;
  19972. /**
  19973. * Binds the material to the mesh
  19974. * @param world defines the world transformation matrix
  19975. * @param mesh defines the mesh to bind the material to
  19976. */
  19977. bind(world: Matrix, mesh?: Mesh): void;
  19978. /**
  19979. * Gets the active textures from the material
  19980. * @returns an array of textures
  19981. */
  19982. getActiveTextures(): BaseTexture[];
  19983. /**
  19984. * Specifies if the material uses a texture
  19985. * @param texture defines the texture to check against the material
  19986. * @returns a boolean specifying if the material uses the texture
  19987. */
  19988. hasTexture(texture: BaseTexture): boolean;
  19989. /**
  19990. * Makes a duplicate of the material, and gives it a new name
  19991. * @param name defines the new name for the duplicated material
  19992. * @returns the cloned material
  19993. */
  19994. clone(name: string): ShaderMaterial;
  19995. /**
  19996. * Disposes the material
  19997. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19998. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19999. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20000. */
  20001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20002. /**
  20003. * Serializes this material in a JSON representation
  20004. * @returns the serialized material object
  20005. */
  20006. serialize(): any;
  20007. /**
  20008. * Creates a shader material from parsed shader material data
  20009. * @param source defines the JSON represnetation of the material
  20010. * @param scene defines the hosting scene
  20011. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20012. * @returns a new material
  20013. */
  20014. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20015. }
  20016. }
  20017. declare module "babylonjs/Shaders/color.fragment" {
  20018. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20019. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20020. /** @hidden */
  20021. export var colorPixelShader: {
  20022. name: string;
  20023. shader: string;
  20024. };
  20025. }
  20026. declare module "babylonjs/Shaders/color.vertex" {
  20027. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20028. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20029. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20030. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20031. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20032. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20033. /** @hidden */
  20034. export var colorVertexShader: {
  20035. name: string;
  20036. shader: string;
  20037. };
  20038. }
  20039. declare module "babylonjs/Meshes/linesMesh" {
  20040. import { Nullable } from "babylonjs/types";
  20041. import { Scene } from "babylonjs/scene";
  20042. import { Color3 } from "babylonjs/Maths/math.color";
  20043. import { Node } from "babylonjs/node";
  20044. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20045. import { Mesh } from "babylonjs/Meshes/mesh";
  20046. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20047. import { Effect } from "babylonjs/Materials/effect";
  20048. import { Material } from "babylonjs/Materials/material";
  20049. import "babylonjs/Shaders/color.fragment";
  20050. import "babylonjs/Shaders/color.vertex";
  20051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20052. /**
  20053. * Line mesh
  20054. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20055. */
  20056. export class LinesMesh extends Mesh {
  20057. /**
  20058. * If vertex color should be applied to the mesh
  20059. */
  20060. readonly useVertexColor?: boolean | undefined;
  20061. /**
  20062. * If vertex alpha should be applied to the mesh
  20063. */
  20064. readonly useVertexAlpha?: boolean | undefined;
  20065. /**
  20066. * Color of the line (Default: White)
  20067. */
  20068. color: Color3;
  20069. /**
  20070. * Alpha of the line (Default: 1)
  20071. */
  20072. alpha: number;
  20073. /**
  20074. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20075. * This margin is expressed in world space coordinates, so its value may vary.
  20076. * Default value is 0.1
  20077. */
  20078. intersectionThreshold: number;
  20079. private _colorShader;
  20080. private color4;
  20081. /**
  20082. * Creates a new LinesMesh
  20083. * @param name defines the name
  20084. * @param scene defines the hosting scene
  20085. * @param parent defines the parent mesh if any
  20086. * @param source defines the optional source LinesMesh used to clone data from
  20087. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20088. * When false, achieved by calling a clone(), also passing False.
  20089. * This will make creation of children, recursive.
  20090. * @param useVertexColor defines if this LinesMesh supports vertex color
  20091. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20092. */
  20093. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20094. /**
  20095. * If vertex color should be applied to the mesh
  20096. */
  20097. useVertexColor?: boolean | undefined,
  20098. /**
  20099. * If vertex alpha should be applied to the mesh
  20100. */
  20101. useVertexAlpha?: boolean | undefined);
  20102. private _addClipPlaneDefine;
  20103. private _removeClipPlaneDefine;
  20104. isReady(): boolean;
  20105. /**
  20106. * Returns the string "LineMesh"
  20107. */
  20108. getClassName(): string;
  20109. /**
  20110. * @hidden
  20111. */
  20112. /**
  20113. * @hidden
  20114. */
  20115. material: Material;
  20116. /**
  20117. * @hidden
  20118. */
  20119. readonly checkCollisions: boolean;
  20120. /** @hidden */
  20121. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20122. /** @hidden */
  20123. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20124. /**
  20125. * Disposes of the line mesh
  20126. * @param doNotRecurse If children should be disposed
  20127. */
  20128. dispose(doNotRecurse?: boolean): void;
  20129. /**
  20130. * Returns a new LineMesh object cloned from the current one.
  20131. */
  20132. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20133. /**
  20134. * Creates a new InstancedLinesMesh object from the mesh model.
  20135. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20136. * @param name defines the name of the new instance
  20137. * @returns a new InstancedLinesMesh
  20138. */
  20139. createInstance(name: string): InstancedLinesMesh;
  20140. }
  20141. /**
  20142. * Creates an instance based on a source LinesMesh
  20143. */
  20144. export class InstancedLinesMesh extends InstancedMesh {
  20145. /**
  20146. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20147. * This margin is expressed in world space coordinates, so its value may vary.
  20148. * Initilized with the intersectionThreshold value of the source LinesMesh
  20149. */
  20150. intersectionThreshold: number;
  20151. constructor(name: string, source: LinesMesh);
  20152. /**
  20153. * Returns the string "InstancedLinesMesh".
  20154. */
  20155. getClassName(): string;
  20156. }
  20157. }
  20158. declare module "babylonjs/Shaders/line.fragment" {
  20159. /** @hidden */
  20160. export var linePixelShader: {
  20161. name: string;
  20162. shader: string;
  20163. };
  20164. }
  20165. declare module "babylonjs/Shaders/line.vertex" {
  20166. /** @hidden */
  20167. export var lineVertexShader: {
  20168. name: string;
  20169. shader: string;
  20170. };
  20171. }
  20172. declare module "babylonjs/Rendering/edgesRenderer" {
  20173. import { Nullable } from "babylonjs/types";
  20174. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20176. import { Vector3 } from "babylonjs/Maths/math.vector";
  20177. import { IDisposable } from "babylonjs/scene";
  20178. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20179. import "babylonjs/Shaders/line.fragment";
  20180. import "babylonjs/Shaders/line.vertex";
  20181. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20182. module "babylonjs/Meshes/abstractMesh" {
  20183. interface AbstractMesh {
  20184. /**
  20185. * Gets the edgesRenderer associated with the mesh
  20186. */
  20187. edgesRenderer: Nullable<EdgesRenderer>;
  20188. }
  20189. }
  20190. module "babylonjs/Meshes/linesMesh" {
  20191. interface LinesMesh {
  20192. /**
  20193. * Enables the edge rendering mode on the mesh.
  20194. * This mode makes the mesh edges visible
  20195. * @param epsilon defines the maximal distance between two angles to detect a face
  20196. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20197. * @returns the currentAbstractMesh
  20198. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20199. */
  20200. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20201. }
  20202. }
  20203. module "babylonjs/Meshes/linesMesh" {
  20204. interface InstancedLinesMesh {
  20205. /**
  20206. * Enables the edge rendering mode on the mesh.
  20207. * This mode makes the mesh edges visible
  20208. * @param epsilon defines the maximal distance between two angles to detect a face
  20209. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20210. * @returns the current InstancedLinesMesh
  20211. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20212. */
  20213. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20214. }
  20215. }
  20216. /**
  20217. * Defines the minimum contract an Edges renderer should follow.
  20218. */
  20219. export interface IEdgesRenderer extends IDisposable {
  20220. /**
  20221. * Gets or sets a boolean indicating if the edgesRenderer is active
  20222. */
  20223. isEnabled: boolean;
  20224. /**
  20225. * Renders the edges of the attached mesh,
  20226. */
  20227. render(): void;
  20228. /**
  20229. * Checks wether or not the edges renderer is ready to render.
  20230. * @return true if ready, otherwise false.
  20231. */
  20232. isReady(): boolean;
  20233. }
  20234. /**
  20235. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20236. */
  20237. export class EdgesRenderer implements IEdgesRenderer {
  20238. /**
  20239. * Define the size of the edges with an orthographic camera
  20240. */
  20241. edgesWidthScalerForOrthographic: number;
  20242. /**
  20243. * Define the size of the edges with a perspective camera
  20244. */
  20245. edgesWidthScalerForPerspective: number;
  20246. protected _source: AbstractMesh;
  20247. protected _linesPositions: number[];
  20248. protected _linesNormals: number[];
  20249. protected _linesIndices: number[];
  20250. protected _epsilon: number;
  20251. protected _indicesCount: number;
  20252. protected _lineShader: ShaderMaterial;
  20253. protected _ib: DataBuffer;
  20254. protected _buffers: {
  20255. [key: string]: Nullable<VertexBuffer>;
  20256. };
  20257. protected _checkVerticesInsteadOfIndices: boolean;
  20258. private _meshRebuildObserver;
  20259. private _meshDisposeObserver;
  20260. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20261. isEnabled: boolean;
  20262. /**
  20263. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20264. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20265. * @param source Mesh used to create edges
  20266. * @param epsilon sum of angles in adjacency to check for edge
  20267. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20268. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20269. */
  20270. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20271. protected _prepareRessources(): void;
  20272. /** @hidden */
  20273. _rebuild(): void;
  20274. /**
  20275. * Releases the required resources for the edges renderer
  20276. */
  20277. dispose(): void;
  20278. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20279. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20280. /**
  20281. * Checks if the pair of p0 and p1 is en edge
  20282. * @param faceIndex
  20283. * @param edge
  20284. * @param faceNormals
  20285. * @param p0
  20286. * @param p1
  20287. * @private
  20288. */
  20289. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20290. /**
  20291. * push line into the position, normal and index buffer
  20292. * @protected
  20293. */
  20294. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20295. /**
  20296. * Generates lines edges from adjacencjes
  20297. * @private
  20298. */
  20299. _generateEdgesLines(): void;
  20300. /**
  20301. * Checks wether or not the edges renderer is ready to render.
  20302. * @return true if ready, otherwise false.
  20303. */
  20304. isReady(): boolean;
  20305. /**
  20306. * Renders the edges of the attached mesh,
  20307. */
  20308. render(): void;
  20309. }
  20310. /**
  20311. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20312. */
  20313. export class LineEdgesRenderer extends EdgesRenderer {
  20314. /**
  20315. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20316. * @param source LineMesh used to generate edges
  20317. * @param epsilon not important (specified angle for edge detection)
  20318. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20319. */
  20320. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20321. /**
  20322. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20323. */
  20324. _generateEdgesLines(): void;
  20325. }
  20326. }
  20327. declare module "babylonjs/Rendering/renderingGroup" {
  20328. import { SmartArray } from "babylonjs/Misc/smartArray";
  20329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20331. import { Nullable } from "babylonjs/types";
  20332. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20333. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20334. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20335. import { Material } from "babylonjs/Materials/material";
  20336. import { Scene } from "babylonjs/scene";
  20337. /**
  20338. * This represents the object necessary to create a rendering group.
  20339. * This is exclusively used and created by the rendering manager.
  20340. * To modify the behavior, you use the available helpers in your scene or meshes.
  20341. * @hidden
  20342. */
  20343. export class RenderingGroup {
  20344. index: number;
  20345. private static _zeroVector;
  20346. private _scene;
  20347. private _opaqueSubMeshes;
  20348. private _transparentSubMeshes;
  20349. private _alphaTestSubMeshes;
  20350. private _depthOnlySubMeshes;
  20351. private _particleSystems;
  20352. private _spriteManagers;
  20353. private _opaqueSortCompareFn;
  20354. private _alphaTestSortCompareFn;
  20355. private _transparentSortCompareFn;
  20356. private _renderOpaque;
  20357. private _renderAlphaTest;
  20358. private _renderTransparent;
  20359. /** @hidden */
  20360. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20361. onBeforeTransparentRendering: () => void;
  20362. /**
  20363. * Set the opaque sort comparison function.
  20364. * If null the sub meshes will be render in the order they were created
  20365. */
  20366. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20367. /**
  20368. * Set the alpha test sort comparison function.
  20369. * If null the sub meshes will be render in the order they were created
  20370. */
  20371. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20372. /**
  20373. * Set the transparent sort comparison function.
  20374. * If null the sub meshes will be render in the order they were created
  20375. */
  20376. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20377. /**
  20378. * Creates a new rendering group.
  20379. * @param index The rendering group index
  20380. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20381. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20382. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20383. */
  20384. 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>);
  20385. /**
  20386. * Render all the sub meshes contained in the group.
  20387. * @param customRenderFunction Used to override the default render behaviour of the group.
  20388. * @returns true if rendered some submeshes.
  20389. */
  20390. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20391. /**
  20392. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20393. * @param subMeshes The submeshes to render
  20394. */
  20395. private renderOpaqueSorted;
  20396. /**
  20397. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20398. * @param subMeshes The submeshes to render
  20399. */
  20400. private renderAlphaTestSorted;
  20401. /**
  20402. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20403. * @param subMeshes The submeshes to render
  20404. */
  20405. private renderTransparentSorted;
  20406. /**
  20407. * Renders the submeshes in a specified order.
  20408. * @param subMeshes The submeshes to sort before render
  20409. * @param sortCompareFn The comparison function use to sort
  20410. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20411. * @param transparent Specifies to activate blending if true
  20412. */
  20413. private static renderSorted;
  20414. /**
  20415. * Renders the submeshes in the order they were dispatched (no sort applied).
  20416. * @param subMeshes The submeshes to render
  20417. */
  20418. private static renderUnsorted;
  20419. /**
  20420. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20421. * are rendered back to front if in the same alpha index.
  20422. *
  20423. * @param a The first submesh
  20424. * @param b The second submesh
  20425. * @returns The result of the comparison
  20426. */
  20427. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20428. /**
  20429. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20430. * are rendered back to front.
  20431. *
  20432. * @param a The first submesh
  20433. * @param b The second submesh
  20434. * @returns The result of the comparison
  20435. */
  20436. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20437. /**
  20438. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20439. * are rendered front to back (prevent overdraw).
  20440. *
  20441. * @param a The first submesh
  20442. * @param b The second submesh
  20443. * @returns The result of the comparison
  20444. */
  20445. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20446. /**
  20447. * Resets the different lists of submeshes to prepare a new frame.
  20448. */
  20449. prepare(): void;
  20450. dispose(): void;
  20451. /**
  20452. * Inserts the submesh in its correct queue depending on its material.
  20453. * @param subMesh The submesh to dispatch
  20454. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20455. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20456. */
  20457. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20458. dispatchSprites(spriteManager: ISpriteManager): void;
  20459. dispatchParticles(particleSystem: IParticleSystem): void;
  20460. private _renderParticles;
  20461. private _renderSprites;
  20462. }
  20463. }
  20464. declare module "babylonjs/Rendering/renderingManager" {
  20465. import { Nullable } from "babylonjs/types";
  20466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20468. import { SmartArray } from "babylonjs/Misc/smartArray";
  20469. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20470. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20471. import { Material } from "babylonjs/Materials/material";
  20472. import { Scene } from "babylonjs/scene";
  20473. import { Camera } from "babylonjs/Cameras/camera";
  20474. /**
  20475. * Interface describing the different options available in the rendering manager
  20476. * regarding Auto Clear between groups.
  20477. */
  20478. export interface IRenderingManagerAutoClearSetup {
  20479. /**
  20480. * Defines whether or not autoclear is enable.
  20481. */
  20482. autoClear: boolean;
  20483. /**
  20484. * Defines whether or not to autoclear the depth buffer.
  20485. */
  20486. depth: boolean;
  20487. /**
  20488. * Defines whether or not to autoclear the stencil buffer.
  20489. */
  20490. stencil: boolean;
  20491. }
  20492. /**
  20493. * This class is used by the onRenderingGroupObservable
  20494. */
  20495. export class RenderingGroupInfo {
  20496. /**
  20497. * The Scene that being rendered
  20498. */
  20499. scene: Scene;
  20500. /**
  20501. * The camera currently used for the rendering pass
  20502. */
  20503. camera: Nullable<Camera>;
  20504. /**
  20505. * The ID of the renderingGroup being processed
  20506. */
  20507. renderingGroupId: number;
  20508. }
  20509. /**
  20510. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20511. * It is enable to manage the different groups as well as the different necessary sort functions.
  20512. * This should not be used directly aside of the few static configurations
  20513. */
  20514. export class RenderingManager {
  20515. /**
  20516. * The max id used for rendering groups (not included)
  20517. */
  20518. static MAX_RENDERINGGROUPS: number;
  20519. /**
  20520. * The min id used for rendering groups (included)
  20521. */
  20522. static MIN_RENDERINGGROUPS: number;
  20523. /**
  20524. * Used to globally prevent autoclearing scenes.
  20525. */
  20526. static AUTOCLEAR: boolean;
  20527. /**
  20528. * @hidden
  20529. */
  20530. _useSceneAutoClearSetup: boolean;
  20531. private _scene;
  20532. private _renderingGroups;
  20533. private _depthStencilBufferAlreadyCleaned;
  20534. private _autoClearDepthStencil;
  20535. private _customOpaqueSortCompareFn;
  20536. private _customAlphaTestSortCompareFn;
  20537. private _customTransparentSortCompareFn;
  20538. private _renderingGroupInfo;
  20539. /**
  20540. * Instantiates a new rendering group for a particular scene
  20541. * @param scene Defines the scene the groups belongs to
  20542. */
  20543. constructor(scene: Scene);
  20544. private _clearDepthStencilBuffer;
  20545. /**
  20546. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20547. * @hidden
  20548. */
  20549. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20550. /**
  20551. * Resets the different information of the group to prepare a new frame
  20552. * @hidden
  20553. */
  20554. reset(): void;
  20555. /**
  20556. * Dispose and release the group and its associated resources.
  20557. * @hidden
  20558. */
  20559. dispose(): void;
  20560. /**
  20561. * Clear the info related to rendering groups preventing retention points during dispose.
  20562. */
  20563. freeRenderingGroups(): void;
  20564. private _prepareRenderingGroup;
  20565. /**
  20566. * Add a sprite manager to the rendering manager in order to render it this frame.
  20567. * @param spriteManager Define the sprite manager to render
  20568. */
  20569. dispatchSprites(spriteManager: ISpriteManager): void;
  20570. /**
  20571. * Add a particle system to the rendering manager in order to render it this frame.
  20572. * @param particleSystem Define the particle system to render
  20573. */
  20574. dispatchParticles(particleSystem: IParticleSystem): void;
  20575. /**
  20576. * Add a submesh to the manager in order to render it this frame
  20577. * @param subMesh The submesh to dispatch
  20578. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20579. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20580. */
  20581. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20582. /**
  20583. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20584. * This allowed control for front to back rendering or reversly depending of the special needs.
  20585. *
  20586. * @param renderingGroupId The rendering group id corresponding to its index
  20587. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20588. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20589. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20590. */
  20591. 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;
  20592. /**
  20593. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20594. *
  20595. * @param renderingGroupId The rendering group id corresponding to its index
  20596. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20597. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20598. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20599. */
  20600. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20601. /**
  20602. * Gets the current auto clear configuration for one rendering group of the rendering
  20603. * manager.
  20604. * @param index the rendering group index to get the information for
  20605. * @returns The auto clear setup for the requested rendering group
  20606. */
  20607. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20608. }
  20609. }
  20610. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20611. import { Observable } from "babylonjs/Misc/observable";
  20612. import { SmartArray } from "babylonjs/Misc/smartArray";
  20613. import { Nullable } from "babylonjs/types";
  20614. import { Camera } from "babylonjs/Cameras/camera";
  20615. import { Scene } from "babylonjs/scene";
  20616. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20617. import { Color4 } from "babylonjs/Maths/math.color";
  20618. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20622. import { Texture } from "babylonjs/Materials/Textures/texture";
  20623. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20624. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20625. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20626. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20627. import { Engine } from "babylonjs/Engines/engine";
  20628. /**
  20629. * This Helps creating a texture that will be created from a camera in your scene.
  20630. * It is basically a dynamic texture that could be used to create special effects for instance.
  20631. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20632. */
  20633. export class RenderTargetTexture extends Texture {
  20634. isCube: boolean;
  20635. /**
  20636. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20637. */
  20638. static readonly REFRESHRATE_RENDER_ONCE: number;
  20639. /**
  20640. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20641. */
  20642. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20643. /**
  20644. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20645. * the central point of your effect and can save a lot of performances.
  20646. */
  20647. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20648. /**
  20649. * Use this predicate to dynamically define the list of mesh you want to render.
  20650. * If set, the renderList property will be overwritten.
  20651. */
  20652. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20653. private _renderList;
  20654. /**
  20655. * Use this list to define the list of mesh you want to render.
  20656. */
  20657. renderList: Nullable<Array<AbstractMesh>>;
  20658. private _hookArray;
  20659. /**
  20660. * Define if particles should be rendered in your texture.
  20661. */
  20662. renderParticles: boolean;
  20663. /**
  20664. * Define if sprites should be rendered in your texture.
  20665. */
  20666. renderSprites: boolean;
  20667. /**
  20668. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20669. */
  20670. coordinatesMode: number;
  20671. /**
  20672. * Define the camera used to render the texture.
  20673. */
  20674. activeCamera: Nullable<Camera>;
  20675. /**
  20676. * Override the render function of the texture with your own one.
  20677. */
  20678. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20679. /**
  20680. * Define if camera post processes should be use while rendering the texture.
  20681. */
  20682. useCameraPostProcesses: boolean;
  20683. /**
  20684. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20685. */
  20686. ignoreCameraViewport: boolean;
  20687. private _postProcessManager;
  20688. private _postProcesses;
  20689. private _resizeObserver;
  20690. /**
  20691. * An event triggered when the texture is unbind.
  20692. */
  20693. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20694. /**
  20695. * An event triggered when the texture is unbind.
  20696. */
  20697. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20698. private _onAfterUnbindObserver;
  20699. /**
  20700. * Set a after unbind callback in the texture.
  20701. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20702. */
  20703. onAfterUnbind: () => void;
  20704. /**
  20705. * An event triggered before rendering the texture
  20706. */
  20707. onBeforeRenderObservable: Observable<number>;
  20708. private _onBeforeRenderObserver;
  20709. /**
  20710. * Set a before render callback in the texture.
  20711. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20712. */
  20713. onBeforeRender: (faceIndex: number) => void;
  20714. /**
  20715. * An event triggered after rendering the texture
  20716. */
  20717. onAfterRenderObservable: Observable<number>;
  20718. private _onAfterRenderObserver;
  20719. /**
  20720. * Set a after render callback in the texture.
  20721. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20722. */
  20723. onAfterRender: (faceIndex: number) => void;
  20724. /**
  20725. * An event triggered after the texture clear
  20726. */
  20727. onClearObservable: Observable<Engine>;
  20728. private _onClearObserver;
  20729. /**
  20730. * Set a clear callback in the texture.
  20731. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20732. */
  20733. onClear: (Engine: Engine) => void;
  20734. /**
  20735. * An event triggered when the texture is resized.
  20736. */
  20737. onResizeObservable: Observable<RenderTargetTexture>;
  20738. /**
  20739. * Define the clear color of the Render Target if it should be different from the scene.
  20740. */
  20741. clearColor: Color4;
  20742. protected _size: number | {
  20743. width: number;
  20744. height: number;
  20745. };
  20746. protected _initialSizeParameter: number | {
  20747. width: number;
  20748. height: number;
  20749. } | {
  20750. ratio: number;
  20751. };
  20752. protected _sizeRatio: Nullable<number>;
  20753. /** @hidden */
  20754. _generateMipMaps: boolean;
  20755. protected _renderingManager: RenderingManager;
  20756. /** @hidden */
  20757. _waitingRenderList: string[];
  20758. protected _doNotChangeAspectRatio: boolean;
  20759. protected _currentRefreshId: number;
  20760. protected _refreshRate: number;
  20761. protected _textureMatrix: Matrix;
  20762. protected _samples: number;
  20763. protected _renderTargetOptions: RenderTargetCreationOptions;
  20764. /**
  20765. * Gets render target creation options that were used.
  20766. */
  20767. readonly renderTargetOptions: RenderTargetCreationOptions;
  20768. protected _engine: Engine;
  20769. protected _onRatioRescale(): void;
  20770. /**
  20771. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20772. * It must define where the camera used to render the texture is set
  20773. */
  20774. boundingBoxPosition: Vector3;
  20775. private _boundingBoxSize;
  20776. /**
  20777. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20778. * When defined, the cubemap will switch to local mode
  20779. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20780. * @example https://www.babylonjs-playground.com/#RNASML
  20781. */
  20782. boundingBoxSize: Vector3;
  20783. /**
  20784. * In case the RTT has been created with a depth texture, get the associated
  20785. * depth texture.
  20786. * Otherwise, return null.
  20787. */
  20788. depthStencilTexture: Nullable<InternalTexture>;
  20789. /**
  20790. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20791. * or used a shadow, depth texture...
  20792. * @param name The friendly name of the texture
  20793. * @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)
  20794. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20795. * @param generateMipMaps True if mip maps need to be generated after render.
  20796. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20797. * @param type The type of the buffer in the RTT (int, half float, float...)
  20798. * @param isCube True if a cube texture needs to be created
  20799. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20800. * @param generateDepthBuffer True to generate a depth buffer
  20801. * @param generateStencilBuffer True to generate a stencil buffer
  20802. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20803. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20804. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20805. */
  20806. constructor(name: string, size: number | {
  20807. width: number;
  20808. height: number;
  20809. } | {
  20810. ratio: number;
  20811. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20812. /**
  20813. * Creates a depth stencil texture.
  20814. * This is only available in WebGL 2 or with the depth texture extension available.
  20815. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20816. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20817. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20818. */
  20819. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20820. private _processSizeParameter;
  20821. /**
  20822. * Define the number of samples to use in case of MSAA.
  20823. * It defaults to one meaning no MSAA has been enabled.
  20824. */
  20825. samples: number;
  20826. /**
  20827. * Resets the refresh counter of the texture and start bak from scratch.
  20828. * Could be useful to regenerate the texture if it is setup to render only once.
  20829. */
  20830. resetRefreshCounter(): void;
  20831. /**
  20832. * Define the refresh rate of the texture or the rendering frequency.
  20833. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20834. */
  20835. refreshRate: number;
  20836. /**
  20837. * Adds a post process to the render target rendering passes.
  20838. * @param postProcess define the post process to add
  20839. */
  20840. addPostProcess(postProcess: PostProcess): void;
  20841. /**
  20842. * Clear all the post processes attached to the render target
  20843. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20844. */
  20845. clearPostProcesses(dispose?: boolean): void;
  20846. /**
  20847. * Remove one of the post process from the list of attached post processes to the texture
  20848. * @param postProcess define the post process to remove from the list
  20849. */
  20850. removePostProcess(postProcess: PostProcess): void;
  20851. /** @hidden */
  20852. _shouldRender(): boolean;
  20853. /**
  20854. * Gets the actual render size of the texture.
  20855. * @returns the width of the render size
  20856. */
  20857. getRenderSize(): number;
  20858. /**
  20859. * Gets the actual render width of the texture.
  20860. * @returns the width of the render size
  20861. */
  20862. getRenderWidth(): number;
  20863. /**
  20864. * Gets the actual render height of the texture.
  20865. * @returns the height of the render size
  20866. */
  20867. getRenderHeight(): number;
  20868. /**
  20869. * Get if the texture can be rescaled or not.
  20870. */
  20871. readonly canRescale: boolean;
  20872. /**
  20873. * Resize the texture using a ratio.
  20874. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20875. */
  20876. scale(ratio: number): void;
  20877. /**
  20878. * Get the texture reflection matrix used to rotate/transform the reflection.
  20879. * @returns the reflection matrix
  20880. */
  20881. getReflectionTextureMatrix(): Matrix;
  20882. /**
  20883. * Resize the texture to a new desired size.
  20884. * Be carrefull as it will recreate all the data in the new texture.
  20885. * @param size Define the new size. It can be:
  20886. * - a number for squared texture,
  20887. * - an object containing { width: number, height: number }
  20888. * - or an object containing a ratio { ratio: number }
  20889. */
  20890. resize(size: number | {
  20891. width: number;
  20892. height: number;
  20893. } | {
  20894. ratio: number;
  20895. }): void;
  20896. /**
  20897. * Renders all the objects from the render list into the texture.
  20898. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20899. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20900. */
  20901. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20902. private _bestReflectionRenderTargetDimension;
  20903. /**
  20904. * @hidden
  20905. * @param faceIndex face index to bind to if this is a cubetexture
  20906. */
  20907. _bindFrameBuffer(faceIndex?: number): void;
  20908. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20909. private renderToTarget;
  20910. /**
  20911. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20912. * This allowed control for front to back rendering or reversly depending of the special needs.
  20913. *
  20914. * @param renderingGroupId The rendering group id corresponding to its index
  20915. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20916. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20917. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20918. */
  20919. 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;
  20920. /**
  20921. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20922. *
  20923. * @param renderingGroupId The rendering group id corresponding to its index
  20924. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20925. */
  20926. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20927. /**
  20928. * Clones the texture.
  20929. * @returns the cloned texture
  20930. */
  20931. clone(): RenderTargetTexture;
  20932. /**
  20933. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20934. * @returns The JSON representation of the texture
  20935. */
  20936. serialize(): any;
  20937. /**
  20938. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20939. */
  20940. disposeFramebufferObjects(): void;
  20941. /**
  20942. * Dispose the texture and release its associated resources.
  20943. */
  20944. dispose(): void;
  20945. /** @hidden */
  20946. _rebuild(): void;
  20947. /**
  20948. * Clear the info related to rendering groups preventing retention point in material dispose.
  20949. */
  20950. freeRenderingGroups(): void;
  20951. /**
  20952. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20953. * @returns the view count
  20954. */
  20955. getViewCount(): number;
  20956. }
  20957. }
  20958. declare module "babylonjs/Materials/material" {
  20959. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20960. import { SmartArray } from "babylonjs/Misc/smartArray";
  20961. import { Observable } from "babylonjs/Misc/observable";
  20962. import { Nullable } from "babylonjs/types";
  20963. import { Scene } from "babylonjs/scene";
  20964. import { Matrix } from "babylonjs/Maths/math.vector";
  20965. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20967. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20968. import { Effect } from "babylonjs/Materials/effect";
  20969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20970. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20971. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20972. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20973. import { Mesh } from "babylonjs/Meshes/mesh";
  20974. import { Animation } from "babylonjs/Animations/animation";
  20975. /**
  20976. * Options for compiling materials.
  20977. */
  20978. export interface IMaterialCompilationOptions {
  20979. /**
  20980. * Defines whether clip planes are enabled.
  20981. */
  20982. clipPlane: boolean;
  20983. /**
  20984. * Defines whether instances are enabled.
  20985. */
  20986. useInstances: boolean;
  20987. }
  20988. /**
  20989. * Base class for the main features of a material in Babylon.js
  20990. */
  20991. export class Material implements IAnimatable {
  20992. /**
  20993. * Returns the triangle fill mode
  20994. */
  20995. static readonly TriangleFillMode: number;
  20996. /**
  20997. * Returns the wireframe mode
  20998. */
  20999. static readonly WireFrameFillMode: number;
  21000. /**
  21001. * Returns the point fill mode
  21002. */
  21003. static readonly PointFillMode: number;
  21004. /**
  21005. * Returns the point list draw mode
  21006. */
  21007. static readonly PointListDrawMode: number;
  21008. /**
  21009. * Returns the line list draw mode
  21010. */
  21011. static readonly LineListDrawMode: number;
  21012. /**
  21013. * Returns the line loop draw mode
  21014. */
  21015. static readonly LineLoopDrawMode: number;
  21016. /**
  21017. * Returns the line strip draw mode
  21018. */
  21019. static readonly LineStripDrawMode: number;
  21020. /**
  21021. * Returns the triangle strip draw mode
  21022. */
  21023. static readonly TriangleStripDrawMode: number;
  21024. /**
  21025. * Returns the triangle fan draw mode
  21026. */
  21027. static readonly TriangleFanDrawMode: number;
  21028. /**
  21029. * Stores the clock-wise side orientation
  21030. */
  21031. static readonly ClockWiseSideOrientation: number;
  21032. /**
  21033. * Stores the counter clock-wise side orientation
  21034. */
  21035. static readonly CounterClockWiseSideOrientation: number;
  21036. /**
  21037. * The dirty texture flag value
  21038. */
  21039. static readonly TextureDirtyFlag: number;
  21040. /**
  21041. * The dirty light flag value
  21042. */
  21043. static readonly LightDirtyFlag: number;
  21044. /**
  21045. * The dirty fresnel flag value
  21046. */
  21047. static readonly FresnelDirtyFlag: number;
  21048. /**
  21049. * The dirty attribute flag value
  21050. */
  21051. static readonly AttributesDirtyFlag: number;
  21052. /**
  21053. * The dirty misc flag value
  21054. */
  21055. static readonly MiscDirtyFlag: number;
  21056. /**
  21057. * The all dirty flag value
  21058. */
  21059. static readonly AllDirtyFlag: number;
  21060. /**
  21061. * The ID of the material
  21062. */
  21063. id: string;
  21064. /**
  21065. * Gets or sets the unique id of the material
  21066. */
  21067. uniqueId: number;
  21068. /**
  21069. * The name of the material
  21070. */
  21071. name: string;
  21072. /**
  21073. * Gets or sets user defined metadata
  21074. */
  21075. metadata: any;
  21076. /**
  21077. * For internal use only. Please do not use.
  21078. */
  21079. reservedDataStore: any;
  21080. /**
  21081. * Specifies if the ready state should be checked on each call
  21082. */
  21083. checkReadyOnEveryCall: boolean;
  21084. /**
  21085. * Specifies if the ready state should be checked once
  21086. */
  21087. checkReadyOnlyOnce: boolean;
  21088. /**
  21089. * The state of the material
  21090. */
  21091. state: string;
  21092. /**
  21093. * The alpha value of the material
  21094. */
  21095. protected _alpha: number;
  21096. /**
  21097. * List of inspectable custom properties (used by the Inspector)
  21098. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21099. */
  21100. inspectableCustomProperties: IInspectable[];
  21101. /**
  21102. * Sets the alpha value of the material
  21103. */
  21104. /**
  21105. * Gets the alpha value of the material
  21106. */
  21107. alpha: number;
  21108. /**
  21109. * Specifies if back face culling is enabled
  21110. */
  21111. protected _backFaceCulling: boolean;
  21112. /**
  21113. * Sets the back-face culling state
  21114. */
  21115. /**
  21116. * Gets the back-face culling state
  21117. */
  21118. backFaceCulling: boolean;
  21119. /**
  21120. * Stores the value for side orientation
  21121. */
  21122. sideOrientation: number;
  21123. /**
  21124. * Callback triggered when the material is compiled
  21125. */
  21126. onCompiled: Nullable<(effect: Effect) => void>;
  21127. /**
  21128. * Callback triggered when an error occurs
  21129. */
  21130. onError: Nullable<(effect: Effect, errors: string) => void>;
  21131. /**
  21132. * Callback triggered to get the render target textures
  21133. */
  21134. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21135. /**
  21136. * Gets a boolean indicating that current material needs to register RTT
  21137. */
  21138. readonly hasRenderTargetTextures: boolean;
  21139. /**
  21140. * Specifies if the material should be serialized
  21141. */
  21142. doNotSerialize: boolean;
  21143. /**
  21144. * @hidden
  21145. */
  21146. _storeEffectOnSubMeshes: boolean;
  21147. /**
  21148. * Stores the animations for the material
  21149. */
  21150. animations: Nullable<Array<Animation>>;
  21151. /**
  21152. * An event triggered when the material is disposed
  21153. */
  21154. onDisposeObservable: Observable<Material>;
  21155. /**
  21156. * An observer which watches for dispose events
  21157. */
  21158. private _onDisposeObserver;
  21159. private _onUnBindObservable;
  21160. /**
  21161. * Called during a dispose event
  21162. */
  21163. onDispose: () => void;
  21164. private _onBindObservable;
  21165. /**
  21166. * An event triggered when the material is bound
  21167. */
  21168. readonly onBindObservable: Observable<AbstractMesh>;
  21169. /**
  21170. * An observer which watches for bind events
  21171. */
  21172. private _onBindObserver;
  21173. /**
  21174. * Called during a bind event
  21175. */
  21176. onBind: (Mesh: AbstractMesh) => void;
  21177. /**
  21178. * An event triggered when the material is unbound
  21179. */
  21180. readonly onUnBindObservable: Observable<Material>;
  21181. /**
  21182. * Stores the value of the alpha mode
  21183. */
  21184. private _alphaMode;
  21185. /**
  21186. * Sets the value of the alpha mode.
  21187. *
  21188. * | Value | Type | Description |
  21189. * | --- | --- | --- |
  21190. * | 0 | ALPHA_DISABLE | |
  21191. * | 1 | ALPHA_ADD | |
  21192. * | 2 | ALPHA_COMBINE | |
  21193. * | 3 | ALPHA_SUBTRACT | |
  21194. * | 4 | ALPHA_MULTIPLY | |
  21195. * | 5 | ALPHA_MAXIMIZED | |
  21196. * | 6 | ALPHA_ONEONE | |
  21197. * | 7 | ALPHA_PREMULTIPLIED | |
  21198. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21199. * | 9 | ALPHA_INTERPOLATE | |
  21200. * | 10 | ALPHA_SCREENMODE | |
  21201. *
  21202. */
  21203. /**
  21204. * Gets the value of the alpha mode
  21205. */
  21206. alphaMode: number;
  21207. /**
  21208. * Stores the state of the need depth pre-pass value
  21209. */
  21210. private _needDepthPrePass;
  21211. /**
  21212. * Sets the need depth pre-pass value
  21213. */
  21214. /**
  21215. * Gets the depth pre-pass value
  21216. */
  21217. needDepthPrePass: boolean;
  21218. /**
  21219. * Specifies if depth writing should be disabled
  21220. */
  21221. disableDepthWrite: boolean;
  21222. /**
  21223. * Specifies if depth writing should be forced
  21224. */
  21225. forceDepthWrite: boolean;
  21226. /**
  21227. * Specifies the depth function that should be used. 0 means the default engine function
  21228. */
  21229. depthFunction: number;
  21230. /**
  21231. * Specifies if there should be a separate pass for culling
  21232. */
  21233. separateCullingPass: boolean;
  21234. /**
  21235. * Stores the state specifing if fog should be enabled
  21236. */
  21237. private _fogEnabled;
  21238. /**
  21239. * Sets the state for enabling fog
  21240. */
  21241. /**
  21242. * Gets the value of the fog enabled state
  21243. */
  21244. fogEnabled: boolean;
  21245. /**
  21246. * Stores the size of points
  21247. */
  21248. pointSize: number;
  21249. /**
  21250. * Stores the z offset value
  21251. */
  21252. zOffset: number;
  21253. /**
  21254. * Gets a value specifying if wireframe mode is enabled
  21255. */
  21256. /**
  21257. * Sets the state of wireframe mode
  21258. */
  21259. wireframe: boolean;
  21260. /**
  21261. * Gets the value specifying if point clouds are enabled
  21262. */
  21263. /**
  21264. * Sets the state of point cloud mode
  21265. */
  21266. pointsCloud: boolean;
  21267. /**
  21268. * Gets the material fill mode
  21269. */
  21270. /**
  21271. * Sets the material fill mode
  21272. */
  21273. fillMode: number;
  21274. /**
  21275. * @hidden
  21276. * Stores the effects for the material
  21277. */
  21278. _effect: Nullable<Effect>;
  21279. /**
  21280. * @hidden
  21281. * Specifies if the material was previously ready
  21282. */
  21283. _wasPreviouslyReady: boolean;
  21284. /**
  21285. * Specifies if uniform buffers should be used
  21286. */
  21287. private _useUBO;
  21288. /**
  21289. * Stores a reference to the scene
  21290. */
  21291. private _scene;
  21292. /**
  21293. * Stores the fill mode state
  21294. */
  21295. private _fillMode;
  21296. /**
  21297. * Specifies if the depth write state should be cached
  21298. */
  21299. private _cachedDepthWriteState;
  21300. /**
  21301. * Specifies if the depth function state should be cached
  21302. */
  21303. private _cachedDepthFunctionState;
  21304. /**
  21305. * Stores the uniform buffer
  21306. */
  21307. protected _uniformBuffer: UniformBuffer;
  21308. /** @hidden */
  21309. _indexInSceneMaterialArray: number;
  21310. /** @hidden */
  21311. meshMap: Nullable<{
  21312. [id: string]: AbstractMesh | undefined;
  21313. }>;
  21314. /**
  21315. * Creates a material instance
  21316. * @param name defines the name of the material
  21317. * @param scene defines the scene to reference
  21318. * @param doNotAdd specifies if the material should be added to the scene
  21319. */
  21320. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21321. /**
  21322. * Returns a string representation of the current material
  21323. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21324. * @returns a string with material information
  21325. */
  21326. toString(fullDetails?: boolean): string;
  21327. /**
  21328. * Gets the class name of the material
  21329. * @returns a string with the class name of the material
  21330. */
  21331. getClassName(): string;
  21332. /**
  21333. * Specifies if updates for the material been locked
  21334. */
  21335. readonly isFrozen: boolean;
  21336. /**
  21337. * Locks updates for the material
  21338. */
  21339. freeze(): void;
  21340. /**
  21341. * Unlocks updates for the material
  21342. */
  21343. unfreeze(): void;
  21344. /**
  21345. * Specifies if the material is ready to be used
  21346. * @param mesh defines the mesh to check
  21347. * @param useInstances specifies if instances should be used
  21348. * @returns a boolean indicating if the material is ready to be used
  21349. */
  21350. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21351. /**
  21352. * Specifies that the submesh is ready to be used
  21353. * @param mesh defines the mesh to check
  21354. * @param subMesh defines which submesh to check
  21355. * @param useInstances specifies that instances should be used
  21356. * @returns a boolean indicating that the submesh is ready or not
  21357. */
  21358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21359. /**
  21360. * Returns the material effect
  21361. * @returns the effect associated with the material
  21362. */
  21363. getEffect(): Nullable<Effect>;
  21364. /**
  21365. * Returns the current scene
  21366. * @returns a Scene
  21367. */
  21368. getScene(): Scene;
  21369. /**
  21370. * Specifies if the material will require alpha blending
  21371. * @returns a boolean specifying if alpha blending is needed
  21372. */
  21373. needAlphaBlending(): boolean;
  21374. /**
  21375. * Specifies if the mesh will require alpha blending
  21376. * @param mesh defines the mesh to check
  21377. * @returns a boolean specifying if alpha blending is needed for the mesh
  21378. */
  21379. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21380. /**
  21381. * Specifies if this material should be rendered in alpha test mode
  21382. * @returns a boolean specifying if an alpha test is needed.
  21383. */
  21384. needAlphaTesting(): boolean;
  21385. /**
  21386. * Gets the texture used for the alpha test
  21387. * @returns the texture to use for alpha testing
  21388. */
  21389. getAlphaTestTexture(): Nullable<BaseTexture>;
  21390. /**
  21391. * Marks the material to indicate that it needs to be re-calculated
  21392. */
  21393. markDirty(): void;
  21394. /** @hidden */
  21395. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21396. /**
  21397. * Binds the material to the mesh
  21398. * @param world defines the world transformation matrix
  21399. * @param mesh defines the mesh to bind the material to
  21400. */
  21401. bind(world: Matrix, mesh?: Mesh): void;
  21402. /**
  21403. * Binds the submesh to the material
  21404. * @param world defines the world transformation matrix
  21405. * @param mesh defines the mesh containing the submesh
  21406. * @param subMesh defines the submesh to bind the material to
  21407. */
  21408. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21409. /**
  21410. * Binds the world matrix to the material
  21411. * @param world defines the world transformation matrix
  21412. */
  21413. bindOnlyWorldMatrix(world: Matrix): void;
  21414. /**
  21415. * Binds the scene's uniform buffer to the effect.
  21416. * @param effect defines the effect to bind to the scene uniform buffer
  21417. * @param sceneUbo defines the uniform buffer storing scene data
  21418. */
  21419. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21420. /**
  21421. * Binds the view matrix to the effect
  21422. * @param effect defines the effect to bind the view matrix to
  21423. */
  21424. bindView(effect: Effect): void;
  21425. /**
  21426. * Binds the view projection matrix to the effect
  21427. * @param effect defines the effect to bind the view projection matrix to
  21428. */
  21429. bindViewProjection(effect: Effect): void;
  21430. /**
  21431. * Specifies if material alpha testing should be turned on for the mesh
  21432. * @param mesh defines the mesh to check
  21433. */
  21434. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21435. /**
  21436. * Processes to execute after binding the material to a mesh
  21437. * @param mesh defines the rendered mesh
  21438. */
  21439. protected _afterBind(mesh?: Mesh): void;
  21440. /**
  21441. * Unbinds the material from the mesh
  21442. */
  21443. unbind(): void;
  21444. /**
  21445. * Gets the active textures from the material
  21446. * @returns an array of textures
  21447. */
  21448. getActiveTextures(): BaseTexture[];
  21449. /**
  21450. * Specifies if the material uses a texture
  21451. * @param texture defines the texture to check against the material
  21452. * @returns a boolean specifying if the material uses the texture
  21453. */
  21454. hasTexture(texture: BaseTexture): boolean;
  21455. /**
  21456. * Makes a duplicate of the material, and gives it a new name
  21457. * @param name defines the new name for the duplicated material
  21458. * @returns the cloned material
  21459. */
  21460. clone(name: string): Nullable<Material>;
  21461. /**
  21462. * Gets the meshes bound to the material
  21463. * @returns an array of meshes bound to the material
  21464. */
  21465. getBindedMeshes(): AbstractMesh[];
  21466. /**
  21467. * Force shader compilation
  21468. * @param mesh defines the mesh associated with this material
  21469. * @param onCompiled defines a function to execute once the material is compiled
  21470. * @param options defines the options to configure the compilation
  21471. * @param onError defines a function to execute if the material fails compiling
  21472. */
  21473. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21474. /**
  21475. * Force shader compilation
  21476. * @param mesh defines the mesh that will use this material
  21477. * @param options defines additional options for compiling the shaders
  21478. * @returns a promise that resolves when the compilation completes
  21479. */
  21480. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21481. private static readonly _AllDirtyCallBack;
  21482. private static readonly _ImageProcessingDirtyCallBack;
  21483. private static readonly _TextureDirtyCallBack;
  21484. private static readonly _FresnelDirtyCallBack;
  21485. private static readonly _MiscDirtyCallBack;
  21486. private static readonly _LightsDirtyCallBack;
  21487. private static readonly _AttributeDirtyCallBack;
  21488. private static _FresnelAndMiscDirtyCallBack;
  21489. private static _TextureAndMiscDirtyCallBack;
  21490. private static readonly _DirtyCallbackArray;
  21491. private static readonly _RunDirtyCallBacks;
  21492. /**
  21493. * Marks a define in the material to indicate that it needs to be re-computed
  21494. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21495. */
  21496. markAsDirty(flag: number): void;
  21497. /**
  21498. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21499. * @param func defines a function which checks material defines against the submeshes
  21500. */
  21501. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21502. /**
  21503. * Indicates that we need to re-calculated for all submeshes
  21504. */
  21505. protected _markAllSubMeshesAsAllDirty(): void;
  21506. /**
  21507. * Indicates that image processing needs to be re-calculated for all submeshes
  21508. */
  21509. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21510. /**
  21511. * Indicates that textures need to be re-calculated for all submeshes
  21512. */
  21513. protected _markAllSubMeshesAsTexturesDirty(): void;
  21514. /**
  21515. * Indicates that fresnel needs to be re-calculated for all submeshes
  21516. */
  21517. protected _markAllSubMeshesAsFresnelDirty(): void;
  21518. /**
  21519. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21520. */
  21521. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21522. /**
  21523. * Indicates that lights need to be re-calculated for all submeshes
  21524. */
  21525. protected _markAllSubMeshesAsLightsDirty(): void;
  21526. /**
  21527. * Indicates that attributes need to be re-calculated for all submeshes
  21528. */
  21529. protected _markAllSubMeshesAsAttributesDirty(): void;
  21530. /**
  21531. * Indicates that misc needs to be re-calculated for all submeshes
  21532. */
  21533. protected _markAllSubMeshesAsMiscDirty(): void;
  21534. /**
  21535. * Indicates that textures and misc need to be re-calculated for all submeshes
  21536. */
  21537. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21538. /**
  21539. * Disposes the material
  21540. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21541. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21542. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21543. */
  21544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21545. /** @hidden */
  21546. private releaseVertexArrayObject;
  21547. /**
  21548. * Serializes this material
  21549. * @returns the serialized material object
  21550. */
  21551. serialize(): any;
  21552. /**
  21553. * Creates a material from parsed material data
  21554. * @param parsedMaterial defines parsed material data
  21555. * @param scene defines the hosting scene
  21556. * @param rootUrl defines the root URL to use to load textures
  21557. * @returns a new material
  21558. */
  21559. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21560. }
  21561. }
  21562. declare module "babylonjs/Materials/multiMaterial" {
  21563. import { Nullable } from "babylonjs/types";
  21564. import { Scene } from "babylonjs/scene";
  21565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21566. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21568. import { Material } from "babylonjs/Materials/material";
  21569. /**
  21570. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21571. * separate meshes. This can be use to improve performances.
  21572. * @see http://doc.babylonjs.com/how_to/multi_materials
  21573. */
  21574. export class MultiMaterial extends Material {
  21575. private _subMaterials;
  21576. /**
  21577. * Gets or Sets the list of Materials used within the multi material.
  21578. * They need to be ordered according to the submeshes order in the associated mesh
  21579. */
  21580. subMaterials: Nullable<Material>[];
  21581. /**
  21582. * Function used to align with Node.getChildren()
  21583. * @returns the list of Materials used within the multi material
  21584. */
  21585. getChildren(): Nullable<Material>[];
  21586. /**
  21587. * Instantiates a new Multi Material
  21588. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21589. * separate meshes. This can be use to improve performances.
  21590. * @see http://doc.babylonjs.com/how_to/multi_materials
  21591. * @param name Define the name in the scene
  21592. * @param scene Define the scene the material belongs to
  21593. */
  21594. constructor(name: string, scene: Scene);
  21595. private _hookArray;
  21596. /**
  21597. * Get one of the submaterial by its index in the submaterials array
  21598. * @param index The index to look the sub material at
  21599. * @returns The Material if the index has been defined
  21600. */
  21601. getSubMaterial(index: number): Nullable<Material>;
  21602. /**
  21603. * Get the list of active textures for the whole sub materials list.
  21604. * @returns All the textures that will be used during the rendering
  21605. */
  21606. getActiveTextures(): BaseTexture[];
  21607. /**
  21608. * Gets the current class name of the material e.g. "MultiMaterial"
  21609. * Mainly use in serialization.
  21610. * @returns the class name
  21611. */
  21612. getClassName(): string;
  21613. /**
  21614. * Checks if the material is ready to render the requested sub mesh
  21615. * @param mesh Define the mesh the submesh belongs to
  21616. * @param subMesh Define the sub mesh to look readyness for
  21617. * @param useInstances Define whether or not the material is used with instances
  21618. * @returns true if ready, otherwise false
  21619. */
  21620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21621. /**
  21622. * Clones the current material and its related sub materials
  21623. * @param name Define the name of the newly cloned material
  21624. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21625. * @returns the cloned material
  21626. */
  21627. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21628. /**
  21629. * Serializes the materials into a JSON representation.
  21630. * @returns the JSON representation
  21631. */
  21632. serialize(): any;
  21633. /**
  21634. * Dispose the material and release its associated resources
  21635. * @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)
  21636. * @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)
  21637. * @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)
  21638. */
  21639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21640. /**
  21641. * Creates a MultiMaterial from parsed MultiMaterial data.
  21642. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21643. * @param scene defines the hosting scene
  21644. * @returns a new MultiMaterial
  21645. */
  21646. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21647. }
  21648. }
  21649. declare module "babylonjs/Meshes/subMesh" {
  21650. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21651. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21652. import { Engine } from "babylonjs/Engines/engine";
  21653. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21654. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21655. import { Effect } from "babylonjs/Materials/effect";
  21656. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21657. import { Plane } from "babylonjs/Maths/math.plane";
  21658. import { Collider } from "babylonjs/Collisions/collider";
  21659. import { Material } from "babylonjs/Materials/material";
  21660. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21662. import { Mesh } from "babylonjs/Meshes/mesh";
  21663. import { Ray } from "babylonjs/Culling/ray";
  21664. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21665. /**
  21666. * Base class for submeshes
  21667. */
  21668. export class BaseSubMesh {
  21669. /** @hidden */
  21670. _materialDefines: Nullable<MaterialDefines>;
  21671. /** @hidden */
  21672. _materialEffect: Nullable<Effect>;
  21673. /**
  21674. * Gets associated effect
  21675. */
  21676. readonly effect: Nullable<Effect>;
  21677. /**
  21678. * Sets associated effect (effect used to render this submesh)
  21679. * @param effect defines the effect to associate with
  21680. * @param defines defines the set of defines used to compile this effect
  21681. */
  21682. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21683. }
  21684. /**
  21685. * Defines a subdivision inside a mesh
  21686. */
  21687. export class SubMesh extends BaseSubMesh implements ICullable {
  21688. /** the material index to use */
  21689. materialIndex: number;
  21690. /** vertex index start */
  21691. verticesStart: number;
  21692. /** vertices count */
  21693. verticesCount: number;
  21694. /** index start */
  21695. indexStart: number;
  21696. /** indices count */
  21697. indexCount: number;
  21698. /** @hidden */
  21699. _linesIndexCount: number;
  21700. private _mesh;
  21701. private _renderingMesh;
  21702. private _boundingInfo;
  21703. private _linesIndexBuffer;
  21704. /** @hidden */
  21705. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21706. /** @hidden */
  21707. _trianglePlanes: Plane[];
  21708. /** @hidden */
  21709. _lastColliderTransformMatrix: Nullable<Matrix>;
  21710. /** @hidden */
  21711. _renderId: number;
  21712. /** @hidden */
  21713. _alphaIndex: number;
  21714. /** @hidden */
  21715. _distanceToCamera: number;
  21716. /** @hidden */
  21717. _id: number;
  21718. private _currentMaterial;
  21719. /**
  21720. * Add a new submesh to a mesh
  21721. * @param materialIndex defines the material index to use
  21722. * @param verticesStart defines vertex index start
  21723. * @param verticesCount defines vertices count
  21724. * @param indexStart defines index start
  21725. * @param indexCount defines indices count
  21726. * @param mesh defines the parent mesh
  21727. * @param renderingMesh defines an optional rendering mesh
  21728. * @param createBoundingBox defines if bounding box should be created for this submesh
  21729. * @returns the new submesh
  21730. */
  21731. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21732. /**
  21733. * Creates a new submesh
  21734. * @param materialIndex defines the material index to use
  21735. * @param verticesStart defines vertex index start
  21736. * @param verticesCount defines vertices count
  21737. * @param indexStart defines index start
  21738. * @param indexCount defines indices count
  21739. * @param mesh defines the parent mesh
  21740. * @param renderingMesh defines an optional rendering mesh
  21741. * @param createBoundingBox defines if bounding box should be created for this submesh
  21742. */
  21743. constructor(
  21744. /** the material index to use */
  21745. materialIndex: number,
  21746. /** vertex index start */
  21747. verticesStart: number,
  21748. /** vertices count */
  21749. verticesCount: number,
  21750. /** index start */
  21751. indexStart: number,
  21752. /** indices count */
  21753. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21754. /**
  21755. * Returns true if this submesh covers the entire parent mesh
  21756. * @ignorenaming
  21757. */
  21758. readonly IsGlobal: boolean;
  21759. /**
  21760. * Returns the submesh BoudingInfo object
  21761. * @returns current bounding info (or mesh's one if the submesh is global)
  21762. */
  21763. getBoundingInfo(): BoundingInfo;
  21764. /**
  21765. * Sets the submesh BoundingInfo
  21766. * @param boundingInfo defines the new bounding info to use
  21767. * @returns the SubMesh
  21768. */
  21769. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21770. /**
  21771. * Returns the mesh of the current submesh
  21772. * @return the parent mesh
  21773. */
  21774. getMesh(): AbstractMesh;
  21775. /**
  21776. * Returns the rendering mesh of the submesh
  21777. * @returns the rendering mesh (could be different from parent mesh)
  21778. */
  21779. getRenderingMesh(): Mesh;
  21780. /**
  21781. * Returns the submesh material
  21782. * @returns null or the current material
  21783. */
  21784. getMaterial(): Nullable<Material>;
  21785. /**
  21786. * Sets a new updated BoundingInfo object to the submesh
  21787. * @param data defines an optional position array to use to determine the bounding info
  21788. * @returns the SubMesh
  21789. */
  21790. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21791. /** @hidden */
  21792. _checkCollision(collider: Collider): boolean;
  21793. /**
  21794. * Updates the submesh BoundingInfo
  21795. * @param world defines the world matrix to use to update the bounding info
  21796. * @returns the submesh
  21797. */
  21798. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21799. /**
  21800. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21801. * @param frustumPlanes defines the frustum planes
  21802. * @returns true if the submesh is intersecting with the frustum
  21803. */
  21804. isInFrustum(frustumPlanes: Plane[]): boolean;
  21805. /**
  21806. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21807. * @param frustumPlanes defines the frustum planes
  21808. * @returns true if the submesh is inside the frustum
  21809. */
  21810. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21811. /**
  21812. * Renders the submesh
  21813. * @param enableAlphaMode defines if alpha needs to be used
  21814. * @returns the submesh
  21815. */
  21816. render(enableAlphaMode: boolean): SubMesh;
  21817. /**
  21818. * @hidden
  21819. */
  21820. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21821. /**
  21822. * Checks if the submesh intersects with a ray
  21823. * @param ray defines the ray to test
  21824. * @returns true is the passed ray intersects the submesh bounding box
  21825. */
  21826. canIntersects(ray: Ray): boolean;
  21827. /**
  21828. * Intersects current submesh with a ray
  21829. * @param ray defines the ray to test
  21830. * @param positions defines mesh's positions array
  21831. * @param indices defines mesh's indices array
  21832. * @param fastCheck defines if only bounding info should be used
  21833. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21834. * @returns intersection info or null if no intersection
  21835. */
  21836. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21837. /** @hidden */
  21838. private _intersectLines;
  21839. /** @hidden */
  21840. private _intersectUnIndexedLines;
  21841. /** @hidden */
  21842. private _intersectTriangles;
  21843. /** @hidden */
  21844. private _intersectUnIndexedTriangles;
  21845. /** @hidden */
  21846. _rebuild(): void;
  21847. /**
  21848. * Creates a new submesh from the passed mesh
  21849. * @param newMesh defines the new hosting mesh
  21850. * @param newRenderingMesh defines an optional rendering mesh
  21851. * @returns the new submesh
  21852. */
  21853. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21854. /**
  21855. * Release associated resources
  21856. */
  21857. dispose(): void;
  21858. /**
  21859. * Gets the class name
  21860. * @returns the string "SubMesh".
  21861. */
  21862. getClassName(): string;
  21863. /**
  21864. * Creates a new submesh from indices data
  21865. * @param materialIndex the index of the main mesh material
  21866. * @param startIndex the index where to start the copy in the mesh indices array
  21867. * @param indexCount the number of indices to copy then from the startIndex
  21868. * @param mesh the main mesh to create the submesh from
  21869. * @param renderingMesh the optional rendering mesh
  21870. * @returns a new submesh
  21871. */
  21872. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21873. }
  21874. }
  21875. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21876. /**
  21877. * Class used to represent data loading progression
  21878. */
  21879. export class SceneLoaderFlags {
  21880. private static _ForceFullSceneLoadingForIncremental;
  21881. private static _ShowLoadingScreen;
  21882. private static _CleanBoneMatrixWeights;
  21883. private static _loggingLevel;
  21884. /**
  21885. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21886. */
  21887. static ForceFullSceneLoadingForIncremental: boolean;
  21888. /**
  21889. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21890. */
  21891. static ShowLoadingScreen: boolean;
  21892. /**
  21893. * Defines the current logging level (while loading the scene)
  21894. * @ignorenaming
  21895. */
  21896. static loggingLevel: number;
  21897. /**
  21898. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21899. */
  21900. static CleanBoneMatrixWeights: boolean;
  21901. }
  21902. }
  21903. declare module "babylonjs/Meshes/geometry" {
  21904. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21905. import { Scene } from "babylonjs/scene";
  21906. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21907. import { Engine } from "babylonjs/Engines/engine";
  21908. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21909. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21910. import { Effect } from "babylonjs/Materials/effect";
  21911. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21913. import { Mesh } from "babylonjs/Meshes/mesh";
  21914. /**
  21915. * Class used to store geometry data (vertex buffers + index buffer)
  21916. */
  21917. export class Geometry implements IGetSetVerticesData {
  21918. /**
  21919. * Gets or sets the ID of the geometry
  21920. */
  21921. id: string;
  21922. /**
  21923. * Gets or sets the unique ID of the geometry
  21924. */
  21925. uniqueId: number;
  21926. /**
  21927. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21928. */
  21929. delayLoadState: number;
  21930. /**
  21931. * Gets the file containing the data to load when running in delay load state
  21932. */
  21933. delayLoadingFile: Nullable<string>;
  21934. /**
  21935. * Callback called when the geometry is updated
  21936. */
  21937. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21938. private _scene;
  21939. private _engine;
  21940. private _meshes;
  21941. private _totalVertices;
  21942. /** @hidden */
  21943. _indices: IndicesArray;
  21944. /** @hidden */
  21945. _vertexBuffers: {
  21946. [key: string]: VertexBuffer;
  21947. };
  21948. private _isDisposed;
  21949. private _extend;
  21950. private _boundingBias;
  21951. /** @hidden */
  21952. _delayInfo: Array<string>;
  21953. private _indexBuffer;
  21954. private _indexBufferIsUpdatable;
  21955. /** @hidden */
  21956. _boundingInfo: Nullable<BoundingInfo>;
  21957. /** @hidden */
  21958. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21959. /** @hidden */
  21960. _softwareSkinningFrameId: number;
  21961. private _vertexArrayObjects;
  21962. private _updatable;
  21963. /** @hidden */
  21964. _positions: Nullable<Vector3[]>;
  21965. /**
  21966. * 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
  21967. */
  21968. /**
  21969. * 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
  21970. */
  21971. boundingBias: Vector2;
  21972. /**
  21973. * Static function used to attach a new empty geometry to a mesh
  21974. * @param mesh defines the mesh to attach the geometry to
  21975. * @returns the new Geometry
  21976. */
  21977. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21978. /**
  21979. * Creates a new geometry
  21980. * @param id defines the unique ID
  21981. * @param scene defines the hosting scene
  21982. * @param vertexData defines the VertexData used to get geometry data
  21983. * @param updatable defines if geometry must be updatable (false by default)
  21984. * @param mesh defines the mesh that will be associated with the geometry
  21985. */
  21986. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21987. /**
  21988. * Gets the current extend of the geometry
  21989. */
  21990. readonly extend: {
  21991. minimum: Vector3;
  21992. maximum: Vector3;
  21993. };
  21994. /**
  21995. * Gets the hosting scene
  21996. * @returns the hosting Scene
  21997. */
  21998. getScene(): Scene;
  21999. /**
  22000. * Gets the hosting engine
  22001. * @returns the hosting Engine
  22002. */
  22003. getEngine(): Engine;
  22004. /**
  22005. * Defines if the geometry is ready to use
  22006. * @returns true if the geometry is ready to be used
  22007. */
  22008. isReady(): boolean;
  22009. /**
  22010. * Gets a value indicating that the geometry should not be serialized
  22011. */
  22012. readonly doNotSerialize: boolean;
  22013. /** @hidden */
  22014. _rebuild(): void;
  22015. /**
  22016. * Affects all geometry data in one call
  22017. * @param vertexData defines the geometry data
  22018. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22019. */
  22020. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22021. /**
  22022. * Set specific vertex data
  22023. * @param kind defines the data kind (Position, normal, etc...)
  22024. * @param data defines the vertex data to use
  22025. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22026. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22027. */
  22028. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22029. /**
  22030. * Removes a specific vertex data
  22031. * @param kind defines the data kind (Position, normal, etc...)
  22032. */
  22033. removeVerticesData(kind: string): void;
  22034. /**
  22035. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22036. * @param buffer defines the vertex buffer to use
  22037. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22038. */
  22039. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22040. /**
  22041. * Update a specific vertex buffer
  22042. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22043. * It will do nothing if the buffer is not updatable
  22044. * @param kind defines the data kind (Position, normal, etc...)
  22045. * @param data defines the data to use
  22046. * @param offset defines the offset in the target buffer where to store the data
  22047. * @param useBytes set to true if the offset is in bytes
  22048. */
  22049. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22050. /**
  22051. * Update a specific vertex buffer
  22052. * This function will create a new buffer if the current one is not updatable
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. * @param data defines the data to use
  22055. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22056. */
  22057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22058. private _updateBoundingInfo;
  22059. /** @hidden */
  22060. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22061. /**
  22062. * Gets total number of vertices
  22063. * @returns the total number of vertices
  22064. */
  22065. getTotalVertices(): number;
  22066. /**
  22067. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22068. * @param kind defines the data kind (Position, normal, etc...)
  22069. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22070. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22071. * @returns a float array containing vertex data
  22072. */
  22073. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22074. /**
  22075. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22076. * @param kind defines the data kind (Position, normal, etc...)
  22077. * @returns true if the vertex buffer with the specified kind is updatable
  22078. */
  22079. isVertexBufferUpdatable(kind: string): boolean;
  22080. /**
  22081. * Gets a specific vertex buffer
  22082. * @param kind defines the data kind (Position, normal, etc...)
  22083. * @returns a VertexBuffer
  22084. */
  22085. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22086. /**
  22087. * Returns all vertex buffers
  22088. * @return an object holding all vertex buffers indexed by kind
  22089. */
  22090. getVertexBuffers(): Nullable<{
  22091. [key: string]: VertexBuffer;
  22092. }>;
  22093. /**
  22094. * Gets a boolean indicating if specific vertex buffer is present
  22095. * @param kind defines the data kind (Position, normal, etc...)
  22096. * @returns true if data is present
  22097. */
  22098. isVerticesDataPresent(kind: string): boolean;
  22099. /**
  22100. * Gets a list of all attached data kinds (Position, normal, etc...)
  22101. * @returns a list of string containing all kinds
  22102. */
  22103. getVerticesDataKinds(): string[];
  22104. /**
  22105. * Update index buffer
  22106. * @param indices defines the indices to store in the index buffer
  22107. * @param offset defines the offset in the target buffer where to store the data
  22108. * @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)
  22109. */
  22110. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22111. /**
  22112. * Creates a new index buffer
  22113. * @param indices defines the indices to store in the index buffer
  22114. * @param totalVertices defines the total number of vertices (could be null)
  22115. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22116. */
  22117. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22118. /**
  22119. * Return the total number of indices
  22120. * @returns the total number of indices
  22121. */
  22122. getTotalIndices(): number;
  22123. /**
  22124. * Gets the index buffer array
  22125. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22126. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22127. * @returns the index buffer array
  22128. */
  22129. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22130. /**
  22131. * Gets the index buffer
  22132. * @return the index buffer
  22133. */
  22134. getIndexBuffer(): Nullable<DataBuffer>;
  22135. /** @hidden */
  22136. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22137. /**
  22138. * Release the associated resources for a specific mesh
  22139. * @param mesh defines the source mesh
  22140. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22141. */
  22142. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22143. /**
  22144. * Apply current geometry to a given mesh
  22145. * @param mesh defines the mesh to apply geometry to
  22146. */
  22147. applyToMesh(mesh: Mesh): void;
  22148. private _updateExtend;
  22149. private _applyToMesh;
  22150. private notifyUpdate;
  22151. /**
  22152. * Load the geometry if it was flagged as delay loaded
  22153. * @param scene defines the hosting scene
  22154. * @param onLoaded defines a callback called when the geometry is loaded
  22155. */
  22156. load(scene: Scene, onLoaded?: () => void): void;
  22157. private _queueLoad;
  22158. /**
  22159. * Invert the geometry to move from a right handed system to a left handed one.
  22160. */
  22161. toLeftHanded(): void;
  22162. /** @hidden */
  22163. _resetPointsArrayCache(): void;
  22164. /** @hidden */
  22165. _generatePointsArray(): boolean;
  22166. /**
  22167. * Gets a value indicating if the geometry is disposed
  22168. * @returns true if the geometry was disposed
  22169. */
  22170. isDisposed(): boolean;
  22171. private _disposeVertexArrayObjects;
  22172. /**
  22173. * Free all associated resources
  22174. */
  22175. dispose(): void;
  22176. /**
  22177. * Clone the current geometry into a new geometry
  22178. * @param id defines the unique ID of the new geometry
  22179. * @returns a new geometry object
  22180. */
  22181. copy(id: string): Geometry;
  22182. /**
  22183. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22184. * @return a JSON representation of the current geometry data (without the vertices data)
  22185. */
  22186. serialize(): any;
  22187. private toNumberArray;
  22188. /**
  22189. * Serialize all vertices data into a JSON oject
  22190. * @returns a JSON representation of the current geometry data
  22191. */
  22192. serializeVerticeData(): any;
  22193. /**
  22194. * Extracts a clone of a mesh geometry
  22195. * @param mesh defines the source mesh
  22196. * @param id defines the unique ID of the new geometry object
  22197. * @returns the new geometry object
  22198. */
  22199. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22200. /**
  22201. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22202. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22203. * Be aware Math.random() could cause collisions, but:
  22204. * "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"
  22205. * @returns a string containing a new GUID
  22206. */
  22207. static RandomId(): string;
  22208. /** @hidden */
  22209. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22210. private static _CleanMatricesWeights;
  22211. /**
  22212. * Create a new geometry from persisted data (Using .babylon file format)
  22213. * @param parsedVertexData defines the persisted data
  22214. * @param scene defines the hosting scene
  22215. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22216. * @returns the new geometry object
  22217. */
  22218. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22219. }
  22220. }
  22221. declare module "babylonjs/Meshes/mesh.vertexData" {
  22222. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22223. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22224. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22225. import { Geometry } from "babylonjs/Meshes/geometry";
  22226. import { Mesh } from "babylonjs/Meshes/mesh";
  22227. /**
  22228. * Define an interface for all classes that will get and set the data on vertices
  22229. */
  22230. export interface IGetSetVerticesData {
  22231. /**
  22232. * Gets a boolean indicating if specific vertex data is present
  22233. * @param kind defines the vertex data kind to use
  22234. * @returns true is data kind is present
  22235. */
  22236. isVerticesDataPresent(kind: string): boolean;
  22237. /**
  22238. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22239. * @param kind defines the data kind (Position, normal, etc...)
  22240. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22241. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22242. * @returns a float array containing vertex data
  22243. */
  22244. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22245. /**
  22246. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22247. * @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.
  22248. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22249. * @returns the indices array or an empty array if the mesh has no geometry
  22250. */
  22251. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22252. /**
  22253. * Set specific vertex data
  22254. * @param kind defines the data kind (Position, normal, etc...)
  22255. * @param data defines the vertex data to use
  22256. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22257. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22258. */
  22259. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22260. /**
  22261. * Update a specific associated vertex buffer
  22262. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22263. * - VertexBuffer.PositionKind
  22264. * - VertexBuffer.UVKind
  22265. * - VertexBuffer.UV2Kind
  22266. * - VertexBuffer.UV3Kind
  22267. * - VertexBuffer.UV4Kind
  22268. * - VertexBuffer.UV5Kind
  22269. * - VertexBuffer.UV6Kind
  22270. * - VertexBuffer.ColorKind
  22271. * - VertexBuffer.MatricesIndicesKind
  22272. * - VertexBuffer.MatricesIndicesExtraKind
  22273. * - VertexBuffer.MatricesWeightsKind
  22274. * - VertexBuffer.MatricesWeightsExtraKind
  22275. * @param data defines the data source
  22276. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22277. * @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)
  22278. */
  22279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22280. /**
  22281. * Creates a new index buffer
  22282. * @param indices defines the indices to store in the index buffer
  22283. * @param totalVertices defines the total number of vertices (could be null)
  22284. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22285. */
  22286. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22287. }
  22288. /**
  22289. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22290. */
  22291. export class VertexData {
  22292. /**
  22293. * Mesh side orientation : usually the external or front surface
  22294. */
  22295. static readonly FRONTSIDE: number;
  22296. /**
  22297. * Mesh side orientation : usually the internal or back surface
  22298. */
  22299. static readonly BACKSIDE: number;
  22300. /**
  22301. * Mesh side orientation : both internal and external or front and back surfaces
  22302. */
  22303. static readonly DOUBLESIDE: number;
  22304. /**
  22305. * Mesh side orientation : by default, `FRONTSIDE`
  22306. */
  22307. static readonly DEFAULTSIDE: number;
  22308. /**
  22309. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22310. */
  22311. positions: Nullable<FloatArray>;
  22312. /**
  22313. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22314. */
  22315. normals: Nullable<FloatArray>;
  22316. /**
  22317. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22318. */
  22319. tangents: Nullable<FloatArray>;
  22320. /**
  22321. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22322. */
  22323. uvs: Nullable<FloatArray>;
  22324. /**
  22325. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22326. */
  22327. uvs2: Nullable<FloatArray>;
  22328. /**
  22329. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22330. */
  22331. uvs3: Nullable<FloatArray>;
  22332. /**
  22333. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22334. */
  22335. uvs4: Nullable<FloatArray>;
  22336. /**
  22337. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22338. */
  22339. uvs5: Nullable<FloatArray>;
  22340. /**
  22341. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22342. */
  22343. uvs6: Nullable<FloatArray>;
  22344. /**
  22345. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22346. */
  22347. colors: Nullable<FloatArray>;
  22348. /**
  22349. * 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).
  22350. */
  22351. matricesIndices: Nullable<FloatArray>;
  22352. /**
  22353. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22354. */
  22355. matricesWeights: Nullable<FloatArray>;
  22356. /**
  22357. * An array extending the number of possible indices
  22358. */
  22359. matricesIndicesExtra: Nullable<FloatArray>;
  22360. /**
  22361. * An array extending the number of possible weights when the number of indices is extended
  22362. */
  22363. matricesWeightsExtra: Nullable<FloatArray>;
  22364. /**
  22365. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22366. */
  22367. indices: Nullable<IndicesArray>;
  22368. /**
  22369. * Uses the passed data array to set the set the values for the specified kind of data
  22370. * @param data a linear array of floating numbers
  22371. * @param kind the type of data that is being set, eg positions, colors etc
  22372. */
  22373. set(data: FloatArray, kind: string): void;
  22374. /**
  22375. * Associates the vertexData to the passed Mesh.
  22376. * Sets it as updatable or not (default `false`)
  22377. * @param mesh the mesh the vertexData is applied to
  22378. * @param updatable when used and having the value true allows new data to update the vertexData
  22379. * @returns the VertexData
  22380. */
  22381. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22382. /**
  22383. * Associates the vertexData to the passed Geometry.
  22384. * Sets it as updatable or not (default `false`)
  22385. * @param geometry the geometry the vertexData is applied to
  22386. * @param updatable when used and having the value true allows new data to update the vertexData
  22387. * @returns VertexData
  22388. */
  22389. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22390. /**
  22391. * Updates the associated mesh
  22392. * @param mesh the mesh to be updated
  22393. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22394. * @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
  22395. * @returns VertexData
  22396. */
  22397. updateMesh(mesh: Mesh): VertexData;
  22398. /**
  22399. * Updates the associated geometry
  22400. * @param geometry the geometry to be updated
  22401. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22402. * @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
  22403. * @returns VertexData.
  22404. */
  22405. updateGeometry(geometry: Geometry): VertexData;
  22406. private _applyTo;
  22407. private _update;
  22408. /**
  22409. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22410. * @param matrix the transforming matrix
  22411. * @returns the VertexData
  22412. */
  22413. transform(matrix: Matrix): VertexData;
  22414. /**
  22415. * Merges the passed VertexData into the current one
  22416. * @param other the VertexData to be merged into the current one
  22417. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22418. * @returns the modified VertexData
  22419. */
  22420. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22421. private _mergeElement;
  22422. private _validate;
  22423. /**
  22424. * Serializes the VertexData
  22425. * @returns a serialized object
  22426. */
  22427. serialize(): any;
  22428. /**
  22429. * Extracts the vertexData from a mesh
  22430. * @param mesh the mesh from which to extract the VertexData
  22431. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22432. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22433. * @returns the object VertexData associated to the passed mesh
  22434. */
  22435. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22436. /**
  22437. * Extracts the vertexData from the geometry
  22438. * @param geometry the geometry from which to extract the VertexData
  22439. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22440. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22441. * @returns the object VertexData associated to the passed mesh
  22442. */
  22443. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22444. private static _ExtractFrom;
  22445. /**
  22446. * Creates the VertexData for a Ribbon
  22447. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22448. * * pathArray array of paths, each of which an array of successive Vector3
  22449. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22450. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22451. * * 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
  22452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22453. * * 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)
  22454. * * 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)
  22455. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22456. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22457. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22458. * @returns the VertexData of the ribbon
  22459. */
  22460. static CreateRibbon(options: {
  22461. pathArray: Vector3[][];
  22462. closeArray?: boolean;
  22463. closePath?: boolean;
  22464. offset?: number;
  22465. sideOrientation?: number;
  22466. frontUVs?: Vector4;
  22467. backUVs?: Vector4;
  22468. invertUV?: boolean;
  22469. uvs?: Vector2[];
  22470. colors?: Color4[];
  22471. }): VertexData;
  22472. /**
  22473. * Creates the VertexData for a box
  22474. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22475. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22476. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22477. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22478. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22479. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22480. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22482. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22483. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22484. * @returns the VertexData of the box
  22485. */
  22486. static CreateBox(options: {
  22487. size?: number;
  22488. width?: number;
  22489. height?: number;
  22490. depth?: number;
  22491. faceUV?: Vector4[];
  22492. faceColors?: Color4[];
  22493. sideOrientation?: number;
  22494. frontUVs?: Vector4;
  22495. backUVs?: Vector4;
  22496. }): VertexData;
  22497. /**
  22498. * Creates the VertexData for a tiled box
  22499. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22500. * * faceTiles sets the pattern, tile size and number of tiles for a face
  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. * @returns the VertexData of the box
  22505. */
  22506. static CreateTiledBox(options: {
  22507. pattern?: number;
  22508. width?: number;
  22509. height?: number;
  22510. depth?: number;
  22511. tileSize?: number;
  22512. tileWidth?: number;
  22513. tileHeight?: number;
  22514. alignHorizontal?: number;
  22515. alignVertical?: number;
  22516. faceUV?: Vector4[];
  22517. faceColors?: Color4[];
  22518. sideOrientation?: number;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData for a tiled plane
  22522. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22523. * * pattern a limited pattern arrangement depending on the number
  22524. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22525. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22526. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * 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)
  22529. * * 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)
  22530. * @returns the VertexData of the tiled plane
  22531. */
  22532. static CreateTiledPlane(options: {
  22533. pattern?: number;
  22534. tileSize?: number;
  22535. tileWidth?: number;
  22536. tileHeight?: number;
  22537. size?: number;
  22538. width?: number;
  22539. height?: number;
  22540. alignHorizontal?: number;
  22541. alignVertical?: number;
  22542. sideOrientation?: number;
  22543. frontUVs?: Vector4;
  22544. backUVs?: Vector4;
  22545. }): VertexData;
  22546. /**
  22547. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22548. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22549. * * segments sets the number of horizontal strips optional, default 32
  22550. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22551. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22552. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22553. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22554. * * 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
  22555. * * 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
  22556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22557. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22558. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22559. * @returns the VertexData of the ellipsoid
  22560. */
  22561. static CreateSphere(options: {
  22562. segments?: number;
  22563. diameter?: number;
  22564. diameterX?: number;
  22565. diameterY?: number;
  22566. diameterZ?: number;
  22567. arc?: number;
  22568. slice?: number;
  22569. sideOrientation?: number;
  22570. frontUVs?: Vector4;
  22571. backUVs?: Vector4;
  22572. }): VertexData;
  22573. /**
  22574. * Creates the VertexData for a cylinder, cone or prism
  22575. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22576. * * height sets the height (y direction) of the cylinder, optional, default 2
  22577. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22578. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22579. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22580. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22581. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22582. * * 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
  22583. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22584. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22585. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22586. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22588. * * 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)
  22589. * * 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)
  22590. * @returns the VertexData of the cylinder, cone or prism
  22591. */
  22592. static CreateCylinder(options: {
  22593. height?: number;
  22594. diameterTop?: number;
  22595. diameterBottom?: number;
  22596. diameter?: number;
  22597. tessellation?: number;
  22598. subdivisions?: number;
  22599. arc?: number;
  22600. faceColors?: Color4[];
  22601. faceUV?: Vector4[];
  22602. hasRings?: boolean;
  22603. enclose?: boolean;
  22604. sideOrientation?: number;
  22605. frontUVs?: Vector4;
  22606. backUVs?: Vector4;
  22607. }): VertexData;
  22608. /**
  22609. * Creates the VertexData for a torus
  22610. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22611. * * diameter the diameter of the torus, optional default 1
  22612. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22613. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22615. * * 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)
  22616. * * 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)
  22617. * @returns the VertexData of the torus
  22618. */
  22619. static CreateTorus(options: {
  22620. diameter?: number;
  22621. thickness?: number;
  22622. tessellation?: number;
  22623. sideOrientation?: number;
  22624. frontUVs?: Vector4;
  22625. backUVs?: Vector4;
  22626. }): VertexData;
  22627. /**
  22628. * Creates the VertexData of the LineSystem
  22629. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22630. * - lines an array of lines, each line being an array of successive Vector3
  22631. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22632. * @returns the VertexData of the LineSystem
  22633. */
  22634. static CreateLineSystem(options: {
  22635. lines: Vector3[][];
  22636. colors?: Nullable<Color4[][]>;
  22637. }): VertexData;
  22638. /**
  22639. * Create the VertexData for a DashedLines
  22640. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22641. * - points an array successive Vector3
  22642. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22643. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22644. * - dashNb the intended total number of dashes, optional, default 200
  22645. * @returns the VertexData for the DashedLines
  22646. */
  22647. static CreateDashedLines(options: {
  22648. points: Vector3[];
  22649. dashSize?: number;
  22650. gapSize?: number;
  22651. dashNb?: number;
  22652. }): VertexData;
  22653. /**
  22654. * Creates the VertexData for a Ground
  22655. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22656. * - width the width (x direction) of the ground, optional, default 1
  22657. * - height the height (z direction) of the ground, optional, default 1
  22658. * - subdivisions the number of subdivisions per side, optional, default 1
  22659. * @returns the VertexData of the Ground
  22660. */
  22661. static CreateGround(options: {
  22662. width?: number;
  22663. height?: number;
  22664. subdivisions?: number;
  22665. subdivisionsX?: number;
  22666. subdivisionsY?: number;
  22667. }): VertexData;
  22668. /**
  22669. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22670. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22671. * * xmin the ground minimum X coordinate, optional, default -1
  22672. * * zmin the ground minimum Z coordinate, optional, default -1
  22673. * * xmax the ground maximum X coordinate, optional, default 1
  22674. * * zmax the ground maximum Z coordinate, optional, default 1
  22675. * * 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}
  22676. * * 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}
  22677. * @returns the VertexData of the TiledGround
  22678. */
  22679. static CreateTiledGround(options: {
  22680. xmin: number;
  22681. zmin: number;
  22682. xmax: number;
  22683. zmax: number;
  22684. subdivisions?: {
  22685. w: number;
  22686. h: number;
  22687. };
  22688. precision?: {
  22689. w: number;
  22690. h: number;
  22691. };
  22692. }): VertexData;
  22693. /**
  22694. * Creates the VertexData of the Ground designed from a heightmap
  22695. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22696. * * width the width (x direction) of the ground
  22697. * * height the height (z direction) of the ground
  22698. * * subdivisions the number of subdivisions per side
  22699. * * minHeight the minimum altitude on the ground, optional, default 0
  22700. * * maxHeight the maximum altitude on the ground, optional default 1
  22701. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22702. * * buffer the array holding the image color data
  22703. * * bufferWidth the width of image
  22704. * * bufferHeight the height of image
  22705. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22706. * @returns the VertexData of the Ground designed from a heightmap
  22707. */
  22708. static CreateGroundFromHeightMap(options: {
  22709. width: number;
  22710. height: number;
  22711. subdivisions: number;
  22712. minHeight: number;
  22713. maxHeight: number;
  22714. colorFilter: Color3;
  22715. buffer: Uint8Array;
  22716. bufferWidth: number;
  22717. bufferHeight: number;
  22718. alphaFilter: number;
  22719. }): VertexData;
  22720. /**
  22721. * Creates the VertexData for a Plane
  22722. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22723. * * size sets the width and height of the plane to the value of size, optional default 1
  22724. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22725. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22727. * * 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)
  22728. * * 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)
  22729. * @returns the VertexData of the box
  22730. */
  22731. static CreatePlane(options: {
  22732. size?: number;
  22733. width?: number;
  22734. height?: number;
  22735. sideOrientation?: number;
  22736. frontUVs?: Vector4;
  22737. backUVs?: Vector4;
  22738. }): VertexData;
  22739. /**
  22740. * Creates the VertexData of the Disc or regular Polygon
  22741. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22742. * * radius the radius of the disc, optional default 0.5
  22743. * * tessellation the number of polygon sides, optional, default 64
  22744. * * 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
  22745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22746. * * 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)
  22747. * * 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)
  22748. * @returns the VertexData of the box
  22749. */
  22750. static CreateDisc(options: {
  22751. radius?: number;
  22752. tessellation?: number;
  22753. arc?: number;
  22754. sideOrientation?: number;
  22755. frontUVs?: Vector4;
  22756. backUVs?: Vector4;
  22757. }): VertexData;
  22758. /**
  22759. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22760. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22761. * @param polygon a mesh built from polygonTriangulation.build()
  22762. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22763. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22764. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22765. * @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)
  22766. * @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)
  22767. * @returns the VertexData of the Polygon
  22768. */
  22769. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22770. /**
  22771. * Creates the VertexData of the IcoSphere
  22772. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22773. * * radius the radius of the IcoSphere, optional default 1
  22774. * * radiusX allows stretching in the x direction, optional, default radius
  22775. * * radiusY allows stretching in the y direction, optional, default radius
  22776. * * radiusZ allows stretching in the z direction, optional, default radius
  22777. * * flat when true creates a flat shaded mesh, optional, default true
  22778. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22780. * * 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)
  22781. * * 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)
  22782. * @returns the VertexData of the IcoSphere
  22783. */
  22784. static CreateIcoSphere(options: {
  22785. radius?: number;
  22786. radiusX?: number;
  22787. radiusY?: number;
  22788. radiusZ?: number;
  22789. flat?: boolean;
  22790. subdivisions?: number;
  22791. sideOrientation?: number;
  22792. frontUVs?: Vector4;
  22793. backUVs?: Vector4;
  22794. }): VertexData;
  22795. /**
  22796. * Creates the VertexData for a Polyhedron
  22797. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22798. * * type provided types are:
  22799. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22800. * * 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)
  22801. * * size the size of the IcoSphere, optional default 1
  22802. * * sizeX allows stretching in the x direction, optional, default size
  22803. * * sizeY allows stretching in the y direction, optional, default size
  22804. * * sizeZ allows stretching in the z direction, optional, default size
  22805. * * 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
  22806. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22807. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22808. * * flat when true creates a flat shaded mesh, optional, default true
  22809. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22811. * * 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)
  22812. * * 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)
  22813. * @returns the VertexData of the Polyhedron
  22814. */
  22815. static CreatePolyhedron(options: {
  22816. type?: number;
  22817. size?: number;
  22818. sizeX?: number;
  22819. sizeY?: number;
  22820. sizeZ?: number;
  22821. custom?: any;
  22822. faceUV?: Vector4[];
  22823. faceColors?: Color4[];
  22824. flat?: boolean;
  22825. sideOrientation?: number;
  22826. frontUVs?: Vector4;
  22827. backUVs?: Vector4;
  22828. }): VertexData;
  22829. /**
  22830. * Creates the VertexData for a TorusKnot
  22831. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22832. * * radius the radius of the torus knot, optional, default 2
  22833. * * tube the thickness of the tube, optional, default 0.5
  22834. * * radialSegments the number of sides on each tube segments, optional, default 32
  22835. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22836. * * p the number of windings around the z axis, optional, default 2
  22837. * * q the number of windings around the x axis, optional, default 3
  22838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22839. * * 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)
  22840. * * 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)
  22841. * @returns the VertexData of the Torus Knot
  22842. */
  22843. static CreateTorusKnot(options: {
  22844. radius?: number;
  22845. tube?: number;
  22846. radialSegments?: number;
  22847. tubularSegments?: number;
  22848. p?: number;
  22849. q?: number;
  22850. sideOrientation?: number;
  22851. frontUVs?: Vector4;
  22852. backUVs?: Vector4;
  22853. }): VertexData;
  22854. /**
  22855. * Compute normals for given positions and indices
  22856. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22857. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22858. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22859. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22860. * * facetNormals : optional array of facet normals (vector3)
  22861. * * facetPositions : optional array of facet positions (vector3)
  22862. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22863. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22864. * * bInfo : optional bounding info, required for facetPartitioning computation
  22865. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22866. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22867. * * useRightHandedSystem: optional boolean to for right handed system computation
  22868. * * depthSort : optional boolean to enable the facet depth sort computation
  22869. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22870. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22871. */
  22872. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22873. facetNormals?: any;
  22874. facetPositions?: any;
  22875. facetPartitioning?: any;
  22876. ratio?: number;
  22877. bInfo?: any;
  22878. bbSize?: Vector3;
  22879. subDiv?: any;
  22880. useRightHandedSystem?: boolean;
  22881. depthSort?: boolean;
  22882. distanceTo?: Vector3;
  22883. depthSortedFacets?: any;
  22884. }): void;
  22885. /** @hidden */
  22886. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22887. /**
  22888. * Applies VertexData created from the imported parameters to the geometry
  22889. * @param parsedVertexData the parsed data from an imported file
  22890. * @param geometry the geometry to apply the VertexData to
  22891. */
  22892. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22893. }
  22894. }
  22895. declare module "babylonjs/Morph/morphTarget" {
  22896. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22897. import { Observable } from "babylonjs/Misc/observable";
  22898. import { Nullable, FloatArray } from "babylonjs/types";
  22899. import { Scene } from "babylonjs/scene";
  22900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22901. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22902. /**
  22903. * Defines a target to use with MorphTargetManager
  22904. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22905. */
  22906. export class MorphTarget implements IAnimatable {
  22907. /** defines the name of the target */
  22908. name: string;
  22909. /**
  22910. * Gets or sets the list of animations
  22911. */
  22912. animations: import("babylonjs/Animations/animation").Animation[];
  22913. private _scene;
  22914. private _positions;
  22915. private _normals;
  22916. private _tangents;
  22917. private _uvs;
  22918. private _influence;
  22919. private _uniqueId;
  22920. /**
  22921. * Observable raised when the influence changes
  22922. */
  22923. onInfluenceChanged: Observable<boolean>;
  22924. /** @hidden */
  22925. _onDataLayoutChanged: Observable<void>;
  22926. /**
  22927. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22928. */
  22929. influence: number;
  22930. /**
  22931. * Gets or sets the id of the morph Target
  22932. */
  22933. id: string;
  22934. private _animationPropertiesOverride;
  22935. /**
  22936. * Gets or sets the animation properties override
  22937. */
  22938. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22939. /**
  22940. * Creates a new MorphTarget
  22941. * @param name defines the name of the target
  22942. * @param influence defines the influence to use
  22943. * @param scene defines the scene the morphtarget belongs to
  22944. */
  22945. constructor(
  22946. /** defines the name of the target */
  22947. name: string, influence?: number, scene?: Nullable<Scene>);
  22948. /**
  22949. * Gets the unique ID of this manager
  22950. */
  22951. readonly uniqueId: number;
  22952. /**
  22953. * Gets a boolean defining if the target contains position data
  22954. */
  22955. readonly hasPositions: boolean;
  22956. /**
  22957. * Gets a boolean defining if the target contains normal data
  22958. */
  22959. readonly hasNormals: boolean;
  22960. /**
  22961. * Gets a boolean defining if the target contains tangent data
  22962. */
  22963. readonly hasTangents: boolean;
  22964. /**
  22965. * Gets a boolean defining if the target contains texture coordinates data
  22966. */
  22967. readonly hasUVs: boolean;
  22968. /**
  22969. * Affects position data to this target
  22970. * @param data defines the position data to use
  22971. */
  22972. setPositions(data: Nullable<FloatArray>): void;
  22973. /**
  22974. * Gets the position data stored in this target
  22975. * @returns a FloatArray containing the position data (or null if not present)
  22976. */
  22977. getPositions(): Nullable<FloatArray>;
  22978. /**
  22979. * Affects normal data to this target
  22980. * @param data defines the normal data to use
  22981. */
  22982. setNormals(data: Nullable<FloatArray>): void;
  22983. /**
  22984. * Gets the normal data stored in this target
  22985. * @returns a FloatArray containing the normal data (or null if not present)
  22986. */
  22987. getNormals(): Nullable<FloatArray>;
  22988. /**
  22989. * Affects tangent data to this target
  22990. * @param data defines the tangent data to use
  22991. */
  22992. setTangents(data: Nullable<FloatArray>): void;
  22993. /**
  22994. * Gets the tangent data stored in this target
  22995. * @returns a FloatArray containing the tangent data (or null if not present)
  22996. */
  22997. getTangents(): Nullable<FloatArray>;
  22998. /**
  22999. * Affects texture coordinates data to this target
  23000. * @param data defines the texture coordinates data to use
  23001. */
  23002. setUVs(data: Nullable<FloatArray>): void;
  23003. /**
  23004. * Gets the texture coordinates data stored in this target
  23005. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23006. */
  23007. getUVs(): Nullable<FloatArray>;
  23008. /**
  23009. * Clone the current target
  23010. * @returns a new MorphTarget
  23011. */
  23012. clone(): MorphTarget;
  23013. /**
  23014. * Serializes the current target into a Serialization object
  23015. * @returns the serialized object
  23016. */
  23017. serialize(): any;
  23018. /**
  23019. * Returns the string "MorphTarget"
  23020. * @returns "MorphTarget"
  23021. */
  23022. getClassName(): string;
  23023. /**
  23024. * Creates a new target from serialized data
  23025. * @param serializationObject defines the serialized data to use
  23026. * @returns a new MorphTarget
  23027. */
  23028. static Parse(serializationObject: any): MorphTarget;
  23029. /**
  23030. * Creates a MorphTarget from mesh data
  23031. * @param mesh defines the source mesh
  23032. * @param name defines the name to use for the new target
  23033. * @param influence defines the influence to attach to the target
  23034. * @returns a new MorphTarget
  23035. */
  23036. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23037. }
  23038. }
  23039. declare module "babylonjs/Morph/morphTargetManager" {
  23040. import { Nullable } from "babylonjs/types";
  23041. import { Scene } from "babylonjs/scene";
  23042. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23043. /**
  23044. * This class is used to deform meshes using morphing between different targets
  23045. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23046. */
  23047. export class MorphTargetManager {
  23048. private _targets;
  23049. private _targetInfluenceChangedObservers;
  23050. private _targetDataLayoutChangedObservers;
  23051. private _activeTargets;
  23052. private _scene;
  23053. private _influences;
  23054. private _supportsNormals;
  23055. private _supportsTangents;
  23056. private _supportsUVs;
  23057. private _vertexCount;
  23058. private _uniqueId;
  23059. private _tempInfluences;
  23060. /**
  23061. * Gets or sets a boolean indicating if normals must be morphed
  23062. */
  23063. enableNormalMorphing: boolean;
  23064. /**
  23065. * Gets or sets a boolean indicating if tangents must be morphed
  23066. */
  23067. enableTangentMorphing: boolean;
  23068. /**
  23069. * Gets or sets a boolean indicating if UV must be morphed
  23070. */
  23071. enableUVMorphing: boolean;
  23072. /**
  23073. * Creates a new MorphTargetManager
  23074. * @param scene defines the current scene
  23075. */
  23076. constructor(scene?: Nullable<Scene>);
  23077. /**
  23078. * Gets the unique ID of this manager
  23079. */
  23080. readonly uniqueId: number;
  23081. /**
  23082. * Gets the number of vertices handled by this manager
  23083. */
  23084. readonly vertexCount: number;
  23085. /**
  23086. * Gets a boolean indicating if this manager supports morphing of normals
  23087. */
  23088. readonly supportsNormals: boolean;
  23089. /**
  23090. * Gets a boolean indicating if this manager supports morphing of tangents
  23091. */
  23092. readonly supportsTangents: boolean;
  23093. /**
  23094. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23095. */
  23096. readonly supportsUVs: boolean;
  23097. /**
  23098. * Gets the number of targets stored in this manager
  23099. */
  23100. readonly numTargets: number;
  23101. /**
  23102. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23103. */
  23104. readonly numInfluencers: number;
  23105. /**
  23106. * Gets the list of influences (one per target)
  23107. */
  23108. readonly influences: Float32Array;
  23109. /**
  23110. * Gets the active target at specified index. An active target is a target with an influence > 0
  23111. * @param index defines the index to check
  23112. * @returns the requested target
  23113. */
  23114. getActiveTarget(index: number): MorphTarget;
  23115. /**
  23116. * Gets the target at specified index
  23117. * @param index defines the index to check
  23118. * @returns the requested target
  23119. */
  23120. getTarget(index: number): MorphTarget;
  23121. /**
  23122. * Add a new target to this manager
  23123. * @param target defines the target to add
  23124. */
  23125. addTarget(target: MorphTarget): void;
  23126. /**
  23127. * Removes a target from the manager
  23128. * @param target defines the target to remove
  23129. */
  23130. removeTarget(target: MorphTarget): void;
  23131. /**
  23132. * Clone the current manager
  23133. * @returns a new MorphTargetManager
  23134. */
  23135. clone(): MorphTargetManager;
  23136. /**
  23137. * Serializes the current manager into a Serialization object
  23138. * @returns the serialized object
  23139. */
  23140. serialize(): any;
  23141. private _syncActiveTargets;
  23142. /**
  23143. * Syncrhonize the targets with all the meshes using this morph target manager
  23144. */
  23145. synchronize(): void;
  23146. /**
  23147. * Creates a new MorphTargetManager from serialized data
  23148. * @param serializationObject defines the serialized data
  23149. * @param scene defines the hosting scene
  23150. * @returns the new MorphTargetManager
  23151. */
  23152. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23153. }
  23154. }
  23155. declare module "babylonjs/Meshes/meshLODLevel" {
  23156. import { Mesh } from "babylonjs/Meshes/mesh";
  23157. import { Nullable } from "babylonjs/types";
  23158. /**
  23159. * Class used to represent a specific level of detail of a mesh
  23160. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23161. */
  23162. export class MeshLODLevel {
  23163. /** Defines the distance where this level should start being displayed */
  23164. distance: number;
  23165. /** Defines the mesh to use to render this level */
  23166. mesh: Nullable<Mesh>;
  23167. /**
  23168. * Creates a new LOD level
  23169. * @param distance defines the distance where this level should star being displayed
  23170. * @param mesh defines the mesh to use to render this level
  23171. */
  23172. constructor(
  23173. /** Defines the distance where this level should start being displayed */
  23174. distance: number,
  23175. /** Defines the mesh to use to render this level */
  23176. mesh: Nullable<Mesh>);
  23177. }
  23178. }
  23179. declare module "babylonjs/Meshes/groundMesh" {
  23180. import { Scene } from "babylonjs/scene";
  23181. import { Vector3 } from "babylonjs/Maths/math.vector";
  23182. import { Mesh } from "babylonjs/Meshes/mesh";
  23183. /**
  23184. * Mesh representing the gorund
  23185. */
  23186. export class GroundMesh extends Mesh {
  23187. /** If octree should be generated */
  23188. generateOctree: boolean;
  23189. private _heightQuads;
  23190. /** @hidden */
  23191. _subdivisionsX: number;
  23192. /** @hidden */
  23193. _subdivisionsY: number;
  23194. /** @hidden */
  23195. _width: number;
  23196. /** @hidden */
  23197. _height: number;
  23198. /** @hidden */
  23199. _minX: number;
  23200. /** @hidden */
  23201. _maxX: number;
  23202. /** @hidden */
  23203. _minZ: number;
  23204. /** @hidden */
  23205. _maxZ: number;
  23206. constructor(name: string, scene: Scene);
  23207. /**
  23208. * "GroundMesh"
  23209. * @returns "GroundMesh"
  23210. */
  23211. getClassName(): string;
  23212. /**
  23213. * The minimum of x and y subdivisions
  23214. */
  23215. readonly subdivisions: number;
  23216. /**
  23217. * X subdivisions
  23218. */
  23219. readonly subdivisionsX: number;
  23220. /**
  23221. * Y subdivisions
  23222. */
  23223. readonly subdivisionsY: number;
  23224. /**
  23225. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23226. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23227. * @param chunksCount the number of subdivisions for x and y
  23228. * @param octreeBlocksSize (Default: 32)
  23229. */
  23230. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23231. /**
  23232. * Returns a height (y) value in the Worl system :
  23233. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23234. * @param x x coordinate
  23235. * @param z z coordinate
  23236. * @returns the ground y position if (x, z) are outside the ground surface.
  23237. */
  23238. getHeightAtCoordinates(x: number, z: number): number;
  23239. /**
  23240. * Returns a normalized vector (Vector3) orthogonal to the ground
  23241. * at the ground coordinates (x, z) expressed in the World system.
  23242. * @param x x coordinate
  23243. * @param z z coordinate
  23244. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23245. */
  23246. getNormalAtCoordinates(x: number, z: number): Vector3;
  23247. /**
  23248. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23249. * at the ground coordinates (x, z) expressed in the World system.
  23250. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23251. * @param x x coordinate
  23252. * @param z z coordinate
  23253. * @param ref vector to store the result
  23254. * @returns the GroundMesh.
  23255. */
  23256. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23257. /**
  23258. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23259. * if the ground has been updated.
  23260. * This can be used in the render loop.
  23261. * @returns the GroundMesh.
  23262. */
  23263. updateCoordinateHeights(): GroundMesh;
  23264. private _getFacetAt;
  23265. private _initHeightQuads;
  23266. private _computeHeightQuads;
  23267. /**
  23268. * Serializes this ground mesh
  23269. * @param serializationObject object to write serialization to
  23270. */
  23271. serialize(serializationObject: any): void;
  23272. /**
  23273. * Parses a serialized ground mesh
  23274. * @param parsedMesh the serialized mesh
  23275. * @param scene the scene to create the ground mesh in
  23276. * @returns the created ground mesh
  23277. */
  23278. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23279. }
  23280. }
  23281. declare module "babylonjs/Physics/physicsJoint" {
  23282. import { Vector3 } from "babylonjs/Maths/math.vector";
  23283. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23284. /**
  23285. * Interface for Physics-Joint data
  23286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23287. */
  23288. export interface PhysicsJointData {
  23289. /**
  23290. * The main pivot of the joint
  23291. */
  23292. mainPivot?: Vector3;
  23293. /**
  23294. * The connected pivot of the joint
  23295. */
  23296. connectedPivot?: Vector3;
  23297. /**
  23298. * The main axis of the joint
  23299. */
  23300. mainAxis?: Vector3;
  23301. /**
  23302. * The connected axis of the joint
  23303. */
  23304. connectedAxis?: Vector3;
  23305. /**
  23306. * The collision of the joint
  23307. */
  23308. collision?: boolean;
  23309. /**
  23310. * Native Oimo/Cannon/Energy data
  23311. */
  23312. nativeParams?: any;
  23313. }
  23314. /**
  23315. * This is a holder class for the physics joint created by the physics plugin
  23316. * It holds a set of functions to control the underlying joint
  23317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23318. */
  23319. export class PhysicsJoint {
  23320. /**
  23321. * The type of the physics joint
  23322. */
  23323. type: number;
  23324. /**
  23325. * The data for the physics joint
  23326. */
  23327. jointData: PhysicsJointData;
  23328. private _physicsJoint;
  23329. protected _physicsPlugin: IPhysicsEnginePlugin;
  23330. /**
  23331. * Initializes the physics joint
  23332. * @param type The type of the physics joint
  23333. * @param jointData The data for the physics joint
  23334. */
  23335. constructor(
  23336. /**
  23337. * The type of the physics joint
  23338. */
  23339. type: number,
  23340. /**
  23341. * The data for the physics joint
  23342. */
  23343. jointData: PhysicsJointData);
  23344. /**
  23345. * Gets the physics joint
  23346. */
  23347. /**
  23348. * Sets the physics joint
  23349. */
  23350. physicsJoint: any;
  23351. /**
  23352. * Sets the physics plugin
  23353. */
  23354. physicsPlugin: IPhysicsEnginePlugin;
  23355. /**
  23356. * Execute a function that is physics-plugin specific.
  23357. * @param {Function} func the function that will be executed.
  23358. * It accepts two parameters: the physics world and the physics joint
  23359. */
  23360. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23361. /**
  23362. * Distance-Joint type
  23363. */
  23364. static DistanceJoint: number;
  23365. /**
  23366. * Hinge-Joint type
  23367. */
  23368. static HingeJoint: number;
  23369. /**
  23370. * Ball-and-Socket joint type
  23371. */
  23372. static BallAndSocketJoint: number;
  23373. /**
  23374. * Wheel-Joint type
  23375. */
  23376. static WheelJoint: number;
  23377. /**
  23378. * Slider-Joint type
  23379. */
  23380. static SliderJoint: number;
  23381. /**
  23382. * Prismatic-Joint type
  23383. */
  23384. static PrismaticJoint: number;
  23385. /**
  23386. * Universal-Joint type
  23387. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23388. */
  23389. static UniversalJoint: number;
  23390. /**
  23391. * Hinge-Joint 2 type
  23392. */
  23393. static Hinge2Joint: number;
  23394. /**
  23395. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23396. */
  23397. static PointToPointJoint: number;
  23398. /**
  23399. * Spring-Joint type
  23400. */
  23401. static SpringJoint: number;
  23402. /**
  23403. * Lock-Joint type
  23404. */
  23405. static LockJoint: number;
  23406. }
  23407. /**
  23408. * A class representing a physics distance joint
  23409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23410. */
  23411. export class DistanceJoint extends PhysicsJoint {
  23412. /**
  23413. *
  23414. * @param jointData The data for the Distance-Joint
  23415. */
  23416. constructor(jointData: DistanceJointData);
  23417. /**
  23418. * Update the predefined distance.
  23419. * @param maxDistance The maximum preferred distance
  23420. * @param minDistance The minimum preferred distance
  23421. */
  23422. updateDistance(maxDistance: number, minDistance?: number): void;
  23423. }
  23424. /**
  23425. * Represents a Motor-Enabled Joint
  23426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23427. */
  23428. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23429. /**
  23430. * Initializes the Motor-Enabled Joint
  23431. * @param type The type of the joint
  23432. * @param jointData The physica joint data for the joint
  23433. */
  23434. constructor(type: number, jointData: PhysicsJointData);
  23435. /**
  23436. * Set the motor values.
  23437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23438. * @param force the force to apply
  23439. * @param maxForce max force for this motor.
  23440. */
  23441. setMotor(force?: number, maxForce?: number): void;
  23442. /**
  23443. * Set the motor's limits.
  23444. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23445. * @param upperLimit The upper limit of the motor
  23446. * @param lowerLimit The lower limit of the motor
  23447. */
  23448. setLimit(upperLimit: number, lowerLimit?: number): void;
  23449. }
  23450. /**
  23451. * This class represents a single physics Hinge-Joint
  23452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23453. */
  23454. export class HingeJoint extends MotorEnabledJoint {
  23455. /**
  23456. * Initializes the Hinge-Joint
  23457. * @param jointData The joint data for the Hinge-Joint
  23458. */
  23459. constructor(jointData: PhysicsJointData);
  23460. /**
  23461. * Set the motor values.
  23462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23463. * @param {number} force the force to apply
  23464. * @param {number} maxForce max force for this motor.
  23465. */
  23466. setMotor(force?: number, maxForce?: number): void;
  23467. /**
  23468. * Set the motor's limits.
  23469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23470. * @param upperLimit The upper limit of the motor
  23471. * @param lowerLimit The lower limit of the motor
  23472. */
  23473. setLimit(upperLimit: number, lowerLimit?: number): void;
  23474. }
  23475. /**
  23476. * This class represents a dual hinge physics joint (same as wheel joint)
  23477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23478. */
  23479. export class Hinge2Joint extends MotorEnabledJoint {
  23480. /**
  23481. * Initializes the Hinge2-Joint
  23482. * @param jointData The joint data for the Hinge2-Joint
  23483. */
  23484. constructor(jointData: PhysicsJointData);
  23485. /**
  23486. * Set the motor values.
  23487. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23488. * @param {number} targetSpeed the speed the motor is to reach
  23489. * @param {number} maxForce max force for this motor.
  23490. * @param {motorIndex} the motor's index, 0 or 1.
  23491. */
  23492. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23493. /**
  23494. * Set the motor limits.
  23495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23496. * @param {number} upperLimit the upper limit
  23497. * @param {number} lowerLimit lower limit
  23498. * @param {motorIndex} the motor's index, 0 or 1.
  23499. */
  23500. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23501. }
  23502. /**
  23503. * Interface for a motor enabled joint
  23504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23505. */
  23506. export interface IMotorEnabledJoint {
  23507. /**
  23508. * Physics joint
  23509. */
  23510. physicsJoint: any;
  23511. /**
  23512. * Sets the motor of the motor-enabled joint
  23513. * @param force The force of the motor
  23514. * @param maxForce The maximum force of the motor
  23515. * @param motorIndex The index of the motor
  23516. */
  23517. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23518. /**
  23519. * Sets the limit of the motor
  23520. * @param upperLimit The upper limit of the motor
  23521. * @param lowerLimit The lower limit of the motor
  23522. * @param motorIndex The index of the motor
  23523. */
  23524. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23525. }
  23526. /**
  23527. * Joint data for a Distance-Joint
  23528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23529. */
  23530. export interface DistanceJointData extends PhysicsJointData {
  23531. /**
  23532. * Max distance the 2 joint objects can be apart
  23533. */
  23534. maxDistance: number;
  23535. }
  23536. /**
  23537. * Joint data from a spring joint
  23538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23539. */
  23540. export interface SpringJointData extends PhysicsJointData {
  23541. /**
  23542. * Length of the spring
  23543. */
  23544. length: number;
  23545. /**
  23546. * Stiffness of the spring
  23547. */
  23548. stiffness: number;
  23549. /**
  23550. * Damping of the spring
  23551. */
  23552. damping: number;
  23553. /** this callback will be called when applying the force to the impostors. */
  23554. forceApplicationCallback: () => void;
  23555. }
  23556. }
  23557. declare module "babylonjs/Physics/physicsRaycastResult" {
  23558. import { Vector3 } from "babylonjs/Maths/math.vector";
  23559. /**
  23560. * Holds the data for the raycast result
  23561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23562. */
  23563. export class PhysicsRaycastResult {
  23564. private _hasHit;
  23565. private _hitDistance;
  23566. private _hitNormalWorld;
  23567. private _hitPointWorld;
  23568. private _rayFromWorld;
  23569. private _rayToWorld;
  23570. /**
  23571. * Gets if there was a hit
  23572. */
  23573. readonly hasHit: boolean;
  23574. /**
  23575. * Gets the distance from the hit
  23576. */
  23577. readonly hitDistance: number;
  23578. /**
  23579. * Gets the hit normal/direction in the world
  23580. */
  23581. readonly hitNormalWorld: Vector3;
  23582. /**
  23583. * Gets the hit point in the world
  23584. */
  23585. readonly hitPointWorld: Vector3;
  23586. /**
  23587. * Gets the ray "start point" of the ray in the world
  23588. */
  23589. readonly rayFromWorld: Vector3;
  23590. /**
  23591. * Gets the ray "end point" of the ray in the world
  23592. */
  23593. readonly rayToWorld: Vector3;
  23594. /**
  23595. * Sets the hit data (normal & point in world space)
  23596. * @param hitNormalWorld defines the normal in world space
  23597. * @param hitPointWorld defines the point in world space
  23598. */
  23599. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23600. /**
  23601. * Sets the distance from the start point to the hit point
  23602. * @param distance
  23603. */
  23604. setHitDistance(distance: number): void;
  23605. /**
  23606. * Calculates the distance manually
  23607. */
  23608. calculateHitDistance(): void;
  23609. /**
  23610. * Resets all the values to default
  23611. * @param from The from point on world space
  23612. * @param to The to point on world space
  23613. */
  23614. reset(from?: Vector3, to?: Vector3): void;
  23615. }
  23616. /**
  23617. * Interface for the size containing width and height
  23618. */
  23619. interface IXYZ {
  23620. /**
  23621. * X
  23622. */
  23623. x: number;
  23624. /**
  23625. * Y
  23626. */
  23627. y: number;
  23628. /**
  23629. * Z
  23630. */
  23631. z: number;
  23632. }
  23633. }
  23634. declare module "babylonjs/Physics/IPhysicsEngine" {
  23635. import { Nullable } from "babylonjs/types";
  23636. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23638. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23639. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23640. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23641. /**
  23642. * Interface used to describe a physics joint
  23643. */
  23644. export interface PhysicsImpostorJoint {
  23645. /** Defines the main impostor to which the joint is linked */
  23646. mainImpostor: PhysicsImpostor;
  23647. /** Defines the impostor that is connected to the main impostor using this joint */
  23648. connectedImpostor: PhysicsImpostor;
  23649. /** Defines the joint itself */
  23650. joint: PhysicsJoint;
  23651. }
  23652. /** @hidden */
  23653. export interface IPhysicsEnginePlugin {
  23654. world: any;
  23655. name: string;
  23656. setGravity(gravity: Vector3): void;
  23657. setTimeStep(timeStep: number): void;
  23658. getTimeStep(): number;
  23659. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23660. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23661. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23662. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23663. removePhysicsBody(impostor: PhysicsImpostor): void;
  23664. generateJoint(joint: PhysicsImpostorJoint): void;
  23665. removeJoint(joint: PhysicsImpostorJoint): void;
  23666. isSupported(): boolean;
  23667. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23668. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23669. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23670. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23671. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23672. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23673. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23674. getBodyMass(impostor: PhysicsImpostor): number;
  23675. getBodyFriction(impostor: PhysicsImpostor): number;
  23676. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23677. getBodyRestitution(impostor: PhysicsImpostor): number;
  23678. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23679. getBodyPressure?(impostor: PhysicsImpostor): number;
  23680. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23681. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23682. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23683. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23684. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23685. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23686. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23687. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23688. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23689. sleepBody(impostor: PhysicsImpostor): void;
  23690. wakeUpBody(impostor: PhysicsImpostor): void;
  23691. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23692. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23693. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23694. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23695. getRadius(impostor: PhysicsImpostor): number;
  23696. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23697. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23698. dispose(): void;
  23699. }
  23700. /**
  23701. * Interface used to define a physics engine
  23702. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23703. */
  23704. export interface IPhysicsEngine {
  23705. /**
  23706. * Gets the gravity vector used by the simulation
  23707. */
  23708. gravity: Vector3;
  23709. /**
  23710. * Sets the gravity vector used by the simulation
  23711. * @param gravity defines the gravity vector to use
  23712. */
  23713. setGravity(gravity: Vector3): void;
  23714. /**
  23715. * Set the time step of the physics engine.
  23716. * Default is 1/60.
  23717. * To slow it down, enter 1/600 for example.
  23718. * To speed it up, 1/30
  23719. * @param newTimeStep the new timestep to apply to this world.
  23720. */
  23721. setTimeStep(newTimeStep: number): void;
  23722. /**
  23723. * Get the time step of the physics engine.
  23724. * @returns the current time step
  23725. */
  23726. getTimeStep(): number;
  23727. /**
  23728. * Release all resources
  23729. */
  23730. dispose(): void;
  23731. /**
  23732. * Gets the name of the current physics plugin
  23733. * @returns the name of the plugin
  23734. */
  23735. getPhysicsPluginName(): string;
  23736. /**
  23737. * Adding a new impostor for the impostor tracking.
  23738. * This will be done by the impostor itself.
  23739. * @param impostor the impostor to add
  23740. */
  23741. addImpostor(impostor: PhysicsImpostor): void;
  23742. /**
  23743. * Remove an impostor from the engine.
  23744. * This impostor and its mesh will not longer be updated by the physics engine.
  23745. * @param impostor the impostor to remove
  23746. */
  23747. removeImpostor(impostor: PhysicsImpostor): void;
  23748. /**
  23749. * Add a joint to the physics engine
  23750. * @param mainImpostor defines the main impostor to which the joint is added.
  23751. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23752. * @param joint defines the joint that will connect both impostors.
  23753. */
  23754. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23755. /**
  23756. * Removes a joint from the simulation
  23757. * @param mainImpostor defines the impostor used with the joint
  23758. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23759. * @param joint defines the joint to remove
  23760. */
  23761. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23762. /**
  23763. * Gets the current plugin used to run the simulation
  23764. * @returns current plugin
  23765. */
  23766. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23767. /**
  23768. * Gets the list of physic impostors
  23769. * @returns an array of PhysicsImpostor
  23770. */
  23771. getImpostors(): Array<PhysicsImpostor>;
  23772. /**
  23773. * Gets the impostor for a physics enabled object
  23774. * @param object defines the object impersonated by the impostor
  23775. * @returns the PhysicsImpostor or null if not found
  23776. */
  23777. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23778. /**
  23779. * Gets the impostor for a physics body object
  23780. * @param body defines physics body used by the impostor
  23781. * @returns the PhysicsImpostor or null if not found
  23782. */
  23783. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23784. /**
  23785. * Does a raycast in the physics world
  23786. * @param from when should the ray start?
  23787. * @param to when should the ray end?
  23788. * @returns PhysicsRaycastResult
  23789. */
  23790. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23791. /**
  23792. * Called by the scene. No need to call it.
  23793. * @param delta defines the timespam between frames
  23794. */
  23795. _step(delta: number): void;
  23796. }
  23797. }
  23798. declare module "babylonjs/Physics/physicsImpostor" {
  23799. import { Nullable, IndicesArray } from "babylonjs/types";
  23800. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23801. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23803. import { Scene } from "babylonjs/scene";
  23804. import { Bone } from "babylonjs/Bones/bone";
  23805. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23806. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23807. import { Space } from "babylonjs/Maths/math.axis";
  23808. /**
  23809. * The interface for the physics imposter parameters
  23810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23811. */
  23812. export interface PhysicsImpostorParameters {
  23813. /**
  23814. * The mass of the physics imposter
  23815. */
  23816. mass: number;
  23817. /**
  23818. * The friction of the physics imposter
  23819. */
  23820. friction?: number;
  23821. /**
  23822. * The coefficient of restitution of the physics imposter
  23823. */
  23824. restitution?: number;
  23825. /**
  23826. * The native options of the physics imposter
  23827. */
  23828. nativeOptions?: any;
  23829. /**
  23830. * Specifies if the parent should be ignored
  23831. */
  23832. ignoreParent?: boolean;
  23833. /**
  23834. * Specifies if bi-directional transformations should be disabled
  23835. */
  23836. disableBidirectionalTransformation?: boolean;
  23837. /**
  23838. * The pressure inside the physics imposter, soft object only
  23839. */
  23840. pressure?: number;
  23841. /**
  23842. * The stiffness the physics imposter, soft object only
  23843. */
  23844. stiffness?: number;
  23845. /**
  23846. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23847. */
  23848. velocityIterations?: number;
  23849. /**
  23850. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23851. */
  23852. positionIterations?: number;
  23853. /**
  23854. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23855. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23856. * Add to fix multiple points
  23857. */
  23858. fixedPoints?: number;
  23859. /**
  23860. * The collision margin around a soft object
  23861. */
  23862. margin?: number;
  23863. /**
  23864. * The collision margin around a soft object
  23865. */
  23866. damping?: number;
  23867. /**
  23868. * The path for a rope based on an extrusion
  23869. */
  23870. path?: any;
  23871. /**
  23872. * The shape of an extrusion used for a rope based on an extrusion
  23873. */
  23874. shape?: any;
  23875. }
  23876. /**
  23877. * Interface for a physics-enabled object
  23878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23879. */
  23880. export interface IPhysicsEnabledObject {
  23881. /**
  23882. * The position of the physics-enabled object
  23883. */
  23884. position: Vector3;
  23885. /**
  23886. * The rotation of the physics-enabled object
  23887. */
  23888. rotationQuaternion: Nullable<Quaternion>;
  23889. /**
  23890. * The scale of the physics-enabled object
  23891. */
  23892. scaling: Vector3;
  23893. /**
  23894. * The rotation of the physics-enabled object
  23895. */
  23896. rotation?: Vector3;
  23897. /**
  23898. * The parent of the physics-enabled object
  23899. */
  23900. parent?: any;
  23901. /**
  23902. * The bounding info of the physics-enabled object
  23903. * @returns The bounding info of the physics-enabled object
  23904. */
  23905. getBoundingInfo(): BoundingInfo;
  23906. /**
  23907. * Computes the world matrix
  23908. * @param force Specifies if the world matrix should be computed by force
  23909. * @returns A world matrix
  23910. */
  23911. computeWorldMatrix(force: boolean): Matrix;
  23912. /**
  23913. * Gets the world matrix
  23914. * @returns A world matrix
  23915. */
  23916. getWorldMatrix?(): Matrix;
  23917. /**
  23918. * Gets the child meshes
  23919. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23920. * @returns An array of abstract meshes
  23921. */
  23922. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23923. /**
  23924. * Gets the vertex data
  23925. * @param kind The type of vertex data
  23926. * @returns A nullable array of numbers, or a float32 array
  23927. */
  23928. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23929. /**
  23930. * Gets the indices from the mesh
  23931. * @returns A nullable array of index arrays
  23932. */
  23933. getIndices?(): Nullable<IndicesArray>;
  23934. /**
  23935. * Gets the scene from the mesh
  23936. * @returns the indices array or null
  23937. */
  23938. getScene?(): Scene;
  23939. /**
  23940. * Gets the absolute position from the mesh
  23941. * @returns the absolute position
  23942. */
  23943. getAbsolutePosition(): Vector3;
  23944. /**
  23945. * Gets the absolute pivot point from the mesh
  23946. * @returns the absolute pivot point
  23947. */
  23948. getAbsolutePivotPoint(): Vector3;
  23949. /**
  23950. * Rotates the mesh
  23951. * @param axis The axis of rotation
  23952. * @param amount The amount of rotation
  23953. * @param space The space of the rotation
  23954. * @returns The rotation transform node
  23955. */
  23956. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23957. /**
  23958. * Translates the mesh
  23959. * @param axis The axis of translation
  23960. * @param distance The distance of translation
  23961. * @param space The space of the translation
  23962. * @returns The transform node
  23963. */
  23964. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23965. /**
  23966. * Sets the absolute position of the mesh
  23967. * @param absolutePosition The absolute position of the mesh
  23968. * @returns The transform node
  23969. */
  23970. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23971. /**
  23972. * Gets the class name of the mesh
  23973. * @returns The class name
  23974. */
  23975. getClassName(): string;
  23976. }
  23977. /**
  23978. * Represents a physics imposter
  23979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23980. */
  23981. export class PhysicsImpostor {
  23982. /**
  23983. * The physics-enabled object used as the physics imposter
  23984. */
  23985. object: IPhysicsEnabledObject;
  23986. /**
  23987. * The type of the physics imposter
  23988. */
  23989. type: number;
  23990. private _options;
  23991. private _scene?;
  23992. /**
  23993. * The default object size of the imposter
  23994. */
  23995. static DEFAULT_OBJECT_SIZE: Vector3;
  23996. /**
  23997. * The identity quaternion of the imposter
  23998. */
  23999. static IDENTITY_QUATERNION: Quaternion;
  24000. /** @hidden */
  24001. _pluginData: any;
  24002. private _physicsEngine;
  24003. private _physicsBody;
  24004. private _bodyUpdateRequired;
  24005. private _onBeforePhysicsStepCallbacks;
  24006. private _onAfterPhysicsStepCallbacks;
  24007. /** @hidden */
  24008. _onPhysicsCollideCallbacks: Array<{
  24009. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24010. otherImpostors: Array<PhysicsImpostor>;
  24011. }>;
  24012. private _deltaPosition;
  24013. private _deltaRotation;
  24014. private _deltaRotationConjugated;
  24015. /** @hidden */
  24016. _isFromLine: boolean;
  24017. private _parent;
  24018. private _isDisposed;
  24019. private static _tmpVecs;
  24020. private static _tmpQuat;
  24021. /**
  24022. * Specifies if the physics imposter is disposed
  24023. */
  24024. readonly isDisposed: boolean;
  24025. /**
  24026. * Gets the mass of the physics imposter
  24027. */
  24028. mass: number;
  24029. /**
  24030. * Gets the coefficient of friction
  24031. */
  24032. /**
  24033. * Sets the coefficient of friction
  24034. */
  24035. friction: number;
  24036. /**
  24037. * Gets the coefficient of restitution
  24038. */
  24039. /**
  24040. * Sets the coefficient of restitution
  24041. */
  24042. restitution: number;
  24043. /**
  24044. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24045. */
  24046. /**
  24047. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24048. */
  24049. pressure: number;
  24050. /**
  24051. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24052. */
  24053. /**
  24054. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24055. */
  24056. stiffness: number;
  24057. /**
  24058. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24059. */
  24060. /**
  24061. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24062. */
  24063. velocityIterations: number;
  24064. /**
  24065. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24066. */
  24067. /**
  24068. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24069. */
  24070. positionIterations: number;
  24071. /**
  24072. * The unique id of the physics imposter
  24073. * set by the physics engine when adding this impostor to the array
  24074. */
  24075. uniqueId: number;
  24076. /**
  24077. * @hidden
  24078. */
  24079. soft: boolean;
  24080. /**
  24081. * @hidden
  24082. */
  24083. segments: number;
  24084. private _joints;
  24085. /**
  24086. * Initializes the physics imposter
  24087. * @param object The physics-enabled object used as the physics imposter
  24088. * @param type The type of the physics imposter
  24089. * @param _options The options for the physics imposter
  24090. * @param _scene The Babylon scene
  24091. */
  24092. constructor(
  24093. /**
  24094. * The physics-enabled object used as the physics imposter
  24095. */
  24096. object: IPhysicsEnabledObject,
  24097. /**
  24098. * The type of the physics imposter
  24099. */
  24100. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24101. /**
  24102. * This function will completly initialize this impostor.
  24103. * It will create a new body - but only if this mesh has no parent.
  24104. * If it has, this impostor will not be used other than to define the impostor
  24105. * of the child mesh.
  24106. * @hidden
  24107. */
  24108. _init(): void;
  24109. private _getPhysicsParent;
  24110. /**
  24111. * Should a new body be generated.
  24112. * @returns boolean specifying if body initialization is required
  24113. */
  24114. isBodyInitRequired(): boolean;
  24115. /**
  24116. * Sets the updated scaling
  24117. * @param updated Specifies if the scaling is updated
  24118. */
  24119. setScalingUpdated(): void;
  24120. /**
  24121. * Force a regeneration of this or the parent's impostor's body.
  24122. * Use under cautious - This will remove all joints already implemented.
  24123. */
  24124. forceUpdate(): void;
  24125. /**
  24126. * Gets the body that holds this impostor. Either its own, or its parent.
  24127. */
  24128. /**
  24129. * Set the physics body. Used mainly by the physics engine/plugin
  24130. */
  24131. physicsBody: any;
  24132. /**
  24133. * Get the parent of the physics imposter
  24134. * @returns Physics imposter or null
  24135. */
  24136. /**
  24137. * Sets the parent of the physics imposter
  24138. */
  24139. parent: Nullable<PhysicsImpostor>;
  24140. /**
  24141. * Resets the update flags
  24142. */
  24143. resetUpdateFlags(): void;
  24144. /**
  24145. * Gets the object extend size
  24146. * @returns the object extend size
  24147. */
  24148. getObjectExtendSize(): Vector3;
  24149. /**
  24150. * Gets the object center
  24151. * @returns The object center
  24152. */
  24153. getObjectCenter(): Vector3;
  24154. /**
  24155. * Get a specific parametes from the options parameter
  24156. * @param paramName The object parameter name
  24157. * @returns The object parameter
  24158. */
  24159. getParam(paramName: string): any;
  24160. /**
  24161. * Sets a specific parameter in the options given to the physics plugin
  24162. * @param paramName The parameter name
  24163. * @param value The value of the parameter
  24164. */
  24165. setParam(paramName: string, value: number): void;
  24166. /**
  24167. * Specifically change the body's mass option. Won't recreate the physics body object
  24168. * @param mass The mass of the physics imposter
  24169. */
  24170. setMass(mass: number): void;
  24171. /**
  24172. * Gets the linear velocity
  24173. * @returns linear velocity or null
  24174. */
  24175. getLinearVelocity(): Nullable<Vector3>;
  24176. /**
  24177. * Sets the linear velocity
  24178. * @param velocity linear velocity or null
  24179. */
  24180. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24181. /**
  24182. * Gets the angular velocity
  24183. * @returns angular velocity or null
  24184. */
  24185. getAngularVelocity(): Nullable<Vector3>;
  24186. /**
  24187. * Sets the angular velocity
  24188. * @param velocity The velocity or null
  24189. */
  24190. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24191. /**
  24192. * Execute a function with the physics plugin native code
  24193. * Provide a function the will have two variables - the world object and the physics body object
  24194. * @param func The function to execute with the physics plugin native code
  24195. */
  24196. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24197. /**
  24198. * Register a function that will be executed before the physics world is stepping forward
  24199. * @param func The function to execute before the physics world is stepped forward
  24200. */
  24201. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24202. /**
  24203. * Unregister a function that will be executed before the physics world is stepping forward
  24204. * @param func The function to execute before the physics world is stepped forward
  24205. */
  24206. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24207. /**
  24208. * Register a function that will be executed after the physics step
  24209. * @param func The function to execute after physics step
  24210. */
  24211. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24212. /**
  24213. * Unregisters a function that will be executed after the physics step
  24214. * @param func The function to execute after physics step
  24215. */
  24216. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24217. /**
  24218. * register a function that will be executed when this impostor collides against a different body
  24219. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24220. * @param func Callback that is executed on collision
  24221. */
  24222. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24223. /**
  24224. * Unregisters the physics imposter on contact
  24225. * @param collideAgainst The physics object to collide against
  24226. * @param func Callback to execute on collision
  24227. */
  24228. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24229. private _tmpQuat;
  24230. private _tmpQuat2;
  24231. /**
  24232. * Get the parent rotation
  24233. * @returns The parent rotation
  24234. */
  24235. getParentsRotation(): Quaternion;
  24236. /**
  24237. * this function is executed by the physics engine.
  24238. */
  24239. beforeStep: () => void;
  24240. /**
  24241. * this function is executed by the physics engine
  24242. */
  24243. afterStep: () => void;
  24244. /**
  24245. * Legacy collision detection event support
  24246. */
  24247. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24248. /**
  24249. * event and body object due to cannon's event-based architecture.
  24250. */
  24251. onCollide: (e: {
  24252. body: any;
  24253. }) => void;
  24254. /**
  24255. * Apply a force
  24256. * @param force The force to apply
  24257. * @param contactPoint The contact point for the force
  24258. * @returns The physics imposter
  24259. */
  24260. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24261. /**
  24262. * Apply an impulse
  24263. * @param force The impulse force
  24264. * @param contactPoint The contact point for the impulse force
  24265. * @returns The physics imposter
  24266. */
  24267. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24268. /**
  24269. * A help function to create a joint
  24270. * @param otherImpostor A physics imposter used to create a joint
  24271. * @param jointType The type of joint
  24272. * @param jointData The data for the joint
  24273. * @returns The physics imposter
  24274. */
  24275. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24276. /**
  24277. * Add a joint to this impostor with a different impostor
  24278. * @param otherImpostor A physics imposter used to add a joint
  24279. * @param joint The joint to add
  24280. * @returns The physics imposter
  24281. */
  24282. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24283. /**
  24284. * Add an anchor to a cloth impostor
  24285. * @param otherImpostor rigid impostor to anchor to
  24286. * @param width ratio across width from 0 to 1
  24287. * @param height ratio up height from 0 to 1
  24288. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24289. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24290. * @returns impostor the soft imposter
  24291. */
  24292. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24293. /**
  24294. * Add a hook to a rope impostor
  24295. * @param otherImpostor rigid impostor to anchor to
  24296. * @param length ratio across rope from 0 to 1
  24297. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24298. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24299. * @returns impostor the rope imposter
  24300. */
  24301. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24302. /**
  24303. * Will keep this body still, in a sleep mode.
  24304. * @returns the physics imposter
  24305. */
  24306. sleep(): PhysicsImpostor;
  24307. /**
  24308. * Wake the body up.
  24309. * @returns The physics imposter
  24310. */
  24311. wakeUp(): PhysicsImpostor;
  24312. /**
  24313. * Clones the physics imposter
  24314. * @param newObject The physics imposter clones to this physics-enabled object
  24315. * @returns A nullable physics imposter
  24316. */
  24317. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24318. /**
  24319. * Disposes the physics imposter
  24320. */
  24321. dispose(): void;
  24322. /**
  24323. * Sets the delta position
  24324. * @param position The delta position amount
  24325. */
  24326. setDeltaPosition(position: Vector3): void;
  24327. /**
  24328. * Sets the delta rotation
  24329. * @param rotation The delta rotation amount
  24330. */
  24331. setDeltaRotation(rotation: Quaternion): void;
  24332. /**
  24333. * Gets the box size of the physics imposter and stores the result in the input parameter
  24334. * @param result Stores the box size
  24335. * @returns The physics imposter
  24336. */
  24337. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24338. /**
  24339. * Gets the radius of the physics imposter
  24340. * @returns Radius of the physics imposter
  24341. */
  24342. getRadius(): number;
  24343. /**
  24344. * Sync a bone with this impostor
  24345. * @param bone The bone to sync to the impostor.
  24346. * @param boneMesh The mesh that the bone is influencing.
  24347. * @param jointPivot The pivot of the joint / bone in local space.
  24348. * @param distToJoint Optional distance from the impostor to the joint.
  24349. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24350. */
  24351. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24352. /**
  24353. * Sync impostor to a bone
  24354. * @param bone The bone that the impostor will be synced to.
  24355. * @param boneMesh The mesh that the bone is influencing.
  24356. * @param jointPivot The pivot of the joint / bone in local space.
  24357. * @param distToJoint Optional distance from the impostor to the joint.
  24358. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24359. * @param boneAxis Optional vector3 axis the bone is aligned with
  24360. */
  24361. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24362. /**
  24363. * No-Imposter type
  24364. */
  24365. static NoImpostor: number;
  24366. /**
  24367. * Sphere-Imposter type
  24368. */
  24369. static SphereImpostor: number;
  24370. /**
  24371. * Box-Imposter type
  24372. */
  24373. static BoxImpostor: number;
  24374. /**
  24375. * Plane-Imposter type
  24376. */
  24377. static PlaneImpostor: number;
  24378. /**
  24379. * Mesh-imposter type
  24380. */
  24381. static MeshImpostor: number;
  24382. /**
  24383. * Capsule-Impostor type (Ammo.js plugin only)
  24384. */
  24385. static CapsuleImpostor: number;
  24386. /**
  24387. * Cylinder-Imposter type
  24388. */
  24389. static CylinderImpostor: number;
  24390. /**
  24391. * Particle-Imposter type
  24392. */
  24393. static ParticleImpostor: number;
  24394. /**
  24395. * Heightmap-Imposter type
  24396. */
  24397. static HeightmapImpostor: number;
  24398. /**
  24399. * ConvexHull-Impostor type (Ammo.js plugin only)
  24400. */
  24401. static ConvexHullImpostor: number;
  24402. /**
  24403. * Rope-Imposter type
  24404. */
  24405. static RopeImpostor: number;
  24406. /**
  24407. * Cloth-Imposter type
  24408. */
  24409. static ClothImpostor: number;
  24410. /**
  24411. * Softbody-Imposter type
  24412. */
  24413. static SoftbodyImpostor: number;
  24414. }
  24415. }
  24416. declare module "babylonjs/Meshes/mesh" {
  24417. import { Observable } from "babylonjs/Misc/observable";
  24418. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24419. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24420. import { Camera } from "babylonjs/Cameras/camera";
  24421. import { Scene } from "babylonjs/scene";
  24422. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24423. import { Color4 } from "babylonjs/Maths/math.color";
  24424. import { Engine } from "babylonjs/Engines/engine";
  24425. import { Node } from "babylonjs/node";
  24426. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24427. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24428. import { Buffer } from "babylonjs/Meshes/buffer";
  24429. import { Geometry } from "babylonjs/Meshes/geometry";
  24430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24431. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24432. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24433. import { Effect } from "babylonjs/Materials/effect";
  24434. import { Material } from "babylonjs/Materials/material";
  24435. import { Skeleton } from "babylonjs/Bones/skeleton";
  24436. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24437. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24438. import { Path3D } from "babylonjs/Maths/math.path";
  24439. import { Plane } from "babylonjs/Maths/math.plane";
  24440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24441. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24442. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24443. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24444. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24445. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24446. /**
  24447. * @hidden
  24448. **/
  24449. export class _CreationDataStorage {
  24450. closePath?: boolean;
  24451. closeArray?: boolean;
  24452. idx: number[];
  24453. dashSize: number;
  24454. gapSize: number;
  24455. path3D: Path3D;
  24456. pathArray: Vector3[][];
  24457. arc: number;
  24458. radius: number;
  24459. cap: number;
  24460. tessellation: number;
  24461. }
  24462. /**
  24463. * @hidden
  24464. **/
  24465. class _InstanceDataStorage {
  24466. visibleInstances: any;
  24467. batchCache: _InstancesBatch;
  24468. instancesBufferSize: number;
  24469. instancesBuffer: Nullable<Buffer>;
  24470. instancesData: Float32Array;
  24471. overridenInstanceCount: number;
  24472. isFrozen: boolean;
  24473. previousBatch: Nullable<_InstancesBatch>;
  24474. hardwareInstancedRendering: boolean;
  24475. sideOrientation: number;
  24476. manualUpdate: boolean;
  24477. }
  24478. /**
  24479. * @hidden
  24480. **/
  24481. export class _InstancesBatch {
  24482. mustReturn: boolean;
  24483. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24484. renderSelf: boolean[];
  24485. hardwareInstancedRendering: boolean[];
  24486. }
  24487. /**
  24488. * Class used to represent renderable models
  24489. */
  24490. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24491. /**
  24492. * Mesh side orientation : usually the external or front surface
  24493. */
  24494. static readonly FRONTSIDE: number;
  24495. /**
  24496. * Mesh side orientation : usually the internal or back surface
  24497. */
  24498. static readonly BACKSIDE: number;
  24499. /**
  24500. * Mesh side orientation : both internal and external or front and back surfaces
  24501. */
  24502. static readonly DOUBLESIDE: number;
  24503. /**
  24504. * Mesh side orientation : by default, `FRONTSIDE`
  24505. */
  24506. static readonly DEFAULTSIDE: number;
  24507. /**
  24508. * Mesh cap setting : no cap
  24509. */
  24510. static readonly NO_CAP: number;
  24511. /**
  24512. * Mesh cap setting : one cap at the beginning of the mesh
  24513. */
  24514. static readonly CAP_START: number;
  24515. /**
  24516. * Mesh cap setting : one cap at the end of the mesh
  24517. */
  24518. static readonly CAP_END: number;
  24519. /**
  24520. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24521. */
  24522. static readonly CAP_ALL: number;
  24523. /**
  24524. * Mesh pattern setting : no flip or rotate
  24525. */
  24526. static readonly NO_FLIP: number;
  24527. /**
  24528. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24529. */
  24530. static readonly FLIP_TILE: number;
  24531. /**
  24532. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24533. */
  24534. static readonly ROTATE_TILE: number;
  24535. /**
  24536. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24537. */
  24538. static readonly FLIP_ROW: number;
  24539. /**
  24540. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24541. */
  24542. static readonly ROTATE_ROW: number;
  24543. /**
  24544. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24545. */
  24546. static readonly FLIP_N_ROTATE_TILE: number;
  24547. /**
  24548. * Mesh pattern setting : rotate pattern and rotate
  24549. */
  24550. static readonly FLIP_N_ROTATE_ROW: number;
  24551. /**
  24552. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24553. */
  24554. static readonly CENTER: number;
  24555. /**
  24556. * Mesh tile positioning : part tiles on left
  24557. */
  24558. static readonly LEFT: number;
  24559. /**
  24560. * Mesh tile positioning : part tiles on right
  24561. */
  24562. static readonly RIGHT: number;
  24563. /**
  24564. * Mesh tile positioning : part tiles on top
  24565. */
  24566. static readonly TOP: number;
  24567. /**
  24568. * Mesh tile positioning : part tiles on bottom
  24569. */
  24570. static readonly BOTTOM: number;
  24571. /**
  24572. * Gets the default side orientation.
  24573. * @param orientation the orientation to value to attempt to get
  24574. * @returns the default orientation
  24575. * @hidden
  24576. */
  24577. static _GetDefaultSideOrientation(orientation?: number): number;
  24578. private _internalMeshDataInfo;
  24579. /**
  24580. * An event triggered before rendering the mesh
  24581. */
  24582. readonly onBeforeRenderObservable: Observable<Mesh>;
  24583. /**
  24584. * An event triggered before binding the mesh
  24585. */
  24586. readonly onBeforeBindObservable: Observable<Mesh>;
  24587. /**
  24588. * An event triggered after rendering the mesh
  24589. */
  24590. readonly onAfterRenderObservable: Observable<Mesh>;
  24591. /**
  24592. * An event triggered before drawing the mesh
  24593. */
  24594. readonly onBeforeDrawObservable: Observable<Mesh>;
  24595. private _onBeforeDrawObserver;
  24596. /**
  24597. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24598. */
  24599. onBeforeDraw: () => void;
  24600. readonly hasInstances: boolean;
  24601. /**
  24602. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24603. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24604. */
  24605. delayLoadState: number;
  24606. /**
  24607. * Gets the list of instances created from this mesh
  24608. * it is not supposed to be modified manually.
  24609. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24610. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24611. */
  24612. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24613. /**
  24614. * Gets the file containing delay loading data for this mesh
  24615. */
  24616. delayLoadingFile: string;
  24617. /** @hidden */
  24618. _binaryInfo: any;
  24619. /**
  24620. * User defined function used to change how LOD level selection is done
  24621. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24622. */
  24623. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24624. /**
  24625. * Gets or sets the morph target manager
  24626. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24627. */
  24628. morphTargetManager: Nullable<MorphTargetManager>;
  24629. /** @hidden */
  24630. _creationDataStorage: Nullable<_CreationDataStorage>;
  24631. /** @hidden */
  24632. _geometry: Nullable<Geometry>;
  24633. /** @hidden */
  24634. _delayInfo: Array<string>;
  24635. /** @hidden */
  24636. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24637. /** @hidden */
  24638. _instanceDataStorage: _InstanceDataStorage;
  24639. private _effectiveMaterial;
  24640. /** @hidden */
  24641. _shouldGenerateFlatShading: boolean;
  24642. /** @hidden */
  24643. _originalBuilderSideOrientation: number;
  24644. /**
  24645. * Use this property to change the original side orientation defined at construction time
  24646. */
  24647. overrideMaterialSideOrientation: Nullable<number>;
  24648. /**
  24649. * Gets the source mesh (the one used to clone this one from)
  24650. */
  24651. readonly source: Nullable<Mesh>;
  24652. /**
  24653. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24654. */
  24655. isUnIndexed: boolean;
  24656. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24657. readonly worldMatrixInstancedBuffer: Float32Array;
  24658. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24659. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24660. /**
  24661. * @constructor
  24662. * @param name The value used by scene.getMeshByName() to do a lookup.
  24663. * @param scene The scene to add this mesh to.
  24664. * @param parent The parent of this mesh, if it has one
  24665. * @param source An optional Mesh from which geometry is shared, cloned.
  24666. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24667. * When false, achieved by calling a clone(), also passing False.
  24668. * This will make creation of children, recursive.
  24669. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24670. */
  24671. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24672. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24673. doNotInstantiate: boolean;
  24674. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24675. /**
  24676. * Gets the class name
  24677. * @returns the string "Mesh".
  24678. */
  24679. getClassName(): string;
  24680. /** @hidden */
  24681. readonly _isMesh: boolean;
  24682. /**
  24683. * Returns a description of this mesh
  24684. * @param fullDetails define if full details about this mesh must be used
  24685. * @returns a descriptive string representing this mesh
  24686. */
  24687. toString(fullDetails?: boolean): string;
  24688. /** @hidden */
  24689. _unBindEffect(): void;
  24690. /**
  24691. * Gets a boolean indicating if this mesh has LOD
  24692. */
  24693. readonly hasLODLevels: boolean;
  24694. /**
  24695. * Gets the list of MeshLODLevel associated with the current mesh
  24696. * @returns an array of MeshLODLevel
  24697. */
  24698. getLODLevels(): MeshLODLevel[];
  24699. private _sortLODLevels;
  24700. /**
  24701. * Add a mesh as LOD level triggered at the given distance.
  24702. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24703. * @param distance The distance from the center of the object to show this level
  24704. * @param mesh The mesh to be added as LOD level (can be null)
  24705. * @return This mesh (for chaining)
  24706. */
  24707. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24708. /**
  24709. * Returns the LOD level mesh at the passed distance or null if not found.
  24710. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24711. * @param distance The distance from the center of the object to show this level
  24712. * @returns a Mesh or `null`
  24713. */
  24714. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24715. /**
  24716. * Remove a mesh from the LOD array
  24717. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24718. * @param mesh defines the mesh to be removed
  24719. * @return This mesh (for chaining)
  24720. */
  24721. removeLODLevel(mesh: Mesh): Mesh;
  24722. /**
  24723. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24724. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24725. * @param camera defines the camera to use to compute distance
  24726. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24727. * @return This mesh (for chaining)
  24728. */
  24729. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24730. /**
  24731. * Gets the mesh internal Geometry object
  24732. */
  24733. readonly geometry: Nullable<Geometry>;
  24734. /**
  24735. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24736. * @returns the total number of vertices
  24737. */
  24738. getTotalVertices(): number;
  24739. /**
  24740. * Returns the content of an associated vertex buffer
  24741. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24742. * - VertexBuffer.PositionKind
  24743. * - VertexBuffer.UVKind
  24744. * - VertexBuffer.UV2Kind
  24745. * - VertexBuffer.UV3Kind
  24746. * - VertexBuffer.UV4Kind
  24747. * - VertexBuffer.UV5Kind
  24748. * - VertexBuffer.UV6Kind
  24749. * - VertexBuffer.ColorKind
  24750. * - VertexBuffer.MatricesIndicesKind
  24751. * - VertexBuffer.MatricesIndicesExtraKind
  24752. * - VertexBuffer.MatricesWeightsKind
  24753. * - VertexBuffer.MatricesWeightsExtraKind
  24754. * @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
  24755. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24756. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24757. */
  24758. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24759. /**
  24760. * Returns the mesh VertexBuffer object from the requested `kind`
  24761. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24762. * - VertexBuffer.PositionKind
  24763. * - VertexBuffer.NormalKind
  24764. * - VertexBuffer.UVKind
  24765. * - VertexBuffer.UV2Kind
  24766. * - VertexBuffer.UV3Kind
  24767. * - VertexBuffer.UV4Kind
  24768. * - VertexBuffer.UV5Kind
  24769. * - VertexBuffer.UV6Kind
  24770. * - VertexBuffer.ColorKind
  24771. * - VertexBuffer.MatricesIndicesKind
  24772. * - VertexBuffer.MatricesIndicesExtraKind
  24773. * - VertexBuffer.MatricesWeightsKind
  24774. * - VertexBuffer.MatricesWeightsExtraKind
  24775. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24776. */
  24777. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24778. /**
  24779. * Tests if a specific vertex buffer is associated with this mesh
  24780. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24781. * - VertexBuffer.PositionKind
  24782. * - VertexBuffer.NormalKind
  24783. * - VertexBuffer.UVKind
  24784. * - VertexBuffer.UV2Kind
  24785. * - VertexBuffer.UV3Kind
  24786. * - VertexBuffer.UV4Kind
  24787. * - VertexBuffer.UV5Kind
  24788. * - VertexBuffer.UV6Kind
  24789. * - VertexBuffer.ColorKind
  24790. * - VertexBuffer.MatricesIndicesKind
  24791. * - VertexBuffer.MatricesIndicesExtraKind
  24792. * - VertexBuffer.MatricesWeightsKind
  24793. * - VertexBuffer.MatricesWeightsExtraKind
  24794. * @returns a boolean
  24795. */
  24796. isVerticesDataPresent(kind: string): boolean;
  24797. /**
  24798. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24799. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24800. * - VertexBuffer.PositionKind
  24801. * - VertexBuffer.UVKind
  24802. * - VertexBuffer.UV2Kind
  24803. * - VertexBuffer.UV3Kind
  24804. * - VertexBuffer.UV4Kind
  24805. * - VertexBuffer.UV5Kind
  24806. * - VertexBuffer.UV6Kind
  24807. * - VertexBuffer.ColorKind
  24808. * - VertexBuffer.MatricesIndicesKind
  24809. * - VertexBuffer.MatricesIndicesExtraKind
  24810. * - VertexBuffer.MatricesWeightsKind
  24811. * - VertexBuffer.MatricesWeightsExtraKind
  24812. * @returns a boolean
  24813. */
  24814. isVertexBufferUpdatable(kind: string): boolean;
  24815. /**
  24816. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24817. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24818. * - VertexBuffer.PositionKind
  24819. * - VertexBuffer.NormalKind
  24820. * - VertexBuffer.UVKind
  24821. * - VertexBuffer.UV2Kind
  24822. * - VertexBuffer.UV3Kind
  24823. * - VertexBuffer.UV4Kind
  24824. * - VertexBuffer.UV5Kind
  24825. * - VertexBuffer.UV6Kind
  24826. * - VertexBuffer.ColorKind
  24827. * - VertexBuffer.MatricesIndicesKind
  24828. * - VertexBuffer.MatricesIndicesExtraKind
  24829. * - VertexBuffer.MatricesWeightsKind
  24830. * - VertexBuffer.MatricesWeightsExtraKind
  24831. * @returns an array of strings
  24832. */
  24833. getVerticesDataKinds(): string[];
  24834. /**
  24835. * Returns a positive integer : the total number of indices in this mesh geometry.
  24836. * @returns the numner of indices or zero if the mesh has no geometry.
  24837. */
  24838. getTotalIndices(): number;
  24839. /**
  24840. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24841. * @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.
  24842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24843. * @returns the indices array or an empty array if the mesh has no geometry
  24844. */
  24845. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24846. readonly isBlocked: boolean;
  24847. /**
  24848. * Determine if the current mesh is ready to be rendered
  24849. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24850. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24851. * @returns true if all associated assets are ready (material, textures, shaders)
  24852. */
  24853. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24854. /**
  24855. * 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.
  24856. */
  24857. readonly areNormalsFrozen: boolean;
  24858. /**
  24859. * 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.
  24860. * @returns the current mesh
  24861. */
  24862. freezeNormals(): Mesh;
  24863. /**
  24864. * 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
  24865. * @returns the current mesh
  24866. */
  24867. unfreezeNormals(): Mesh;
  24868. /**
  24869. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24870. */
  24871. overridenInstanceCount: number;
  24872. /** @hidden */
  24873. _preActivate(): Mesh;
  24874. /** @hidden */
  24875. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24876. /** @hidden */
  24877. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24878. /**
  24879. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24880. * This means the mesh underlying bounding box and sphere are recomputed.
  24881. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24882. * @returns the current mesh
  24883. */
  24884. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24885. /** @hidden */
  24886. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24887. /**
  24888. * This function will subdivide the mesh into multiple submeshes
  24889. * @param count defines the expected number of submeshes
  24890. */
  24891. subdivide(count: number): void;
  24892. /**
  24893. * Copy a FloatArray into a specific associated vertex buffer
  24894. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24895. * - VertexBuffer.PositionKind
  24896. * - VertexBuffer.UVKind
  24897. * - VertexBuffer.UV2Kind
  24898. * - VertexBuffer.UV3Kind
  24899. * - VertexBuffer.UV4Kind
  24900. * - VertexBuffer.UV5Kind
  24901. * - VertexBuffer.UV6Kind
  24902. * - VertexBuffer.ColorKind
  24903. * - VertexBuffer.MatricesIndicesKind
  24904. * - VertexBuffer.MatricesIndicesExtraKind
  24905. * - VertexBuffer.MatricesWeightsKind
  24906. * - VertexBuffer.MatricesWeightsExtraKind
  24907. * @param data defines the data source
  24908. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24909. * @param stride defines the data stride size (can be null)
  24910. * @returns the current mesh
  24911. */
  24912. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24913. /**
  24914. * Delete a vertex buffer associated with this mesh
  24915. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24916. * - VertexBuffer.PositionKind
  24917. * - VertexBuffer.UVKind
  24918. * - VertexBuffer.UV2Kind
  24919. * - VertexBuffer.UV3Kind
  24920. * - VertexBuffer.UV4Kind
  24921. * - VertexBuffer.UV5Kind
  24922. * - VertexBuffer.UV6Kind
  24923. * - VertexBuffer.ColorKind
  24924. * - VertexBuffer.MatricesIndicesKind
  24925. * - VertexBuffer.MatricesIndicesExtraKind
  24926. * - VertexBuffer.MatricesWeightsKind
  24927. * - VertexBuffer.MatricesWeightsExtraKind
  24928. */
  24929. removeVerticesData(kind: string): void;
  24930. /**
  24931. * Flags an associated vertex buffer as updatable
  24932. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24933. * - VertexBuffer.PositionKind
  24934. * - VertexBuffer.UVKind
  24935. * - VertexBuffer.UV2Kind
  24936. * - VertexBuffer.UV3Kind
  24937. * - VertexBuffer.UV4Kind
  24938. * - VertexBuffer.UV5Kind
  24939. * - VertexBuffer.UV6Kind
  24940. * - VertexBuffer.ColorKind
  24941. * - VertexBuffer.MatricesIndicesKind
  24942. * - VertexBuffer.MatricesIndicesExtraKind
  24943. * - VertexBuffer.MatricesWeightsKind
  24944. * - VertexBuffer.MatricesWeightsExtraKind
  24945. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24946. */
  24947. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24948. /**
  24949. * Sets the mesh global Vertex Buffer
  24950. * @param buffer defines the buffer to use
  24951. * @returns the current mesh
  24952. */
  24953. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24954. /**
  24955. * Update a specific associated vertex buffer
  24956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24957. * - VertexBuffer.PositionKind
  24958. * - VertexBuffer.UVKind
  24959. * - VertexBuffer.UV2Kind
  24960. * - VertexBuffer.UV3Kind
  24961. * - VertexBuffer.UV4Kind
  24962. * - VertexBuffer.UV5Kind
  24963. * - VertexBuffer.UV6Kind
  24964. * - VertexBuffer.ColorKind
  24965. * - VertexBuffer.MatricesIndicesKind
  24966. * - VertexBuffer.MatricesIndicesExtraKind
  24967. * - VertexBuffer.MatricesWeightsKind
  24968. * - VertexBuffer.MatricesWeightsExtraKind
  24969. * @param data defines the data source
  24970. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24971. * @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)
  24972. * @returns the current mesh
  24973. */
  24974. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24975. /**
  24976. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24977. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24978. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24979. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24980. * @returns the current mesh
  24981. */
  24982. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24983. /**
  24984. * Creates a un-shared specific occurence of the geometry for the mesh.
  24985. * @returns the current mesh
  24986. */
  24987. makeGeometryUnique(): Mesh;
  24988. /**
  24989. * Set the index buffer of this mesh
  24990. * @param indices defines the source data
  24991. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24992. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24993. * @returns the current mesh
  24994. */
  24995. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24996. /**
  24997. * Update the current index buffer
  24998. * @param indices defines the source data
  24999. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25000. * @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)
  25001. * @returns the current mesh
  25002. */
  25003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25004. /**
  25005. * Invert the geometry to move from a right handed system to a left handed one.
  25006. * @returns the current mesh
  25007. */
  25008. toLeftHanded(): Mesh;
  25009. /** @hidden */
  25010. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25011. /** @hidden */
  25012. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25013. /**
  25014. * Registers for this mesh a javascript function called just before the rendering process
  25015. * @param func defines the function to call before rendering this mesh
  25016. * @returns the current mesh
  25017. */
  25018. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25019. /**
  25020. * Disposes a previously registered javascript function called before the rendering
  25021. * @param func defines the function to remove
  25022. * @returns the current mesh
  25023. */
  25024. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25025. /**
  25026. * Registers for this mesh a javascript function called just after the rendering is complete
  25027. * @param func defines the function to call after rendering this mesh
  25028. * @returns the current mesh
  25029. */
  25030. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25031. /**
  25032. * Disposes a previously registered javascript function called after the rendering.
  25033. * @param func defines the function to remove
  25034. * @returns the current mesh
  25035. */
  25036. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25037. /** @hidden */
  25038. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  25039. /** @hidden */
  25040. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25041. /** @hidden */
  25042. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25043. /** @hidden */
  25044. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25045. /** @hidden */
  25046. _rebuild(): void;
  25047. /** @hidden */
  25048. _freeze(): void;
  25049. /** @hidden */
  25050. _unFreeze(): void;
  25051. /**
  25052. * 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
  25053. * @param subMesh defines the subMesh to render
  25054. * @param enableAlphaMode defines if alpha mode can be changed
  25055. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25056. * @returns the current mesh
  25057. */
  25058. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25059. private _onBeforeDraw;
  25060. /**
  25061. * Renormalize the mesh and patch it up if there are no weights
  25062. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25063. * However in the case of zero weights then we set just a single influence to 1.
  25064. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25065. */
  25066. cleanMatrixWeights(): void;
  25067. private normalizeSkinFourWeights;
  25068. private normalizeSkinWeightsAndExtra;
  25069. /**
  25070. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25071. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25072. * the user know there was an issue with importing the mesh
  25073. * @returns a validation object with skinned, valid and report string
  25074. */
  25075. validateSkinning(): {
  25076. skinned: boolean;
  25077. valid: boolean;
  25078. report: string;
  25079. };
  25080. /** @hidden */
  25081. _checkDelayState(): Mesh;
  25082. private _queueLoad;
  25083. /**
  25084. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25085. * A mesh is in the frustum if its bounding box intersects the frustum
  25086. * @param frustumPlanes defines the frustum to test
  25087. * @returns true if the mesh is in the frustum planes
  25088. */
  25089. isInFrustum(frustumPlanes: Plane[]): boolean;
  25090. /**
  25091. * Sets the mesh material by the material or multiMaterial `id` property
  25092. * @param id is a string identifying the material or the multiMaterial
  25093. * @returns the current mesh
  25094. */
  25095. setMaterialByID(id: string): Mesh;
  25096. /**
  25097. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25098. * @returns an array of IAnimatable
  25099. */
  25100. getAnimatables(): IAnimatable[];
  25101. /**
  25102. * Modifies the mesh geometry according to the passed transformation matrix.
  25103. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25104. * The mesh normals are modified using the same transformation.
  25105. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25106. * @param transform defines the transform matrix to use
  25107. * @see http://doc.babylonjs.com/resources/baking_transformations
  25108. * @returns the current mesh
  25109. */
  25110. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25111. /**
  25112. * Modifies the mesh geometry according to its own current World Matrix.
  25113. * The mesh World Matrix is then reset.
  25114. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25115. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25116. * @see http://doc.babylonjs.com/resources/baking_transformations
  25117. * @returns the current mesh
  25118. */
  25119. bakeCurrentTransformIntoVertices(): Mesh;
  25120. /** @hidden */
  25121. readonly _positions: Nullable<Vector3[]>;
  25122. /** @hidden */
  25123. _resetPointsArrayCache(): Mesh;
  25124. /** @hidden */
  25125. _generatePointsArray(): boolean;
  25126. /**
  25127. * Returns a new Mesh object generated from the current mesh properties.
  25128. * This method must not get confused with createInstance()
  25129. * @param name is a string, the name given to the new mesh
  25130. * @param newParent can be any Node object (default `null`)
  25131. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25132. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25133. * @returns a new mesh
  25134. */
  25135. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25136. /**
  25137. * Releases resources associated with this mesh.
  25138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25140. */
  25141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25142. /** @hidden */
  25143. _disposeInstanceSpecificData(): void;
  25144. /**
  25145. * Modifies the mesh geometry according to a displacement map.
  25146. * 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.
  25147. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25148. * @param url is a string, the URL from the image file is to be downloaded.
  25149. * @param minHeight is the lower limit of the displacement.
  25150. * @param maxHeight is the upper limit of the displacement.
  25151. * @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.
  25152. * @param uvOffset is an optional vector2 used to offset UV.
  25153. * @param uvScale is an optional vector2 used to scale UV.
  25154. * @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.
  25155. * @returns the Mesh.
  25156. */
  25157. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25158. /**
  25159. * Modifies the mesh geometry according to a displacementMap buffer.
  25160. * 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.
  25161. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25162. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25163. * @param heightMapWidth is the width of the buffer image.
  25164. * @param heightMapHeight is the height of the buffer image.
  25165. * @param minHeight is the lower limit of the displacement.
  25166. * @param maxHeight is the upper limit of the displacement.
  25167. * @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.
  25168. * @param uvOffset is an optional vector2 used to offset UV.
  25169. * @param uvScale is an optional vector2 used to scale UV.
  25170. * @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.
  25171. * @returns the Mesh.
  25172. */
  25173. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25174. /**
  25175. * Modify the mesh to get a flat shading rendering.
  25176. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25177. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25178. * @returns current mesh
  25179. */
  25180. convertToFlatShadedMesh(): Mesh;
  25181. /**
  25182. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25183. * In other words, more vertices, no more indices and a single bigger VBO.
  25184. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25185. * @returns current mesh
  25186. */
  25187. convertToUnIndexedMesh(): Mesh;
  25188. /**
  25189. * Inverses facet orientations.
  25190. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25191. * @param flipNormals will also inverts the normals
  25192. * @returns current mesh
  25193. */
  25194. flipFaces(flipNormals?: boolean): Mesh;
  25195. /**
  25196. * Increase the number of facets and hence vertices in a mesh
  25197. * Vertex normals are interpolated from existing vertex normals
  25198. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25199. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25200. */
  25201. increaseVertices(numberPerEdge: number): void;
  25202. /**
  25203. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25204. * This will undo any application of covertToFlatShadedMesh
  25205. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25206. */
  25207. forceSharedVertices(): void;
  25208. /** @hidden */
  25209. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25210. /** @hidden */
  25211. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25212. /**
  25213. * Creates a new InstancedMesh object from the mesh model.
  25214. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25215. * @param name defines the name of the new instance
  25216. * @returns a new InstancedMesh
  25217. */
  25218. createInstance(name: string): InstancedMesh;
  25219. /**
  25220. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25221. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25222. * @returns the current mesh
  25223. */
  25224. synchronizeInstances(): Mesh;
  25225. /**
  25226. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25227. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25228. * This should be used together with the simplification to avoid disappearing triangles.
  25229. * @param successCallback an optional success callback to be called after the optimization finished.
  25230. * @returns the current mesh
  25231. */
  25232. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25233. /**
  25234. * Serialize current mesh
  25235. * @param serializationObject defines the object which will receive the serialization data
  25236. */
  25237. serialize(serializationObject: any): void;
  25238. /** @hidden */
  25239. _syncGeometryWithMorphTargetManager(): void;
  25240. /** @hidden */
  25241. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25242. /**
  25243. * Returns a new Mesh object parsed from the source provided.
  25244. * @param parsedMesh is the source
  25245. * @param scene defines the hosting scene
  25246. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25247. * @returns a new Mesh
  25248. */
  25249. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25250. /**
  25251. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25252. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25253. * @param name defines the name of the mesh to create
  25254. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25255. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25256. * @param closePath creates a seam between the first and the last points of each path of the path array
  25257. * @param offset is taken in account only if the `pathArray` is containing a single path
  25258. * @param scene defines the hosting scene
  25259. * @param updatable defines if the mesh must be flagged as updatable
  25260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25261. * @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)
  25262. * @returns a new Mesh
  25263. */
  25264. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25265. /**
  25266. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25267. * @param name defines the name of the mesh to create
  25268. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25269. * @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
  25270. * @param scene defines the hosting scene
  25271. * @param updatable defines if the mesh must be flagged as updatable
  25272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25273. * @returns a new Mesh
  25274. */
  25275. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25276. /**
  25277. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25278. * @param name defines the name of the mesh to create
  25279. * @param size sets the size (float) of each box side (default 1)
  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. * @returns a new Mesh
  25284. */
  25285. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25286. /**
  25287. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25288. * @param name defines the name of the mesh to create
  25289. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25290. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25291. * @param scene defines the hosting scene
  25292. * @param updatable defines if the mesh must be flagged as updatable
  25293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25294. * @returns a new Mesh
  25295. */
  25296. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25297. /**
  25298. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25299. * @param name defines the name of the mesh to create
  25300. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25301. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25302. * @param scene defines the hosting scene
  25303. * @returns a new Mesh
  25304. */
  25305. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25306. /**
  25307. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25308. * @param name defines the name of the mesh to create
  25309. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25310. * @param diameterTop set the top cap diameter (floats, default 1)
  25311. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25312. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25313. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25314. * @param scene defines the hosting scene
  25315. * @param updatable defines if the mesh must be flagged as updatable
  25316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25317. * @returns a new Mesh
  25318. */
  25319. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25320. /**
  25321. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25322. * @param name defines the name of the mesh to create
  25323. * @param diameter sets the diameter size (float) of the torus (default 1)
  25324. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25325. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25326. * @param scene defines the hosting scene
  25327. * @param updatable defines if the mesh must be flagged as updatable
  25328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25329. * @returns a new Mesh
  25330. */
  25331. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25332. /**
  25333. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25334. * @param name defines the name of the mesh to create
  25335. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25336. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25337. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25338. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25339. * @param p the number of windings on X axis (positive integers, default 2)
  25340. * @param q the number of windings on Y axis (positive integers, default 3)
  25341. * @param scene defines the hosting scene
  25342. * @param updatable defines if the mesh must be flagged as updatable
  25343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25344. * @returns a new Mesh
  25345. */
  25346. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25347. /**
  25348. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25349. * @param name defines the name of the mesh to create
  25350. * @param points is an array successive Vector3
  25351. * @param scene defines the hosting scene
  25352. * @param updatable defines if the mesh must be flagged as updatable
  25353. * @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).
  25354. * @returns a new Mesh
  25355. */
  25356. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25357. /**
  25358. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25359. * @param name defines the name of the mesh to create
  25360. * @param points is an array successive Vector3
  25361. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25362. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25363. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25364. * @param scene defines the hosting scene
  25365. * @param updatable defines if the mesh must be flagged as updatable
  25366. * @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)
  25367. * @returns a new Mesh
  25368. */
  25369. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25370. /**
  25371. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25372. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25373. * 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.
  25374. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25375. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25376. * Remember you can only change the shape positions, not their number when updating a polygon.
  25377. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25378. * @param name defines the name of the mesh to create
  25379. * @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
  25380. * @param scene defines the hosting scene
  25381. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25382. * @param updatable defines if the mesh must be flagged as updatable
  25383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25384. * @param earcutInjection can be used to inject your own earcut reference
  25385. * @returns a new Mesh
  25386. */
  25387. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25388. /**
  25389. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25390. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25391. * @param name defines the name of the mesh to create
  25392. * @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
  25393. * @param depth defines the height of extrusion
  25394. * @param scene defines the hosting scene
  25395. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25396. * @param updatable defines if the mesh must be flagged as updatable
  25397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25398. * @param earcutInjection can be used to inject your own earcut reference
  25399. * @returns a new Mesh
  25400. */
  25401. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25402. /**
  25403. * Creates an extruded shape mesh.
  25404. * 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
  25405. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25406. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25407. * @param name defines the name of the mesh to create
  25408. * @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
  25409. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25410. * @param scale is the value to scale the shape
  25411. * @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
  25412. * @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
  25413. * @param scene defines the hosting scene
  25414. * @param updatable defines if the mesh must be flagged as updatable
  25415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25416. * @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)
  25417. * @returns a new Mesh
  25418. */
  25419. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25420. /**
  25421. * Creates an custom extruded shape mesh.
  25422. * The custom extrusion is a parametric shape.
  25423. * It has no predefined shape. Its final shape will depend on the input parameters.
  25424. * Please consider using the same method from the MeshBuilder class instead
  25425. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25426. * @param name defines the name of the mesh to create
  25427. * @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
  25428. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25429. * @param scaleFunction is a custom Javascript function called on each path point
  25430. * @param rotationFunction is a custom Javascript function called on each path point
  25431. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25432. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25433. * @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
  25434. * @param scene defines the hosting scene
  25435. * @param updatable defines if the mesh must be flagged as updatable
  25436. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25437. * @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)
  25438. * @returns a new Mesh
  25439. */
  25440. 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;
  25441. /**
  25442. * Creates lathe mesh.
  25443. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25444. * Please consider using the same method from the MeshBuilder class instead
  25445. * @param name defines the name of the mesh to create
  25446. * @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
  25447. * @param radius is the radius value of the lathe
  25448. * @param tessellation is the side number of the lathe.
  25449. * @param scene defines the hosting scene
  25450. * @param updatable defines if the mesh must be flagged as updatable
  25451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25452. * @returns a new Mesh
  25453. */
  25454. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25455. /**
  25456. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25457. * @param name defines the name of the mesh to create
  25458. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25459. * @param scene defines the hosting scene
  25460. * @param updatable defines if the mesh must be flagged as updatable
  25461. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25462. * @returns a new Mesh
  25463. */
  25464. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25465. /**
  25466. * Creates a ground mesh.
  25467. * Please consider using the same method from the MeshBuilder class instead
  25468. * @param name defines the name of the mesh to create
  25469. * @param width set the width of the ground
  25470. * @param height set the height of the ground
  25471. * @param subdivisions sets the number of subdivisions per side
  25472. * @param scene defines the hosting scene
  25473. * @param updatable defines if the mesh must be flagged as updatable
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25477. /**
  25478. * Creates a tiled ground mesh.
  25479. * Please consider using the same method from the MeshBuilder class instead
  25480. * @param name defines the name of the mesh to create
  25481. * @param xmin set the ground minimum X coordinate
  25482. * @param zmin set the ground minimum Y coordinate
  25483. * @param xmax set the ground maximum X coordinate
  25484. * @param zmax set the ground maximum Z coordinate
  25485. * @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
  25486. * @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
  25487. * @param scene defines the hosting scene
  25488. * @param updatable defines if the mesh must be flagged as updatable
  25489. * @returns a new Mesh
  25490. */
  25491. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25492. w: number;
  25493. h: number;
  25494. }, precision: {
  25495. w: number;
  25496. h: number;
  25497. }, scene: Scene, updatable?: boolean): Mesh;
  25498. /**
  25499. * Creates a ground mesh from a height map.
  25500. * Please consider using the same method from the MeshBuilder class instead
  25501. * @see http://doc.babylonjs.com/babylon101/height_map
  25502. * @param name defines the name of the mesh to create
  25503. * @param url sets the URL of the height map image resource
  25504. * @param width set the ground width size
  25505. * @param height set the ground height size
  25506. * @param subdivisions sets the number of subdivision per side
  25507. * @param minHeight is the minimum altitude on the ground
  25508. * @param maxHeight is the maximum altitude on the ground
  25509. * @param scene defines the hosting scene
  25510. * @param updatable defines if the mesh must be flagged as updatable
  25511. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25512. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25513. * @returns a new Mesh
  25514. */
  25515. 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;
  25516. /**
  25517. * Creates a tube mesh.
  25518. * The tube is a parametric shape.
  25519. * It has no predefined shape. Its final shape will depend on the input parameters.
  25520. * Please consider using the same method from the MeshBuilder class instead
  25521. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25522. * @param name defines the name of the mesh to create
  25523. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25524. * @param radius sets the tube radius size
  25525. * @param tessellation is the number of sides on the tubular surface
  25526. * @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
  25527. * @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
  25528. * @param scene defines the hosting scene
  25529. * @param updatable defines if the mesh must be flagged as updatable
  25530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25531. * @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)
  25532. * @returns a new Mesh
  25533. */
  25534. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25535. (i: number, distance: number): number;
  25536. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25537. /**
  25538. * Creates a polyhedron mesh.
  25539. * Please consider using the same method from the MeshBuilder class instead.
  25540. * * 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
  25541. * * The parameter `size` (positive float, default 1) sets the polygon size
  25542. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25543. * * 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`
  25544. * * 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
  25545. * * 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)`)
  25546. * * 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
  25547. * * 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
  25548. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25549. * * If you create a double-sided mesh, you can choose what parts of 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
  25550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25551. * @param name defines the name of the mesh to create
  25552. * @param options defines the options used to create the mesh
  25553. * @param scene defines the hosting scene
  25554. * @returns a new Mesh
  25555. */
  25556. static CreatePolyhedron(name: string, options: {
  25557. type?: number;
  25558. size?: number;
  25559. sizeX?: number;
  25560. sizeY?: number;
  25561. sizeZ?: number;
  25562. custom?: any;
  25563. faceUV?: Vector4[];
  25564. faceColors?: Color4[];
  25565. updatable?: boolean;
  25566. sideOrientation?: number;
  25567. }, scene: Scene): Mesh;
  25568. /**
  25569. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25570. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25571. * * 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`)
  25572. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25573. * * 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
  25574. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25575. * * If you create a double-sided mesh, you can choose what parts of 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
  25576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25577. * @param name defines the name of the mesh
  25578. * @param options defines the options used to create the mesh
  25579. * @param scene defines the hosting scene
  25580. * @returns a new Mesh
  25581. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25582. */
  25583. static CreateIcoSphere(name: string, options: {
  25584. radius?: number;
  25585. flat?: boolean;
  25586. subdivisions?: number;
  25587. sideOrientation?: number;
  25588. updatable?: boolean;
  25589. }, scene: Scene): Mesh;
  25590. /**
  25591. * Creates a decal mesh.
  25592. * Please consider using the same method from the MeshBuilder class instead.
  25593. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25594. * @param name defines the name of the mesh
  25595. * @param sourceMesh defines the mesh receiving the decal
  25596. * @param position sets the position of the decal in world coordinates
  25597. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25598. * @param size sets the decal scaling
  25599. * @param angle sets the angle to rotate the decal
  25600. * @returns a new Mesh
  25601. */
  25602. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25603. /**
  25604. * Prepare internal position array for software CPU skinning
  25605. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25606. */
  25607. setPositionsForCPUSkinning(): Float32Array;
  25608. /**
  25609. * Prepare internal normal array for software CPU skinning
  25610. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25611. */
  25612. setNormalsForCPUSkinning(): Float32Array;
  25613. /**
  25614. * Updates the vertex buffer by applying transformation from the bones
  25615. * @param skeleton defines the skeleton to apply to current mesh
  25616. * @returns the current mesh
  25617. */
  25618. applySkeleton(skeleton: Skeleton): Mesh;
  25619. /**
  25620. * 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
  25621. * @param meshes defines the list of meshes to scan
  25622. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25623. */
  25624. static MinMax(meshes: AbstractMesh[]): {
  25625. min: Vector3;
  25626. max: Vector3;
  25627. };
  25628. /**
  25629. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25630. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25631. * @returns a vector3
  25632. */
  25633. static Center(meshesOrMinMaxVector: {
  25634. min: Vector3;
  25635. max: Vector3;
  25636. } | AbstractMesh[]): Vector3;
  25637. /**
  25638. * Merge the array of meshes into a single mesh for performance reasons.
  25639. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25640. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25641. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25642. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25643. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25644. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25645. * @returns a new mesh
  25646. */
  25647. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25648. /** @hidden */
  25649. addInstance(instance: InstancedMesh): void;
  25650. /** @hidden */
  25651. removeInstance(instance: InstancedMesh): void;
  25652. }
  25653. }
  25654. declare module "babylonjs/Cameras/camera" {
  25655. import { SmartArray } from "babylonjs/Misc/smartArray";
  25656. import { Observable } from "babylonjs/Misc/observable";
  25657. import { Nullable } from "babylonjs/types";
  25658. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25659. import { Scene } from "babylonjs/scene";
  25660. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25661. import { Node } from "babylonjs/node";
  25662. import { Mesh } from "babylonjs/Meshes/mesh";
  25663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25664. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25665. import { Viewport } from "babylonjs/Maths/math.viewport";
  25666. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25668. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25669. import { Ray } from "babylonjs/Culling/ray";
  25670. /**
  25671. * This is the base class of all the camera used in the application.
  25672. * @see http://doc.babylonjs.com/features/cameras
  25673. */
  25674. export class Camera extends Node {
  25675. /** @hidden */
  25676. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25677. /**
  25678. * This is the default projection mode used by the cameras.
  25679. * It helps recreating a feeling of perspective and better appreciate depth.
  25680. * This is the best way to simulate real life cameras.
  25681. */
  25682. static readonly PERSPECTIVE_CAMERA: number;
  25683. /**
  25684. * This helps creating camera with an orthographic mode.
  25685. * 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.
  25686. */
  25687. static readonly ORTHOGRAPHIC_CAMERA: number;
  25688. /**
  25689. * This is the default FOV mode for perspective cameras.
  25690. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25691. */
  25692. static readonly FOVMODE_VERTICAL_FIXED: number;
  25693. /**
  25694. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25695. */
  25696. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25697. /**
  25698. * This specifies ther is no need for a camera rig.
  25699. * Basically only one eye is rendered corresponding to the camera.
  25700. */
  25701. static readonly RIG_MODE_NONE: number;
  25702. /**
  25703. * Simulates a camera Rig with one blue eye and one red eye.
  25704. * This can be use with 3d blue and red glasses.
  25705. */
  25706. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25707. /**
  25708. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25709. */
  25710. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25711. /**
  25712. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25713. */
  25714. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25715. /**
  25716. * Defines that both eyes of the camera will be rendered over under each other.
  25717. */
  25718. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25719. /**
  25720. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25721. */
  25722. static readonly RIG_MODE_VR: number;
  25723. /**
  25724. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25725. */
  25726. static readonly RIG_MODE_WEBVR: number;
  25727. /**
  25728. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25729. */
  25730. static readonly RIG_MODE_CUSTOM: number;
  25731. /**
  25732. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25733. */
  25734. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25735. /**
  25736. * Define the input manager associated with the camera.
  25737. */
  25738. inputs: CameraInputsManager<Camera>;
  25739. /** @hidden */
  25740. _position: Vector3;
  25741. /**
  25742. * Define the current local position of the camera in the scene
  25743. */
  25744. position: Vector3;
  25745. /**
  25746. * The vector the camera should consider as up.
  25747. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25748. */
  25749. upVector: Vector3;
  25750. /**
  25751. * Define the current limit on the left side for an orthographic camera
  25752. * In scene unit
  25753. */
  25754. orthoLeft: Nullable<number>;
  25755. /**
  25756. * Define the current limit on the right side for an orthographic camera
  25757. * In scene unit
  25758. */
  25759. orthoRight: Nullable<number>;
  25760. /**
  25761. * Define the current limit on the bottom side for an orthographic camera
  25762. * In scene unit
  25763. */
  25764. orthoBottom: Nullable<number>;
  25765. /**
  25766. * Define the current limit on the top side for an orthographic camera
  25767. * In scene unit
  25768. */
  25769. orthoTop: Nullable<number>;
  25770. /**
  25771. * Field Of View is set in Radians. (default is 0.8)
  25772. */
  25773. fov: number;
  25774. /**
  25775. * Define the minimum distance the camera can see from.
  25776. * This is important to note that the depth buffer are not infinite and the closer it starts
  25777. * the more your scene might encounter depth fighting issue.
  25778. */
  25779. minZ: number;
  25780. /**
  25781. * Define the maximum distance the camera can see to.
  25782. * This is important to note that the depth buffer are not infinite and the further it end
  25783. * the more your scene might encounter depth fighting issue.
  25784. */
  25785. maxZ: number;
  25786. /**
  25787. * Define the default inertia of the camera.
  25788. * This helps giving a smooth feeling to the camera movement.
  25789. */
  25790. inertia: number;
  25791. /**
  25792. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25793. */
  25794. mode: number;
  25795. /**
  25796. * Define wether the camera is intermediate.
  25797. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25798. */
  25799. isIntermediate: boolean;
  25800. /**
  25801. * Define the viewport of the camera.
  25802. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25803. */
  25804. viewport: Viewport;
  25805. /**
  25806. * Restricts the camera to viewing objects with the same layerMask.
  25807. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25808. */
  25809. layerMask: number;
  25810. /**
  25811. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25812. */
  25813. fovMode: number;
  25814. /**
  25815. * Rig mode of the camera.
  25816. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25817. * This is normally controlled byt the camera themselves as internal use.
  25818. */
  25819. cameraRigMode: number;
  25820. /**
  25821. * Defines the distance between both "eyes" in case of a RIG
  25822. */
  25823. interaxialDistance: number;
  25824. /**
  25825. * Defines if stereoscopic rendering is done side by side or over under.
  25826. */
  25827. isStereoscopicSideBySide: boolean;
  25828. /**
  25829. * 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
  25830. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25831. * else in the scene. (Eg. security camera)
  25832. *
  25833. * 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)
  25834. */
  25835. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25836. /**
  25837. * When set, the camera will render to this render target instead of the default canvas
  25838. *
  25839. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25840. */
  25841. outputRenderTarget: Nullable<RenderTargetTexture>;
  25842. /**
  25843. * Observable triggered when the camera view matrix has changed.
  25844. */
  25845. onViewMatrixChangedObservable: Observable<Camera>;
  25846. /**
  25847. * Observable triggered when the camera Projection matrix has changed.
  25848. */
  25849. onProjectionMatrixChangedObservable: Observable<Camera>;
  25850. /**
  25851. * Observable triggered when the inputs have been processed.
  25852. */
  25853. onAfterCheckInputsObservable: Observable<Camera>;
  25854. /**
  25855. * Observable triggered when reset has been called and applied to the camera.
  25856. */
  25857. onRestoreStateObservable: Observable<Camera>;
  25858. /** @hidden */
  25859. _cameraRigParams: any;
  25860. /** @hidden */
  25861. _rigCameras: Camera[];
  25862. /** @hidden */
  25863. _rigPostProcess: Nullable<PostProcess>;
  25864. protected _webvrViewMatrix: Matrix;
  25865. /** @hidden */
  25866. _skipRendering: boolean;
  25867. /** @hidden */
  25868. _projectionMatrix: Matrix;
  25869. /** @hidden */
  25870. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25871. /** @hidden */
  25872. _activeMeshes: SmartArray<AbstractMesh>;
  25873. protected _globalPosition: Vector3;
  25874. /** @hidden */
  25875. _computedViewMatrix: Matrix;
  25876. private _doNotComputeProjectionMatrix;
  25877. private _transformMatrix;
  25878. private _frustumPlanes;
  25879. private _refreshFrustumPlanes;
  25880. private _storedFov;
  25881. private _stateStored;
  25882. /**
  25883. * Instantiates a new camera object.
  25884. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25885. * @see http://doc.babylonjs.com/features/cameras
  25886. * @param name Defines the name of the camera in the scene
  25887. * @param position Defines the position of the camera
  25888. * @param scene Defines the scene the camera belongs too
  25889. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25890. */
  25891. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25892. /**
  25893. * Store current camera state (fov, position, etc..)
  25894. * @returns the camera
  25895. */
  25896. storeState(): Camera;
  25897. /**
  25898. * Restores the camera state values if it has been stored. You must call storeState() first
  25899. */
  25900. protected _restoreStateValues(): boolean;
  25901. /**
  25902. * Restored camera state. You must call storeState() first.
  25903. * @returns true if restored and false otherwise
  25904. */
  25905. restoreState(): boolean;
  25906. /**
  25907. * Gets the class name of the camera.
  25908. * @returns the class name
  25909. */
  25910. getClassName(): string;
  25911. /** @hidden */
  25912. readonly _isCamera: boolean;
  25913. /**
  25914. * Gets a string representation of the camera useful for debug purpose.
  25915. * @param fullDetails Defines that a more verboe level of logging is required
  25916. * @returns the string representation
  25917. */
  25918. toString(fullDetails?: boolean): string;
  25919. /**
  25920. * Gets the current world space position of the camera.
  25921. */
  25922. readonly globalPosition: Vector3;
  25923. /**
  25924. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25925. * @returns the active meshe list
  25926. */
  25927. getActiveMeshes(): SmartArray<AbstractMesh>;
  25928. /**
  25929. * Check wether a mesh is part of the current active mesh list of the camera
  25930. * @param mesh Defines the mesh to check
  25931. * @returns true if active, false otherwise
  25932. */
  25933. isActiveMesh(mesh: Mesh): boolean;
  25934. /**
  25935. * Is this camera ready to be used/rendered
  25936. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25937. * @return true if the camera is ready
  25938. */
  25939. isReady(completeCheck?: boolean): boolean;
  25940. /** @hidden */
  25941. _initCache(): void;
  25942. /** @hidden */
  25943. _updateCache(ignoreParentClass?: boolean): void;
  25944. /** @hidden */
  25945. _isSynchronized(): boolean;
  25946. /** @hidden */
  25947. _isSynchronizedViewMatrix(): boolean;
  25948. /** @hidden */
  25949. _isSynchronizedProjectionMatrix(): boolean;
  25950. /**
  25951. * Attach the input controls to a specific dom element to get the input from.
  25952. * @param element Defines the element the controls should be listened from
  25953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25954. */
  25955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25956. /**
  25957. * Detach the current controls from the specified dom element.
  25958. * @param element Defines the element to stop listening the inputs from
  25959. */
  25960. detachControl(element: HTMLElement): void;
  25961. /**
  25962. * Update the camera state according to the different inputs gathered during the frame.
  25963. */
  25964. update(): void;
  25965. /** @hidden */
  25966. _checkInputs(): void;
  25967. /** @hidden */
  25968. readonly rigCameras: Camera[];
  25969. /**
  25970. * Gets the post process used by the rig cameras
  25971. */
  25972. readonly rigPostProcess: Nullable<PostProcess>;
  25973. /**
  25974. * Internal, gets the first post proces.
  25975. * @returns the first post process to be run on this camera.
  25976. */
  25977. _getFirstPostProcess(): Nullable<PostProcess>;
  25978. private _cascadePostProcessesToRigCams;
  25979. /**
  25980. * Attach a post process to the camera.
  25981. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25982. * @param postProcess The post process to attach to the camera
  25983. * @param insertAt The position of the post process in case several of them are in use in the scene
  25984. * @returns the position the post process has been inserted at
  25985. */
  25986. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25987. /**
  25988. * Detach a post process to the camera.
  25989. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25990. * @param postProcess The post process to detach from the camera
  25991. */
  25992. detachPostProcess(postProcess: PostProcess): void;
  25993. /**
  25994. * Gets the current world matrix of the camera
  25995. */
  25996. getWorldMatrix(): Matrix;
  25997. /** @hidden */
  25998. _getViewMatrix(): Matrix;
  25999. /**
  26000. * Gets the current view matrix of the camera.
  26001. * @param force forces the camera to recompute the matrix without looking at the cached state
  26002. * @returns the view matrix
  26003. */
  26004. getViewMatrix(force?: boolean): Matrix;
  26005. /**
  26006. * Freeze the projection matrix.
  26007. * It will prevent the cache check of the camera projection compute and can speed up perf
  26008. * if no parameter of the camera are meant to change
  26009. * @param projection Defines manually a projection if necessary
  26010. */
  26011. freezeProjectionMatrix(projection?: Matrix): void;
  26012. /**
  26013. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26014. */
  26015. unfreezeProjectionMatrix(): void;
  26016. /**
  26017. * Gets the current projection matrix of the camera.
  26018. * @param force forces the camera to recompute the matrix without looking at the cached state
  26019. * @returns the projection matrix
  26020. */
  26021. getProjectionMatrix(force?: boolean): Matrix;
  26022. /**
  26023. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26024. * @returns a Matrix
  26025. */
  26026. getTransformationMatrix(): Matrix;
  26027. private _updateFrustumPlanes;
  26028. /**
  26029. * Checks if a cullable object (mesh...) is in the camera frustum
  26030. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26031. * @param target The object to check
  26032. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26033. * @returns true if the object is in frustum otherwise false
  26034. */
  26035. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26036. /**
  26037. * Checks if a cullable object (mesh...) is in the camera frustum
  26038. * Unlike isInFrustum this cheks the full bounding box
  26039. * @param target The object to check
  26040. * @returns true if the object is in frustum otherwise false
  26041. */
  26042. isCompletelyInFrustum(target: ICullable): boolean;
  26043. /**
  26044. * Gets a ray in the forward direction from the camera.
  26045. * @param length Defines the length of the ray to create
  26046. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26047. * @param origin Defines the start point of the ray which defaults to the camera position
  26048. * @returns the forward ray
  26049. */
  26050. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26051. /**
  26052. * Releases resources associated with this node.
  26053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26055. */
  26056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26057. /** @hidden */
  26058. _isLeftCamera: boolean;
  26059. /**
  26060. * Gets the left camera of a rig setup in case of Rigged Camera
  26061. */
  26062. readonly isLeftCamera: boolean;
  26063. /** @hidden */
  26064. _isRightCamera: boolean;
  26065. /**
  26066. * Gets the right camera of a rig setup in case of Rigged Camera
  26067. */
  26068. readonly isRightCamera: boolean;
  26069. /**
  26070. * Gets the left camera of a rig setup in case of Rigged Camera
  26071. */
  26072. readonly leftCamera: Nullable<FreeCamera>;
  26073. /**
  26074. * Gets the right camera of a rig setup in case of Rigged Camera
  26075. */
  26076. readonly rightCamera: Nullable<FreeCamera>;
  26077. /**
  26078. * Gets the left camera target of a rig setup in case of Rigged Camera
  26079. * @returns the target position
  26080. */
  26081. getLeftTarget(): Nullable<Vector3>;
  26082. /**
  26083. * Gets the right camera target of a rig setup in case of Rigged Camera
  26084. * @returns the target position
  26085. */
  26086. getRightTarget(): Nullable<Vector3>;
  26087. /**
  26088. * @hidden
  26089. */
  26090. setCameraRigMode(mode: number, rigParams: any): void;
  26091. /** @hidden */
  26092. static _setStereoscopicRigMode(camera: Camera): void;
  26093. /** @hidden */
  26094. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26095. /** @hidden */
  26096. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26097. /** @hidden */
  26098. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26099. /** @hidden */
  26100. _getVRProjectionMatrix(): Matrix;
  26101. protected _updateCameraRotationMatrix(): void;
  26102. protected _updateWebVRCameraRotationMatrix(): void;
  26103. /**
  26104. * This function MUST be overwritten by the different WebVR cameras available.
  26105. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26106. * @hidden
  26107. */
  26108. _getWebVRProjectionMatrix(): Matrix;
  26109. /**
  26110. * This function MUST be overwritten by the different WebVR cameras available.
  26111. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26112. * @hidden
  26113. */
  26114. _getWebVRViewMatrix(): Matrix;
  26115. /** @hidden */
  26116. setCameraRigParameter(name: string, value: any): void;
  26117. /**
  26118. * needs to be overridden by children so sub has required properties to be copied
  26119. * @hidden
  26120. */
  26121. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26122. /**
  26123. * May need to be overridden by children
  26124. * @hidden
  26125. */
  26126. _updateRigCameras(): void;
  26127. /** @hidden */
  26128. _setupInputs(): void;
  26129. /**
  26130. * Serialiaze the camera setup to a json represention
  26131. * @returns the JSON representation
  26132. */
  26133. serialize(): any;
  26134. /**
  26135. * Clones the current camera.
  26136. * @param name The cloned camera name
  26137. * @returns the cloned camera
  26138. */
  26139. clone(name: string): Camera;
  26140. /**
  26141. * Gets the direction of the camera relative to a given local axis.
  26142. * @param localAxis Defines the reference axis to provide a relative direction.
  26143. * @return the direction
  26144. */
  26145. getDirection(localAxis: Vector3): Vector3;
  26146. /**
  26147. * Returns the current camera absolute rotation
  26148. */
  26149. readonly absoluteRotation: Quaternion;
  26150. /**
  26151. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26152. * @param localAxis Defines the reference axis to provide a relative direction.
  26153. * @param result Defines the vector to store the result in
  26154. */
  26155. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26156. /**
  26157. * Gets a camera constructor for a given camera type
  26158. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26159. * @param name The name of the camera the result will be able to instantiate
  26160. * @param scene The scene the result will construct the camera in
  26161. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26162. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26163. * @returns a factory method to construc the camera
  26164. */
  26165. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26166. /**
  26167. * Compute the world matrix of the camera.
  26168. * @returns the camera world matrix
  26169. */
  26170. computeWorldMatrix(): Matrix;
  26171. /**
  26172. * Parse a JSON and creates the camera from the parsed information
  26173. * @param parsedCamera The JSON to parse
  26174. * @param scene The scene to instantiate the camera in
  26175. * @returns the newly constructed camera
  26176. */
  26177. static Parse(parsedCamera: any, scene: Scene): Camera;
  26178. }
  26179. }
  26180. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26181. import { Nullable } from "babylonjs/types";
  26182. import { Scene } from "babylonjs/scene";
  26183. import { Vector4 } from "babylonjs/Maths/math.vector";
  26184. import { Mesh } from "babylonjs/Meshes/mesh";
  26185. /**
  26186. * Class containing static functions to help procedurally build meshes
  26187. */
  26188. export class DiscBuilder {
  26189. /**
  26190. * Creates a plane polygonal mesh. By default, this is a disc
  26191. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26192. * * 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
  26193. * * 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
  26194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26197. * @param name defines the name of the mesh
  26198. * @param options defines the options used to create the mesh
  26199. * @param scene defines the hosting scene
  26200. * @returns the plane polygonal mesh
  26201. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26202. */
  26203. static CreateDisc(name: string, options: {
  26204. radius?: number;
  26205. tessellation?: number;
  26206. arc?: number;
  26207. updatable?: boolean;
  26208. sideOrientation?: number;
  26209. frontUVs?: Vector4;
  26210. backUVs?: Vector4;
  26211. }, scene?: Nullable<Scene>): Mesh;
  26212. }
  26213. }
  26214. declare module "babylonjs/Particles/solidParticleSystem" {
  26215. import { Nullable } from "babylonjs/types";
  26216. import { Vector3 } from "babylonjs/Maths/math.vector";
  26217. import { Mesh } from "babylonjs/Meshes/mesh";
  26218. import { Scene, IDisposable } from "babylonjs/scene";
  26219. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26220. /**
  26221. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26222. *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.
  26223. * The SPS is also a particle system. It provides some methods to manage the particles.
  26224. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26225. *
  26226. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26227. */
  26228. export class SolidParticleSystem implements IDisposable {
  26229. /**
  26230. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26231. * Example : var p = SPS.particles[i];
  26232. */
  26233. particles: SolidParticle[];
  26234. /**
  26235. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26236. */
  26237. nbParticles: number;
  26238. /**
  26239. * If the particles must ever face the camera (default false). Useful for planar particles.
  26240. */
  26241. billboard: boolean;
  26242. /**
  26243. * Recompute normals when adding a shape
  26244. */
  26245. recomputeNormals: boolean;
  26246. /**
  26247. * This a counter ofr your own usage. It's not set by any SPS functions.
  26248. */
  26249. counter: number;
  26250. /**
  26251. * The SPS name. This name is also given to the underlying mesh.
  26252. */
  26253. name: string;
  26254. /**
  26255. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26256. */
  26257. mesh: Mesh;
  26258. /**
  26259. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26260. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26261. */
  26262. vars: any;
  26263. /**
  26264. * This array is populated when the SPS is set as 'pickable'.
  26265. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26266. * Each element of this array is an object `{idx: int, faceId: int}`.
  26267. * `idx` is the picked particle index in the `SPS.particles` array
  26268. * `faceId` is the picked face index counted within this particle.
  26269. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26270. */
  26271. pickedParticles: {
  26272. idx: number;
  26273. faceId: number;
  26274. }[];
  26275. /**
  26276. * This array is populated when `enableDepthSort` is set to true.
  26277. * Each element of this array is an instance of the class DepthSortedParticle.
  26278. */
  26279. depthSortedParticles: DepthSortedParticle[];
  26280. /**
  26281. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26282. * @hidden
  26283. */
  26284. _bSphereOnly: boolean;
  26285. /**
  26286. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26287. * @hidden
  26288. */
  26289. _bSphereRadiusFactor: number;
  26290. private _scene;
  26291. private _positions;
  26292. private _indices;
  26293. private _normals;
  26294. private _colors;
  26295. private _uvs;
  26296. private _indices32;
  26297. private _positions32;
  26298. private _normals32;
  26299. private _fixedNormal32;
  26300. private _colors32;
  26301. private _uvs32;
  26302. private _index;
  26303. private _updatable;
  26304. private _pickable;
  26305. private _isVisibilityBoxLocked;
  26306. private _alwaysVisible;
  26307. private _depthSort;
  26308. private _expandable;
  26309. private _shapeCounter;
  26310. private _copy;
  26311. private _color;
  26312. private _computeParticleColor;
  26313. private _computeParticleTexture;
  26314. private _computeParticleRotation;
  26315. private _computeParticleVertex;
  26316. private _computeBoundingBox;
  26317. private _depthSortParticles;
  26318. private _camera;
  26319. private _mustUnrotateFixedNormals;
  26320. private _particlesIntersect;
  26321. private _needs32Bits;
  26322. private _isNotBuilt;
  26323. private _lastParticleId;
  26324. private _idxOfId;
  26325. /**
  26326. * Creates a SPS (Solid Particle System) object.
  26327. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26328. * @param scene (Scene) is the scene in which the SPS is added.
  26329. * @param options defines the options of the sps e.g.
  26330. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26331. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26332. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26333. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26334. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26335. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26336. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26337. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26338. */
  26339. constructor(name: string, scene: Scene, options?: {
  26340. updatable?: boolean;
  26341. isPickable?: boolean;
  26342. enableDepthSort?: boolean;
  26343. particleIntersection?: boolean;
  26344. boundingSphereOnly?: boolean;
  26345. bSphereRadiusFactor?: number;
  26346. expandable?: boolean;
  26347. });
  26348. /**
  26349. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26350. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26351. * @returns the created mesh
  26352. */
  26353. buildMesh(): Mesh;
  26354. /**
  26355. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26356. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26357. * Thus the particles generated from `digest()` have their property `position` set yet.
  26358. * @param mesh ( Mesh ) is the mesh to be digested
  26359. * @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
  26360. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26361. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26362. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26363. * @returns the current SPS
  26364. */
  26365. digest(mesh: Mesh, options?: {
  26366. facetNb?: number;
  26367. number?: number;
  26368. delta?: number;
  26369. storage?: [];
  26370. }): SolidParticleSystem;
  26371. /**
  26372. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26373. * @hidden
  26374. */
  26375. private _unrotateFixedNormals;
  26376. /**
  26377. * Resets the temporary working copy particle
  26378. * @hidden
  26379. */
  26380. private _resetCopy;
  26381. /**
  26382. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26383. * @param p the current index in the positions array to be updated
  26384. * @param shape a Vector3 array, the shape geometry
  26385. * @param positions the positions array to be updated
  26386. * @param meshInd the shape indices array
  26387. * @param indices the indices array to be updated
  26388. * @param meshUV the shape uv array
  26389. * @param uvs the uv array to be updated
  26390. * @param meshCol the shape color array
  26391. * @param colors the color array to be updated
  26392. * @param meshNor the shape normals array
  26393. * @param normals the normals array to be updated
  26394. * @param idx the particle index
  26395. * @param idxInShape the particle index in its shape
  26396. * @param options the addShape() method passed options
  26397. * @hidden
  26398. */
  26399. private _meshBuilder;
  26400. /**
  26401. * Returns a shape Vector3 array from positions float array
  26402. * @param positions float array
  26403. * @returns a vector3 array
  26404. * @hidden
  26405. */
  26406. private _posToShape;
  26407. /**
  26408. * Returns a shapeUV array from a float uvs (array deep copy)
  26409. * @param uvs as a float array
  26410. * @returns a shapeUV array
  26411. * @hidden
  26412. */
  26413. private _uvsToShapeUV;
  26414. /**
  26415. * Adds a new particle object in the particles array
  26416. * @param idx particle index in particles array
  26417. * @param id particle id
  26418. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26419. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26420. * @param model particle ModelShape object
  26421. * @param shapeId model shape identifier
  26422. * @param idxInShape index of the particle in the current model
  26423. * @param bInfo model bounding info object
  26424. * @param storage target storage array, if any
  26425. * @hidden
  26426. */
  26427. private _addParticle;
  26428. /**
  26429. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26430. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26431. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26432. * @param nb (positive integer) the number of particles to be created from this model
  26433. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26434. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26435. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26436. * @returns the number of shapes in the system
  26437. */
  26438. addShape(mesh: Mesh, nb: number, options?: {
  26439. positionFunction?: any;
  26440. vertexFunction?: any;
  26441. storage?: [];
  26442. }): number;
  26443. /**
  26444. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26445. * @hidden
  26446. */
  26447. private _rebuildParticle;
  26448. /**
  26449. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26450. * @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.
  26451. * @returns the SPS.
  26452. */
  26453. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26454. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26455. * Returns an array with the removed particles.
  26456. * 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.
  26457. * The SPS can't be empty so at least one particle needs to remain in place.
  26458. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26459. * @param start index of the first particle to remove
  26460. * @param end index of the last particle to remove (included)
  26461. * @returns an array populated with the removed particles
  26462. */
  26463. removeParticles(start: number, end: number): SolidParticle[];
  26464. /**
  26465. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26466. * @param solidParticleArray an array populated with Solid Particles objects
  26467. * @returns the SPS
  26468. */
  26469. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26470. /**
  26471. * Creates a new particle and modifies the SPS mesh geometry :
  26472. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26473. * - calls _addParticle() to populate the particle array
  26474. * factorized code from addShape() and insertParticlesFromArray()
  26475. * @param idx particle index in the particles array
  26476. * @param i particle index in its shape
  26477. * @param modelShape particle ModelShape object
  26478. * @param shape shape vertex array
  26479. * @param meshInd shape indices array
  26480. * @param meshUV shape uv array
  26481. * @param meshCol shape color array
  26482. * @param meshNor shape normals array
  26483. * @param bbInfo shape bounding info
  26484. * @param storage target particle storage
  26485. * @options addShape() passed options
  26486. * @hidden
  26487. */
  26488. private _insertNewParticle;
  26489. /**
  26490. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26491. * This method calls `updateParticle()` for each particle of the SPS.
  26492. * For an animated SPS, it is usually called within the render loop.
  26493. * 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.
  26494. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26495. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26496. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26497. * @returns the SPS.
  26498. */
  26499. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26500. /**
  26501. * Disposes the SPS.
  26502. */
  26503. dispose(): void;
  26504. /**
  26505. * Returns a SolidParticle object from its identifier : particle.id
  26506. * @param id (integer) the particle Id
  26507. * @returns the searched particle or null if not found in the SPS.
  26508. */
  26509. getParticleById(id: number): Nullable<SolidParticle>;
  26510. /**
  26511. * Returns a new array populated with the particles having the passed shapeId.
  26512. * @param shapeId (integer) the shape identifier
  26513. * @returns a new solid particle array
  26514. */
  26515. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26516. /**
  26517. * Populates the passed array "ref" with the particles having the passed shapeId.
  26518. * @param shapeId the shape identifier
  26519. * @returns the SPS
  26520. * @param ref
  26521. */
  26522. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26523. /**
  26524. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26525. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26526. * @returns the SPS.
  26527. */
  26528. refreshVisibleSize(): SolidParticleSystem;
  26529. /**
  26530. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26531. * @param size the size (float) of the visibility box
  26532. * note : this doesn't lock the SPS mesh bounding box.
  26533. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26534. */
  26535. setVisibilityBox(size: number): void;
  26536. /**
  26537. * Gets whether the SPS as always visible or not
  26538. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26539. */
  26540. /**
  26541. * Sets the SPS as always visible or not
  26542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26543. */
  26544. isAlwaysVisible: boolean;
  26545. /**
  26546. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26548. */
  26549. /**
  26550. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26551. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26552. */
  26553. isVisibilityBoxLocked: boolean;
  26554. /**
  26555. * Tells to `setParticles()` to compute the particle rotations or not.
  26556. * Default value : true. The SPS is faster when it's set to false.
  26557. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26558. */
  26559. /**
  26560. * Gets if `setParticles()` computes the particle rotations or not.
  26561. * Default value : true. The SPS is faster when it's set to false.
  26562. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26563. */
  26564. computeParticleRotation: boolean;
  26565. /**
  26566. * Tells to `setParticles()` to compute the particle colors or not.
  26567. * Default value : true. The SPS is faster when it's set to false.
  26568. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26569. */
  26570. /**
  26571. * Gets if `setParticles()` computes the particle colors or not.
  26572. * Default value : true. The SPS is faster when it's set to false.
  26573. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26574. */
  26575. computeParticleColor: boolean;
  26576. /**
  26577. * Gets if `setParticles()` computes the particle textures or not.
  26578. * Default value : true. The SPS is faster when it's set to false.
  26579. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26580. */
  26581. computeParticleTexture: boolean;
  26582. /**
  26583. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26584. * Default value : false. The SPS is faster when it's set to false.
  26585. * Note : the particle custom vertex positions aren't stored values.
  26586. */
  26587. /**
  26588. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26589. * Default value : false. The SPS is faster when it's set to false.
  26590. * Note : the particle custom vertex positions aren't stored values.
  26591. */
  26592. computeParticleVertex: boolean;
  26593. /**
  26594. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26595. */
  26596. /**
  26597. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26598. */
  26599. computeBoundingBox: boolean;
  26600. /**
  26601. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26602. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26603. * Default : `true`
  26604. */
  26605. /**
  26606. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26607. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26608. * Default : `true`
  26609. */
  26610. depthSortParticles: boolean;
  26611. /**
  26612. * Gets if the SPS is created as expandable at construction time.
  26613. * Default : `false`
  26614. */
  26615. readonly expandable: boolean;
  26616. /**
  26617. * This function does nothing. It may be overwritten to set all the particle first values.
  26618. * The SPS doesn't call this function, you may have to call it by your own.
  26619. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26620. */
  26621. initParticles(): void;
  26622. /**
  26623. * This function does nothing. It may be overwritten to recycle a particle.
  26624. * The SPS doesn't call this function, you may have to call it by your own.
  26625. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26626. * @param particle The particle to recycle
  26627. * @returns the recycled particle
  26628. */
  26629. recycleParticle(particle: SolidParticle): SolidParticle;
  26630. /**
  26631. * Updates a particle : this function should be overwritten by the user.
  26632. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26633. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26634. * @example : just set a particle position or velocity and recycle conditions
  26635. * @param particle The particle to update
  26636. * @returns the updated particle
  26637. */
  26638. updateParticle(particle: SolidParticle): SolidParticle;
  26639. /**
  26640. * Updates a vertex of a particle : it can be overwritten by the user.
  26641. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26642. * @param particle the current particle
  26643. * @param vertex the current index of the current particle
  26644. * @param pt the index of the current vertex in the particle shape
  26645. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26646. * @example : just set a vertex particle position
  26647. * @returns the updated vertex
  26648. */
  26649. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26650. /**
  26651. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26652. * This does nothing and may be overwritten by the user.
  26653. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26654. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26655. * @param update the boolean update value actually passed to setParticles()
  26656. */
  26657. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26658. /**
  26659. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26660. * This will be passed three parameters.
  26661. * This does nothing and may be overwritten by the user.
  26662. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26664. * @param update the boolean update value actually passed to setParticles()
  26665. */
  26666. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26667. }
  26668. }
  26669. declare module "babylonjs/Particles/solidParticle" {
  26670. import { Nullable } from "babylonjs/types";
  26671. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26672. import { Color4 } from "babylonjs/Maths/math.color";
  26673. import { Mesh } from "babylonjs/Meshes/mesh";
  26674. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26675. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26676. import { Plane } from "babylonjs/Maths/math.plane";
  26677. /**
  26678. * Represents one particle of a solid particle system.
  26679. */
  26680. export class SolidParticle {
  26681. /**
  26682. * particle global index
  26683. */
  26684. idx: number;
  26685. /**
  26686. * particle identifier
  26687. */
  26688. id: number;
  26689. /**
  26690. * The color of the particle
  26691. */
  26692. color: Nullable<Color4>;
  26693. /**
  26694. * The world space position of the particle.
  26695. */
  26696. position: Vector3;
  26697. /**
  26698. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26699. */
  26700. rotation: Vector3;
  26701. /**
  26702. * The world space rotation quaternion of the particle.
  26703. */
  26704. rotationQuaternion: Nullable<Quaternion>;
  26705. /**
  26706. * The scaling of the particle.
  26707. */
  26708. scaling: Vector3;
  26709. /**
  26710. * The uvs of the particle.
  26711. */
  26712. uvs: Vector4;
  26713. /**
  26714. * The current speed of the particle.
  26715. */
  26716. velocity: Vector3;
  26717. /**
  26718. * The pivot point in the particle local space.
  26719. */
  26720. pivot: Vector3;
  26721. /**
  26722. * Must the particle be translated from its pivot point in its local space ?
  26723. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26724. * Default : false
  26725. */
  26726. translateFromPivot: boolean;
  26727. /**
  26728. * Is the particle active or not ?
  26729. */
  26730. alive: boolean;
  26731. /**
  26732. * Is the particle visible or not ?
  26733. */
  26734. isVisible: boolean;
  26735. /**
  26736. * Index of this particle in the global "positions" array (Internal use)
  26737. * @hidden
  26738. */
  26739. _pos: number;
  26740. /**
  26741. * @hidden Index of this particle in the global "indices" array (Internal use)
  26742. */
  26743. _ind: number;
  26744. /**
  26745. * @hidden ModelShape of this particle (Internal use)
  26746. */
  26747. _model: ModelShape;
  26748. /**
  26749. * ModelShape id of this particle
  26750. */
  26751. shapeId: number;
  26752. /**
  26753. * Index of the particle in its shape id
  26754. */
  26755. idxInShape: number;
  26756. /**
  26757. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26758. */
  26759. _modelBoundingInfo: BoundingInfo;
  26760. /**
  26761. * @hidden Particle BoundingInfo object (Internal use)
  26762. */
  26763. _boundingInfo: BoundingInfo;
  26764. /**
  26765. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26766. */
  26767. _sps: SolidParticleSystem;
  26768. /**
  26769. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26770. */
  26771. _stillInvisible: boolean;
  26772. /**
  26773. * @hidden Last computed particle rotation matrix
  26774. */
  26775. _rotationMatrix: number[];
  26776. /**
  26777. * Parent particle Id, if any.
  26778. * Default null.
  26779. */
  26780. parentId: Nullable<number>;
  26781. /**
  26782. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26783. * The possible values are :
  26784. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26785. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26786. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26787. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26788. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26789. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26790. * */
  26791. cullingStrategy: number;
  26792. /**
  26793. * @hidden Internal global position in the SPS.
  26794. */
  26795. _globalPosition: Vector3;
  26796. /**
  26797. * Creates a Solid Particle object.
  26798. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26799. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26800. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26801. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26802. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26803. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26804. * @param shapeId (integer) is the model shape identifier in the SPS.
  26805. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26806. * @param sps defines the sps it is associated to
  26807. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26808. */
  26809. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26810. /**
  26811. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26812. * @param target the particle target
  26813. * @returns the current particle
  26814. */
  26815. copyToRef(target: SolidParticle): SolidParticle;
  26816. /**
  26817. * Legacy support, changed scale to scaling
  26818. */
  26819. /**
  26820. * Legacy support, changed scale to scaling
  26821. */
  26822. scale: Vector3;
  26823. /**
  26824. * Legacy support, changed quaternion to rotationQuaternion
  26825. */
  26826. /**
  26827. * Legacy support, changed quaternion to rotationQuaternion
  26828. */
  26829. quaternion: Nullable<Quaternion>;
  26830. /**
  26831. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26832. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26833. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26834. * @returns true if it intersects
  26835. */
  26836. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26837. /**
  26838. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26839. * A particle is in the frustum if its bounding box intersects the frustum
  26840. * @param frustumPlanes defines the frustum to test
  26841. * @returns true if the particle is in the frustum planes
  26842. */
  26843. isInFrustum(frustumPlanes: Plane[]): boolean;
  26844. /**
  26845. * get the rotation matrix of the particle
  26846. * @hidden
  26847. */
  26848. getRotationMatrix(m: Matrix): void;
  26849. }
  26850. /**
  26851. * Represents the shape of the model used by one particle of a solid particle system.
  26852. * SPS internal tool, don't use it manually.
  26853. */
  26854. export class ModelShape {
  26855. /**
  26856. * The shape id
  26857. * @hidden
  26858. */
  26859. shapeID: number;
  26860. /**
  26861. * flat array of model positions (internal use)
  26862. * @hidden
  26863. */
  26864. _shape: Vector3[];
  26865. /**
  26866. * flat array of model UVs (internal use)
  26867. * @hidden
  26868. */
  26869. _shapeUV: number[];
  26870. /**
  26871. * color array of the model
  26872. * @hidden
  26873. */
  26874. _shapeColors: number[];
  26875. /**
  26876. * indices array of the model
  26877. * @hidden
  26878. */
  26879. _indices: number[];
  26880. /**
  26881. * normals array of the model
  26882. * @hidden
  26883. */
  26884. _normals: number[];
  26885. /**
  26886. * length of the shape in the model indices array (internal use)
  26887. * @hidden
  26888. */
  26889. _indicesLength: number;
  26890. /**
  26891. * Custom position function (internal use)
  26892. * @hidden
  26893. */
  26894. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26895. /**
  26896. * Custom vertex function (internal use)
  26897. * @hidden
  26898. */
  26899. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26900. /**
  26901. * 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.
  26902. * SPS internal tool, don't use it manually.
  26903. * @hidden
  26904. */
  26905. 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>);
  26906. }
  26907. /**
  26908. * Represents a Depth Sorted Particle in the solid particle system.
  26909. */
  26910. export class DepthSortedParticle {
  26911. /**
  26912. * Index of the particle in the "indices" array
  26913. */
  26914. ind: number;
  26915. /**
  26916. * Length of the particle shape in the "indices" array
  26917. */
  26918. indicesLength: number;
  26919. /**
  26920. * Squared distance from the particle to the camera
  26921. */
  26922. sqDistance: number;
  26923. }
  26924. }
  26925. declare module "babylonjs/Collisions/meshCollisionData" {
  26926. import { Collider } from "babylonjs/Collisions/collider";
  26927. import { Vector3 } from "babylonjs/Maths/math.vector";
  26928. import { Nullable } from "babylonjs/types";
  26929. import { Observer } from "babylonjs/Misc/observable";
  26930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26931. /**
  26932. * @hidden
  26933. */
  26934. export class _MeshCollisionData {
  26935. _checkCollisions: boolean;
  26936. _collisionMask: number;
  26937. _collisionGroup: number;
  26938. _collider: Nullable<Collider>;
  26939. _oldPositionForCollisions: Vector3;
  26940. _diffPositionForCollisions: Vector3;
  26941. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26942. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26943. }
  26944. }
  26945. declare module "babylonjs/Meshes/abstractMesh" {
  26946. import { Observable } from "babylonjs/Misc/observable";
  26947. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26948. import { Camera } from "babylonjs/Cameras/camera";
  26949. import { Scene, IDisposable } from "babylonjs/scene";
  26950. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26951. import { Node } from "babylonjs/node";
  26952. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26953. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26955. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26956. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26957. import { Material } from "babylonjs/Materials/material";
  26958. import { Light } from "babylonjs/Lights/light";
  26959. import { Skeleton } from "babylonjs/Bones/skeleton";
  26960. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26961. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26962. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26963. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26964. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26965. import { Plane } from "babylonjs/Maths/math.plane";
  26966. import { Ray } from "babylonjs/Culling/ray";
  26967. import { Collider } from "babylonjs/Collisions/collider";
  26968. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26969. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26970. /** @hidden */
  26971. class _FacetDataStorage {
  26972. facetPositions: Vector3[];
  26973. facetNormals: Vector3[];
  26974. facetPartitioning: number[][];
  26975. facetNb: number;
  26976. partitioningSubdivisions: number;
  26977. partitioningBBoxRatio: number;
  26978. facetDataEnabled: boolean;
  26979. facetParameters: any;
  26980. bbSize: Vector3;
  26981. subDiv: {
  26982. max: number;
  26983. X: number;
  26984. Y: number;
  26985. Z: number;
  26986. };
  26987. facetDepthSort: boolean;
  26988. facetDepthSortEnabled: boolean;
  26989. depthSortedIndices: IndicesArray;
  26990. depthSortedFacets: {
  26991. ind: number;
  26992. sqDistance: number;
  26993. }[];
  26994. facetDepthSortFunction: (f1: {
  26995. ind: number;
  26996. sqDistance: number;
  26997. }, f2: {
  26998. ind: number;
  26999. sqDistance: number;
  27000. }) => number;
  27001. facetDepthSortFrom: Vector3;
  27002. facetDepthSortOrigin: Vector3;
  27003. invertedMatrix: Matrix;
  27004. }
  27005. /**
  27006. * @hidden
  27007. **/
  27008. class _InternalAbstractMeshDataInfo {
  27009. _hasVertexAlpha: boolean;
  27010. _useVertexColors: boolean;
  27011. _numBoneInfluencers: number;
  27012. _applyFog: boolean;
  27013. _receiveShadows: boolean;
  27014. _facetData: _FacetDataStorage;
  27015. _visibility: number;
  27016. _skeleton: Nullable<Skeleton>;
  27017. _layerMask: number;
  27018. _computeBonesUsingShaders: boolean;
  27019. _isActive: boolean;
  27020. _onlyForInstances: boolean;
  27021. _isActiveIntermediate: boolean;
  27022. _onlyForInstancesIntermediate: boolean;
  27023. _actAsRegularMesh: boolean;
  27024. }
  27025. /**
  27026. * Class used to store all common mesh properties
  27027. */
  27028. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27029. /** No occlusion */
  27030. static OCCLUSION_TYPE_NONE: number;
  27031. /** Occlusion set to optimisitic */
  27032. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27033. /** Occlusion set to strict */
  27034. static OCCLUSION_TYPE_STRICT: number;
  27035. /** Use an accurante occlusion algorithm */
  27036. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27037. /** Use a conservative occlusion algorithm */
  27038. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27039. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27040. * Test order :
  27041. * Is the bounding sphere outside the frustum ?
  27042. * If not, are the bounding box vertices outside the frustum ?
  27043. * It not, then the cullable object is in the frustum.
  27044. */
  27045. static readonly CULLINGSTRATEGY_STANDARD: number;
  27046. /** Culling strategy : Bounding Sphere Only.
  27047. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27048. * It's also less accurate than the standard because some not visible objects can still be selected.
  27049. * Test : is the bounding sphere outside the frustum ?
  27050. * If not, then the cullable object is in the frustum.
  27051. */
  27052. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27053. /** Culling strategy : Optimistic Inclusion.
  27054. * This in an inclusion test first, then the standard exclusion test.
  27055. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27056. * 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.
  27057. * Anyway, it's as accurate as the standard strategy.
  27058. * Test :
  27059. * Is the cullable object bounding sphere center in the frustum ?
  27060. * If not, apply the default culling strategy.
  27061. */
  27062. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27063. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27064. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27065. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27066. * 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.
  27067. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27068. * Test :
  27069. * Is the cullable object bounding sphere center in the frustum ?
  27070. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27071. */
  27072. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27073. /**
  27074. * No billboard
  27075. */
  27076. static readonly BILLBOARDMODE_NONE: number;
  27077. /** Billboard on X axis */
  27078. static readonly BILLBOARDMODE_X: number;
  27079. /** Billboard on Y axis */
  27080. static readonly BILLBOARDMODE_Y: number;
  27081. /** Billboard on Z axis */
  27082. static readonly BILLBOARDMODE_Z: number;
  27083. /** Billboard on all axes */
  27084. static readonly BILLBOARDMODE_ALL: number;
  27085. /** Billboard on using position instead of orientation */
  27086. static readonly BILLBOARDMODE_USE_POSITION: number;
  27087. /** @hidden */
  27088. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27089. /**
  27090. * The culling strategy to use to check whether the mesh must be rendered or not.
  27091. * This value can be changed at any time and will be used on the next render mesh selection.
  27092. * The possible values are :
  27093. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27094. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27095. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27096. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27097. * Please read each static variable documentation to get details about the culling process.
  27098. * */
  27099. cullingStrategy: number;
  27100. /**
  27101. * Gets the number of facets in the mesh
  27102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27103. */
  27104. readonly facetNb: number;
  27105. /**
  27106. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27108. */
  27109. partitioningSubdivisions: number;
  27110. /**
  27111. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27112. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27114. */
  27115. partitioningBBoxRatio: number;
  27116. /**
  27117. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27118. * Works only for updatable meshes.
  27119. * Doesn't work with multi-materials
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27121. */
  27122. mustDepthSortFacets: boolean;
  27123. /**
  27124. * The location (Vector3) where the facet depth sort must be computed from.
  27125. * By default, the active camera position.
  27126. * Used only when facet depth sort is enabled
  27127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27128. */
  27129. facetDepthSortFrom: Vector3;
  27130. /**
  27131. * gets a boolean indicating if facetData is enabled
  27132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27133. */
  27134. readonly isFacetDataEnabled: boolean;
  27135. /** @hidden */
  27136. _updateNonUniformScalingState(value: boolean): boolean;
  27137. /**
  27138. * An event triggered when this mesh collides with another one
  27139. */
  27140. onCollideObservable: Observable<AbstractMesh>;
  27141. /** Set a function to call when this mesh collides with another one */
  27142. onCollide: () => void;
  27143. /**
  27144. * An event triggered when the collision's position changes
  27145. */
  27146. onCollisionPositionChangeObservable: Observable<Vector3>;
  27147. /** Set a function to call when the collision's position changes */
  27148. onCollisionPositionChange: () => void;
  27149. /**
  27150. * An event triggered when material is changed
  27151. */
  27152. onMaterialChangedObservable: Observable<AbstractMesh>;
  27153. /**
  27154. * Gets or sets the orientation for POV movement & rotation
  27155. */
  27156. definedFacingForward: boolean;
  27157. /** @hidden */
  27158. _occlusionQuery: Nullable<WebGLQuery>;
  27159. /** @hidden */
  27160. _renderingGroup: Nullable<RenderingGroup>;
  27161. /**
  27162. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27163. */
  27164. /**
  27165. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27166. */
  27167. visibility: number;
  27168. /** Gets or sets the alpha index used to sort transparent meshes
  27169. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27170. */
  27171. alphaIndex: number;
  27172. /**
  27173. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27174. */
  27175. isVisible: boolean;
  27176. /**
  27177. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27178. */
  27179. isPickable: boolean;
  27180. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27181. showSubMeshesBoundingBox: boolean;
  27182. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27184. */
  27185. isBlocker: boolean;
  27186. /**
  27187. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27188. */
  27189. enablePointerMoveEvents: boolean;
  27190. /**
  27191. * Specifies the rendering group id for this mesh (0 by default)
  27192. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27193. */
  27194. renderingGroupId: number;
  27195. private _material;
  27196. /** Gets or sets current material */
  27197. material: Nullable<Material>;
  27198. /**
  27199. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27200. * @see http://doc.babylonjs.com/babylon101/shadows
  27201. */
  27202. receiveShadows: boolean;
  27203. /** Defines color to use when rendering outline */
  27204. outlineColor: Color3;
  27205. /** Define width to use when rendering outline */
  27206. outlineWidth: number;
  27207. /** Defines color to use when rendering overlay */
  27208. overlayColor: Color3;
  27209. /** Defines alpha to use when rendering overlay */
  27210. overlayAlpha: number;
  27211. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27212. hasVertexAlpha: boolean;
  27213. /** 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) */
  27214. useVertexColors: boolean;
  27215. /**
  27216. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27217. */
  27218. computeBonesUsingShaders: boolean;
  27219. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27220. numBoneInfluencers: number;
  27221. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27222. applyFog: boolean;
  27223. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27224. useOctreeForRenderingSelection: boolean;
  27225. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27226. useOctreeForPicking: boolean;
  27227. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27228. useOctreeForCollisions: boolean;
  27229. /**
  27230. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27231. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27232. */
  27233. layerMask: number;
  27234. /**
  27235. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27236. */
  27237. alwaysSelectAsActiveMesh: boolean;
  27238. /**
  27239. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27240. */
  27241. doNotSyncBoundingInfo: boolean;
  27242. /**
  27243. * Gets or sets the current action manager
  27244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27245. */
  27246. actionManager: Nullable<AbstractActionManager>;
  27247. private _meshCollisionData;
  27248. /**
  27249. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27251. */
  27252. ellipsoid: Vector3;
  27253. /**
  27254. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27256. */
  27257. ellipsoidOffset: Vector3;
  27258. /**
  27259. * Gets or sets a collision mask used to mask collisions (default is -1).
  27260. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27261. */
  27262. collisionMask: number;
  27263. /**
  27264. * Gets or sets the current collision group mask (-1 by default).
  27265. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27266. */
  27267. collisionGroup: number;
  27268. /**
  27269. * Defines edge width used when edgesRenderer is enabled
  27270. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27271. */
  27272. edgesWidth: number;
  27273. /**
  27274. * Defines edge color used when edgesRenderer is enabled
  27275. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27276. */
  27277. edgesColor: Color4;
  27278. /** @hidden */
  27279. _edgesRenderer: Nullable<IEdgesRenderer>;
  27280. /** @hidden */
  27281. _masterMesh: Nullable<AbstractMesh>;
  27282. /** @hidden */
  27283. _boundingInfo: Nullable<BoundingInfo>;
  27284. /** @hidden */
  27285. _renderId: number;
  27286. /**
  27287. * Gets or sets the list of subMeshes
  27288. * @see http://doc.babylonjs.com/how_to/multi_materials
  27289. */
  27290. subMeshes: SubMesh[];
  27291. /** @hidden */
  27292. _intersectionsInProgress: AbstractMesh[];
  27293. /** @hidden */
  27294. _unIndexed: boolean;
  27295. /** @hidden */
  27296. _lightSources: Light[];
  27297. /** Gets the list of lights affecting that mesh */
  27298. readonly lightSources: Light[];
  27299. /** @hidden */
  27300. readonly _positions: Nullable<Vector3[]>;
  27301. /** @hidden */
  27302. _waitingData: {
  27303. lods: Nullable<any>;
  27304. actions: Nullable<any>;
  27305. freezeWorldMatrix: Nullable<boolean>;
  27306. };
  27307. /** @hidden */
  27308. _bonesTransformMatrices: Nullable<Float32Array>;
  27309. /** @hidden */
  27310. _transformMatrixTexture: Nullable<RawTexture>;
  27311. /**
  27312. * Gets or sets a skeleton to apply skining transformations
  27313. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27314. */
  27315. skeleton: Nullable<Skeleton>;
  27316. /**
  27317. * An event triggered when the mesh is rebuilt.
  27318. */
  27319. onRebuildObservable: Observable<AbstractMesh>;
  27320. /**
  27321. * Creates a new AbstractMesh
  27322. * @param name defines the name of the mesh
  27323. * @param scene defines the hosting scene
  27324. */
  27325. constructor(name: string, scene?: Nullable<Scene>);
  27326. /**
  27327. * Returns the string "AbstractMesh"
  27328. * @returns "AbstractMesh"
  27329. */
  27330. getClassName(): string;
  27331. /**
  27332. * Gets a string representation of the current mesh
  27333. * @param fullDetails defines a boolean indicating if full details must be included
  27334. * @returns a string representation of the current mesh
  27335. */
  27336. toString(fullDetails?: boolean): string;
  27337. /**
  27338. * @hidden
  27339. */
  27340. protected _getEffectiveParent(): Nullable<Node>;
  27341. /** @hidden */
  27342. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27343. /** @hidden */
  27344. _rebuild(): void;
  27345. /** @hidden */
  27346. _resyncLightSources(): void;
  27347. /** @hidden */
  27348. _resyncLighSource(light: Light): void;
  27349. /** @hidden */
  27350. _unBindEffect(): void;
  27351. /** @hidden */
  27352. _removeLightSource(light: Light, dispose: boolean): void;
  27353. private _markSubMeshesAsDirty;
  27354. /** @hidden */
  27355. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27356. /** @hidden */
  27357. _markSubMeshesAsAttributesDirty(): void;
  27358. /** @hidden */
  27359. _markSubMeshesAsMiscDirty(): void;
  27360. /**
  27361. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27362. */
  27363. scaling: Vector3;
  27364. /**
  27365. * Returns true if the mesh is blocked. Implemented by child classes
  27366. */
  27367. readonly isBlocked: boolean;
  27368. /**
  27369. * Returns the mesh itself by default. Implemented by child classes
  27370. * @param camera defines the camera to use to pick the right LOD level
  27371. * @returns the currentAbstractMesh
  27372. */
  27373. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27374. /**
  27375. * Returns 0 by default. Implemented by child classes
  27376. * @returns an integer
  27377. */
  27378. getTotalVertices(): number;
  27379. /**
  27380. * Returns a positive integer : the total number of indices in this mesh geometry.
  27381. * @returns the numner of indices or zero if the mesh has no geometry.
  27382. */
  27383. getTotalIndices(): number;
  27384. /**
  27385. * Returns null by default. Implemented by child classes
  27386. * @returns null
  27387. */
  27388. getIndices(): Nullable<IndicesArray>;
  27389. /**
  27390. * Returns the array of the requested vertex data kind. Implemented by child classes
  27391. * @param kind defines the vertex data kind to use
  27392. * @returns null
  27393. */
  27394. getVerticesData(kind: string): Nullable<FloatArray>;
  27395. /**
  27396. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27397. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27398. * Note that a new underlying VertexBuffer object is created each call.
  27399. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27400. * @param kind defines vertex data kind:
  27401. * * VertexBuffer.PositionKind
  27402. * * VertexBuffer.UVKind
  27403. * * VertexBuffer.UV2Kind
  27404. * * VertexBuffer.UV3Kind
  27405. * * VertexBuffer.UV4Kind
  27406. * * VertexBuffer.UV5Kind
  27407. * * VertexBuffer.UV6Kind
  27408. * * VertexBuffer.ColorKind
  27409. * * VertexBuffer.MatricesIndicesKind
  27410. * * VertexBuffer.MatricesIndicesExtraKind
  27411. * * VertexBuffer.MatricesWeightsKind
  27412. * * VertexBuffer.MatricesWeightsExtraKind
  27413. * @param data defines the data source
  27414. * @param updatable defines if the data must be flagged as updatable (or static)
  27415. * @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
  27416. * @returns the current mesh
  27417. */
  27418. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27419. /**
  27420. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27421. * If the mesh has no geometry, it is simply returned as it is.
  27422. * @param kind defines vertex data kind:
  27423. * * VertexBuffer.PositionKind
  27424. * * VertexBuffer.UVKind
  27425. * * VertexBuffer.UV2Kind
  27426. * * VertexBuffer.UV3Kind
  27427. * * VertexBuffer.UV4Kind
  27428. * * VertexBuffer.UV5Kind
  27429. * * VertexBuffer.UV6Kind
  27430. * * VertexBuffer.ColorKind
  27431. * * VertexBuffer.MatricesIndicesKind
  27432. * * VertexBuffer.MatricesIndicesExtraKind
  27433. * * VertexBuffer.MatricesWeightsKind
  27434. * * VertexBuffer.MatricesWeightsExtraKind
  27435. * @param data defines the data source
  27436. * @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
  27437. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27438. * @returns the current mesh
  27439. */
  27440. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27441. /**
  27442. * Sets the mesh indices,
  27443. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27444. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27445. * @param totalVertices Defines the total number of vertices
  27446. * @returns the current mesh
  27447. */
  27448. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27449. /**
  27450. * Gets a boolean indicating if specific vertex data is present
  27451. * @param kind defines the vertex data kind to use
  27452. * @returns true is data kind is present
  27453. */
  27454. isVerticesDataPresent(kind: string): boolean;
  27455. /**
  27456. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27457. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27458. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27459. * @returns a BoundingInfo
  27460. */
  27461. getBoundingInfo(): BoundingInfo;
  27462. /**
  27463. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27464. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27465. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27466. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27467. * @returns the current mesh
  27468. */
  27469. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27470. /**
  27471. * Overwrite the current bounding info
  27472. * @param boundingInfo defines the new bounding info
  27473. * @returns the current mesh
  27474. */
  27475. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27476. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27477. readonly useBones: boolean;
  27478. /** @hidden */
  27479. _preActivate(): void;
  27480. /** @hidden */
  27481. _preActivateForIntermediateRendering(renderId: number): void;
  27482. /** @hidden */
  27483. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27484. /** @hidden */
  27485. _postActivate(): void;
  27486. /** @hidden */
  27487. _freeze(): void;
  27488. /** @hidden */
  27489. _unFreeze(): void;
  27490. /**
  27491. * Gets the current world matrix
  27492. * @returns a Matrix
  27493. */
  27494. getWorldMatrix(): Matrix;
  27495. /** @hidden */
  27496. _getWorldMatrixDeterminant(): number;
  27497. /**
  27498. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27499. */
  27500. readonly isAnInstance: boolean;
  27501. /**
  27502. * Gets a boolean indicating if this mesh has instances
  27503. */
  27504. readonly hasInstances: boolean;
  27505. /**
  27506. * Perform relative position change from the point of view of behind the front of the mesh.
  27507. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27508. * Supports definition of mesh facing forward or backward
  27509. * @param amountRight defines the distance on the right axis
  27510. * @param amountUp defines the distance on the up axis
  27511. * @param amountForward defines the distance on the forward axis
  27512. * @returns the current mesh
  27513. */
  27514. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27515. /**
  27516. * Calculate relative position change from the point of view of behind the front of the mesh.
  27517. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27518. * Supports definition of mesh facing forward or backward
  27519. * @param amountRight defines the distance on the right axis
  27520. * @param amountUp defines the distance on the up axis
  27521. * @param amountForward defines the distance on the forward axis
  27522. * @returns the new displacement vector
  27523. */
  27524. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27525. /**
  27526. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27527. * Supports definition of mesh facing forward or backward
  27528. * @param flipBack defines the flip
  27529. * @param twirlClockwise defines the twirl
  27530. * @param tiltRight defines the tilt
  27531. * @returns the current mesh
  27532. */
  27533. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27534. /**
  27535. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27536. * Supports definition of mesh facing forward or backward.
  27537. * @param flipBack defines the flip
  27538. * @param twirlClockwise defines the twirl
  27539. * @param tiltRight defines the tilt
  27540. * @returns the new rotation vector
  27541. */
  27542. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27543. /**
  27544. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27545. * This means the mesh underlying bounding box and sphere are recomputed.
  27546. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27547. * @returns the current mesh
  27548. */
  27549. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27550. /** @hidden */
  27551. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27552. /** @hidden */
  27553. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27554. /** @hidden */
  27555. _updateBoundingInfo(): AbstractMesh;
  27556. /** @hidden */
  27557. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27558. /** @hidden */
  27559. protected _afterComputeWorldMatrix(): void;
  27560. /** @hidden */
  27561. readonly _effectiveMesh: AbstractMesh;
  27562. /**
  27563. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27564. * A mesh is in the frustum if its bounding box intersects the frustum
  27565. * @param frustumPlanes defines the frustum to test
  27566. * @returns true if the mesh is in the frustum planes
  27567. */
  27568. isInFrustum(frustumPlanes: Plane[]): boolean;
  27569. /**
  27570. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27571. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27572. * @param frustumPlanes defines the frustum to test
  27573. * @returns true if the mesh is completely in the frustum planes
  27574. */
  27575. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27576. /**
  27577. * True if the mesh intersects another mesh or a SolidParticle object
  27578. * @param mesh defines a target mesh or SolidParticle to test
  27579. * @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)
  27580. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27581. * @returns true if there is an intersection
  27582. */
  27583. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27584. /**
  27585. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27586. * @param point defines the point to test
  27587. * @returns true if there is an intersection
  27588. */
  27589. intersectsPoint(point: Vector3): boolean;
  27590. /**
  27591. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27592. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27593. */
  27594. checkCollisions: boolean;
  27595. /**
  27596. * Gets Collider object used to compute collisions (not physics)
  27597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27598. */
  27599. readonly collider: Nullable<Collider>;
  27600. /**
  27601. * Move the mesh using collision engine
  27602. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27603. * @param displacement defines the requested displacement vector
  27604. * @returns the current mesh
  27605. */
  27606. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27607. private _onCollisionPositionChange;
  27608. /** @hidden */
  27609. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27610. /** @hidden */
  27611. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27612. /** @hidden */
  27613. _checkCollision(collider: Collider): AbstractMesh;
  27614. /** @hidden */
  27615. _generatePointsArray(): boolean;
  27616. /**
  27617. * Checks if the passed Ray intersects with the mesh
  27618. * @param ray defines the ray to use
  27619. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27620. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27621. * @returns the picking info
  27622. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27623. */
  27624. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27625. /**
  27626. * Clones the current mesh
  27627. * @param name defines the mesh name
  27628. * @param newParent defines the new mesh parent
  27629. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27630. * @returns the new mesh
  27631. */
  27632. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27633. /**
  27634. * Disposes all the submeshes of the current meshnp
  27635. * @returns the current mesh
  27636. */
  27637. releaseSubMeshes(): AbstractMesh;
  27638. /**
  27639. * Releases resources associated with this abstract mesh.
  27640. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27641. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27642. */
  27643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27644. /**
  27645. * Adds the passed mesh as a child to the current mesh
  27646. * @param mesh defines the child mesh
  27647. * @returns the current mesh
  27648. */
  27649. addChild(mesh: AbstractMesh): AbstractMesh;
  27650. /**
  27651. * Removes the passed mesh from the current mesh children list
  27652. * @param mesh defines the child mesh
  27653. * @returns the current mesh
  27654. */
  27655. removeChild(mesh: AbstractMesh): AbstractMesh;
  27656. /** @hidden */
  27657. private _initFacetData;
  27658. /**
  27659. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27660. * This method can be called within the render loop.
  27661. * 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
  27662. * @returns the current mesh
  27663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27664. */
  27665. updateFacetData(): AbstractMesh;
  27666. /**
  27667. * Returns the facetLocalNormals array.
  27668. * The normals are expressed in the mesh local spac
  27669. * @returns an array of Vector3
  27670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27671. */
  27672. getFacetLocalNormals(): Vector3[];
  27673. /**
  27674. * Returns the facetLocalPositions array.
  27675. * The facet positions are expressed in the mesh local space
  27676. * @returns an array of Vector3
  27677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27678. */
  27679. getFacetLocalPositions(): Vector3[];
  27680. /**
  27681. * Returns the facetLocalPartioning array
  27682. * @returns an array of array of numbers
  27683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27684. */
  27685. getFacetLocalPartitioning(): number[][];
  27686. /**
  27687. * Returns the i-th facet position in the world system.
  27688. * This method allocates a new Vector3 per call
  27689. * @param i defines the facet index
  27690. * @returns a new Vector3
  27691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27692. */
  27693. getFacetPosition(i: number): Vector3;
  27694. /**
  27695. * Sets the reference Vector3 with the i-th facet position in the world system
  27696. * @param i defines the facet index
  27697. * @param ref defines the target vector
  27698. * @returns the current mesh
  27699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27700. */
  27701. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27702. /**
  27703. * Returns the i-th facet normal in the world system.
  27704. * This method allocates a new Vector3 per call
  27705. * @param i defines the facet index
  27706. * @returns a new Vector3
  27707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27708. */
  27709. getFacetNormal(i: number): Vector3;
  27710. /**
  27711. * Sets the reference Vector3 with the i-th facet normal in the world system
  27712. * @param i defines the facet index
  27713. * @param ref defines the target vector
  27714. * @returns the current mesh
  27715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27716. */
  27717. getFacetNormalToRef(i: number, ref: Vector3): this;
  27718. /**
  27719. * 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)
  27720. * @param x defines x coordinate
  27721. * @param y defines y coordinate
  27722. * @param z defines z coordinate
  27723. * @returns the array of facet indexes
  27724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27725. */
  27726. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27727. /**
  27728. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27729. * @param projected sets as the (x,y,z) world projection on the facet
  27730. * @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
  27731. * @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
  27732. * @param x defines x coordinate
  27733. * @param y defines y coordinate
  27734. * @param z defines z coordinate
  27735. * @returns the face index if found (or null instead)
  27736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27737. */
  27738. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27739. /**
  27740. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27741. * @param projected sets as the (x,y,z) local projection on the facet
  27742. * @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
  27743. * @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
  27744. * @param x defines x coordinate
  27745. * @param y defines y coordinate
  27746. * @param z defines z coordinate
  27747. * @returns the face index if found (or null instead)
  27748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27749. */
  27750. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27751. /**
  27752. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27753. * @returns the parameters
  27754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27755. */
  27756. getFacetDataParameters(): any;
  27757. /**
  27758. * Disables the feature FacetData and frees the related memory
  27759. * @returns the current mesh
  27760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27761. */
  27762. disableFacetData(): AbstractMesh;
  27763. /**
  27764. * Updates the AbstractMesh indices array
  27765. * @param indices defines the data source
  27766. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27767. * @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)
  27768. * @returns the current mesh
  27769. */
  27770. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27771. /**
  27772. * Creates new normals data for the mesh
  27773. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27774. * @returns the current mesh
  27775. */
  27776. createNormals(updatable: boolean): AbstractMesh;
  27777. /**
  27778. * Align the mesh with a normal
  27779. * @param normal defines the normal to use
  27780. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27781. * @returns the current mesh
  27782. */
  27783. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27784. /** @hidden */
  27785. _checkOcclusionQuery(): boolean;
  27786. /**
  27787. * Disables the mesh edge rendering mode
  27788. * @returns the currentAbstractMesh
  27789. */
  27790. disableEdgesRendering(): AbstractMesh;
  27791. /**
  27792. * Enables the edge rendering mode on the mesh.
  27793. * This mode makes the mesh edges visible
  27794. * @param epsilon defines the maximal distance between two angles to detect a face
  27795. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27796. * @returns the currentAbstractMesh
  27797. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27798. */
  27799. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27800. }
  27801. }
  27802. declare module "babylonjs/Actions/actionEvent" {
  27803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27804. import { Nullable } from "babylonjs/types";
  27805. import { Sprite } from "babylonjs/Sprites/sprite";
  27806. import { Scene } from "babylonjs/scene";
  27807. import { Vector2 } from "babylonjs/Maths/math.vector";
  27808. /**
  27809. * Interface used to define ActionEvent
  27810. */
  27811. export interface IActionEvent {
  27812. /** The mesh or sprite that triggered the action */
  27813. source: any;
  27814. /** The X mouse cursor position at the time of the event */
  27815. pointerX: number;
  27816. /** The Y mouse cursor position at the time of the event */
  27817. pointerY: number;
  27818. /** The mesh that is currently pointed at (can be null) */
  27819. meshUnderPointer: Nullable<AbstractMesh>;
  27820. /** the original (browser) event that triggered the ActionEvent */
  27821. sourceEvent?: any;
  27822. /** additional data for the event */
  27823. additionalData?: any;
  27824. }
  27825. /**
  27826. * ActionEvent is the event being sent when an action is triggered.
  27827. */
  27828. export class ActionEvent implements IActionEvent {
  27829. /** The mesh or sprite that triggered the action */
  27830. source: any;
  27831. /** The X mouse cursor position at the time of the event */
  27832. pointerX: number;
  27833. /** The Y mouse cursor position at the time of the event */
  27834. pointerY: number;
  27835. /** The mesh that is currently pointed at (can be null) */
  27836. meshUnderPointer: Nullable<AbstractMesh>;
  27837. /** the original (browser) event that triggered the ActionEvent */
  27838. sourceEvent?: any;
  27839. /** additional data for the event */
  27840. additionalData?: any;
  27841. /**
  27842. * Creates a new ActionEvent
  27843. * @param source The mesh or sprite that triggered the action
  27844. * @param pointerX The X mouse cursor position at the time of the event
  27845. * @param pointerY The Y mouse cursor position at the time of the event
  27846. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27847. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27848. * @param additionalData additional data for the event
  27849. */
  27850. constructor(
  27851. /** The mesh or sprite that triggered the action */
  27852. source: any,
  27853. /** The X mouse cursor position at the time of the event */
  27854. pointerX: number,
  27855. /** The Y mouse cursor position at the time of the event */
  27856. pointerY: number,
  27857. /** The mesh that is currently pointed at (can be null) */
  27858. meshUnderPointer: Nullable<AbstractMesh>,
  27859. /** the original (browser) event that triggered the ActionEvent */
  27860. sourceEvent?: any,
  27861. /** additional data for the event */
  27862. additionalData?: any);
  27863. /**
  27864. * Helper function to auto-create an ActionEvent from a source mesh.
  27865. * @param source The source mesh that triggered the event
  27866. * @param evt The original (browser) event
  27867. * @param additionalData additional data for the event
  27868. * @returns the new ActionEvent
  27869. */
  27870. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27871. /**
  27872. * Helper function to auto-create an ActionEvent from a source sprite
  27873. * @param source The source sprite that triggered the event
  27874. * @param scene Scene associated with the sprite
  27875. * @param evt The original (browser) event
  27876. * @param additionalData additional data for the event
  27877. * @returns the new ActionEvent
  27878. */
  27879. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27880. /**
  27881. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27882. * @param scene the scene where the event occurred
  27883. * @param evt The original (browser) event
  27884. * @returns the new ActionEvent
  27885. */
  27886. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27887. /**
  27888. * Helper function to auto-create an ActionEvent from a primitive
  27889. * @param prim defines the target primitive
  27890. * @param pointerPos defines the pointer position
  27891. * @param evt The original (browser) event
  27892. * @param additionalData additional data for the event
  27893. * @returns the new ActionEvent
  27894. */
  27895. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27896. }
  27897. }
  27898. declare module "babylonjs/Actions/abstractActionManager" {
  27899. import { IDisposable } from "babylonjs/scene";
  27900. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27901. import { IAction } from "babylonjs/Actions/action";
  27902. import { Nullable } from "babylonjs/types";
  27903. /**
  27904. * Abstract class used to decouple action Manager from scene and meshes.
  27905. * Do not instantiate.
  27906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27907. */
  27908. export abstract class AbstractActionManager implements IDisposable {
  27909. /** Gets the list of active triggers */
  27910. static Triggers: {
  27911. [key: string]: number;
  27912. };
  27913. /** Gets the cursor to use when hovering items */
  27914. hoverCursor: string;
  27915. /** Gets the list of actions */
  27916. actions: IAction[];
  27917. /**
  27918. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27919. */
  27920. isRecursive: boolean;
  27921. /**
  27922. * Releases all associated resources
  27923. */
  27924. abstract dispose(): void;
  27925. /**
  27926. * Does this action manager has pointer triggers
  27927. */
  27928. abstract readonly hasPointerTriggers: boolean;
  27929. /**
  27930. * Does this action manager has pick triggers
  27931. */
  27932. abstract readonly hasPickTriggers: boolean;
  27933. /**
  27934. * Process a specific trigger
  27935. * @param trigger defines the trigger to process
  27936. * @param evt defines the event details to be processed
  27937. */
  27938. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27939. /**
  27940. * Does this action manager handles actions of any of the given triggers
  27941. * @param triggers defines the triggers to be tested
  27942. * @return a boolean indicating whether one (or more) of the triggers is handled
  27943. */
  27944. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27945. /**
  27946. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27947. * speed.
  27948. * @param triggerA defines the trigger to be tested
  27949. * @param triggerB defines the trigger to be tested
  27950. * @return a boolean indicating whether one (or more) of the triggers is handled
  27951. */
  27952. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27953. /**
  27954. * Does this action manager handles actions of a given trigger
  27955. * @param trigger defines the trigger to be tested
  27956. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27957. * @return whether the trigger is handled
  27958. */
  27959. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27960. /**
  27961. * Serialize this manager to a JSON object
  27962. * @param name defines the property name to store this manager
  27963. * @returns a JSON representation of this manager
  27964. */
  27965. abstract serialize(name: string): any;
  27966. /**
  27967. * Registers an action to this action manager
  27968. * @param action defines the action to be registered
  27969. * @return the action amended (prepared) after registration
  27970. */
  27971. abstract registerAction(action: IAction): Nullable<IAction>;
  27972. /**
  27973. * Unregisters an action to this action manager
  27974. * @param action defines the action to be unregistered
  27975. * @return a boolean indicating whether the action has been unregistered
  27976. */
  27977. abstract unregisterAction(action: IAction): Boolean;
  27978. /**
  27979. * Does exist one action manager with at least one trigger
  27980. **/
  27981. static readonly HasTriggers: boolean;
  27982. /**
  27983. * Does exist one action manager with at least one pick trigger
  27984. **/
  27985. static readonly HasPickTriggers: boolean;
  27986. /**
  27987. * Does exist one action manager that handles actions of a given trigger
  27988. * @param trigger defines the trigger to be tested
  27989. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27990. **/
  27991. static HasSpecificTrigger(trigger: number): boolean;
  27992. }
  27993. }
  27994. declare module "babylonjs/node" {
  27995. import { Scene } from "babylonjs/scene";
  27996. import { Nullable } from "babylonjs/types";
  27997. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27998. import { Engine } from "babylonjs/Engines/engine";
  27999. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  28000. import { Observable } from "babylonjs/Misc/observable";
  28001. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28002. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28003. import { Animatable } from "babylonjs/Animations/animatable";
  28004. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  28005. import { Animation } from "babylonjs/Animations/animation";
  28006. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28008. /**
  28009. * Defines how a node can be built from a string name.
  28010. */
  28011. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28012. /**
  28013. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28014. */
  28015. export class Node implements IBehaviorAware<Node> {
  28016. /** @hidden */
  28017. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28018. private static _NodeConstructors;
  28019. /**
  28020. * Add a new node constructor
  28021. * @param type defines the type name of the node to construct
  28022. * @param constructorFunc defines the constructor function
  28023. */
  28024. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28025. /**
  28026. * Returns a node constructor based on type name
  28027. * @param type defines the type name
  28028. * @param name defines the new node name
  28029. * @param scene defines the hosting scene
  28030. * @param options defines optional options to transmit to constructors
  28031. * @returns the new constructor or null
  28032. */
  28033. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28034. /**
  28035. * Gets or sets the name of the node
  28036. */
  28037. name: string;
  28038. /**
  28039. * Gets or sets the id of the node
  28040. */
  28041. id: string;
  28042. /**
  28043. * Gets or sets the unique id of the node
  28044. */
  28045. uniqueId: number;
  28046. /**
  28047. * Gets or sets a string used to store user defined state for the node
  28048. */
  28049. state: string;
  28050. /**
  28051. * Gets or sets an object used to store user defined information for the node
  28052. */
  28053. metadata: any;
  28054. /**
  28055. * For internal use only. Please do not use.
  28056. */
  28057. reservedDataStore: any;
  28058. /**
  28059. * List of inspectable custom properties (used by the Inspector)
  28060. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28061. */
  28062. inspectableCustomProperties: IInspectable[];
  28063. private _doNotSerialize;
  28064. /**
  28065. * Gets or sets a boolean used to define if the node must be serialized
  28066. */
  28067. doNotSerialize: boolean;
  28068. /** @hidden */
  28069. _isDisposed: boolean;
  28070. /**
  28071. * Gets a list of Animations associated with the node
  28072. */
  28073. animations: import("babylonjs/Animations/animation").Animation[];
  28074. protected _ranges: {
  28075. [name: string]: Nullable<AnimationRange>;
  28076. };
  28077. /**
  28078. * Callback raised when the node is ready to be used
  28079. */
  28080. onReady: Nullable<(node: Node) => void>;
  28081. private _isEnabled;
  28082. private _isParentEnabled;
  28083. private _isReady;
  28084. /** @hidden */
  28085. _currentRenderId: number;
  28086. private _parentUpdateId;
  28087. /** @hidden */
  28088. _childUpdateId: number;
  28089. /** @hidden */
  28090. _waitingParentId: Nullable<string>;
  28091. /** @hidden */
  28092. _scene: Scene;
  28093. /** @hidden */
  28094. _cache: any;
  28095. private _parentNode;
  28096. private _children;
  28097. /** @hidden */
  28098. _worldMatrix: Matrix;
  28099. /** @hidden */
  28100. _worldMatrixDeterminant: number;
  28101. /** @hidden */
  28102. _worldMatrixDeterminantIsDirty: boolean;
  28103. /** @hidden */
  28104. private _sceneRootNodesIndex;
  28105. /**
  28106. * Gets a boolean indicating if the node has been disposed
  28107. * @returns true if the node was disposed
  28108. */
  28109. isDisposed(): boolean;
  28110. /**
  28111. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28112. * @see https://doc.babylonjs.com/how_to/parenting
  28113. */
  28114. parent: Nullable<Node>;
  28115. /** @hidden */
  28116. _addToSceneRootNodes(): void;
  28117. /** @hidden */
  28118. _removeFromSceneRootNodes(): void;
  28119. private _animationPropertiesOverride;
  28120. /**
  28121. * Gets or sets the animation properties override
  28122. */
  28123. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28124. /**
  28125. * Gets a string idenfifying the name of the class
  28126. * @returns "Node" string
  28127. */
  28128. getClassName(): string;
  28129. /** @hidden */
  28130. readonly _isNode: boolean;
  28131. /**
  28132. * An event triggered when the mesh is disposed
  28133. */
  28134. onDisposeObservable: Observable<Node>;
  28135. private _onDisposeObserver;
  28136. /**
  28137. * Sets a callback that will be raised when the node will be disposed
  28138. */
  28139. onDispose: () => void;
  28140. /**
  28141. * Creates a new Node
  28142. * @param name the name and id to be given to this node
  28143. * @param scene the scene this node will be added to
  28144. */
  28145. constructor(name: string, scene?: Nullable<Scene>);
  28146. /**
  28147. * Gets the scene of the node
  28148. * @returns a scene
  28149. */
  28150. getScene(): Scene;
  28151. /**
  28152. * Gets the engine of the node
  28153. * @returns a Engine
  28154. */
  28155. getEngine(): Engine;
  28156. private _behaviors;
  28157. /**
  28158. * Attach a behavior to the node
  28159. * @see http://doc.babylonjs.com/features/behaviour
  28160. * @param behavior defines the behavior to attach
  28161. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28162. * @returns the current Node
  28163. */
  28164. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28165. /**
  28166. * Remove an attached behavior
  28167. * @see http://doc.babylonjs.com/features/behaviour
  28168. * @param behavior defines the behavior to attach
  28169. * @returns the current Node
  28170. */
  28171. removeBehavior(behavior: Behavior<Node>): Node;
  28172. /**
  28173. * Gets the list of attached behaviors
  28174. * @see http://doc.babylonjs.com/features/behaviour
  28175. */
  28176. readonly behaviors: Behavior<Node>[];
  28177. /**
  28178. * Gets an attached behavior by name
  28179. * @param name defines the name of the behavior to look for
  28180. * @see http://doc.babylonjs.com/features/behaviour
  28181. * @returns null if behavior was not found else the requested behavior
  28182. */
  28183. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28184. /**
  28185. * Returns the latest update of the World matrix
  28186. * @returns a Matrix
  28187. */
  28188. getWorldMatrix(): Matrix;
  28189. /** @hidden */
  28190. _getWorldMatrixDeterminant(): number;
  28191. /**
  28192. * Returns directly the latest state of the mesh World matrix.
  28193. * A Matrix is returned.
  28194. */
  28195. readonly worldMatrixFromCache: Matrix;
  28196. /** @hidden */
  28197. _initCache(): void;
  28198. /** @hidden */
  28199. updateCache(force?: boolean): void;
  28200. /** @hidden */
  28201. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28202. /** @hidden */
  28203. _updateCache(ignoreParentClass?: boolean): void;
  28204. /** @hidden */
  28205. _isSynchronized(): boolean;
  28206. /** @hidden */
  28207. _markSyncedWithParent(): void;
  28208. /** @hidden */
  28209. isSynchronizedWithParent(): boolean;
  28210. /** @hidden */
  28211. isSynchronized(): boolean;
  28212. /**
  28213. * Is this node ready to be used/rendered
  28214. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28215. * @return true if the node is ready
  28216. */
  28217. isReady(completeCheck?: boolean): boolean;
  28218. /**
  28219. * Is this node enabled?
  28220. * 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
  28221. * @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
  28222. * @return whether this node (and its parent) is enabled
  28223. */
  28224. isEnabled(checkAncestors?: boolean): boolean;
  28225. /** @hidden */
  28226. protected _syncParentEnabledState(): void;
  28227. /**
  28228. * Set the enabled state of this node
  28229. * @param value defines the new enabled state
  28230. */
  28231. setEnabled(value: boolean): void;
  28232. /**
  28233. * Is this node a descendant of the given node?
  28234. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28235. * @param ancestor defines the parent node to inspect
  28236. * @returns a boolean indicating if this node is a descendant of the given node
  28237. */
  28238. isDescendantOf(ancestor: Node): boolean;
  28239. /** @hidden */
  28240. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28241. /**
  28242. * Will return all nodes that have this node as ascendant
  28243. * @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
  28244. * @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
  28245. * @return all children nodes of all types
  28246. */
  28247. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28248. /**
  28249. * Get all child-meshes of this node
  28250. * @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)
  28251. * @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
  28252. * @returns an array of AbstractMesh
  28253. */
  28254. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28255. /**
  28256. * Get all direct children of this node
  28257. * @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
  28258. * @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)
  28259. * @returns an array of Node
  28260. */
  28261. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28262. /** @hidden */
  28263. _setReady(state: boolean): void;
  28264. /**
  28265. * Get an animation by name
  28266. * @param name defines the name of the animation to look for
  28267. * @returns null if not found else the requested animation
  28268. */
  28269. getAnimationByName(name: string): Nullable<Animation>;
  28270. /**
  28271. * Creates an animation range for this node
  28272. * @param name defines the name of the range
  28273. * @param from defines the starting key
  28274. * @param to defines the end key
  28275. */
  28276. createAnimationRange(name: string, from: number, to: number): void;
  28277. /**
  28278. * Delete a specific animation range
  28279. * @param name defines the name of the range to delete
  28280. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28281. */
  28282. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28283. /**
  28284. * Get an animation range by name
  28285. * @param name defines the name of the animation range to look for
  28286. * @returns null if not found else the requested animation range
  28287. */
  28288. getAnimationRange(name: string): Nullable<AnimationRange>;
  28289. /**
  28290. * Gets the list of all animation ranges defined on this node
  28291. * @returns an array
  28292. */
  28293. getAnimationRanges(): Nullable<AnimationRange>[];
  28294. /**
  28295. * Will start the animation sequence
  28296. * @param name defines the range frames for animation sequence
  28297. * @param loop defines if the animation should loop (false by default)
  28298. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28299. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28300. * @returns the object created for this animation. If range does not exist, it will return null
  28301. */
  28302. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28303. /**
  28304. * Serialize animation ranges into a JSON compatible object
  28305. * @returns serialization object
  28306. */
  28307. serializeAnimationRanges(): any;
  28308. /**
  28309. * Computes the world matrix of the node
  28310. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28311. * @returns the world matrix
  28312. */
  28313. computeWorldMatrix(force?: boolean): Matrix;
  28314. /**
  28315. * Releases resources associated with this node.
  28316. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28317. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28318. */
  28319. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28320. /**
  28321. * Parse animation range data from a serialization object and store them into a given node
  28322. * @param node defines where to store the animation ranges
  28323. * @param parsedNode defines the serialization object to read data from
  28324. * @param scene defines the hosting scene
  28325. */
  28326. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28327. /**
  28328. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28329. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28330. * @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
  28331. * @returns the new bounding vectors
  28332. */
  28333. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28334. min: Vector3;
  28335. max: Vector3;
  28336. };
  28337. }
  28338. }
  28339. declare module "babylonjs/Animations/animation" {
  28340. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28341. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28342. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28343. import { Nullable } from "babylonjs/types";
  28344. import { Scene } from "babylonjs/scene";
  28345. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28346. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28347. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28348. import { Node } from "babylonjs/node";
  28349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28350. import { Size } from "babylonjs/Maths/math.size";
  28351. import { Animatable } from "babylonjs/Animations/animatable";
  28352. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28353. /**
  28354. * @hidden
  28355. */
  28356. export class _IAnimationState {
  28357. key: number;
  28358. repeatCount: number;
  28359. workValue?: any;
  28360. loopMode?: number;
  28361. offsetValue?: any;
  28362. highLimitValue?: any;
  28363. }
  28364. /**
  28365. * Class used to store any kind of animation
  28366. */
  28367. export class Animation {
  28368. /**Name of the animation */
  28369. name: string;
  28370. /**Property to animate */
  28371. targetProperty: string;
  28372. /**The frames per second of the animation */
  28373. framePerSecond: number;
  28374. /**The data type of the animation */
  28375. dataType: number;
  28376. /**The loop mode of the animation */
  28377. loopMode?: number | undefined;
  28378. /**Specifies if blending should be enabled */
  28379. enableBlending?: boolean | undefined;
  28380. /**
  28381. * Use matrix interpolation instead of using direct key value when animating matrices
  28382. */
  28383. static AllowMatricesInterpolation: boolean;
  28384. /**
  28385. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28386. */
  28387. static AllowMatrixDecomposeForInterpolation: boolean;
  28388. /**
  28389. * Stores the key frames of the animation
  28390. */
  28391. private _keys;
  28392. /**
  28393. * Stores the easing function of the animation
  28394. */
  28395. private _easingFunction;
  28396. /**
  28397. * @hidden Internal use only
  28398. */
  28399. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28400. /**
  28401. * The set of event that will be linked to this animation
  28402. */
  28403. private _events;
  28404. /**
  28405. * Stores an array of target property paths
  28406. */
  28407. targetPropertyPath: string[];
  28408. /**
  28409. * Stores the blending speed of the animation
  28410. */
  28411. blendingSpeed: number;
  28412. /**
  28413. * Stores the animation ranges for the animation
  28414. */
  28415. private _ranges;
  28416. /**
  28417. * @hidden Internal use
  28418. */
  28419. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28420. /**
  28421. * Sets up an animation
  28422. * @param property The property to animate
  28423. * @param animationType The animation type to apply
  28424. * @param framePerSecond The frames per second of the animation
  28425. * @param easingFunction The easing function used in the animation
  28426. * @returns The created animation
  28427. */
  28428. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28429. /**
  28430. * Create and start an animation on a node
  28431. * @param name defines the name of the global animation that will be run on all nodes
  28432. * @param node defines the root node where the animation will take place
  28433. * @param targetProperty defines property to animate
  28434. * @param framePerSecond defines the number of frame per second yo use
  28435. * @param totalFrame defines the number of frames in total
  28436. * @param from defines the initial value
  28437. * @param to defines the final value
  28438. * @param loopMode defines which loop mode you want to use (off by default)
  28439. * @param easingFunction defines the easing function to use (linear by default)
  28440. * @param onAnimationEnd defines the callback to call when animation end
  28441. * @returns the animatable created for this animation
  28442. */
  28443. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28444. /**
  28445. * Create and start an animation on a node and its descendants
  28446. * @param name defines the name of the global animation that will be run on all nodes
  28447. * @param node defines the root node where the animation will take place
  28448. * @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
  28449. * @param targetProperty defines property to animate
  28450. * @param framePerSecond defines the number of frame per second to use
  28451. * @param totalFrame defines the number of frames in total
  28452. * @param from defines the initial value
  28453. * @param to defines the final value
  28454. * @param loopMode defines which loop mode you want to use (off by default)
  28455. * @param easingFunction defines the easing function to use (linear by default)
  28456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28457. * @returns the list of animatables created for all nodes
  28458. * @example https://www.babylonjs-playground.com/#MH0VLI
  28459. */
  28460. 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[]>;
  28461. /**
  28462. * Creates a new animation, merges it with the existing animations and starts it
  28463. * @param name Name of the animation
  28464. * @param node Node which contains the scene that begins the animations
  28465. * @param targetProperty Specifies which property to animate
  28466. * @param framePerSecond The frames per second of the animation
  28467. * @param totalFrame The total number of frames
  28468. * @param from The frame at the beginning of the animation
  28469. * @param to The frame at the end of the animation
  28470. * @param loopMode Specifies the loop mode of the animation
  28471. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28472. * @param onAnimationEnd Callback to run once the animation is complete
  28473. * @returns Nullable animation
  28474. */
  28475. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28476. /**
  28477. * Transition property of an host to the target Value
  28478. * @param property The property to transition
  28479. * @param targetValue The target Value of the property
  28480. * @param host The object where the property to animate belongs
  28481. * @param scene Scene used to run the animation
  28482. * @param frameRate Framerate (in frame/s) to use
  28483. * @param transition The transition type we want to use
  28484. * @param duration The duration of the animation, in milliseconds
  28485. * @param onAnimationEnd Callback trigger at the end of the animation
  28486. * @returns Nullable animation
  28487. */
  28488. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28489. /**
  28490. * Return the array of runtime animations currently using this animation
  28491. */
  28492. readonly runtimeAnimations: RuntimeAnimation[];
  28493. /**
  28494. * Specifies if any of the runtime animations are currently running
  28495. */
  28496. readonly hasRunningRuntimeAnimations: boolean;
  28497. /**
  28498. * Initializes the animation
  28499. * @param name Name of the animation
  28500. * @param targetProperty Property to animate
  28501. * @param framePerSecond The frames per second of the animation
  28502. * @param dataType The data type of the animation
  28503. * @param loopMode The loop mode of the animation
  28504. * @param enableBlending Specifies if blending should be enabled
  28505. */
  28506. constructor(
  28507. /**Name of the animation */
  28508. name: string,
  28509. /**Property to animate */
  28510. targetProperty: string,
  28511. /**The frames per second of the animation */
  28512. framePerSecond: number,
  28513. /**The data type of the animation */
  28514. dataType: number,
  28515. /**The loop mode of the animation */
  28516. loopMode?: number | undefined,
  28517. /**Specifies if blending should be enabled */
  28518. enableBlending?: boolean | undefined);
  28519. /**
  28520. * Converts the animation to a string
  28521. * @param fullDetails support for multiple levels of logging within scene loading
  28522. * @returns String form of the animation
  28523. */
  28524. toString(fullDetails?: boolean): string;
  28525. /**
  28526. * Add an event to this animation
  28527. * @param event Event to add
  28528. */
  28529. addEvent(event: AnimationEvent): void;
  28530. /**
  28531. * Remove all events found at the given frame
  28532. * @param frame The frame to remove events from
  28533. */
  28534. removeEvents(frame: number): void;
  28535. /**
  28536. * Retrieves all the events from the animation
  28537. * @returns Events from the animation
  28538. */
  28539. getEvents(): AnimationEvent[];
  28540. /**
  28541. * Creates an animation range
  28542. * @param name Name of the animation range
  28543. * @param from Starting frame of the animation range
  28544. * @param to Ending frame of the animation
  28545. */
  28546. createRange(name: string, from: number, to: number): void;
  28547. /**
  28548. * Deletes an animation range by name
  28549. * @param name Name of the animation range to delete
  28550. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28551. */
  28552. deleteRange(name: string, deleteFrames?: boolean): void;
  28553. /**
  28554. * Gets the animation range by name, or null if not defined
  28555. * @param name Name of the animation range
  28556. * @returns Nullable animation range
  28557. */
  28558. getRange(name: string): Nullable<AnimationRange>;
  28559. /**
  28560. * Gets the key frames from the animation
  28561. * @returns The key frames of the animation
  28562. */
  28563. getKeys(): Array<IAnimationKey>;
  28564. /**
  28565. * Gets the highest frame rate of the animation
  28566. * @returns Highest frame rate of the animation
  28567. */
  28568. getHighestFrame(): number;
  28569. /**
  28570. * Gets the easing function of the animation
  28571. * @returns Easing function of the animation
  28572. */
  28573. getEasingFunction(): IEasingFunction;
  28574. /**
  28575. * Sets the easing function of the animation
  28576. * @param easingFunction A custom mathematical formula for animation
  28577. */
  28578. setEasingFunction(easingFunction: EasingFunction): void;
  28579. /**
  28580. * Interpolates a scalar linearly
  28581. * @param startValue Start value of the animation curve
  28582. * @param endValue End value of the animation curve
  28583. * @param gradient Scalar amount to interpolate
  28584. * @returns Interpolated scalar value
  28585. */
  28586. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28587. /**
  28588. * Interpolates a scalar cubically
  28589. * @param startValue Start value of the animation curve
  28590. * @param outTangent End tangent of the animation
  28591. * @param endValue End value of the animation curve
  28592. * @param inTangent Start tangent of the animation curve
  28593. * @param gradient Scalar amount to interpolate
  28594. * @returns Interpolated scalar value
  28595. */
  28596. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28597. /**
  28598. * Interpolates a quaternion using a spherical linear interpolation
  28599. * @param startValue Start value of the animation curve
  28600. * @param endValue End value of the animation curve
  28601. * @param gradient Scalar amount to interpolate
  28602. * @returns Interpolated quaternion value
  28603. */
  28604. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28605. /**
  28606. * Interpolates a quaternion cubically
  28607. * @param startValue Start value of the animation curve
  28608. * @param outTangent End tangent of the animation curve
  28609. * @param endValue End value of the animation curve
  28610. * @param inTangent Start tangent of the animation curve
  28611. * @param gradient Scalar amount to interpolate
  28612. * @returns Interpolated quaternion value
  28613. */
  28614. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28615. /**
  28616. * Interpolates a Vector3 linearl
  28617. * @param startValue Start value of the animation curve
  28618. * @param endValue End value of the animation curve
  28619. * @param gradient Scalar amount to interpolate
  28620. * @returns Interpolated scalar value
  28621. */
  28622. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28623. /**
  28624. * Interpolates a Vector3 cubically
  28625. * @param startValue Start value of the animation curve
  28626. * @param outTangent End tangent of the animation
  28627. * @param endValue End value of the animation curve
  28628. * @param inTangent Start tangent of the animation curve
  28629. * @param gradient Scalar amount to interpolate
  28630. * @returns InterpolatedVector3 value
  28631. */
  28632. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28633. /**
  28634. * Interpolates a Vector2 linearly
  28635. * @param startValue Start value of the animation curve
  28636. * @param endValue End value of the animation curve
  28637. * @param gradient Scalar amount to interpolate
  28638. * @returns Interpolated Vector2 value
  28639. */
  28640. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28641. /**
  28642. * Interpolates a Vector2 cubically
  28643. * @param startValue Start value of the animation curve
  28644. * @param outTangent End tangent of the animation
  28645. * @param endValue End value of the animation curve
  28646. * @param inTangent Start tangent of the animation curve
  28647. * @param gradient Scalar amount to interpolate
  28648. * @returns Interpolated Vector2 value
  28649. */
  28650. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28651. /**
  28652. * Interpolates a size linearly
  28653. * @param startValue Start value of the animation curve
  28654. * @param endValue End value of the animation curve
  28655. * @param gradient Scalar amount to interpolate
  28656. * @returns Interpolated Size value
  28657. */
  28658. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28659. /**
  28660. * Interpolates a Color3 linearly
  28661. * @param startValue Start value of the animation curve
  28662. * @param endValue End value of the animation curve
  28663. * @param gradient Scalar amount to interpolate
  28664. * @returns Interpolated Color3 value
  28665. */
  28666. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28667. /**
  28668. * Interpolates a Color4 linearly
  28669. * @param startValue Start value of the animation curve
  28670. * @param endValue End value of the animation curve
  28671. * @param gradient Scalar amount to interpolate
  28672. * @returns Interpolated Color3 value
  28673. */
  28674. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28675. /**
  28676. * @hidden Internal use only
  28677. */
  28678. _getKeyValue(value: any): any;
  28679. /**
  28680. * @hidden Internal use only
  28681. */
  28682. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28683. /**
  28684. * Defines the function to use to interpolate matrices
  28685. * @param startValue defines the start matrix
  28686. * @param endValue defines the end matrix
  28687. * @param gradient defines the gradient between both matrices
  28688. * @param result defines an optional target matrix where to store the interpolation
  28689. * @returns the interpolated matrix
  28690. */
  28691. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28692. /**
  28693. * Makes a copy of the animation
  28694. * @returns Cloned animation
  28695. */
  28696. clone(): Animation;
  28697. /**
  28698. * Sets the key frames of the animation
  28699. * @param values The animation key frames to set
  28700. */
  28701. setKeys(values: Array<IAnimationKey>): void;
  28702. /**
  28703. * Serializes the animation to an object
  28704. * @returns Serialized object
  28705. */
  28706. serialize(): any;
  28707. /**
  28708. * Float animation type
  28709. */
  28710. static readonly ANIMATIONTYPE_FLOAT: number;
  28711. /**
  28712. * Vector3 animation type
  28713. */
  28714. static readonly ANIMATIONTYPE_VECTOR3: number;
  28715. /**
  28716. * Quaternion animation type
  28717. */
  28718. static readonly ANIMATIONTYPE_QUATERNION: number;
  28719. /**
  28720. * Matrix animation type
  28721. */
  28722. static readonly ANIMATIONTYPE_MATRIX: number;
  28723. /**
  28724. * Color3 animation type
  28725. */
  28726. static readonly ANIMATIONTYPE_COLOR3: number;
  28727. /**
  28728. * Color3 animation type
  28729. */
  28730. static readonly ANIMATIONTYPE_COLOR4: number;
  28731. /**
  28732. * Vector2 animation type
  28733. */
  28734. static readonly ANIMATIONTYPE_VECTOR2: number;
  28735. /**
  28736. * Size animation type
  28737. */
  28738. static readonly ANIMATIONTYPE_SIZE: number;
  28739. /**
  28740. * Relative Loop Mode
  28741. */
  28742. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28743. /**
  28744. * Cycle Loop Mode
  28745. */
  28746. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28747. /**
  28748. * Constant Loop Mode
  28749. */
  28750. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28751. /** @hidden */
  28752. static _UniversalLerp(left: any, right: any, amount: number): any;
  28753. /**
  28754. * Parses an animation object and creates an animation
  28755. * @param parsedAnimation Parsed animation object
  28756. * @returns Animation object
  28757. */
  28758. static Parse(parsedAnimation: any): Animation;
  28759. /**
  28760. * Appends the serialized animations from the source animations
  28761. * @param source Source containing the animations
  28762. * @param destination Target to store the animations
  28763. */
  28764. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28765. }
  28766. }
  28767. declare module "babylonjs/Animations/animatable.interface" {
  28768. import { Nullable } from "babylonjs/types";
  28769. import { Animation } from "babylonjs/Animations/animation";
  28770. /**
  28771. * Interface containing an array of animations
  28772. */
  28773. export interface IAnimatable {
  28774. /**
  28775. * Array of animations
  28776. */
  28777. animations: Nullable<Array<Animation>>;
  28778. }
  28779. }
  28780. declare module "babylonjs/Materials/fresnelParameters" {
  28781. import { Color3 } from "babylonjs/Maths/math.color";
  28782. /**
  28783. * This represents all the required information to add a fresnel effect on a material:
  28784. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28785. */
  28786. export class FresnelParameters {
  28787. private _isEnabled;
  28788. /**
  28789. * Define if the fresnel effect is enable or not.
  28790. */
  28791. isEnabled: boolean;
  28792. /**
  28793. * Define the color used on edges (grazing angle)
  28794. */
  28795. leftColor: Color3;
  28796. /**
  28797. * Define the color used on center
  28798. */
  28799. rightColor: Color3;
  28800. /**
  28801. * Define bias applied to computed fresnel term
  28802. */
  28803. bias: number;
  28804. /**
  28805. * Defined the power exponent applied to fresnel term
  28806. */
  28807. power: number;
  28808. /**
  28809. * Clones the current fresnel and its valuues
  28810. * @returns a clone fresnel configuration
  28811. */
  28812. clone(): FresnelParameters;
  28813. /**
  28814. * Serializes the current fresnel parameters to a JSON representation.
  28815. * @return the JSON serialization
  28816. */
  28817. serialize(): any;
  28818. /**
  28819. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28820. * @param parsedFresnelParameters Define the JSON representation
  28821. * @returns the parsed parameters
  28822. */
  28823. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28824. }
  28825. }
  28826. declare module "babylonjs/Misc/decorators" {
  28827. import { Nullable } from "babylonjs/types";
  28828. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28829. import { Scene } from "babylonjs/scene";
  28830. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28831. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28832. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28833. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28834. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28835. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28836. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28837. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28838. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28839. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28840. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28841. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28842. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28843. /**
  28844. * Decorator used to define property that can be serialized as reference to a camera
  28845. * @param sourceName defines the name of the property to decorate
  28846. */
  28847. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28848. /**
  28849. * Class used to help serialization objects
  28850. */
  28851. export class SerializationHelper {
  28852. /** @hidden */
  28853. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28854. /** @hidden */
  28855. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28856. /** @hidden */
  28857. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28858. /** @hidden */
  28859. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28860. /**
  28861. * Appends the serialized animations from the source animations
  28862. * @param source Source containing the animations
  28863. * @param destination Target to store the animations
  28864. */
  28865. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28866. /**
  28867. * Static function used to serialized a specific entity
  28868. * @param entity defines the entity to serialize
  28869. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28870. * @returns a JSON compatible object representing the serialization of the entity
  28871. */
  28872. static Serialize<T>(entity: T, serializationObject?: any): any;
  28873. /**
  28874. * Creates a new entity from a serialization data object
  28875. * @param creationFunction defines a function used to instanciated the new entity
  28876. * @param source defines the source serialization data
  28877. * @param scene defines the hosting scene
  28878. * @param rootUrl defines the root url for resources
  28879. * @returns a new entity
  28880. */
  28881. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28882. /**
  28883. * Clones an object
  28884. * @param creationFunction defines the function used to instanciate the new object
  28885. * @param source defines the source object
  28886. * @returns the cloned object
  28887. */
  28888. static Clone<T>(creationFunction: () => T, source: T): T;
  28889. /**
  28890. * Instanciates a new object based on a source one (some data will be shared between both object)
  28891. * @param creationFunction defines the function used to instanciate the new object
  28892. * @param source defines the source object
  28893. * @returns the new object
  28894. */
  28895. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28896. }
  28897. }
  28898. declare module "babylonjs/Misc/guid" {
  28899. /**
  28900. * Class used to manipulate GUIDs
  28901. */
  28902. export class GUID {
  28903. /**
  28904. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28905. * Be aware Math.random() could cause collisions, but:
  28906. * "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"
  28907. * @returns a pseudo random id
  28908. */
  28909. static RandomId(): string;
  28910. }
  28911. }
  28912. declare module "babylonjs/Materials/Textures/baseTexture" {
  28913. import { Observable } from "babylonjs/Misc/observable";
  28914. import { Nullable } from "babylonjs/types";
  28915. import { Scene } from "babylonjs/scene";
  28916. import { Matrix } from "babylonjs/Maths/math.vector";
  28917. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28918. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28919. import { ISize } from "babylonjs/Maths/math.size";
  28920. /**
  28921. * Base class of all the textures in babylon.
  28922. * It groups all the common properties the materials, post process, lights... might need
  28923. * in order to make a correct use of the texture.
  28924. */
  28925. export class BaseTexture implements IAnimatable {
  28926. /**
  28927. * Default anisotropic filtering level for the application.
  28928. * It is set to 4 as a good tradeoff between perf and quality.
  28929. */
  28930. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28931. /**
  28932. * Gets or sets the unique id of the texture
  28933. */
  28934. uniqueId: number;
  28935. /**
  28936. * Define the name of the texture.
  28937. */
  28938. name: string;
  28939. /**
  28940. * Gets or sets an object used to store user defined information.
  28941. */
  28942. metadata: any;
  28943. /**
  28944. * For internal use only. Please do not use.
  28945. */
  28946. reservedDataStore: any;
  28947. private _hasAlpha;
  28948. /**
  28949. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28950. */
  28951. hasAlpha: boolean;
  28952. /**
  28953. * Defines if the alpha value should be determined via the rgb values.
  28954. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28955. */
  28956. getAlphaFromRGB: boolean;
  28957. /**
  28958. * Intensity or strength of the texture.
  28959. * It is commonly used by materials to fine tune the intensity of the texture
  28960. */
  28961. level: number;
  28962. /**
  28963. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28964. * This is part of the texture as textures usually maps to one uv set.
  28965. */
  28966. coordinatesIndex: number;
  28967. private _coordinatesMode;
  28968. /**
  28969. * How a texture is mapped.
  28970. *
  28971. * | Value | Type | Description |
  28972. * | ----- | ----------------------------------- | ----------- |
  28973. * | 0 | EXPLICIT_MODE | |
  28974. * | 1 | SPHERICAL_MODE | |
  28975. * | 2 | PLANAR_MODE | |
  28976. * | 3 | CUBIC_MODE | |
  28977. * | 4 | PROJECTION_MODE | |
  28978. * | 5 | SKYBOX_MODE | |
  28979. * | 6 | INVCUBIC_MODE | |
  28980. * | 7 | EQUIRECTANGULAR_MODE | |
  28981. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28982. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28983. */
  28984. coordinatesMode: number;
  28985. /**
  28986. * | Value | Type | Description |
  28987. * | ----- | ------------------ | ----------- |
  28988. * | 0 | CLAMP_ADDRESSMODE | |
  28989. * | 1 | WRAP_ADDRESSMODE | |
  28990. * | 2 | MIRROR_ADDRESSMODE | |
  28991. */
  28992. wrapU: number;
  28993. /**
  28994. * | Value | Type | Description |
  28995. * | ----- | ------------------ | ----------- |
  28996. * | 0 | CLAMP_ADDRESSMODE | |
  28997. * | 1 | WRAP_ADDRESSMODE | |
  28998. * | 2 | MIRROR_ADDRESSMODE | |
  28999. */
  29000. wrapV: number;
  29001. /**
  29002. * | Value | Type | Description |
  29003. * | ----- | ------------------ | ----------- |
  29004. * | 0 | CLAMP_ADDRESSMODE | |
  29005. * | 1 | WRAP_ADDRESSMODE | |
  29006. * | 2 | MIRROR_ADDRESSMODE | |
  29007. */
  29008. wrapR: number;
  29009. /**
  29010. * With compliant hardware and browser (supporting anisotropic filtering)
  29011. * this defines the level of anisotropic filtering in the texture.
  29012. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29013. */
  29014. anisotropicFilteringLevel: number;
  29015. /**
  29016. * Define if the texture is a cube texture or if false a 2d texture.
  29017. */
  29018. isCube: boolean;
  29019. /**
  29020. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29021. */
  29022. is3D: boolean;
  29023. /**
  29024. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29025. */
  29026. is2DArray: boolean;
  29027. /**
  29028. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29029. * HDR texture are usually stored in linear space.
  29030. * This only impacts the PBR and Background materials
  29031. */
  29032. gammaSpace: boolean;
  29033. /**
  29034. * Gets or sets whether or not the texture contains RGBD data.
  29035. */
  29036. isRGBD: boolean;
  29037. /**
  29038. * Is Z inverted in the texture (useful in a cube texture).
  29039. */
  29040. invertZ: boolean;
  29041. /**
  29042. * Are mip maps generated for this texture or not.
  29043. */
  29044. readonly noMipmap: boolean;
  29045. /**
  29046. * @hidden
  29047. */
  29048. lodLevelInAlpha: boolean;
  29049. /**
  29050. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29051. */
  29052. lodGenerationOffset: number;
  29053. /**
  29054. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29055. */
  29056. lodGenerationScale: number;
  29057. /**
  29058. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29059. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29060. * average roughness values.
  29061. */
  29062. linearSpecularLOD: boolean;
  29063. /**
  29064. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29065. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29066. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29067. */
  29068. irradianceTexture: Nullable<BaseTexture>;
  29069. /**
  29070. * Define if the texture is a render target.
  29071. */
  29072. isRenderTarget: boolean;
  29073. /**
  29074. * Define the unique id of the texture in the scene.
  29075. */
  29076. readonly uid: string;
  29077. /**
  29078. * Return a string representation of the texture.
  29079. * @returns the texture as a string
  29080. */
  29081. toString(): string;
  29082. /**
  29083. * Get the class name of the texture.
  29084. * @returns "BaseTexture"
  29085. */
  29086. getClassName(): string;
  29087. /**
  29088. * Define the list of animation attached to the texture.
  29089. */
  29090. animations: import("babylonjs/Animations/animation").Animation[];
  29091. /**
  29092. * An event triggered when the texture is disposed.
  29093. */
  29094. onDisposeObservable: Observable<BaseTexture>;
  29095. private _onDisposeObserver;
  29096. /**
  29097. * Callback triggered when the texture has been disposed.
  29098. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29099. */
  29100. onDispose: () => void;
  29101. /**
  29102. * Define the current state of the loading sequence when in delayed load mode.
  29103. */
  29104. delayLoadState: number;
  29105. private _scene;
  29106. /** @hidden */
  29107. _texture: Nullable<InternalTexture>;
  29108. private _uid;
  29109. /**
  29110. * Define if the texture is preventinga material to render or not.
  29111. * If not and the texture is not ready, the engine will use a default black texture instead.
  29112. */
  29113. readonly isBlocking: boolean;
  29114. /**
  29115. * Instantiates a new BaseTexture.
  29116. * Base class of all the textures in babylon.
  29117. * It groups all the common properties the materials, post process, lights... might need
  29118. * in order to make a correct use of the texture.
  29119. * @param scene Define the scene the texture blongs to
  29120. */
  29121. constructor(scene: Nullable<Scene>);
  29122. /**
  29123. * Get the scene the texture belongs to.
  29124. * @returns the scene or null if undefined
  29125. */
  29126. getScene(): Nullable<Scene>;
  29127. /**
  29128. * Get the texture transform matrix used to offset tile the texture for istance.
  29129. * @returns the transformation matrix
  29130. */
  29131. getTextureMatrix(): Matrix;
  29132. /**
  29133. * Get the texture reflection matrix used to rotate/transform the reflection.
  29134. * @returns the reflection matrix
  29135. */
  29136. getReflectionTextureMatrix(): Matrix;
  29137. /**
  29138. * Get the underlying lower level texture from Babylon.
  29139. * @returns the insternal texture
  29140. */
  29141. getInternalTexture(): Nullable<InternalTexture>;
  29142. /**
  29143. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29144. * @returns true if ready or not blocking
  29145. */
  29146. isReadyOrNotBlocking(): boolean;
  29147. /**
  29148. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29149. * @returns true if fully ready
  29150. */
  29151. isReady(): boolean;
  29152. private _cachedSize;
  29153. /**
  29154. * Get the size of the texture.
  29155. * @returns the texture size.
  29156. */
  29157. getSize(): ISize;
  29158. /**
  29159. * Get the base size of the texture.
  29160. * It can be different from the size if the texture has been resized for POT for instance
  29161. * @returns the base size
  29162. */
  29163. getBaseSize(): ISize;
  29164. /**
  29165. * Update the sampling mode of the texture.
  29166. * Default is Trilinear mode.
  29167. *
  29168. * | Value | Type | Description |
  29169. * | ----- | ------------------ | ----------- |
  29170. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29171. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29172. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29173. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29174. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29175. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29176. * | 7 | NEAREST_LINEAR | |
  29177. * | 8 | NEAREST_NEAREST | |
  29178. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29179. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29180. * | 11 | LINEAR_LINEAR | |
  29181. * | 12 | LINEAR_NEAREST | |
  29182. *
  29183. * > _mag_: magnification filter (close to the viewer)
  29184. * > _min_: minification filter (far from the viewer)
  29185. * > _mip_: filter used between mip map levels
  29186. *@param samplingMode Define the new sampling mode of the texture
  29187. */
  29188. updateSamplingMode(samplingMode: number): void;
  29189. /**
  29190. * Scales the texture if is `canRescale()`
  29191. * @param ratio the resize factor we want to use to rescale
  29192. */
  29193. scale(ratio: number): void;
  29194. /**
  29195. * Get if the texture can rescale.
  29196. */
  29197. readonly canRescale: boolean;
  29198. /** @hidden */
  29199. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29200. /** @hidden */
  29201. _rebuild(): void;
  29202. /**
  29203. * Triggers the load sequence in delayed load mode.
  29204. */
  29205. delayLoad(): void;
  29206. /**
  29207. * Clones the texture.
  29208. * @returns the cloned texture
  29209. */
  29210. clone(): Nullable<BaseTexture>;
  29211. /**
  29212. * Get the texture underlying type (INT, FLOAT...)
  29213. */
  29214. readonly textureType: number;
  29215. /**
  29216. * Get the texture underlying format (RGB, RGBA...)
  29217. */
  29218. readonly textureFormat: number;
  29219. /**
  29220. * Indicates that textures need to be re-calculated for all materials
  29221. */
  29222. protected _markAllSubMeshesAsTexturesDirty(): void;
  29223. /**
  29224. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29225. * This will returns an RGBA array buffer containing either in values (0-255) or
  29226. * float values (0-1) depending of the underlying buffer type.
  29227. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29228. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29229. * @param buffer defines a user defined buffer to fill with data (can be null)
  29230. * @returns The Array buffer containing the pixels data.
  29231. */
  29232. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29233. /**
  29234. * Release and destroy the underlying lower level texture aka internalTexture.
  29235. */
  29236. releaseInternalTexture(): void;
  29237. /** @hidden */
  29238. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29239. /** @hidden */
  29240. readonly _lodTextureMid: Nullable<BaseTexture>;
  29241. /** @hidden */
  29242. readonly _lodTextureLow: Nullable<BaseTexture>;
  29243. /**
  29244. * Dispose the texture and release its associated resources.
  29245. */
  29246. dispose(): void;
  29247. /**
  29248. * Serialize the texture into a JSON representation that can be parsed later on.
  29249. * @returns the JSON representation of the texture
  29250. */
  29251. serialize(): any;
  29252. /**
  29253. * Helper function to be called back once a list of texture contains only ready textures.
  29254. * @param textures Define the list of textures to wait for
  29255. * @param callback Define the callback triggered once the entire list will be ready
  29256. */
  29257. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29258. }
  29259. }
  29260. declare module "babylonjs/Materials/effect" {
  29261. import { Observable } from "babylonjs/Misc/observable";
  29262. import { Nullable } from "babylonjs/types";
  29263. import { IDisposable } from "babylonjs/scene";
  29264. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29265. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29266. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29267. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29268. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29269. import { Engine } from "babylonjs/Engines/engine";
  29270. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29272. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29273. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29274. /**
  29275. * Options to be used when creating an effect.
  29276. */
  29277. export interface IEffectCreationOptions {
  29278. /**
  29279. * Atrributes that will be used in the shader.
  29280. */
  29281. attributes: string[];
  29282. /**
  29283. * Uniform varible names that will be set in the shader.
  29284. */
  29285. uniformsNames: string[];
  29286. /**
  29287. * Uniform buffer variable names that will be set in the shader.
  29288. */
  29289. uniformBuffersNames: string[];
  29290. /**
  29291. * Sampler texture variable names that will be set in the shader.
  29292. */
  29293. samplers: string[];
  29294. /**
  29295. * Define statements that will be set in the shader.
  29296. */
  29297. defines: any;
  29298. /**
  29299. * Possible fallbacks for this effect to improve performance when needed.
  29300. */
  29301. fallbacks: Nullable<IEffectFallbacks>;
  29302. /**
  29303. * Callback that will be called when the shader is compiled.
  29304. */
  29305. onCompiled: Nullable<(effect: Effect) => void>;
  29306. /**
  29307. * Callback that will be called if an error occurs during shader compilation.
  29308. */
  29309. onError: Nullable<(effect: Effect, errors: string) => void>;
  29310. /**
  29311. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29312. */
  29313. indexParameters?: any;
  29314. /**
  29315. * Max number of lights that can be used in the shader.
  29316. */
  29317. maxSimultaneousLights?: number;
  29318. /**
  29319. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29320. */
  29321. transformFeedbackVaryings?: Nullable<string[]>;
  29322. }
  29323. /**
  29324. * Effect containing vertex and fragment shader that can be executed on an object.
  29325. */
  29326. export class Effect implements IDisposable {
  29327. /**
  29328. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29329. */
  29330. static ShadersRepository: string;
  29331. /**
  29332. * Name of the effect.
  29333. */
  29334. name: any;
  29335. /**
  29336. * String container all the define statements that should be set on the shader.
  29337. */
  29338. defines: string;
  29339. /**
  29340. * Callback that will be called when the shader is compiled.
  29341. */
  29342. onCompiled: Nullable<(effect: Effect) => void>;
  29343. /**
  29344. * Callback that will be called if an error occurs during shader compilation.
  29345. */
  29346. onError: Nullable<(effect: Effect, errors: string) => void>;
  29347. /**
  29348. * Callback that will be called when effect is bound.
  29349. */
  29350. onBind: Nullable<(effect: Effect) => void>;
  29351. /**
  29352. * Unique ID of the effect.
  29353. */
  29354. uniqueId: number;
  29355. /**
  29356. * Observable that will be called when the shader is compiled.
  29357. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29358. */
  29359. onCompileObservable: Observable<Effect>;
  29360. /**
  29361. * Observable that will be called if an error occurs during shader compilation.
  29362. */
  29363. onErrorObservable: Observable<Effect>;
  29364. /** @hidden */
  29365. _onBindObservable: Nullable<Observable<Effect>>;
  29366. /**
  29367. * Observable that will be called when effect is bound.
  29368. */
  29369. readonly onBindObservable: Observable<Effect>;
  29370. /** @hidden */
  29371. _bonesComputationForcedToCPU: boolean;
  29372. private static _uniqueIdSeed;
  29373. private _engine;
  29374. private _uniformBuffersNames;
  29375. private _uniformsNames;
  29376. private _samplerList;
  29377. private _samplers;
  29378. private _isReady;
  29379. private _compilationError;
  29380. private _allFallbacksProcessed;
  29381. private _attributesNames;
  29382. private _attributes;
  29383. private _uniforms;
  29384. /**
  29385. * Key for the effect.
  29386. * @hidden
  29387. */
  29388. _key: string;
  29389. private _indexParameters;
  29390. private _fallbacks;
  29391. private _vertexSourceCode;
  29392. private _fragmentSourceCode;
  29393. private _vertexSourceCodeOverride;
  29394. private _fragmentSourceCodeOverride;
  29395. private _transformFeedbackVaryings;
  29396. /**
  29397. * Compiled shader to webGL program.
  29398. * @hidden
  29399. */
  29400. _pipelineContext: Nullable<IPipelineContext>;
  29401. private _valueCache;
  29402. private static _baseCache;
  29403. /**
  29404. * Instantiates an effect.
  29405. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29406. * @param baseName Name of the effect.
  29407. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29408. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29409. * @param samplers List of sampler variables that will be passed to the shader.
  29410. * @param engine Engine to be used to render the effect
  29411. * @param defines Define statements to be added to the shader.
  29412. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29413. * @param onCompiled Callback that will be called when the shader is compiled.
  29414. * @param onError Callback that will be called if an error occurs during shader compilation.
  29415. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29416. */
  29417. 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);
  29418. private _useFinalCode;
  29419. /**
  29420. * Unique key for this effect
  29421. */
  29422. readonly key: string;
  29423. /**
  29424. * If the effect has been compiled and prepared.
  29425. * @returns if the effect is compiled and prepared.
  29426. */
  29427. isReady(): boolean;
  29428. private _isReadyInternal;
  29429. /**
  29430. * The engine the effect was initialized with.
  29431. * @returns the engine.
  29432. */
  29433. getEngine(): Engine;
  29434. /**
  29435. * The pipeline context for this effect
  29436. * @returns the associated pipeline context
  29437. */
  29438. getPipelineContext(): Nullable<IPipelineContext>;
  29439. /**
  29440. * The set of names of attribute variables for the shader.
  29441. * @returns An array of attribute names.
  29442. */
  29443. getAttributesNames(): string[];
  29444. /**
  29445. * Returns the attribute at the given index.
  29446. * @param index The index of the attribute.
  29447. * @returns The location of the attribute.
  29448. */
  29449. getAttributeLocation(index: number): number;
  29450. /**
  29451. * Returns the attribute based on the name of the variable.
  29452. * @param name of the attribute to look up.
  29453. * @returns the attribute location.
  29454. */
  29455. getAttributeLocationByName(name: string): number;
  29456. /**
  29457. * The number of attributes.
  29458. * @returns the numnber of attributes.
  29459. */
  29460. getAttributesCount(): number;
  29461. /**
  29462. * Gets the index of a uniform variable.
  29463. * @param uniformName of the uniform to look up.
  29464. * @returns the index.
  29465. */
  29466. getUniformIndex(uniformName: string): number;
  29467. /**
  29468. * Returns the attribute based on the name of the variable.
  29469. * @param uniformName of the uniform to look up.
  29470. * @returns the location of the uniform.
  29471. */
  29472. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29473. /**
  29474. * Returns an array of sampler variable names
  29475. * @returns The array of sampler variable neames.
  29476. */
  29477. getSamplers(): string[];
  29478. /**
  29479. * The error from the last compilation.
  29480. * @returns the error string.
  29481. */
  29482. getCompilationError(): string;
  29483. /**
  29484. * Gets a boolean indicating that all fallbacks were used during compilation
  29485. * @returns true if all fallbacks were used
  29486. */
  29487. allFallbacksProcessed(): boolean;
  29488. /**
  29489. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29490. * @param func The callback to be used.
  29491. */
  29492. executeWhenCompiled(func: (effect: Effect) => void): void;
  29493. private _checkIsReady;
  29494. private _loadShader;
  29495. /**
  29496. * Recompiles the webGL program
  29497. * @param vertexSourceCode The source code for the vertex shader.
  29498. * @param fragmentSourceCode The source code for the fragment shader.
  29499. * @param onCompiled Callback called when completed.
  29500. * @param onError Callback called on error.
  29501. * @hidden
  29502. */
  29503. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29504. /**
  29505. * Prepares the effect
  29506. * @hidden
  29507. */
  29508. _prepareEffect(): void;
  29509. private _processCompilationErrors;
  29510. /**
  29511. * Checks if the effect is supported. (Must be called after compilation)
  29512. */
  29513. readonly isSupported: boolean;
  29514. /**
  29515. * Binds a texture to the engine to be used as output of the shader.
  29516. * @param channel Name of the output variable.
  29517. * @param texture Texture to bind.
  29518. * @hidden
  29519. */
  29520. _bindTexture(channel: string, texture: InternalTexture): void;
  29521. /**
  29522. * Sets a texture on the engine to be used in the shader.
  29523. * @param channel Name of the sampler variable.
  29524. * @param texture Texture to set.
  29525. */
  29526. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29527. /**
  29528. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29529. * @param channel Name of the sampler variable.
  29530. * @param texture Texture to set.
  29531. */
  29532. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29533. /**
  29534. * Sets an array of textures on the engine to be used in the shader.
  29535. * @param channel Name of the variable.
  29536. * @param textures Textures to set.
  29537. */
  29538. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29539. /**
  29540. * 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)
  29541. * @param channel Name of the sampler variable.
  29542. * @param postProcess Post process to get the input texture from.
  29543. */
  29544. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29545. /**
  29546. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29547. * 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)
  29548. * @param channel Name of the sampler variable.
  29549. * @param postProcess Post process to get the output texture from.
  29550. */
  29551. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29552. /** @hidden */
  29553. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29554. /** @hidden */
  29555. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29556. /** @hidden */
  29557. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29558. /** @hidden */
  29559. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29560. /**
  29561. * Binds a buffer to a uniform.
  29562. * @param buffer Buffer to bind.
  29563. * @param name Name of the uniform variable to bind to.
  29564. */
  29565. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29566. /**
  29567. * Binds block to a uniform.
  29568. * @param blockName Name of the block to bind.
  29569. * @param index Index to bind.
  29570. */
  29571. bindUniformBlock(blockName: string, index: number): void;
  29572. /**
  29573. * Sets an interger value on a uniform variable.
  29574. * @param uniformName Name of the variable.
  29575. * @param value Value to be set.
  29576. * @returns this effect.
  29577. */
  29578. setInt(uniformName: string, value: number): Effect;
  29579. /**
  29580. * Sets an int array on a uniform variable.
  29581. * @param uniformName Name of the variable.
  29582. * @param array array to be set.
  29583. * @returns this effect.
  29584. */
  29585. setIntArray(uniformName: string, array: Int32Array): Effect;
  29586. /**
  29587. * 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)
  29588. * @param uniformName Name of the variable.
  29589. * @param array array to be set.
  29590. * @returns this effect.
  29591. */
  29592. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29593. /**
  29594. * 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)
  29595. * @param uniformName Name of the variable.
  29596. * @param array array to be set.
  29597. * @returns this effect.
  29598. */
  29599. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29600. /**
  29601. * 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)
  29602. * @param uniformName Name of the variable.
  29603. * @param array array to be set.
  29604. * @returns this effect.
  29605. */
  29606. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29607. /**
  29608. * Sets an float array on a uniform variable.
  29609. * @param uniformName Name of the variable.
  29610. * @param array array to be set.
  29611. * @returns this effect.
  29612. */
  29613. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29614. /**
  29615. * 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)
  29616. * @param uniformName Name of the variable.
  29617. * @param array array to be set.
  29618. * @returns this effect.
  29619. */
  29620. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29621. /**
  29622. * 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)
  29623. * @param uniformName Name of the variable.
  29624. * @param array array to be set.
  29625. * @returns this effect.
  29626. */
  29627. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29628. /**
  29629. * 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)
  29630. * @param uniformName Name of the variable.
  29631. * @param array array to be set.
  29632. * @returns this effect.
  29633. */
  29634. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29635. /**
  29636. * Sets an array on a uniform variable.
  29637. * @param uniformName Name of the variable.
  29638. * @param array array to be set.
  29639. * @returns this effect.
  29640. */
  29641. setArray(uniformName: string, array: number[]): Effect;
  29642. /**
  29643. * 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)
  29644. * @param uniformName Name of the variable.
  29645. * @param array array to be set.
  29646. * @returns this effect.
  29647. */
  29648. setArray2(uniformName: string, array: number[]): Effect;
  29649. /**
  29650. * 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)
  29651. * @param uniformName Name of the variable.
  29652. * @param array array to be set.
  29653. * @returns this effect.
  29654. */
  29655. setArray3(uniformName: string, array: number[]): Effect;
  29656. /**
  29657. * 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)
  29658. * @param uniformName Name of the variable.
  29659. * @param array array to be set.
  29660. * @returns this effect.
  29661. */
  29662. setArray4(uniformName: string, array: number[]): Effect;
  29663. /**
  29664. * Sets matrices on a uniform variable.
  29665. * @param uniformName Name of the variable.
  29666. * @param matrices matrices to be set.
  29667. * @returns this effect.
  29668. */
  29669. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29670. /**
  29671. * Sets matrix on a uniform variable.
  29672. * @param uniformName Name of the variable.
  29673. * @param matrix matrix to be set.
  29674. * @returns this effect.
  29675. */
  29676. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29677. /**
  29678. * 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)
  29679. * @param uniformName Name of the variable.
  29680. * @param matrix matrix to be set.
  29681. * @returns this effect.
  29682. */
  29683. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29684. /**
  29685. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29686. * @param uniformName Name of the variable.
  29687. * @param matrix matrix to be set.
  29688. * @returns this effect.
  29689. */
  29690. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29691. /**
  29692. * Sets a float on a uniform variable.
  29693. * @param uniformName Name of the variable.
  29694. * @param value value to be set.
  29695. * @returns this effect.
  29696. */
  29697. setFloat(uniformName: string, value: number): Effect;
  29698. /**
  29699. * Sets a boolean on a uniform variable.
  29700. * @param uniformName Name of the variable.
  29701. * @param bool value to be set.
  29702. * @returns this effect.
  29703. */
  29704. setBool(uniformName: string, bool: boolean): Effect;
  29705. /**
  29706. * Sets a Vector2 on a uniform variable.
  29707. * @param uniformName Name of the variable.
  29708. * @param vector2 vector2 to be set.
  29709. * @returns this effect.
  29710. */
  29711. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29712. /**
  29713. * Sets a float2 on a uniform variable.
  29714. * @param uniformName Name of the variable.
  29715. * @param x First float in float2.
  29716. * @param y Second float in float2.
  29717. * @returns this effect.
  29718. */
  29719. setFloat2(uniformName: string, x: number, y: number): Effect;
  29720. /**
  29721. * Sets a Vector3 on a uniform variable.
  29722. * @param uniformName Name of the variable.
  29723. * @param vector3 Value to be set.
  29724. * @returns this effect.
  29725. */
  29726. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29727. /**
  29728. * Sets a float3 on a uniform variable.
  29729. * @param uniformName Name of the variable.
  29730. * @param x First float in float3.
  29731. * @param y Second float in float3.
  29732. * @param z Third float in float3.
  29733. * @returns this effect.
  29734. */
  29735. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29736. /**
  29737. * Sets a Vector4 on a uniform variable.
  29738. * @param uniformName Name of the variable.
  29739. * @param vector4 Value to be set.
  29740. * @returns this effect.
  29741. */
  29742. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29743. /**
  29744. * Sets a float4 on a uniform variable.
  29745. * @param uniformName Name of the variable.
  29746. * @param x First float in float4.
  29747. * @param y Second float in float4.
  29748. * @param z Third float in float4.
  29749. * @param w Fourth float in float4.
  29750. * @returns this effect.
  29751. */
  29752. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29753. /**
  29754. * Sets a Color3 on a uniform variable.
  29755. * @param uniformName Name of the variable.
  29756. * @param color3 Value to be set.
  29757. * @returns this effect.
  29758. */
  29759. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29760. /**
  29761. * Sets a Color4 on a uniform variable.
  29762. * @param uniformName Name of the variable.
  29763. * @param color3 Value to be set.
  29764. * @param alpha Alpha value to be set.
  29765. * @returns this effect.
  29766. */
  29767. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29768. /**
  29769. * Sets a Color4 on a uniform variable
  29770. * @param uniformName defines the name of the variable
  29771. * @param color4 defines the value to be set
  29772. * @returns this effect.
  29773. */
  29774. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29775. /** Release all associated resources */
  29776. dispose(): void;
  29777. /**
  29778. * This function will add a new shader to the shader store
  29779. * @param name the name of the shader
  29780. * @param pixelShader optional pixel shader content
  29781. * @param vertexShader optional vertex shader content
  29782. */
  29783. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29784. /**
  29785. * Store of each shader (The can be looked up using effect.key)
  29786. */
  29787. static ShadersStore: {
  29788. [key: string]: string;
  29789. };
  29790. /**
  29791. * Store of each included file for a shader (The can be looked up using effect.key)
  29792. */
  29793. static IncludesShadersStore: {
  29794. [key: string]: string;
  29795. };
  29796. /**
  29797. * Resets the cache of effects.
  29798. */
  29799. static ResetCache(): void;
  29800. }
  29801. }
  29802. declare module "babylonjs/Engines/engineCapabilities" {
  29803. /**
  29804. * Interface used to describe the capabilities of the engine relatively to the current browser
  29805. */
  29806. export interface EngineCapabilities {
  29807. /** Maximum textures units per fragment shader */
  29808. maxTexturesImageUnits: number;
  29809. /** Maximum texture units per vertex shader */
  29810. maxVertexTextureImageUnits: number;
  29811. /** Maximum textures units in the entire pipeline */
  29812. maxCombinedTexturesImageUnits: number;
  29813. /** Maximum texture size */
  29814. maxTextureSize: number;
  29815. /** Maximum cube texture size */
  29816. maxCubemapTextureSize: number;
  29817. /** Maximum render texture size */
  29818. maxRenderTextureSize: number;
  29819. /** Maximum number of vertex attributes */
  29820. maxVertexAttribs: number;
  29821. /** Maximum number of varyings */
  29822. maxVaryingVectors: number;
  29823. /** Maximum number of uniforms per vertex shader */
  29824. maxVertexUniformVectors: number;
  29825. /** Maximum number of uniforms per fragment shader */
  29826. maxFragmentUniformVectors: number;
  29827. /** Defines if standard derivates (dx/dy) are supported */
  29828. standardDerivatives: boolean;
  29829. /** Defines if s3tc texture compression is supported */
  29830. s3tc?: WEBGL_compressed_texture_s3tc;
  29831. /** Defines if pvrtc texture compression is supported */
  29832. pvrtc: any;
  29833. /** Defines if etc1 texture compression is supported */
  29834. etc1: any;
  29835. /** Defines if etc2 texture compression is supported */
  29836. etc2: any;
  29837. /** Defines if astc texture compression is supported */
  29838. astc: any;
  29839. /** Defines if float textures are supported */
  29840. textureFloat: boolean;
  29841. /** Defines if vertex array objects are supported */
  29842. vertexArrayObject: boolean;
  29843. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29844. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29845. /** Gets the maximum level of anisotropy supported */
  29846. maxAnisotropy: number;
  29847. /** Defines if instancing is supported */
  29848. instancedArrays: boolean;
  29849. /** Defines if 32 bits indices are supported */
  29850. uintIndices: boolean;
  29851. /** Defines if high precision shaders are supported */
  29852. highPrecisionShaderSupported: boolean;
  29853. /** Defines if depth reading in the fragment shader is supported */
  29854. fragmentDepthSupported: boolean;
  29855. /** Defines if float texture linear filtering is supported*/
  29856. textureFloatLinearFiltering: boolean;
  29857. /** Defines if rendering to float textures is supported */
  29858. textureFloatRender: boolean;
  29859. /** Defines if half float textures are supported*/
  29860. textureHalfFloat: boolean;
  29861. /** Defines if half float texture linear filtering is supported*/
  29862. textureHalfFloatLinearFiltering: boolean;
  29863. /** Defines if rendering to half float textures is supported */
  29864. textureHalfFloatRender: boolean;
  29865. /** Defines if textureLOD shader command is supported */
  29866. textureLOD: boolean;
  29867. /** Defines if draw buffers extension is supported */
  29868. drawBuffersExtension: boolean;
  29869. /** Defines if depth textures are supported */
  29870. depthTextureExtension: boolean;
  29871. /** Defines if float color buffer are supported */
  29872. colorBufferFloat: boolean;
  29873. /** Gets disjoint timer query extension (null if not supported) */
  29874. timerQuery?: EXT_disjoint_timer_query;
  29875. /** Defines if timestamp can be used with timer query */
  29876. canUseTimestampForTimerQuery: boolean;
  29877. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29878. multiview?: any;
  29879. /** Function used to let the system compiles shaders in background */
  29880. parallelShaderCompile?: {
  29881. COMPLETION_STATUS_KHR: number;
  29882. };
  29883. /** Max number of texture samples for MSAA */
  29884. maxMSAASamples: number;
  29885. /** Defines if the blend min max extension is supported */
  29886. blendMinMax: boolean;
  29887. }
  29888. }
  29889. declare module "babylonjs/States/depthCullingState" {
  29890. import { Nullable } from "babylonjs/types";
  29891. /**
  29892. * @hidden
  29893. **/
  29894. export class DepthCullingState {
  29895. private _isDepthTestDirty;
  29896. private _isDepthMaskDirty;
  29897. private _isDepthFuncDirty;
  29898. private _isCullFaceDirty;
  29899. private _isCullDirty;
  29900. private _isZOffsetDirty;
  29901. private _isFrontFaceDirty;
  29902. private _depthTest;
  29903. private _depthMask;
  29904. private _depthFunc;
  29905. private _cull;
  29906. private _cullFace;
  29907. private _zOffset;
  29908. private _frontFace;
  29909. /**
  29910. * Initializes the state.
  29911. */
  29912. constructor();
  29913. readonly isDirty: boolean;
  29914. zOffset: number;
  29915. cullFace: Nullable<number>;
  29916. cull: Nullable<boolean>;
  29917. depthFunc: Nullable<number>;
  29918. depthMask: boolean;
  29919. depthTest: boolean;
  29920. frontFace: Nullable<number>;
  29921. reset(): void;
  29922. apply(gl: WebGLRenderingContext): void;
  29923. }
  29924. }
  29925. declare module "babylonjs/States/stencilState" {
  29926. /**
  29927. * @hidden
  29928. **/
  29929. export class StencilState {
  29930. /** 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 */
  29931. static readonly ALWAYS: number;
  29932. /** Passed to stencilOperation to specify that stencil value must be kept */
  29933. static readonly KEEP: number;
  29934. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29935. static readonly REPLACE: number;
  29936. private _isStencilTestDirty;
  29937. private _isStencilMaskDirty;
  29938. private _isStencilFuncDirty;
  29939. private _isStencilOpDirty;
  29940. private _stencilTest;
  29941. private _stencilMask;
  29942. private _stencilFunc;
  29943. private _stencilFuncRef;
  29944. private _stencilFuncMask;
  29945. private _stencilOpStencilFail;
  29946. private _stencilOpDepthFail;
  29947. private _stencilOpStencilDepthPass;
  29948. readonly isDirty: boolean;
  29949. stencilFunc: number;
  29950. stencilFuncRef: number;
  29951. stencilFuncMask: number;
  29952. stencilOpStencilFail: number;
  29953. stencilOpDepthFail: number;
  29954. stencilOpStencilDepthPass: number;
  29955. stencilMask: number;
  29956. stencilTest: boolean;
  29957. constructor();
  29958. reset(): void;
  29959. apply(gl: WebGLRenderingContext): void;
  29960. }
  29961. }
  29962. declare module "babylonjs/States/alphaCullingState" {
  29963. /**
  29964. * @hidden
  29965. **/
  29966. export class AlphaState {
  29967. private _isAlphaBlendDirty;
  29968. private _isBlendFunctionParametersDirty;
  29969. private _isBlendEquationParametersDirty;
  29970. private _isBlendConstantsDirty;
  29971. private _alphaBlend;
  29972. private _blendFunctionParameters;
  29973. private _blendEquationParameters;
  29974. private _blendConstants;
  29975. /**
  29976. * Initializes the state.
  29977. */
  29978. constructor();
  29979. readonly isDirty: boolean;
  29980. alphaBlend: boolean;
  29981. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29982. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29983. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29984. reset(): void;
  29985. apply(gl: WebGLRenderingContext): void;
  29986. }
  29987. }
  29988. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29989. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29990. /** @hidden */
  29991. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29992. attributeProcessor(attribute: string): string;
  29993. varyingProcessor(varying: string, isFragment: boolean): string;
  29994. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29995. }
  29996. }
  29997. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29998. /**
  29999. * Interface for attribute information associated with buffer instanciation
  30000. */
  30001. export interface InstancingAttributeInfo {
  30002. /**
  30003. * Index/offset of the attribute in the vertex shader
  30004. */
  30005. index: number;
  30006. /**
  30007. * size of the attribute, 1, 2, 3 or 4
  30008. */
  30009. attributeSize: number;
  30010. /**
  30011. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30012. * default is FLOAT
  30013. */
  30014. attributeType: number;
  30015. /**
  30016. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30017. */
  30018. normalized: boolean;
  30019. /**
  30020. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30021. */
  30022. offset: number;
  30023. /**
  30024. * Name of the GLSL attribute, for debugging purpose only
  30025. */
  30026. attributeName: string;
  30027. }
  30028. }
  30029. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30031. import { Nullable } from "babylonjs/types";
  30032. module "babylonjs/Engines/thinEngine" {
  30033. interface ThinEngine {
  30034. /**
  30035. * Update a video texture
  30036. * @param texture defines the texture to update
  30037. * @param video defines the video element to use
  30038. * @param invertY defines if data must be stored with Y axis inverted
  30039. */
  30040. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30041. }
  30042. }
  30043. }
  30044. declare module "babylonjs/Materials/Textures/videoTexture" {
  30045. import { Observable } from "babylonjs/Misc/observable";
  30046. import { Nullable } from "babylonjs/types";
  30047. import { Scene } from "babylonjs/scene";
  30048. import { Texture } from "babylonjs/Materials/Textures/texture";
  30049. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30050. /**
  30051. * Settings for finer control over video usage
  30052. */
  30053. export interface VideoTextureSettings {
  30054. /**
  30055. * Applies `autoplay` to video, if specified
  30056. */
  30057. autoPlay?: boolean;
  30058. /**
  30059. * Applies `loop` to video, if specified
  30060. */
  30061. loop?: boolean;
  30062. /**
  30063. * Automatically updates internal texture from video at every frame in the render loop
  30064. */
  30065. autoUpdateTexture: boolean;
  30066. /**
  30067. * Image src displayed during the video loading or until the user interacts with the video.
  30068. */
  30069. poster?: string;
  30070. }
  30071. /**
  30072. * If you want to display a video in your scene, this is the special texture for that.
  30073. * This special texture works similar to other textures, with the exception of a few parameters.
  30074. * @see https://doc.babylonjs.com/how_to/video_texture
  30075. */
  30076. export class VideoTexture extends Texture {
  30077. /**
  30078. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30079. */
  30080. readonly autoUpdateTexture: boolean;
  30081. /**
  30082. * The video instance used by the texture internally
  30083. */
  30084. readonly video: HTMLVideoElement;
  30085. private _onUserActionRequestedObservable;
  30086. /**
  30087. * Event triggerd when a dom action is required by the user to play the video.
  30088. * This happens due to recent changes in browser policies preventing video to auto start.
  30089. */
  30090. readonly onUserActionRequestedObservable: Observable<Texture>;
  30091. private _generateMipMaps;
  30092. private _engine;
  30093. private _stillImageCaptured;
  30094. private _displayingPosterTexture;
  30095. private _settings;
  30096. private _createInternalTextureOnEvent;
  30097. private _frameId;
  30098. /**
  30099. * Creates a video texture.
  30100. * If you want to display a video in your scene, this is the special texture for that.
  30101. * This special texture works similar to other textures, with the exception of a few parameters.
  30102. * @see https://doc.babylonjs.com/how_to/video_texture
  30103. * @param name optional name, will detect from video source, if not defined
  30104. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30105. * @param scene is obviously the current scene.
  30106. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30107. * @param invertY is false by default but can be used to invert video on Y axis
  30108. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30109. * @param settings allows finer control over video usage
  30110. */
  30111. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30112. private _getName;
  30113. private _getVideo;
  30114. private _createInternalTexture;
  30115. private reset;
  30116. /**
  30117. * @hidden Internal method to initiate `update`.
  30118. */
  30119. _rebuild(): void;
  30120. /**
  30121. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30122. */
  30123. update(): void;
  30124. /**
  30125. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30126. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30127. */
  30128. updateTexture(isVisible: boolean): void;
  30129. protected _updateInternalTexture: () => void;
  30130. /**
  30131. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30132. * @param url New url.
  30133. */
  30134. updateURL(url: string): void;
  30135. /**
  30136. * Dispose the texture and release its associated resources.
  30137. */
  30138. dispose(): void;
  30139. /**
  30140. * Creates a video texture straight from a stream.
  30141. * @param scene Define the scene the texture should be created in
  30142. * @param stream Define the stream the texture should be created from
  30143. * @returns The created video texture as a promise
  30144. */
  30145. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30146. /**
  30147. * Creates a video texture straight from your WebCam video feed.
  30148. * @param scene Define the scene the texture should be created in
  30149. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30150. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30151. * @returns The created video texture as a promise
  30152. */
  30153. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30154. minWidth: number;
  30155. maxWidth: number;
  30156. minHeight: number;
  30157. maxHeight: number;
  30158. deviceId: string;
  30159. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30160. /**
  30161. * Creates a video texture straight from your WebCam video feed.
  30162. * @param scene Define the scene the texture should be created in
  30163. * @param onReady Define a callback to triggered once the texture will be ready
  30164. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30165. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30166. */
  30167. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30168. minWidth: number;
  30169. maxWidth: number;
  30170. minHeight: number;
  30171. maxHeight: number;
  30172. deviceId: string;
  30173. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30174. }
  30175. }
  30176. declare module "babylonjs/Engines/thinEngine" {
  30177. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30178. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30179. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30180. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30181. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30182. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30183. import { Observable } from "babylonjs/Misc/observable";
  30184. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30185. import { StencilState } from "babylonjs/States/stencilState";
  30186. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30188. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30189. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30190. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30192. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30193. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30194. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30196. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30197. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30198. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30199. /**
  30200. * Defines the interface used by objects working like Scene
  30201. * @hidden
  30202. */
  30203. interface ISceneLike {
  30204. _addPendingData(data: any): void;
  30205. _removePendingData(data: any): void;
  30206. offlineProvider: IOfflineProvider;
  30207. }
  30208. /** Interface defining initialization parameters for Engine class */
  30209. export interface EngineOptions extends WebGLContextAttributes {
  30210. /**
  30211. * Defines if the engine should no exceed a specified device ratio
  30212. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30213. */
  30214. limitDeviceRatio?: number;
  30215. /**
  30216. * Defines if webvr should be enabled automatically
  30217. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30218. */
  30219. autoEnableWebVR?: boolean;
  30220. /**
  30221. * Defines if webgl2 should be turned off even if supported
  30222. * @see http://doc.babylonjs.com/features/webgl2
  30223. */
  30224. disableWebGL2Support?: boolean;
  30225. /**
  30226. * Defines if webaudio should be initialized as well
  30227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30228. */
  30229. audioEngine?: boolean;
  30230. /**
  30231. * Defines if animations should run using a deterministic lock step
  30232. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30233. */
  30234. deterministicLockstep?: boolean;
  30235. /** Defines the maximum steps to use with deterministic lock step mode */
  30236. lockstepMaxSteps?: number;
  30237. /**
  30238. * Defines that engine should ignore context lost events
  30239. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30240. */
  30241. doNotHandleContextLost?: boolean;
  30242. /**
  30243. * Defines that engine should ignore modifying touch action attribute and style
  30244. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30245. */
  30246. doNotHandleTouchAction?: boolean;
  30247. /**
  30248. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30249. */
  30250. useHighPrecisionFloats?: boolean;
  30251. }
  30252. /**
  30253. * The base engine class (root of all engines)
  30254. */
  30255. export class ThinEngine {
  30256. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30257. static ExceptionList: ({
  30258. key: string;
  30259. capture: string;
  30260. captureConstraint: number;
  30261. targets: string[];
  30262. } | {
  30263. key: string;
  30264. capture: null;
  30265. captureConstraint: null;
  30266. targets: string[];
  30267. })[];
  30268. /** @hidden */
  30269. static _TextureLoaders: IInternalTextureLoader[];
  30270. /**
  30271. * Returns the current npm package of the sdk
  30272. */
  30273. static readonly NpmPackage: string;
  30274. /**
  30275. * Returns the current version of the framework
  30276. */
  30277. static readonly Version: string;
  30278. /**
  30279. * Returns a string describing the current engine
  30280. */
  30281. readonly description: string;
  30282. /**
  30283. * Gets or sets the epsilon value used by collision engine
  30284. */
  30285. static CollisionsEpsilon: number;
  30286. /**
  30287. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30288. */
  30289. static ShadersRepository: string;
  30290. /** @hidden */
  30291. _shaderProcessor: IShaderProcessor;
  30292. /**
  30293. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30294. */
  30295. forcePOTTextures: boolean;
  30296. /**
  30297. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30298. */
  30299. isFullscreen: boolean;
  30300. /**
  30301. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30302. */
  30303. cullBackFaces: boolean;
  30304. /**
  30305. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30306. */
  30307. renderEvenInBackground: boolean;
  30308. /**
  30309. * Gets or sets a boolean indicating that cache can be kept between frames
  30310. */
  30311. preventCacheWipeBetweenFrames: boolean;
  30312. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30313. validateShaderPrograms: boolean;
  30314. /**
  30315. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30316. */
  30317. disableUniformBuffers: boolean;
  30318. /** @hidden */
  30319. _uniformBuffers: UniformBuffer[];
  30320. /**
  30321. * Gets a boolean indicating that the engine supports uniform buffers
  30322. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30323. */
  30324. readonly supportsUniformBuffers: boolean;
  30325. /** @hidden */
  30326. _gl: WebGLRenderingContext;
  30327. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30328. protected _windowIsBackground: boolean;
  30329. protected _webGLVersion: number;
  30330. protected _creationOptions: EngineOptions;
  30331. protected _highPrecisionShadersAllowed: boolean;
  30332. /** @hidden */
  30333. readonly _shouldUseHighPrecisionShader: boolean;
  30334. /**
  30335. * Gets a boolean indicating that only power of 2 textures are supported
  30336. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30337. */
  30338. readonly needPOTTextures: boolean;
  30339. /** @hidden */
  30340. _badOS: boolean;
  30341. /** @hidden */
  30342. _badDesktopOS: boolean;
  30343. private _hardwareScalingLevel;
  30344. /** @hidden */
  30345. _caps: EngineCapabilities;
  30346. private _isStencilEnable;
  30347. protected _colorWrite: boolean;
  30348. private _glVersion;
  30349. private _glRenderer;
  30350. private _glVendor;
  30351. /** @hidden */
  30352. _videoTextureSupported: boolean;
  30353. protected _renderingQueueLaunched: boolean;
  30354. protected _activeRenderLoops: (() => void)[];
  30355. /**
  30356. * Observable signaled when a context lost event is raised
  30357. */
  30358. onContextLostObservable: Observable<ThinEngine>;
  30359. /**
  30360. * Observable signaled when a context restored event is raised
  30361. */
  30362. onContextRestoredObservable: Observable<ThinEngine>;
  30363. private _onContextLost;
  30364. private _onContextRestored;
  30365. protected _contextWasLost: boolean;
  30366. /** @hidden */
  30367. _doNotHandleContextLost: boolean;
  30368. /**
  30369. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30371. */
  30372. doNotHandleContextLost: boolean;
  30373. /**
  30374. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30375. */
  30376. disableVertexArrayObjects: boolean;
  30377. /** @hidden */
  30378. protected _depthCullingState: DepthCullingState;
  30379. /** @hidden */
  30380. protected _stencilState: StencilState;
  30381. /** @hidden */
  30382. protected _alphaState: AlphaState;
  30383. /** @hidden */
  30384. _internalTexturesCache: InternalTexture[];
  30385. /** @hidden */
  30386. protected _activeChannel: number;
  30387. private _currentTextureChannel;
  30388. /** @hidden */
  30389. protected _boundTexturesCache: {
  30390. [key: string]: Nullable<InternalTexture>;
  30391. };
  30392. /** @hidden */
  30393. protected _currentEffect: Nullable<Effect>;
  30394. /** @hidden */
  30395. protected _currentProgram: Nullable<WebGLProgram>;
  30396. private _compiledEffects;
  30397. private _vertexAttribArraysEnabled;
  30398. /** @hidden */
  30399. protected _cachedViewport: Nullable<IViewportLike>;
  30400. private _cachedVertexArrayObject;
  30401. /** @hidden */
  30402. protected _cachedVertexBuffers: any;
  30403. /** @hidden */
  30404. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30405. /** @hidden */
  30406. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30407. /** @hidden */
  30408. _currentRenderTarget: Nullable<InternalTexture>;
  30409. private _uintIndicesCurrentlySet;
  30410. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30411. /** @hidden */
  30412. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30413. private _currentBufferPointers;
  30414. private _currentInstanceLocations;
  30415. private _currentInstanceBuffers;
  30416. private _textureUnits;
  30417. /** @hidden */
  30418. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30419. /** @hidden */
  30420. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30421. /** @hidden */
  30422. _boundRenderFunction: any;
  30423. private _vaoRecordInProgress;
  30424. private _mustWipeVertexAttributes;
  30425. private _emptyTexture;
  30426. private _emptyCubeTexture;
  30427. private _emptyTexture3D;
  30428. private _emptyTexture2DArray;
  30429. /** @hidden */
  30430. _frameHandler: number;
  30431. private _nextFreeTextureSlots;
  30432. private _maxSimultaneousTextures;
  30433. private _activeRequests;
  30434. protected _texturesSupported: string[];
  30435. /** @hidden */
  30436. _textureFormatInUse: Nullable<string>;
  30437. protected readonly _supportsHardwareTextureRescaling: boolean;
  30438. /**
  30439. * Gets the list of texture formats supported
  30440. */
  30441. readonly texturesSupported: Array<string>;
  30442. /**
  30443. * Gets the list of texture formats in use
  30444. */
  30445. readonly textureFormatInUse: Nullable<string>;
  30446. /**
  30447. * Gets the current viewport
  30448. */
  30449. readonly currentViewport: Nullable<IViewportLike>;
  30450. /**
  30451. * Gets the default empty texture
  30452. */
  30453. readonly emptyTexture: InternalTexture;
  30454. /**
  30455. * Gets the default empty 3D texture
  30456. */
  30457. readonly emptyTexture3D: InternalTexture;
  30458. /**
  30459. * Gets the default empty 2D array texture
  30460. */
  30461. readonly emptyTexture2DArray: InternalTexture;
  30462. /**
  30463. * Gets the default empty cube texture
  30464. */
  30465. readonly emptyCubeTexture: InternalTexture;
  30466. /**
  30467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30468. */
  30469. readonly premultipliedAlpha: boolean;
  30470. /**
  30471. * Observable event triggered before each texture is initialized
  30472. */
  30473. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30474. /**
  30475. * Creates a new engine
  30476. * @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
  30477. * @param antialias defines enable antialiasing (default: false)
  30478. * @param options defines further options to be sent to the getContext() function
  30479. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30480. */
  30481. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30482. private _rebuildInternalTextures;
  30483. private _rebuildEffects;
  30484. /**
  30485. * Gets a boolean indicating if all created effects are ready
  30486. * @returns true if all effects are ready
  30487. */
  30488. areAllEffectsReady(): boolean;
  30489. protected _rebuildBuffers(): void;
  30490. private _initGLContext;
  30491. /**
  30492. * Gets version of the current webGL context
  30493. */
  30494. readonly webGLVersion: number;
  30495. /**
  30496. * Gets a string idenfifying the name of the class
  30497. * @returns "Engine" string
  30498. */
  30499. getClassName(): string;
  30500. /**
  30501. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30502. */
  30503. readonly isStencilEnable: boolean;
  30504. /** @hidden */
  30505. _prepareWorkingCanvas(): void;
  30506. /**
  30507. * Reset the texture cache to empty state
  30508. */
  30509. resetTextureCache(): void;
  30510. /**
  30511. * Gets an object containing information about the current webGL context
  30512. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30513. */
  30514. getGlInfo(): {
  30515. vendor: string;
  30516. renderer: string;
  30517. version: string;
  30518. };
  30519. /**
  30520. * Defines the hardware scaling level.
  30521. * By default the hardware scaling level is computed from the window device ratio.
  30522. * 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.
  30523. * @param level defines the level to use
  30524. */
  30525. setHardwareScalingLevel(level: number): void;
  30526. /**
  30527. * Gets the current hardware scaling level.
  30528. * By default the hardware scaling level is computed from the window device ratio.
  30529. * 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.
  30530. * @returns a number indicating the current hardware scaling level
  30531. */
  30532. getHardwareScalingLevel(): number;
  30533. /**
  30534. * Gets the list of loaded textures
  30535. * @returns an array containing all loaded textures
  30536. */
  30537. getLoadedTexturesCache(): InternalTexture[];
  30538. /**
  30539. * Gets the object containing all engine capabilities
  30540. * @returns the EngineCapabilities object
  30541. */
  30542. getCaps(): EngineCapabilities;
  30543. /**
  30544. * stop executing a render loop function and remove it from the execution array
  30545. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30546. */
  30547. stopRenderLoop(renderFunction?: () => void): void;
  30548. /** @hidden */
  30549. _renderLoop(): void;
  30550. /**
  30551. * Gets the HTML canvas attached with the current webGL context
  30552. * @returns a HTML canvas
  30553. */
  30554. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30555. /**
  30556. * Gets host window
  30557. * @returns the host window object
  30558. */
  30559. getHostWindow(): Nullable<Window>;
  30560. /**
  30561. * Gets the current render width
  30562. * @param useScreen defines if screen size must be used (or the current render target if any)
  30563. * @returns a number defining the current render width
  30564. */
  30565. getRenderWidth(useScreen?: boolean): number;
  30566. /**
  30567. * Gets the current render height
  30568. * @param useScreen defines if screen size must be used (or the current render target if any)
  30569. * @returns a number defining the current render height
  30570. */
  30571. getRenderHeight(useScreen?: boolean): number;
  30572. /**
  30573. * Can be used to override the current requestAnimationFrame requester.
  30574. * @hidden
  30575. */
  30576. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30577. /**
  30578. * Register and execute a render loop. The engine can have more than one render function
  30579. * @param renderFunction defines the function to continuously execute
  30580. */
  30581. runRenderLoop(renderFunction: () => void): void;
  30582. /**
  30583. * Clear the current render buffer or the current render target (if any is set up)
  30584. * @param color defines the color to use
  30585. * @param backBuffer defines if the back buffer must be cleared
  30586. * @param depth defines if the depth buffer must be cleared
  30587. * @param stencil defines if the stencil buffer must be cleared
  30588. */
  30589. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30590. private _viewportCached;
  30591. /** @hidden */
  30592. _viewport(x: number, y: number, width: number, height: number): void;
  30593. /**
  30594. * Set the WebGL's viewport
  30595. * @param viewport defines the viewport element to be used
  30596. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30597. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30598. */
  30599. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30600. /**
  30601. * Begin a new frame
  30602. */
  30603. beginFrame(): void;
  30604. /**
  30605. * Enf the current frame
  30606. */
  30607. endFrame(): void;
  30608. /**
  30609. * Resize the view according to the canvas' size
  30610. */
  30611. resize(): void;
  30612. /**
  30613. * Force a specific size of the canvas
  30614. * @param width defines the new canvas' width
  30615. * @param height defines the new canvas' height
  30616. */
  30617. setSize(width: number, height: number): void;
  30618. /**
  30619. * Binds the frame buffer to the specified texture.
  30620. * @param texture The texture to render to or null for the default canvas
  30621. * @param faceIndex The face of the texture to render to in case of cube texture
  30622. * @param requiredWidth The width of the target to render to
  30623. * @param requiredHeight The height of the target to render to
  30624. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30625. * @param depthStencilTexture The depth stencil texture to use to render
  30626. * @param lodLevel defines le lod level to bind to the frame buffer
  30627. */
  30628. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30629. /** @hidden */
  30630. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30631. /**
  30632. * Unbind the current render target texture from the webGL context
  30633. * @param texture defines the render target texture to unbind
  30634. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30635. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30636. */
  30637. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30638. /**
  30639. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30640. */
  30641. flushFramebuffer(): void;
  30642. /**
  30643. * Unbind the current render target and bind the default framebuffer
  30644. */
  30645. restoreDefaultFramebuffer(): void;
  30646. /** @hidden */
  30647. protected _resetVertexBufferBinding(): void;
  30648. /**
  30649. * Creates a vertex buffer
  30650. * @param data the data for the vertex buffer
  30651. * @returns the new WebGL static buffer
  30652. */
  30653. createVertexBuffer(data: DataArray): DataBuffer;
  30654. private _createVertexBuffer;
  30655. /**
  30656. * Creates a dynamic vertex buffer
  30657. * @param data the data for the dynamic vertex buffer
  30658. * @returns the new WebGL dynamic buffer
  30659. */
  30660. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30661. protected _resetIndexBufferBinding(): void;
  30662. /**
  30663. * Creates a new index buffer
  30664. * @param indices defines the content of the index buffer
  30665. * @param updatable defines if the index buffer must be updatable
  30666. * @returns a new webGL buffer
  30667. */
  30668. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30669. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30670. /**
  30671. * Bind a webGL buffer to the webGL context
  30672. * @param buffer defines the buffer to bind
  30673. */
  30674. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30675. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30676. private bindBuffer;
  30677. /**
  30678. * update the bound buffer with the given data
  30679. * @param data defines the data to update
  30680. */
  30681. updateArrayBuffer(data: Float32Array): void;
  30682. private _vertexAttribPointer;
  30683. private _bindIndexBufferWithCache;
  30684. private _bindVertexBuffersAttributes;
  30685. /**
  30686. * Records a vertex array object
  30687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30688. * @param vertexBuffers defines the list of vertex buffers to store
  30689. * @param indexBuffer defines the index buffer to store
  30690. * @param effect defines the effect to store
  30691. * @returns the new vertex array object
  30692. */
  30693. recordVertexArrayObject(vertexBuffers: {
  30694. [key: string]: VertexBuffer;
  30695. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30696. /**
  30697. * Bind a specific vertex array object
  30698. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30699. * @param vertexArrayObject defines the vertex array object to bind
  30700. * @param indexBuffer defines the index buffer to bind
  30701. */
  30702. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30703. /**
  30704. * Bind webGl buffers directly to the webGL context
  30705. * @param vertexBuffer defines the vertex buffer to bind
  30706. * @param indexBuffer defines the index buffer to bind
  30707. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30708. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30709. * @param effect defines the effect associated with the vertex buffer
  30710. */
  30711. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30712. private _unbindVertexArrayObject;
  30713. /**
  30714. * Bind a list of vertex buffers to the webGL context
  30715. * @param vertexBuffers defines the list of vertex buffers to bind
  30716. * @param indexBuffer defines the index buffer to bind
  30717. * @param effect defines the effect associated with the vertex buffers
  30718. */
  30719. bindBuffers(vertexBuffers: {
  30720. [key: string]: Nullable<VertexBuffer>;
  30721. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30722. /**
  30723. * Unbind all instance attributes
  30724. */
  30725. unbindInstanceAttributes(): void;
  30726. /**
  30727. * Release and free the memory of a vertex array object
  30728. * @param vao defines the vertex array object to delete
  30729. */
  30730. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30731. /** @hidden */
  30732. _releaseBuffer(buffer: DataBuffer): boolean;
  30733. protected _deleteBuffer(buffer: DataBuffer): void;
  30734. /**
  30735. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30736. * @param instancesBuffer defines the webGL buffer to update and bind
  30737. * @param data defines the data to store in the buffer
  30738. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30739. */
  30740. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30741. /**
  30742. * Apply all cached states (depth, culling, stencil and alpha)
  30743. */
  30744. applyStates(): void;
  30745. /**
  30746. * Send a draw order
  30747. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30748. * @param indexStart defines the starting index
  30749. * @param indexCount defines the number of index to draw
  30750. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30751. */
  30752. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30753. /**
  30754. * Draw a list of points
  30755. * @param verticesStart defines the index of first vertex to draw
  30756. * @param verticesCount defines the count of vertices to draw
  30757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30758. */
  30759. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30760. /**
  30761. * Draw a list of unindexed primitives
  30762. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30763. * @param verticesStart defines the index of first vertex to draw
  30764. * @param verticesCount defines the count of vertices to draw
  30765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30766. */
  30767. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30768. /**
  30769. * Draw a list of indexed primitives
  30770. * @param fillMode defines the primitive to use
  30771. * @param indexStart defines the starting index
  30772. * @param indexCount defines the number of index to draw
  30773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30774. */
  30775. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30776. /**
  30777. * Draw a list of unindexed primitives
  30778. * @param fillMode defines the primitive to use
  30779. * @param verticesStart defines the index of first vertex to draw
  30780. * @param verticesCount defines the count of vertices to draw
  30781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30782. */
  30783. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30784. private _drawMode;
  30785. /** @hidden */
  30786. protected _reportDrawCall(): void;
  30787. /** @hidden */
  30788. _releaseEffect(effect: Effect): void;
  30789. /** @hidden */
  30790. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30791. /**
  30792. * Create a new effect (used to store vertex/fragment shaders)
  30793. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30794. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30795. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30796. * @param samplers defines an array of string used to represent textures
  30797. * @param defines defines the string containing the defines to use to compile the shaders
  30798. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30799. * @param onCompiled defines a function to call when the effect creation is successful
  30800. * @param onError defines a function to call when the effect creation has failed
  30801. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30802. * @returns the new Effect
  30803. */
  30804. 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;
  30805. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30806. private _compileShader;
  30807. private _compileRawShader;
  30808. /**
  30809. * Directly creates a webGL program
  30810. * @param pipelineContext defines the pipeline context to attach to
  30811. * @param vertexCode defines the vertex shader code to use
  30812. * @param fragmentCode defines the fragment shader code to use
  30813. * @param context defines the webGL context to use (if not set, the current one will be used)
  30814. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30815. * @returns the new webGL program
  30816. */
  30817. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30818. /**
  30819. * Creates a webGL program
  30820. * @param pipelineContext defines the pipeline context to attach to
  30821. * @param vertexCode defines the vertex shader code to use
  30822. * @param fragmentCode defines the fragment shader code to use
  30823. * @param defines defines the string containing the defines to use to compile the shaders
  30824. * @param context defines the webGL context to use (if not set, the current one will be used)
  30825. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30826. * @returns the new webGL program
  30827. */
  30828. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30829. /**
  30830. * Creates a new pipeline context
  30831. * @returns the new pipeline
  30832. */
  30833. createPipelineContext(): IPipelineContext;
  30834. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30835. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30836. /** @hidden */
  30837. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30838. /** @hidden */
  30839. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30840. /** @hidden */
  30841. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30842. /**
  30843. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30844. * @param pipelineContext defines the pipeline context to use
  30845. * @param uniformsNames defines the list of uniform names
  30846. * @returns an array of webGL uniform locations
  30847. */
  30848. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30849. /**
  30850. * Gets the lsit of active attributes for a given webGL program
  30851. * @param pipelineContext defines the pipeline context to use
  30852. * @param attributesNames defines the list of attribute names to get
  30853. * @returns an array of indices indicating the offset of each attribute
  30854. */
  30855. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30856. /**
  30857. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30858. * @param effect defines the effect to activate
  30859. */
  30860. enableEffect(effect: Nullable<Effect>): void;
  30861. /**
  30862. * Set the value of an uniform to a number (int)
  30863. * @param uniform defines the webGL uniform location where to store the value
  30864. * @param value defines the int number to store
  30865. */
  30866. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30867. /**
  30868. * Set the value of an uniform to an array of int32
  30869. * @param uniform defines the webGL uniform location where to store the value
  30870. * @param array defines the array of int32 to store
  30871. */
  30872. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30873. /**
  30874. * Set the value of an uniform to an array of int32 (stored as vec2)
  30875. * @param uniform defines the webGL uniform location where to store the value
  30876. * @param array defines the array of int32 to store
  30877. */
  30878. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30879. /**
  30880. * Set the value of an uniform to an array of int32 (stored as vec3)
  30881. * @param uniform defines the webGL uniform location where to store the value
  30882. * @param array defines the array of int32 to store
  30883. */
  30884. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30885. /**
  30886. * Set the value of an uniform to an array of int32 (stored as vec4)
  30887. * @param uniform defines the webGL uniform location where to store the value
  30888. * @param array defines the array of int32 to store
  30889. */
  30890. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30891. /**
  30892. * Set the value of an uniform to an array of number
  30893. * @param uniform defines the webGL uniform location where to store the value
  30894. * @param array defines the array of number to store
  30895. */
  30896. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30897. /**
  30898. * Set the value of an uniform to an array of number (stored as vec2)
  30899. * @param uniform defines the webGL uniform location where to store the value
  30900. * @param array defines the array of number to store
  30901. */
  30902. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30903. /**
  30904. * Set the value of an uniform to an array of number (stored as vec3)
  30905. * @param uniform defines the webGL uniform location where to store the value
  30906. * @param array defines the array of number to store
  30907. */
  30908. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30909. /**
  30910. * Set the value of an uniform to an array of number (stored as vec4)
  30911. * @param uniform defines the webGL uniform location where to store the value
  30912. * @param array defines the array of number to store
  30913. */
  30914. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30915. /**
  30916. * Set the value of an uniform to an array of float32 (stored as matrices)
  30917. * @param uniform defines the webGL uniform location where to store the value
  30918. * @param matrices defines the array of float32 to store
  30919. */
  30920. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30921. /**
  30922. * Set the value of an uniform to a matrix (3x3)
  30923. * @param uniform defines the webGL uniform location where to store the value
  30924. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30925. */
  30926. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30927. /**
  30928. * Set the value of an uniform to a matrix (2x2)
  30929. * @param uniform defines the webGL uniform location where to store the value
  30930. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30931. */
  30932. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30933. /**
  30934. * Set the value of an uniform to a number (float)
  30935. * @param uniform defines the webGL uniform location where to store the value
  30936. * @param value defines the float number to store
  30937. */
  30938. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30939. /**
  30940. * Set the value of an uniform to a vec2
  30941. * @param uniform defines the webGL uniform location where to store the value
  30942. * @param x defines the 1st component of the value
  30943. * @param y defines the 2nd component of the value
  30944. */
  30945. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30946. /**
  30947. * Set the value of an uniform to a vec3
  30948. * @param uniform defines the webGL uniform location where to store the value
  30949. * @param x defines the 1st component of the value
  30950. * @param y defines the 2nd component of the value
  30951. * @param z defines the 3rd component of the value
  30952. */
  30953. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30954. /**
  30955. * Set the value of an uniform to a vec4
  30956. * @param uniform defines the webGL uniform location where to store the value
  30957. * @param x defines the 1st component of the value
  30958. * @param y defines the 2nd component of the value
  30959. * @param z defines the 3rd component of the value
  30960. * @param w defines the 4th component of the value
  30961. */
  30962. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30963. /**
  30964. * Gets the depth culling state manager
  30965. */
  30966. readonly depthCullingState: DepthCullingState;
  30967. /**
  30968. * Gets the alpha state manager
  30969. */
  30970. readonly alphaState: AlphaState;
  30971. /**
  30972. * Gets the stencil state manager
  30973. */
  30974. readonly stencilState: StencilState;
  30975. /**
  30976. * Clears the list of texture accessible through engine.
  30977. * This can help preventing texture load conflict due to name collision.
  30978. */
  30979. clearInternalTexturesCache(): void;
  30980. /**
  30981. * Force the entire cache to be cleared
  30982. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30983. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30984. */
  30985. wipeCaches(bruteForce?: boolean): void;
  30986. /** @hidden */
  30987. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30988. min: number;
  30989. mag: number;
  30990. };
  30991. /** @hidden */
  30992. _createTexture(): WebGLTexture;
  30993. /**
  30994. * Usually called from Texture.ts.
  30995. * Passed information to create a WebGLTexture
  30996. * @param urlArg defines a value which contains one of the following:
  30997. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30998. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30999. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31000. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31001. * @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)
  31002. * @param scene needed for loading to the correct scene
  31003. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31004. * @param onLoad optional callback to be called upon successful completion
  31005. * @param onError optional callback to be called upon failure
  31006. * @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
  31007. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31008. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31009. * @param forcedExtension defines the extension to use to pick the right loader
  31010. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31011. * @param mimeType defines an optional mime type
  31012. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31013. */
  31014. 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;
  31015. /**
  31016. * @hidden
  31017. */
  31018. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31019. /**
  31020. * Creates a raw texture
  31021. * @param data defines the data to store in the texture
  31022. * @param width defines the width of the texture
  31023. * @param height defines the height of the texture
  31024. * @param format defines the format of the data
  31025. * @param generateMipMaps defines if the engine should generate the mip levels
  31026. * @param invertY defines if data must be stored with Y axis inverted
  31027. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31028. * @param compression defines the compression used (null by default)
  31029. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31030. * @returns the raw texture inside an InternalTexture
  31031. */
  31032. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31033. /**
  31034. * Creates a new raw cube texture
  31035. * @param data defines the array of data to use to create each face
  31036. * @param size defines the size of the textures
  31037. * @param format defines the format of the data
  31038. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31039. * @param generateMipMaps defines if the engine should generate the mip levels
  31040. * @param invertY defines if data must be stored with Y axis inverted
  31041. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31042. * @param compression defines the compression used (null by default)
  31043. * @returns the cube texture as an InternalTexture
  31044. */
  31045. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31046. /**
  31047. * Creates a new raw 3D texture
  31048. * @param data defines the data used to create the texture
  31049. * @param width defines the width of the texture
  31050. * @param height defines the height of the texture
  31051. * @param depth defines the depth of the texture
  31052. * @param format defines the format of the texture
  31053. * @param generateMipMaps defines if the engine must generate mip levels
  31054. * @param invertY defines if data must be stored with Y axis inverted
  31055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31056. * @param compression defines the compressed used (can be null)
  31057. * @param textureType defines the compressed used (can be null)
  31058. * @returns a new raw 3D texture (stored in an InternalTexture)
  31059. */
  31060. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31061. /**
  31062. * Creates a new raw 2D array texture
  31063. * @param data defines the data used to create the texture
  31064. * @param width defines the width of the texture
  31065. * @param height defines the height of the texture
  31066. * @param depth defines the number of layers of the texture
  31067. * @param format defines the format of the texture
  31068. * @param generateMipMaps defines if the engine must generate mip levels
  31069. * @param invertY defines if data must be stored with Y axis inverted
  31070. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31071. * @param compression defines the compressed used (can be null)
  31072. * @param textureType defines the compressed used (can be null)
  31073. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31074. */
  31075. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31076. private _unpackFlipYCached;
  31077. /**
  31078. * In case you are sharing the context with other applications, it might
  31079. * be interested to not cache the unpack flip y state to ensure a consistent
  31080. * value would be set.
  31081. */
  31082. enableUnpackFlipYCached: boolean;
  31083. /** @hidden */
  31084. _unpackFlipY(value: boolean): void;
  31085. /** @hidden */
  31086. _getUnpackAlignement(): number;
  31087. /**
  31088. * Update the sampling mode of a given texture
  31089. * @param samplingMode defines the required sampling mode
  31090. * @param texture defines the texture to update
  31091. */
  31092. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31093. /** @hidden */
  31094. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31095. width: number;
  31096. height: number;
  31097. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31098. /** @hidden */
  31099. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31100. /** @hidden */
  31101. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31102. /** @hidden */
  31103. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31104. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31105. private _prepareWebGLTexture;
  31106. /** @hidden */
  31107. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31108. /** @hidden */
  31109. _releaseFramebufferObjects(texture: InternalTexture): void;
  31110. /** @hidden */
  31111. _releaseTexture(texture: InternalTexture): void;
  31112. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31113. protected _setProgram(program: WebGLProgram): void;
  31114. protected _boundUniforms: {
  31115. [key: number]: WebGLUniformLocation;
  31116. };
  31117. /**
  31118. * Binds an effect to the webGL context
  31119. * @param effect defines the effect to bind
  31120. */
  31121. bindSamplers(effect: Effect): void;
  31122. private _activateCurrentTexture;
  31123. /** @hidden */
  31124. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31125. /** @hidden */
  31126. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31127. /**
  31128. * Unbind all textures from the webGL context
  31129. */
  31130. unbindAllTextures(): void;
  31131. /**
  31132. * Sets a texture to the according uniform.
  31133. * @param channel The texture channel
  31134. * @param uniform The uniform to set
  31135. * @param texture The texture to apply
  31136. */
  31137. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31138. private _bindSamplerUniformToChannel;
  31139. private _getTextureWrapMode;
  31140. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31141. /**
  31142. * Sets an array of texture to the webGL context
  31143. * @param channel defines the channel where the texture array must be set
  31144. * @param uniform defines the associated uniform location
  31145. * @param textures defines the array of textures to bind
  31146. */
  31147. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31148. /** @hidden */
  31149. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31150. private _setTextureParameterFloat;
  31151. private _setTextureParameterInteger;
  31152. /**
  31153. * Unbind all vertex attributes from the webGL context
  31154. */
  31155. unbindAllAttributes(): void;
  31156. /**
  31157. * 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
  31158. */
  31159. releaseEffects(): void;
  31160. /**
  31161. * Dispose and release all associated resources
  31162. */
  31163. dispose(): void;
  31164. /**
  31165. * Attach a new callback raised when context lost event is fired
  31166. * @param callback defines the callback to call
  31167. */
  31168. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31169. /**
  31170. * Attach a new callback raised when context restored event is fired
  31171. * @param callback defines the callback to call
  31172. */
  31173. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31174. /**
  31175. * Get the current error code of the webGL context
  31176. * @returns the error code
  31177. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31178. */
  31179. getError(): number;
  31180. private _canRenderToFloatFramebuffer;
  31181. private _canRenderToHalfFloatFramebuffer;
  31182. private _canRenderToFramebuffer;
  31183. /** @hidden */
  31184. _getWebGLTextureType(type: number): number;
  31185. /** @hidden */
  31186. _getInternalFormat(format: number): number;
  31187. /** @hidden */
  31188. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31189. /** @hidden */
  31190. _getRGBAMultiSampleBufferFormat(type: number): number;
  31191. /** @hidden */
  31192. _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;
  31193. /**
  31194. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31195. * @returns true if the engine can be created
  31196. * @ignorenaming
  31197. */
  31198. static isSupported(): boolean;
  31199. /**
  31200. * Find the next highest power of two.
  31201. * @param x Number to start search from.
  31202. * @return Next highest power of two.
  31203. */
  31204. static CeilingPOT(x: number): number;
  31205. /**
  31206. * Find the next lowest power of two.
  31207. * @param x Number to start search from.
  31208. * @return Next lowest power of two.
  31209. */
  31210. static FloorPOT(x: number): number;
  31211. /**
  31212. * Find the nearest power of two.
  31213. * @param x Number to start search from.
  31214. * @return Next nearest power of two.
  31215. */
  31216. static NearestPOT(x: number): number;
  31217. /**
  31218. * Get the closest exponent of two
  31219. * @param value defines the value to approximate
  31220. * @param max defines the maximum value to return
  31221. * @param mode defines how to define the closest value
  31222. * @returns closest exponent of two of the given value
  31223. */
  31224. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31225. /**
  31226. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31227. * @param func - the function to be called
  31228. * @param requester - the object that will request the next frame. Falls back to window.
  31229. * @returns frame number
  31230. */
  31231. static QueueNewFrame(func: () => void, requester?: any): number;
  31232. }
  31233. }
  31234. declare module "babylonjs/Maths/sphericalPolynomial" {
  31235. import { Vector3 } from "babylonjs/Maths/math.vector";
  31236. import { Color3 } from "babylonjs/Maths/math.color";
  31237. /**
  31238. * Class representing spherical harmonics coefficients to the 3rd degree
  31239. */
  31240. export class SphericalHarmonics {
  31241. /**
  31242. * Defines whether or not the harmonics have been prescaled for rendering.
  31243. */
  31244. preScaled: boolean;
  31245. /**
  31246. * The l0,0 coefficients of the spherical harmonics
  31247. */
  31248. l00: Vector3;
  31249. /**
  31250. * The l1,-1 coefficients of the spherical harmonics
  31251. */
  31252. l1_1: Vector3;
  31253. /**
  31254. * The l1,0 coefficients of the spherical harmonics
  31255. */
  31256. l10: Vector3;
  31257. /**
  31258. * The l1,1 coefficients of the spherical harmonics
  31259. */
  31260. l11: Vector3;
  31261. /**
  31262. * The l2,-2 coefficients of the spherical harmonics
  31263. */
  31264. l2_2: Vector3;
  31265. /**
  31266. * The l2,-1 coefficients of the spherical harmonics
  31267. */
  31268. l2_1: Vector3;
  31269. /**
  31270. * The l2,0 coefficients of the spherical harmonics
  31271. */
  31272. l20: Vector3;
  31273. /**
  31274. * The l2,1 coefficients of the spherical harmonics
  31275. */
  31276. l21: Vector3;
  31277. /**
  31278. * The l2,2 coefficients of the spherical harmonics
  31279. */
  31280. l22: Vector3;
  31281. /**
  31282. * Adds a light to the spherical harmonics
  31283. * @param direction the direction of the light
  31284. * @param color the color of the light
  31285. * @param deltaSolidAngle the delta solid angle of the light
  31286. */
  31287. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31288. /**
  31289. * Scales the spherical harmonics by the given amount
  31290. * @param scale the amount to scale
  31291. */
  31292. scaleInPlace(scale: number): void;
  31293. /**
  31294. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31295. *
  31296. * ```
  31297. * E_lm = A_l * L_lm
  31298. * ```
  31299. *
  31300. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31301. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31302. * the scaling factors are given in equation 9.
  31303. */
  31304. convertIncidentRadianceToIrradiance(): void;
  31305. /**
  31306. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31307. *
  31308. * ```
  31309. * L = (1/pi) * E * rho
  31310. * ```
  31311. *
  31312. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31313. */
  31314. convertIrradianceToLambertianRadiance(): void;
  31315. /**
  31316. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31317. * required operations at run time.
  31318. *
  31319. * This is simply done by scaling back the SH with Ylm constants parameter.
  31320. * The trigonometric part being applied by the shader at run time.
  31321. */
  31322. preScaleForRendering(): void;
  31323. /**
  31324. * Constructs a spherical harmonics from an array.
  31325. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31326. * @returns the spherical harmonics
  31327. */
  31328. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31329. /**
  31330. * Gets the spherical harmonics from polynomial
  31331. * @param polynomial the spherical polynomial
  31332. * @returns the spherical harmonics
  31333. */
  31334. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31335. }
  31336. /**
  31337. * Class representing spherical polynomial coefficients to the 3rd degree
  31338. */
  31339. export class SphericalPolynomial {
  31340. private _harmonics;
  31341. /**
  31342. * The spherical harmonics used to create the polynomials.
  31343. */
  31344. readonly preScaledHarmonics: SphericalHarmonics;
  31345. /**
  31346. * The x coefficients of the spherical polynomial
  31347. */
  31348. x: Vector3;
  31349. /**
  31350. * The y coefficients of the spherical polynomial
  31351. */
  31352. y: Vector3;
  31353. /**
  31354. * The z coefficients of the spherical polynomial
  31355. */
  31356. z: Vector3;
  31357. /**
  31358. * The xx coefficients of the spherical polynomial
  31359. */
  31360. xx: Vector3;
  31361. /**
  31362. * The yy coefficients of the spherical polynomial
  31363. */
  31364. yy: Vector3;
  31365. /**
  31366. * The zz coefficients of the spherical polynomial
  31367. */
  31368. zz: Vector3;
  31369. /**
  31370. * The xy coefficients of the spherical polynomial
  31371. */
  31372. xy: Vector3;
  31373. /**
  31374. * The yz coefficients of the spherical polynomial
  31375. */
  31376. yz: Vector3;
  31377. /**
  31378. * The zx coefficients of the spherical polynomial
  31379. */
  31380. zx: Vector3;
  31381. /**
  31382. * Adds an ambient color to the spherical polynomial
  31383. * @param color the color to add
  31384. */
  31385. addAmbient(color: Color3): void;
  31386. /**
  31387. * Scales the spherical polynomial by the given amount
  31388. * @param scale the amount to scale
  31389. */
  31390. scaleInPlace(scale: number): void;
  31391. /**
  31392. * Gets the spherical polynomial from harmonics
  31393. * @param harmonics the spherical harmonics
  31394. * @returns the spherical polynomial
  31395. */
  31396. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31397. /**
  31398. * Constructs a spherical polynomial from an array.
  31399. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31400. * @returns the spherical polynomial
  31401. */
  31402. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31403. }
  31404. }
  31405. declare module "babylonjs/Materials/Textures/internalTexture" {
  31406. import { Observable } from "babylonjs/Misc/observable";
  31407. import { Nullable, int } from "babylonjs/types";
  31408. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31410. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31411. /**
  31412. * Defines the source of the internal texture
  31413. */
  31414. export enum InternalTextureSource {
  31415. /**
  31416. * The source of the texture data is unknown
  31417. */
  31418. Unknown = 0,
  31419. /**
  31420. * Texture data comes from an URL
  31421. */
  31422. Url = 1,
  31423. /**
  31424. * Texture data is only used for temporary storage
  31425. */
  31426. Temp = 2,
  31427. /**
  31428. * Texture data comes from raw data (ArrayBuffer)
  31429. */
  31430. Raw = 3,
  31431. /**
  31432. * Texture content is dynamic (video or dynamic texture)
  31433. */
  31434. Dynamic = 4,
  31435. /**
  31436. * Texture content is generated by rendering to it
  31437. */
  31438. RenderTarget = 5,
  31439. /**
  31440. * Texture content is part of a multi render target process
  31441. */
  31442. MultiRenderTarget = 6,
  31443. /**
  31444. * Texture data comes from a cube data file
  31445. */
  31446. Cube = 7,
  31447. /**
  31448. * Texture data comes from a raw cube data
  31449. */
  31450. CubeRaw = 8,
  31451. /**
  31452. * Texture data come from a prefiltered cube data file
  31453. */
  31454. CubePrefiltered = 9,
  31455. /**
  31456. * Texture content is raw 3D data
  31457. */
  31458. Raw3D = 10,
  31459. /**
  31460. * Texture content is raw 2D array data
  31461. */
  31462. Raw2DArray = 11,
  31463. /**
  31464. * Texture content is a depth texture
  31465. */
  31466. Depth = 12,
  31467. /**
  31468. * Texture data comes from a raw cube data encoded with RGBD
  31469. */
  31470. CubeRawRGBD = 13
  31471. }
  31472. /**
  31473. * Class used to store data associated with WebGL texture data for the engine
  31474. * This class should not be used directly
  31475. */
  31476. export class InternalTexture {
  31477. /** @hidden */
  31478. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31479. /**
  31480. * Defines if the texture is ready
  31481. */
  31482. isReady: boolean;
  31483. /**
  31484. * Defines if the texture is a cube texture
  31485. */
  31486. isCube: boolean;
  31487. /**
  31488. * Defines if the texture contains 3D data
  31489. */
  31490. is3D: boolean;
  31491. /**
  31492. * Defines if the texture contains 2D array data
  31493. */
  31494. is2DArray: boolean;
  31495. /**
  31496. * Defines if the texture contains multiview data
  31497. */
  31498. isMultiview: boolean;
  31499. /**
  31500. * Gets the URL used to load this texture
  31501. */
  31502. url: string;
  31503. /**
  31504. * Gets the sampling mode of the texture
  31505. */
  31506. samplingMode: number;
  31507. /**
  31508. * Gets a boolean indicating if the texture needs mipmaps generation
  31509. */
  31510. generateMipMaps: boolean;
  31511. /**
  31512. * Gets the number of samples used by the texture (WebGL2+ only)
  31513. */
  31514. samples: number;
  31515. /**
  31516. * Gets the type of the texture (int, float...)
  31517. */
  31518. type: number;
  31519. /**
  31520. * Gets the format of the texture (RGB, RGBA...)
  31521. */
  31522. format: number;
  31523. /**
  31524. * Observable called when the texture is loaded
  31525. */
  31526. onLoadedObservable: Observable<InternalTexture>;
  31527. /**
  31528. * Gets the width of the texture
  31529. */
  31530. width: number;
  31531. /**
  31532. * Gets the height of the texture
  31533. */
  31534. height: number;
  31535. /**
  31536. * Gets the depth of the texture
  31537. */
  31538. depth: number;
  31539. /**
  31540. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31541. */
  31542. baseWidth: number;
  31543. /**
  31544. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31545. */
  31546. baseHeight: number;
  31547. /**
  31548. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31549. */
  31550. baseDepth: number;
  31551. /**
  31552. * Gets a boolean indicating if the texture is inverted on Y axis
  31553. */
  31554. invertY: boolean;
  31555. /** @hidden */
  31556. _invertVScale: boolean;
  31557. /** @hidden */
  31558. _associatedChannel: number;
  31559. /** @hidden */
  31560. _source: InternalTextureSource;
  31561. /** @hidden */
  31562. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31563. /** @hidden */
  31564. _bufferView: Nullable<ArrayBufferView>;
  31565. /** @hidden */
  31566. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31567. /** @hidden */
  31568. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31569. /** @hidden */
  31570. _size: number;
  31571. /** @hidden */
  31572. _extension: string;
  31573. /** @hidden */
  31574. _files: Nullable<string[]>;
  31575. /** @hidden */
  31576. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31577. /** @hidden */
  31578. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31579. /** @hidden */
  31580. _framebuffer: Nullable<WebGLFramebuffer>;
  31581. /** @hidden */
  31582. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31583. /** @hidden */
  31584. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31585. /** @hidden */
  31586. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31587. /** @hidden */
  31588. _attachments: Nullable<number[]>;
  31589. /** @hidden */
  31590. _cachedCoordinatesMode: Nullable<number>;
  31591. /** @hidden */
  31592. _cachedWrapU: Nullable<number>;
  31593. /** @hidden */
  31594. _cachedWrapV: Nullable<number>;
  31595. /** @hidden */
  31596. _cachedWrapR: Nullable<number>;
  31597. /** @hidden */
  31598. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31599. /** @hidden */
  31600. _isDisabled: boolean;
  31601. /** @hidden */
  31602. _compression: Nullable<string>;
  31603. /** @hidden */
  31604. _generateStencilBuffer: boolean;
  31605. /** @hidden */
  31606. _generateDepthBuffer: boolean;
  31607. /** @hidden */
  31608. _comparisonFunction: number;
  31609. /** @hidden */
  31610. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31611. /** @hidden */
  31612. _lodGenerationScale: number;
  31613. /** @hidden */
  31614. _lodGenerationOffset: number;
  31615. /** @hidden */
  31616. _colorTextureArray: Nullable<WebGLTexture>;
  31617. /** @hidden */
  31618. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31619. /** @hidden */
  31620. _lodTextureHigh: Nullable<BaseTexture>;
  31621. /** @hidden */
  31622. _lodTextureMid: Nullable<BaseTexture>;
  31623. /** @hidden */
  31624. _lodTextureLow: Nullable<BaseTexture>;
  31625. /** @hidden */
  31626. _isRGBD: boolean;
  31627. /** @hidden */
  31628. _linearSpecularLOD: boolean;
  31629. /** @hidden */
  31630. _irradianceTexture: Nullable<BaseTexture>;
  31631. /** @hidden */
  31632. _webGLTexture: Nullable<WebGLTexture>;
  31633. /** @hidden */
  31634. _references: number;
  31635. private _engine;
  31636. /**
  31637. * Gets the Engine the texture belongs to.
  31638. * @returns The babylon engine
  31639. */
  31640. getEngine(): ThinEngine;
  31641. /**
  31642. * Gets the data source type of the texture
  31643. */
  31644. readonly source: InternalTextureSource;
  31645. /**
  31646. * Creates a new InternalTexture
  31647. * @param engine defines the engine to use
  31648. * @param source defines the type of data that will be used
  31649. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31650. */
  31651. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31652. /**
  31653. * Increments the number of references (ie. the number of Texture that point to it)
  31654. */
  31655. incrementReferences(): void;
  31656. /**
  31657. * Change the size of the texture (not the size of the content)
  31658. * @param width defines the new width
  31659. * @param height defines the new height
  31660. * @param depth defines the new depth (1 by default)
  31661. */
  31662. updateSize(width: int, height: int, depth?: int): void;
  31663. /** @hidden */
  31664. _rebuild(): void;
  31665. /** @hidden */
  31666. _swapAndDie(target: InternalTexture): void;
  31667. /**
  31668. * Dispose the current allocated resources
  31669. */
  31670. dispose(): void;
  31671. }
  31672. }
  31673. declare module "babylonjs/Audio/analyser" {
  31674. import { Scene } from "babylonjs/scene";
  31675. /**
  31676. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31678. */
  31679. export class Analyser {
  31680. /**
  31681. * Gets or sets the smoothing
  31682. * @ignorenaming
  31683. */
  31684. SMOOTHING: number;
  31685. /**
  31686. * Gets or sets the FFT table size
  31687. * @ignorenaming
  31688. */
  31689. FFT_SIZE: number;
  31690. /**
  31691. * Gets or sets the bar graph amplitude
  31692. * @ignorenaming
  31693. */
  31694. BARGRAPHAMPLITUDE: number;
  31695. /**
  31696. * Gets or sets the position of the debug canvas
  31697. * @ignorenaming
  31698. */
  31699. DEBUGCANVASPOS: {
  31700. x: number;
  31701. y: number;
  31702. };
  31703. /**
  31704. * Gets or sets the debug canvas size
  31705. * @ignorenaming
  31706. */
  31707. DEBUGCANVASSIZE: {
  31708. width: number;
  31709. height: number;
  31710. };
  31711. private _byteFreqs;
  31712. private _byteTime;
  31713. private _floatFreqs;
  31714. private _webAudioAnalyser;
  31715. private _debugCanvas;
  31716. private _debugCanvasContext;
  31717. private _scene;
  31718. private _registerFunc;
  31719. private _audioEngine;
  31720. /**
  31721. * Creates a new analyser
  31722. * @param scene defines hosting scene
  31723. */
  31724. constructor(scene: Scene);
  31725. /**
  31726. * Get the number of data values you will have to play with for the visualization
  31727. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31728. * @returns a number
  31729. */
  31730. getFrequencyBinCount(): number;
  31731. /**
  31732. * Gets the current frequency data as a byte array
  31733. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31734. * @returns a Uint8Array
  31735. */
  31736. getByteFrequencyData(): Uint8Array;
  31737. /**
  31738. * Gets the current waveform as a byte array
  31739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31740. * @returns a Uint8Array
  31741. */
  31742. getByteTimeDomainData(): Uint8Array;
  31743. /**
  31744. * Gets the current frequency data as a float array
  31745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31746. * @returns a Float32Array
  31747. */
  31748. getFloatFrequencyData(): Float32Array;
  31749. /**
  31750. * Renders the debug canvas
  31751. */
  31752. drawDebugCanvas(): void;
  31753. /**
  31754. * Stops rendering the debug canvas and removes it
  31755. */
  31756. stopDebugCanvas(): void;
  31757. /**
  31758. * Connects two audio nodes
  31759. * @param inputAudioNode defines first node to connect
  31760. * @param outputAudioNode defines second node to connect
  31761. */
  31762. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31763. /**
  31764. * Releases all associated resources
  31765. */
  31766. dispose(): void;
  31767. }
  31768. }
  31769. declare module "babylonjs/Audio/audioEngine" {
  31770. import { IDisposable } from "babylonjs/scene";
  31771. import { Analyser } from "babylonjs/Audio/analyser";
  31772. import { Nullable } from "babylonjs/types";
  31773. import { Observable } from "babylonjs/Misc/observable";
  31774. /**
  31775. * This represents an audio engine and it is responsible
  31776. * to play, synchronize and analyse sounds throughout the application.
  31777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31778. */
  31779. export interface IAudioEngine extends IDisposable {
  31780. /**
  31781. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31782. */
  31783. readonly canUseWebAudio: boolean;
  31784. /**
  31785. * Gets the current AudioContext if available.
  31786. */
  31787. readonly audioContext: Nullable<AudioContext>;
  31788. /**
  31789. * The master gain node defines the global audio volume of your audio engine.
  31790. */
  31791. readonly masterGain: GainNode;
  31792. /**
  31793. * Gets whether or not mp3 are supported by your browser.
  31794. */
  31795. readonly isMP3supported: boolean;
  31796. /**
  31797. * Gets whether or not ogg are supported by your browser.
  31798. */
  31799. readonly isOGGsupported: boolean;
  31800. /**
  31801. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31802. * @ignoreNaming
  31803. */
  31804. WarnedWebAudioUnsupported: boolean;
  31805. /**
  31806. * Defines if the audio engine relies on a custom unlocked button.
  31807. * In this case, the embedded button will not be displayed.
  31808. */
  31809. useCustomUnlockedButton: boolean;
  31810. /**
  31811. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31812. */
  31813. readonly unlocked: boolean;
  31814. /**
  31815. * Event raised when audio has been unlocked on the browser.
  31816. */
  31817. onAudioUnlockedObservable: Observable<AudioEngine>;
  31818. /**
  31819. * Event raised when audio has been locked on the browser.
  31820. */
  31821. onAudioLockedObservable: Observable<AudioEngine>;
  31822. /**
  31823. * Flags the audio engine in Locked state.
  31824. * This happens due to new browser policies preventing audio to autoplay.
  31825. */
  31826. lock(): void;
  31827. /**
  31828. * Unlocks the audio engine once a user action has been done on the dom.
  31829. * This is helpful to resume play once browser policies have been satisfied.
  31830. */
  31831. unlock(): void;
  31832. }
  31833. /**
  31834. * This represents the default audio engine used in babylon.
  31835. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31837. */
  31838. export class AudioEngine implements IAudioEngine {
  31839. private _audioContext;
  31840. private _audioContextInitialized;
  31841. private _muteButton;
  31842. private _hostElement;
  31843. /**
  31844. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31845. */
  31846. canUseWebAudio: boolean;
  31847. /**
  31848. * The master gain node defines the global audio volume of your audio engine.
  31849. */
  31850. masterGain: GainNode;
  31851. /**
  31852. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31853. * @ignoreNaming
  31854. */
  31855. WarnedWebAudioUnsupported: boolean;
  31856. /**
  31857. * Gets whether or not mp3 are supported by your browser.
  31858. */
  31859. isMP3supported: boolean;
  31860. /**
  31861. * Gets whether or not ogg are supported by your browser.
  31862. */
  31863. isOGGsupported: boolean;
  31864. /**
  31865. * Gets whether audio has been unlocked on the device.
  31866. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31867. * a user interaction has happened.
  31868. */
  31869. unlocked: boolean;
  31870. /**
  31871. * Defines if the audio engine relies on a custom unlocked button.
  31872. * In this case, the embedded button will not be displayed.
  31873. */
  31874. useCustomUnlockedButton: boolean;
  31875. /**
  31876. * Event raised when audio has been unlocked on the browser.
  31877. */
  31878. onAudioUnlockedObservable: Observable<AudioEngine>;
  31879. /**
  31880. * Event raised when audio has been locked on the browser.
  31881. */
  31882. onAudioLockedObservable: Observable<AudioEngine>;
  31883. /**
  31884. * Gets the current AudioContext if available.
  31885. */
  31886. readonly audioContext: Nullable<AudioContext>;
  31887. private _connectedAnalyser;
  31888. /**
  31889. * Instantiates a new audio engine.
  31890. *
  31891. * There should be only one per page as some browsers restrict the number
  31892. * of audio contexts you can create.
  31893. * @param hostElement defines the host element where to display the mute icon if necessary
  31894. */
  31895. constructor(hostElement?: Nullable<HTMLElement>);
  31896. /**
  31897. * Flags the audio engine in Locked state.
  31898. * This happens due to new browser policies preventing audio to autoplay.
  31899. */
  31900. lock(): void;
  31901. /**
  31902. * Unlocks the audio engine once a user action has been done on the dom.
  31903. * This is helpful to resume play once browser policies have been satisfied.
  31904. */
  31905. unlock(): void;
  31906. private _resumeAudioContext;
  31907. private _initializeAudioContext;
  31908. private _tryToRun;
  31909. private _triggerRunningState;
  31910. private _triggerSuspendedState;
  31911. private _displayMuteButton;
  31912. private _moveButtonToTopLeft;
  31913. private _onResize;
  31914. private _hideMuteButton;
  31915. /**
  31916. * Destroy and release the resources associated with the audio ccontext.
  31917. */
  31918. dispose(): void;
  31919. /**
  31920. * Gets the global volume sets on the master gain.
  31921. * @returns the global volume if set or -1 otherwise
  31922. */
  31923. getGlobalVolume(): number;
  31924. /**
  31925. * Sets the global volume of your experience (sets on the master gain).
  31926. * @param newVolume Defines the new global volume of the application
  31927. */
  31928. setGlobalVolume(newVolume: number): void;
  31929. /**
  31930. * Connect the audio engine to an audio analyser allowing some amazing
  31931. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31933. * @param analyser The analyser to connect to the engine
  31934. */
  31935. connectToAnalyser(analyser: Analyser): void;
  31936. }
  31937. }
  31938. declare module "babylonjs/Loading/loadingScreen" {
  31939. /**
  31940. * Interface used to present a loading screen while loading a scene
  31941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31942. */
  31943. export interface ILoadingScreen {
  31944. /**
  31945. * Function called to display the loading screen
  31946. */
  31947. displayLoadingUI: () => void;
  31948. /**
  31949. * Function called to hide the loading screen
  31950. */
  31951. hideLoadingUI: () => void;
  31952. /**
  31953. * Gets or sets the color to use for the background
  31954. */
  31955. loadingUIBackgroundColor: string;
  31956. /**
  31957. * Gets or sets the text to display while loading
  31958. */
  31959. loadingUIText: string;
  31960. }
  31961. /**
  31962. * Class used for the default loading screen
  31963. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31964. */
  31965. export class DefaultLoadingScreen implements ILoadingScreen {
  31966. private _renderingCanvas;
  31967. private _loadingText;
  31968. private _loadingDivBackgroundColor;
  31969. private _loadingDiv;
  31970. private _loadingTextDiv;
  31971. /** Gets or sets the logo url to use for the default loading screen */
  31972. static DefaultLogoUrl: string;
  31973. /** Gets or sets the spinner url to use for the default loading screen */
  31974. static DefaultSpinnerUrl: string;
  31975. /**
  31976. * Creates a new default loading screen
  31977. * @param _renderingCanvas defines the canvas used to render the scene
  31978. * @param _loadingText defines the default text to display
  31979. * @param _loadingDivBackgroundColor defines the default background color
  31980. */
  31981. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31982. /**
  31983. * Function called to display the loading screen
  31984. */
  31985. displayLoadingUI(): void;
  31986. /**
  31987. * Function called to hide the loading screen
  31988. */
  31989. hideLoadingUI(): void;
  31990. /**
  31991. * Gets or sets the text to display while loading
  31992. */
  31993. loadingUIText: string;
  31994. /**
  31995. * Gets or sets the color to use for the background
  31996. */
  31997. loadingUIBackgroundColor: string;
  31998. private _resizeLoadingUI;
  31999. }
  32000. }
  32001. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32002. /**
  32003. * Interface for any object that can request an animation frame
  32004. */
  32005. export interface ICustomAnimationFrameRequester {
  32006. /**
  32007. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32008. */
  32009. renderFunction?: Function;
  32010. /**
  32011. * Called to request the next frame to render to
  32012. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32013. */
  32014. requestAnimationFrame: Function;
  32015. /**
  32016. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32017. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32018. */
  32019. requestID?: number;
  32020. }
  32021. }
  32022. declare module "babylonjs/Misc/performanceMonitor" {
  32023. /**
  32024. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32025. */
  32026. export class PerformanceMonitor {
  32027. private _enabled;
  32028. private _rollingFrameTime;
  32029. private _lastFrameTimeMs;
  32030. /**
  32031. * constructor
  32032. * @param frameSampleSize The number of samples required to saturate the sliding window
  32033. */
  32034. constructor(frameSampleSize?: number);
  32035. /**
  32036. * Samples current frame
  32037. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32038. */
  32039. sampleFrame(timeMs?: number): void;
  32040. /**
  32041. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32042. */
  32043. readonly averageFrameTime: number;
  32044. /**
  32045. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32046. */
  32047. readonly averageFrameTimeVariance: number;
  32048. /**
  32049. * Returns the frame time of the most recent frame
  32050. */
  32051. readonly instantaneousFrameTime: number;
  32052. /**
  32053. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32054. */
  32055. readonly averageFPS: number;
  32056. /**
  32057. * Returns the average framerate in frames per second using the most recent frame time
  32058. */
  32059. readonly instantaneousFPS: number;
  32060. /**
  32061. * Returns true if enough samples have been taken to completely fill the sliding window
  32062. */
  32063. readonly isSaturated: boolean;
  32064. /**
  32065. * Enables contributions to the sliding window sample set
  32066. */
  32067. enable(): void;
  32068. /**
  32069. * Disables contributions to the sliding window sample set
  32070. * Samples will not be interpolated over the disabled period
  32071. */
  32072. disable(): void;
  32073. /**
  32074. * Returns true if sampling is enabled
  32075. */
  32076. readonly isEnabled: boolean;
  32077. /**
  32078. * Resets performance monitor
  32079. */
  32080. reset(): void;
  32081. }
  32082. /**
  32083. * RollingAverage
  32084. *
  32085. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32086. */
  32087. export class RollingAverage {
  32088. /**
  32089. * Current average
  32090. */
  32091. average: number;
  32092. /**
  32093. * Current variance
  32094. */
  32095. variance: number;
  32096. protected _samples: Array<number>;
  32097. protected _sampleCount: number;
  32098. protected _pos: number;
  32099. protected _m2: number;
  32100. /**
  32101. * constructor
  32102. * @param length The number of samples required to saturate the sliding window
  32103. */
  32104. constructor(length: number);
  32105. /**
  32106. * Adds a sample to the sample set
  32107. * @param v The sample value
  32108. */
  32109. add(v: number): void;
  32110. /**
  32111. * Returns previously added values or null if outside of history or outside the sliding window domain
  32112. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32113. * @return Value previously recorded with add() or null if outside of range
  32114. */
  32115. history(i: number): number;
  32116. /**
  32117. * Returns true if enough samples have been taken to completely fill the sliding window
  32118. * @return true if sample-set saturated
  32119. */
  32120. isSaturated(): boolean;
  32121. /**
  32122. * Resets the rolling average (equivalent to 0 samples taken so far)
  32123. */
  32124. reset(): void;
  32125. /**
  32126. * Wraps a value around the sample range boundaries
  32127. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32128. * @return Wrapped position in sample range
  32129. */
  32130. protected _wrapPosition(i: number): number;
  32131. }
  32132. }
  32133. declare module "babylonjs/Misc/perfCounter" {
  32134. /**
  32135. * This class is used to track a performance counter which is number based.
  32136. * The user has access to many properties which give statistics of different nature.
  32137. *
  32138. * The implementer can track two kinds of Performance Counter: time and count.
  32139. * 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.
  32140. * 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.
  32141. */
  32142. export class PerfCounter {
  32143. /**
  32144. * Gets or sets a global boolean to turn on and off all the counters
  32145. */
  32146. static Enabled: boolean;
  32147. /**
  32148. * Returns the smallest value ever
  32149. */
  32150. readonly min: number;
  32151. /**
  32152. * Returns the biggest value ever
  32153. */
  32154. readonly max: number;
  32155. /**
  32156. * Returns the average value since the performance counter is running
  32157. */
  32158. readonly average: number;
  32159. /**
  32160. * Returns the average value of the last second the counter was monitored
  32161. */
  32162. readonly lastSecAverage: number;
  32163. /**
  32164. * Returns the current value
  32165. */
  32166. readonly current: number;
  32167. /**
  32168. * Gets the accumulated total
  32169. */
  32170. readonly total: number;
  32171. /**
  32172. * Gets the total value count
  32173. */
  32174. readonly count: number;
  32175. /**
  32176. * Creates a new counter
  32177. */
  32178. constructor();
  32179. /**
  32180. * Call this method to start monitoring a new frame.
  32181. * 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.
  32182. */
  32183. fetchNewFrame(): void;
  32184. /**
  32185. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32186. * @param newCount the count value to add to the monitored count
  32187. * @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.
  32188. */
  32189. addCount(newCount: number, fetchResult: boolean): void;
  32190. /**
  32191. * Start monitoring this performance counter
  32192. */
  32193. beginMonitoring(): void;
  32194. /**
  32195. * Compute the time lapsed since the previous beginMonitoring() call.
  32196. * @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
  32197. */
  32198. endMonitoring(newFrame?: boolean): void;
  32199. private _fetchResult;
  32200. private _startMonitoringTime;
  32201. private _min;
  32202. private _max;
  32203. private _average;
  32204. private _current;
  32205. private _totalValueCount;
  32206. private _totalAccumulated;
  32207. private _lastSecAverage;
  32208. private _lastSecAccumulated;
  32209. private _lastSecTime;
  32210. private _lastSecValueCount;
  32211. }
  32212. }
  32213. declare module "babylonjs/Engines/engine" {
  32214. import { Observable } from "babylonjs/Misc/observable";
  32215. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32216. import { Scene } from "babylonjs/scene";
  32217. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32218. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32219. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32220. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32221. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32222. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32223. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32224. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32225. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32226. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32227. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32228. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32229. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32230. import { Material } from "babylonjs/Materials/material";
  32231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32232. /**
  32233. * Defines the interface used by display changed events
  32234. */
  32235. export interface IDisplayChangedEventArgs {
  32236. /** Gets the vrDisplay object (if any) */
  32237. vrDisplay: Nullable<any>;
  32238. /** Gets a boolean indicating if webVR is supported */
  32239. vrSupported: boolean;
  32240. }
  32241. /**
  32242. * Defines the interface used by objects containing a viewport (like a camera)
  32243. */
  32244. interface IViewportOwnerLike {
  32245. /**
  32246. * Gets or sets the viewport
  32247. */
  32248. viewport: IViewportLike;
  32249. }
  32250. /**
  32251. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32252. */
  32253. export class Engine extends ThinEngine {
  32254. /** Defines that alpha blending is disabled */
  32255. static readonly ALPHA_DISABLE: number;
  32256. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32257. static readonly ALPHA_ADD: number;
  32258. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32259. static readonly ALPHA_COMBINE: number;
  32260. /** Defines that alpha blending to DEST - SRC * DEST */
  32261. static readonly ALPHA_SUBTRACT: number;
  32262. /** Defines that alpha blending to SRC * DEST */
  32263. static readonly ALPHA_MULTIPLY: number;
  32264. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32265. static readonly ALPHA_MAXIMIZED: number;
  32266. /** Defines that alpha blending to SRC + DEST */
  32267. static readonly ALPHA_ONEONE: number;
  32268. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32269. static readonly ALPHA_PREMULTIPLIED: number;
  32270. /**
  32271. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32272. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32273. */
  32274. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32275. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32276. static readonly ALPHA_INTERPOLATE: number;
  32277. /**
  32278. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32279. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32280. */
  32281. static readonly ALPHA_SCREENMODE: number;
  32282. /** Defines that the ressource is not delayed*/
  32283. static readonly DELAYLOADSTATE_NONE: number;
  32284. /** Defines that the ressource was successfully delay loaded */
  32285. static readonly DELAYLOADSTATE_LOADED: number;
  32286. /** Defines that the ressource is currently delay loading */
  32287. static readonly DELAYLOADSTATE_LOADING: number;
  32288. /** Defines that the ressource is delayed and has not started loading */
  32289. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32290. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32291. static readonly NEVER: number;
  32292. /** 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 */
  32293. static readonly ALWAYS: number;
  32294. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32295. static readonly LESS: number;
  32296. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32297. static readonly EQUAL: number;
  32298. /** 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 */
  32299. static readonly LEQUAL: number;
  32300. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32301. static readonly GREATER: number;
  32302. /** 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 */
  32303. static readonly GEQUAL: number;
  32304. /** 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 */
  32305. static readonly NOTEQUAL: number;
  32306. /** Passed to stencilOperation to specify that stencil value must be kept */
  32307. static readonly KEEP: number;
  32308. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32309. static readonly REPLACE: number;
  32310. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32311. static readonly INCR: number;
  32312. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32313. static readonly DECR: number;
  32314. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32315. static readonly INVERT: number;
  32316. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32317. static readonly INCR_WRAP: number;
  32318. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32319. static readonly DECR_WRAP: number;
  32320. /** Texture is not repeating outside of 0..1 UVs */
  32321. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32322. /** Texture is repeating outside of 0..1 UVs */
  32323. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32324. /** Texture is repeating and mirrored */
  32325. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32326. /** ALPHA */
  32327. static readonly TEXTUREFORMAT_ALPHA: number;
  32328. /** LUMINANCE */
  32329. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32330. /** LUMINANCE_ALPHA */
  32331. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32332. /** RGB */
  32333. static readonly TEXTUREFORMAT_RGB: number;
  32334. /** RGBA */
  32335. static readonly TEXTUREFORMAT_RGBA: number;
  32336. /** RED */
  32337. static readonly TEXTUREFORMAT_RED: number;
  32338. /** RED (2nd reference) */
  32339. static readonly TEXTUREFORMAT_R: number;
  32340. /** RG */
  32341. static readonly TEXTUREFORMAT_RG: number;
  32342. /** RED_INTEGER */
  32343. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32344. /** RED_INTEGER (2nd reference) */
  32345. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32346. /** RG_INTEGER */
  32347. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32348. /** RGB_INTEGER */
  32349. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32350. /** RGBA_INTEGER */
  32351. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32352. /** UNSIGNED_BYTE */
  32353. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32354. /** UNSIGNED_BYTE (2nd reference) */
  32355. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32356. /** FLOAT */
  32357. static readonly TEXTURETYPE_FLOAT: number;
  32358. /** HALF_FLOAT */
  32359. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32360. /** BYTE */
  32361. static readonly TEXTURETYPE_BYTE: number;
  32362. /** SHORT */
  32363. static readonly TEXTURETYPE_SHORT: number;
  32364. /** UNSIGNED_SHORT */
  32365. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32366. /** INT */
  32367. static readonly TEXTURETYPE_INT: number;
  32368. /** UNSIGNED_INT */
  32369. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32370. /** UNSIGNED_SHORT_4_4_4_4 */
  32371. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32372. /** UNSIGNED_SHORT_5_5_5_1 */
  32373. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32374. /** UNSIGNED_SHORT_5_6_5 */
  32375. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32376. /** UNSIGNED_INT_2_10_10_10_REV */
  32377. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32378. /** UNSIGNED_INT_24_8 */
  32379. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32380. /** UNSIGNED_INT_10F_11F_11F_REV */
  32381. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32382. /** UNSIGNED_INT_5_9_9_9_REV */
  32383. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32384. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32385. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32386. /** nearest is mag = nearest and min = nearest and mip = linear */
  32387. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32388. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32389. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32390. /** Trilinear is mag = linear and min = linear and mip = linear */
  32391. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32392. /** nearest is mag = nearest and min = nearest and mip = linear */
  32393. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32394. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32395. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32396. /** Trilinear is mag = linear and min = linear and mip = linear */
  32397. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32398. /** mag = nearest and min = nearest and mip = nearest */
  32399. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32400. /** mag = nearest and min = linear and mip = nearest */
  32401. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32402. /** mag = nearest and min = linear and mip = linear */
  32403. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32404. /** mag = nearest and min = linear and mip = none */
  32405. static readonly TEXTURE_NEAREST_LINEAR: number;
  32406. /** mag = nearest and min = nearest and mip = none */
  32407. static readonly TEXTURE_NEAREST_NEAREST: number;
  32408. /** mag = linear and min = nearest and mip = nearest */
  32409. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32410. /** mag = linear and min = nearest and mip = linear */
  32411. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32412. /** mag = linear and min = linear and mip = none */
  32413. static readonly TEXTURE_LINEAR_LINEAR: number;
  32414. /** mag = linear and min = nearest and mip = none */
  32415. static readonly TEXTURE_LINEAR_NEAREST: number;
  32416. /** Explicit coordinates mode */
  32417. static readonly TEXTURE_EXPLICIT_MODE: number;
  32418. /** Spherical coordinates mode */
  32419. static readonly TEXTURE_SPHERICAL_MODE: number;
  32420. /** Planar coordinates mode */
  32421. static readonly TEXTURE_PLANAR_MODE: number;
  32422. /** Cubic coordinates mode */
  32423. static readonly TEXTURE_CUBIC_MODE: number;
  32424. /** Projection coordinates mode */
  32425. static readonly TEXTURE_PROJECTION_MODE: number;
  32426. /** Skybox coordinates mode */
  32427. static readonly TEXTURE_SKYBOX_MODE: number;
  32428. /** Inverse Cubic coordinates mode */
  32429. static readonly TEXTURE_INVCUBIC_MODE: number;
  32430. /** Equirectangular coordinates mode */
  32431. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32432. /** Equirectangular Fixed coordinates mode */
  32433. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32434. /** Equirectangular Fixed Mirrored coordinates mode */
  32435. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32436. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32437. static readonly SCALEMODE_FLOOR: number;
  32438. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32439. static readonly SCALEMODE_NEAREST: number;
  32440. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32441. static readonly SCALEMODE_CEILING: number;
  32442. /**
  32443. * Returns the current npm package of the sdk
  32444. */
  32445. static readonly NpmPackage: string;
  32446. /**
  32447. * Returns the current version of the framework
  32448. */
  32449. static readonly Version: string;
  32450. /** Gets the list of created engines */
  32451. static readonly Instances: Engine[];
  32452. /**
  32453. * Gets the latest created engine
  32454. */
  32455. static readonly LastCreatedEngine: Nullable<Engine>;
  32456. /**
  32457. * Gets the latest created scene
  32458. */
  32459. static readonly LastCreatedScene: Nullable<Scene>;
  32460. /**
  32461. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32462. * @param flag defines which part of the materials must be marked as dirty
  32463. * @param predicate defines a predicate used to filter which materials should be affected
  32464. */
  32465. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32466. /**
  32467. * Method called to create the default loading screen.
  32468. * This can be overriden in your own app.
  32469. * @param canvas The rendering canvas element
  32470. * @returns The loading screen
  32471. */
  32472. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32473. /**
  32474. * Method called to create the default rescale post process on each engine.
  32475. */
  32476. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32477. /**
  32478. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32479. **/
  32480. enableOfflineSupport: boolean;
  32481. /**
  32482. * 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)
  32483. **/
  32484. disableManifestCheck: boolean;
  32485. /**
  32486. * Gets the list of created scenes
  32487. */
  32488. scenes: Scene[];
  32489. /**
  32490. * Event raised when a new scene is created
  32491. */
  32492. onNewSceneAddedObservable: Observable<Scene>;
  32493. /**
  32494. * Gets the list of created postprocesses
  32495. */
  32496. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32497. /**
  32498. * Gets a boolean indicating if the pointer is currently locked
  32499. */
  32500. isPointerLock: boolean;
  32501. /**
  32502. * Observable event triggered each time the rendering canvas is resized
  32503. */
  32504. onResizeObservable: Observable<Engine>;
  32505. /**
  32506. * Observable event triggered each time the canvas loses focus
  32507. */
  32508. onCanvasBlurObservable: Observable<Engine>;
  32509. /**
  32510. * Observable event triggered each time the canvas gains focus
  32511. */
  32512. onCanvasFocusObservable: Observable<Engine>;
  32513. /**
  32514. * Observable event triggered each time the canvas receives pointerout event
  32515. */
  32516. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32517. /**
  32518. * Observable raised when the engine begins a new frame
  32519. */
  32520. onBeginFrameObservable: Observable<Engine>;
  32521. /**
  32522. * If set, will be used to request the next animation frame for the render loop
  32523. */
  32524. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32525. /**
  32526. * Observable raised when the engine ends the current frame
  32527. */
  32528. onEndFrameObservable: Observable<Engine>;
  32529. /**
  32530. * Observable raised when the engine is about to compile a shader
  32531. */
  32532. onBeforeShaderCompilationObservable: Observable<Engine>;
  32533. /**
  32534. * Observable raised when the engine has jsut compiled a shader
  32535. */
  32536. onAfterShaderCompilationObservable: Observable<Engine>;
  32537. /**
  32538. * Gets the audio engine
  32539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32540. * @ignorenaming
  32541. */
  32542. static audioEngine: IAudioEngine;
  32543. /**
  32544. * Default AudioEngine factory responsible of creating the Audio Engine.
  32545. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32546. */
  32547. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32548. /**
  32549. * Default offline support factory responsible of creating a tool used to store data locally.
  32550. * By default, this will create a Database object if the workload has been embedded.
  32551. */
  32552. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32553. private _loadingScreen;
  32554. private _pointerLockRequested;
  32555. private _dummyFramebuffer;
  32556. private _rescalePostProcess;
  32557. /** @hidden */
  32558. protected _alphaMode: number;
  32559. /** @hidden */
  32560. protected _alphaEquation: number;
  32561. private _deterministicLockstep;
  32562. private _lockstepMaxSteps;
  32563. protected readonly _supportsHardwareTextureRescaling: boolean;
  32564. private _fps;
  32565. private _deltaTime;
  32566. /** @hidden */
  32567. _drawCalls: PerfCounter;
  32568. /**
  32569. * Turn this value on if you want to pause FPS computation when in background
  32570. */
  32571. disablePerformanceMonitorInBackground: boolean;
  32572. private _performanceMonitor;
  32573. /**
  32574. * Gets the performance monitor attached to this engine
  32575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32576. */
  32577. readonly performanceMonitor: PerformanceMonitor;
  32578. private _onFocus;
  32579. private _onBlur;
  32580. private _onCanvasPointerOut;
  32581. private _onCanvasBlur;
  32582. private _onCanvasFocus;
  32583. private _onFullscreenChange;
  32584. private _onPointerLockChange;
  32585. /**
  32586. * Gets the HTML element used to attach event listeners
  32587. * @returns a HTML element
  32588. */
  32589. getInputElement(): Nullable<HTMLElement>;
  32590. /**
  32591. * Creates a new engine
  32592. * @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
  32593. * @param antialias defines enable antialiasing (default: false)
  32594. * @param options defines further options to be sent to the getContext() function
  32595. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32596. */
  32597. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32598. /**
  32599. * Gets current aspect ratio
  32600. * @param viewportOwner defines the camera to use to get the aspect ratio
  32601. * @param useScreen defines if screen size must be used (or the current render target if any)
  32602. * @returns a number defining the aspect ratio
  32603. */
  32604. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32605. /**
  32606. * Gets current screen aspect ratio
  32607. * @returns a number defining the aspect ratio
  32608. */
  32609. getScreenAspectRatio(): number;
  32610. /**
  32611. * Gets host document
  32612. * @returns the host document object
  32613. */
  32614. getHostDocument(): Document;
  32615. /**
  32616. * Gets the client rect of the HTML canvas attached with the current webGL context
  32617. * @returns a client rectanglee
  32618. */
  32619. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32620. /**
  32621. * Gets the client rect of the HTML element used for events
  32622. * @returns a client rectanglee
  32623. */
  32624. getInputElementClientRect(): Nullable<ClientRect>;
  32625. /**
  32626. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32628. * @returns true if engine is in deterministic lock step mode
  32629. */
  32630. isDeterministicLockStep(): boolean;
  32631. /**
  32632. * Gets the max steps when engine is running in deterministic lock step
  32633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32634. * @returns the max steps
  32635. */
  32636. getLockstepMaxSteps(): number;
  32637. /**
  32638. * Force the mipmap generation for the given render target texture
  32639. * @param texture defines the render target texture to use
  32640. */
  32641. generateMipMapsForCubemap(texture: InternalTexture): void;
  32642. /** States */
  32643. /**
  32644. * Set various states to the webGL context
  32645. * @param culling defines backface culling state
  32646. * @param zOffset defines the value to apply to zOffset (0 by default)
  32647. * @param force defines if states must be applied even if cache is up to date
  32648. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32649. */
  32650. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32651. /**
  32652. * Set the z offset to apply to current rendering
  32653. * @param value defines the offset to apply
  32654. */
  32655. setZOffset(value: number): void;
  32656. /**
  32657. * Gets the current value of the zOffset
  32658. * @returns the current zOffset state
  32659. */
  32660. getZOffset(): number;
  32661. /**
  32662. * Enable or disable depth buffering
  32663. * @param enable defines the state to set
  32664. */
  32665. setDepthBuffer(enable: boolean): void;
  32666. /**
  32667. * Gets a boolean indicating if depth writing is enabled
  32668. * @returns the current depth writing state
  32669. */
  32670. getDepthWrite(): boolean;
  32671. /**
  32672. * Enable or disable depth writing
  32673. * @param enable defines the state to set
  32674. */
  32675. setDepthWrite(enable: boolean): void;
  32676. /**
  32677. * Enable or disable color writing
  32678. * @param enable defines the state to set
  32679. */
  32680. setColorWrite(enable: boolean): void;
  32681. /**
  32682. * Gets a boolean indicating if color writing is enabled
  32683. * @returns the current color writing state
  32684. */
  32685. getColorWrite(): boolean;
  32686. /**
  32687. * Sets alpha constants used by some alpha blending modes
  32688. * @param r defines the red component
  32689. * @param g defines the green component
  32690. * @param b defines the blue component
  32691. * @param a defines the alpha component
  32692. */
  32693. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32694. /**
  32695. * Sets the current alpha mode
  32696. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32697. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32698. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32699. */
  32700. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32701. /**
  32702. * Gets the current alpha mode
  32703. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32704. * @returns the current alpha mode
  32705. */
  32706. getAlphaMode(): number;
  32707. /**
  32708. * Sets the current alpha equation
  32709. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32710. */
  32711. setAlphaEquation(equation: number): void;
  32712. /**
  32713. * Gets the current alpha equation.
  32714. * @returns the current alpha equation
  32715. */
  32716. getAlphaEquation(): number;
  32717. /**
  32718. * Gets a boolean indicating if stencil buffer is enabled
  32719. * @returns the current stencil buffer state
  32720. */
  32721. getStencilBuffer(): boolean;
  32722. /**
  32723. * Enable or disable the stencil buffer
  32724. * @param enable defines if the stencil buffer must be enabled or disabled
  32725. */
  32726. setStencilBuffer(enable: boolean): void;
  32727. /**
  32728. * Gets the current stencil mask
  32729. * @returns a number defining the new stencil mask to use
  32730. */
  32731. getStencilMask(): number;
  32732. /**
  32733. * Sets the current stencil mask
  32734. * @param mask defines the new stencil mask to use
  32735. */
  32736. setStencilMask(mask: number): void;
  32737. /**
  32738. * Gets the current stencil function
  32739. * @returns a number defining the stencil function to use
  32740. */
  32741. getStencilFunction(): number;
  32742. /**
  32743. * Gets the current stencil reference value
  32744. * @returns a number defining the stencil reference value to use
  32745. */
  32746. getStencilFunctionReference(): number;
  32747. /**
  32748. * Gets the current stencil mask
  32749. * @returns a number defining the stencil mask to use
  32750. */
  32751. getStencilFunctionMask(): number;
  32752. /**
  32753. * Sets the current stencil function
  32754. * @param stencilFunc defines the new stencil function to use
  32755. */
  32756. setStencilFunction(stencilFunc: number): void;
  32757. /**
  32758. * Sets the current stencil reference
  32759. * @param reference defines the new stencil reference to use
  32760. */
  32761. setStencilFunctionReference(reference: number): void;
  32762. /**
  32763. * Sets the current stencil mask
  32764. * @param mask defines the new stencil mask to use
  32765. */
  32766. setStencilFunctionMask(mask: number): void;
  32767. /**
  32768. * Gets the current stencil operation when stencil fails
  32769. * @returns a number defining stencil operation to use when stencil fails
  32770. */
  32771. getStencilOperationFail(): number;
  32772. /**
  32773. * Gets the current stencil operation when depth fails
  32774. * @returns a number defining stencil operation to use when depth fails
  32775. */
  32776. getStencilOperationDepthFail(): number;
  32777. /**
  32778. * Gets the current stencil operation when stencil passes
  32779. * @returns a number defining stencil operation to use when stencil passes
  32780. */
  32781. getStencilOperationPass(): number;
  32782. /**
  32783. * Sets the stencil operation to use when stencil fails
  32784. * @param operation defines the stencil operation to use when stencil fails
  32785. */
  32786. setStencilOperationFail(operation: number): void;
  32787. /**
  32788. * Sets the stencil operation to use when depth fails
  32789. * @param operation defines the stencil operation to use when depth fails
  32790. */
  32791. setStencilOperationDepthFail(operation: number): void;
  32792. /**
  32793. * Sets the stencil operation to use when stencil passes
  32794. * @param operation defines the stencil operation to use when stencil passes
  32795. */
  32796. setStencilOperationPass(operation: number): void;
  32797. /**
  32798. * Sets a boolean indicating if the dithering state is enabled or disabled
  32799. * @param value defines the dithering state
  32800. */
  32801. setDitheringState(value: boolean): void;
  32802. /**
  32803. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32804. * @param value defines the rasterizer state
  32805. */
  32806. setRasterizerState(value: boolean): void;
  32807. /**
  32808. * Gets the current depth function
  32809. * @returns a number defining the depth function
  32810. */
  32811. getDepthFunction(): Nullable<number>;
  32812. /**
  32813. * Sets the current depth function
  32814. * @param depthFunc defines the function to use
  32815. */
  32816. setDepthFunction(depthFunc: number): void;
  32817. /**
  32818. * Sets the current depth function to GREATER
  32819. */
  32820. setDepthFunctionToGreater(): void;
  32821. /**
  32822. * Sets the current depth function to GEQUAL
  32823. */
  32824. setDepthFunctionToGreaterOrEqual(): void;
  32825. /**
  32826. * Sets the current depth function to LESS
  32827. */
  32828. setDepthFunctionToLess(): void;
  32829. /**
  32830. * Sets the current depth function to LEQUAL
  32831. */
  32832. setDepthFunctionToLessOrEqual(): void;
  32833. private _cachedStencilBuffer;
  32834. private _cachedStencilFunction;
  32835. private _cachedStencilMask;
  32836. private _cachedStencilOperationPass;
  32837. private _cachedStencilOperationFail;
  32838. private _cachedStencilOperationDepthFail;
  32839. private _cachedStencilReference;
  32840. /**
  32841. * Caches the the state of the stencil buffer
  32842. */
  32843. cacheStencilState(): void;
  32844. /**
  32845. * Restores the state of the stencil buffer
  32846. */
  32847. restoreStencilState(): void;
  32848. /**
  32849. * Directly set the WebGL Viewport
  32850. * @param x defines the x coordinate of the viewport (in screen space)
  32851. * @param y defines the y coordinate of the viewport (in screen space)
  32852. * @param width defines the width of the viewport (in screen space)
  32853. * @param height defines the height of the viewport (in screen space)
  32854. * @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
  32855. */
  32856. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32857. /**
  32858. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32859. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32860. * @param y defines the y-coordinate of the corner of the clear rectangle
  32861. * @param width defines the width of the clear rectangle
  32862. * @param height defines the height of the clear rectangle
  32863. * @param clearColor defines the clear color
  32864. */
  32865. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32866. /**
  32867. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32868. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32869. * @param y defines the y-coordinate of the corner of the clear rectangle
  32870. * @param width defines the width of the clear rectangle
  32871. * @param height defines the height of the clear rectangle
  32872. */
  32873. enableScissor(x: number, y: number, width: number, height: number): void;
  32874. /**
  32875. * Disable previously set scissor test rectangle
  32876. */
  32877. disableScissor(): void;
  32878. protected _reportDrawCall(): void;
  32879. /**
  32880. * Initializes a webVR display and starts listening to display change events
  32881. * The onVRDisplayChangedObservable will be notified upon these changes
  32882. * @returns The onVRDisplayChangedObservable
  32883. */
  32884. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32885. /** @hidden */
  32886. _prepareVRComponent(): void;
  32887. /** @hidden */
  32888. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32889. /** @hidden */
  32890. _submitVRFrame(): void;
  32891. /**
  32892. * Call this function to leave webVR mode
  32893. * Will do nothing if webVR is not supported or if there is no webVR device
  32894. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32895. */
  32896. disableVR(): void;
  32897. /**
  32898. * Gets a boolean indicating that the system is in VR mode and is presenting
  32899. * @returns true if VR mode is engaged
  32900. */
  32901. isVRPresenting(): boolean;
  32902. /** @hidden */
  32903. _requestVRFrame(): void;
  32904. /** @hidden */
  32905. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32906. /**
  32907. * Gets the source code of the vertex shader associated with a specific webGL program
  32908. * @param program defines the program to use
  32909. * @returns a string containing the source code of the vertex shader associated with the program
  32910. */
  32911. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32912. /**
  32913. * Gets the source code of the fragment shader associated with a specific webGL program
  32914. * @param program defines the program to use
  32915. * @returns a string containing the source code of the fragment shader associated with the program
  32916. */
  32917. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32918. /**
  32919. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32920. * @param x defines the x coordinate of the rectangle where pixels must be read
  32921. * @param y defines the y coordinate of the rectangle where pixels must be read
  32922. * @param width defines the width of the rectangle where pixels must be read
  32923. * @param height defines the height of the rectangle where pixels must be read
  32924. * @returns a Uint8Array containing RGBA colors
  32925. */
  32926. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32927. /**
  32928. * Sets a depth stencil texture from a render target to the according uniform.
  32929. * @param channel The texture channel
  32930. * @param uniform The uniform to set
  32931. * @param texture The render target texture containing the depth stencil texture to apply
  32932. */
  32933. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32934. /**
  32935. * Sets a texture to the webGL context from a postprocess
  32936. * @param channel defines the channel to use
  32937. * @param postProcess defines the source postprocess
  32938. */
  32939. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32940. /**
  32941. * Binds the output of the passed in post process to the texture channel specified
  32942. * @param channel The channel the texture should be bound to
  32943. * @param postProcess The post process which's output should be bound
  32944. */
  32945. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32946. /** @hidden */
  32947. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32948. protected _rebuildBuffers(): void;
  32949. /** @hidden */
  32950. _renderFrame(): void;
  32951. _renderLoop(): void;
  32952. /** @hidden */
  32953. _renderViews(): boolean;
  32954. /**
  32955. * Toggle full screen mode
  32956. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32957. */
  32958. switchFullscreen(requestPointerLock: boolean): void;
  32959. /**
  32960. * Enters full screen mode
  32961. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32962. */
  32963. enterFullscreen(requestPointerLock: boolean): void;
  32964. /**
  32965. * Exits full screen mode
  32966. */
  32967. exitFullscreen(): void;
  32968. /**
  32969. * Enters Pointerlock mode
  32970. */
  32971. enterPointerlock(): void;
  32972. /**
  32973. * Exits Pointerlock mode
  32974. */
  32975. exitPointerlock(): void;
  32976. /**
  32977. * Begin a new frame
  32978. */
  32979. beginFrame(): void;
  32980. /**
  32981. * Enf the current frame
  32982. */
  32983. endFrame(): void;
  32984. resize(): void;
  32985. /**
  32986. * Set the compressed texture format to use, based on the formats you have, and the formats
  32987. * supported by the hardware / browser.
  32988. *
  32989. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32990. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32991. * to API arguments needed to compressed textures. This puts the burden on the container
  32992. * generator to house the arcane code for determining these for current & future formats.
  32993. *
  32994. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32995. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32996. *
  32997. * Note: The result of this call is not taken into account when a texture is base64.
  32998. *
  32999. * @param formatsAvailable defines the list of those format families you have created
  33000. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33001. *
  33002. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33003. * @returns The extension selected.
  33004. */
  33005. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33006. /**
  33007. * Force a specific size of the canvas
  33008. * @param width defines the new canvas' width
  33009. * @param height defines the new canvas' height
  33010. */
  33011. setSize(width: number, height: number): void;
  33012. /**
  33013. * Updates a dynamic vertex buffer.
  33014. * @param vertexBuffer the vertex buffer to update
  33015. * @param data the data used to update the vertex buffer
  33016. * @param byteOffset the byte offset of the data
  33017. * @param byteLength the byte length of the data
  33018. */
  33019. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33020. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33021. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33022. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33023. _releaseTexture(texture: InternalTexture): void;
  33024. /**
  33025. * @hidden
  33026. * Rescales a texture
  33027. * @param source input texutre
  33028. * @param destination destination texture
  33029. * @param scene scene to use to render the resize
  33030. * @param internalFormat format to use when resizing
  33031. * @param onComplete callback to be called when resize has completed
  33032. */
  33033. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33034. /**
  33035. * Gets the current framerate
  33036. * @returns a number representing the framerate
  33037. */
  33038. getFps(): number;
  33039. /**
  33040. * Gets the time spent between current and previous frame
  33041. * @returns a number representing the delta time in ms
  33042. */
  33043. getDeltaTime(): number;
  33044. private _measureFps;
  33045. /** @hidden */
  33046. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33047. /**
  33048. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33049. * @param renderTarget The render target to set the frame buffer for
  33050. */
  33051. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33052. /**
  33053. * Update a dynamic index buffer
  33054. * @param indexBuffer defines the target index buffer
  33055. * @param indices defines the data to update
  33056. * @param offset defines the offset in the target index buffer where update should start
  33057. */
  33058. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33059. /**
  33060. * Updates the sample count of a render target texture
  33061. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33062. * @param texture defines the texture to update
  33063. * @param samples defines the sample count to set
  33064. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33065. */
  33066. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33067. /**
  33068. * Updates a depth texture Comparison Mode and Function.
  33069. * If the comparison Function is equal to 0, the mode will be set to none.
  33070. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33071. * @param texture The texture to set the comparison function for
  33072. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33073. */
  33074. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33075. /**
  33076. * Creates a webGL buffer to use with instanciation
  33077. * @param capacity defines the size of the buffer
  33078. * @returns the webGL buffer
  33079. */
  33080. createInstancesBuffer(capacity: number): DataBuffer;
  33081. /**
  33082. * Delete a webGL buffer used with instanciation
  33083. * @param buffer defines the webGL buffer to delete
  33084. */
  33085. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33086. /** @hidden */
  33087. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33088. dispose(): void;
  33089. private _disableTouchAction;
  33090. /**
  33091. * Display the loading screen
  33092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33093. */
  33094. displayLoadingUI(): void;
  33095. /**
  33096. * Hide the loading screen
  33097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33098. */
  33099. hideLoadingUI(): void;
  33100. /**
  33101. * Gets the current loading screen object
  33102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33103. */
  33104. /**
  33105. * Sets the current loading screen object
  33106. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33107. */
  33108. loadingScreen: ILoadingScreen;
  33109. /**
  33110. * Sets the current loading screen text
  33111. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33112. */
  33113. loadingUIText: string;
  33114. /**
  33115. * Sets the current loading screen background color
  33116. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33117. */
  33118. loadingUIBackgroundColor: string;
  33119. /** Pointerlock and fullscreen */
  33120. /**
  33121. * Ask the browser to promote the current element to pointerlock mode
  33122. * @param element defines the DOM element to promote
  33123. */
  33124. static _RequestPointerlock(element: HTMLElement): void;
  33125. /**
  33126. * Asks the browser to exit pointerlock mode
  33127. */
  33128. static _ExitPointerlock(): void;
  33129. /**
  33130. * Ask the browser to promote the current element to fullscreen rendering mode
  33131. * @param element defines the DOM element to promote
  33132. */
  33133. static _RequestFullscreen(element: HTMLElement): void;
  33134. /**
  33135. * Asks the browser to exit fullscreen mode
  33136. */
  33137. static _ExitFullscreen(): void;
  33138. }
  33139. }
  33140. declare module "babylonjs/Engines/engineStore" {
  33141. import { Nullable } from "babylonjs/types";
  33142. import { Engine } from "babylonjs/Engines/engine";
  33143. import { Scene } from "babylonjs/scene";
  33144. /**
  33145. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33146. * during the life time of the application.
  33147. */
  33148. export class EngineStore {
  33149. /** Gets the list of created engines */
  33150. static Instances: import("babylonjs/Engines/engine").Engine[];
  33151. /** @hidden */
  33152. static _LastCreatedScene: Nullable<Scene>;
  33153. /**
  33154. * Gets the latest created engine
  33155. */
  33156. static readonly LastCreatedEngine: Nullable<Engine>;
  33157. /**
  33158. * Gets the latest created scene
  33159. */
  33160. static readonly LastCreatedScene: Nullable<Scene>;
  33161. /**
  33162. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33163. * @ignorenaming
  33164. */
  33165. static UseFallbackTexture: boolean;
  33166. /**
  33167. * Texture content used if a texture cannot loaded
  33168. * @ignorenaming
  33169. */
  33170. static FallbackTexture: string;
  33171. }
  33172. }
  33173. declare module "babylonjs/Misc/promise" {
  33174. /**
  33175. * Helper class that provides a small promise polyfill
  33176. */
  33177. export class PromisePolyfill {
  33178. /**
  33179. * Static function used to check if the polyfill is required
  33180. * If this is the case then the function will inject the polyfill to window.Promise
  33181. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33182. */
  33183. static Apply(force?: boolean): void;
  33184. }
  33185. }
  33186. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33187. /**
  33188. * Interface for screenshot methods with describe argument called `size` as object with options
  33189. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33190. */
  33191. export interface IScreenshotSize {
  33192. /**
  33193. * number in pixels for canvas height
  33194. */
  33195. height?: number;
  33196. /**
  33197. * multiplier allowing render at a higher or lower resolution
  33198. * If value is defined then height and width will be ignored and taken from camera
  33199. */
  33200. precision?: number;
  33201. /**
  33202. * number in pixels for canvas width
  33203. */
  33204. width?: number;
  33205. }
  33206. }
  33207. declare module "babylonjs/Misc/tools" {
  33208. import { Nullable, float } from "babylonjs/types";
  33209. import { DomManagement } from "babylonjs/Misc/domManagement";
  33210. import { WebRequest } from "babylonjs/Misc/webRequest";
  33211. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33212. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33213. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33214. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33215. import { Camera } from "babylonjs/Cameras/camera";
  33216. import { Engine } from "babylonjs/Engines/engine";
  33217. interface IColor4Like {
  33218. r: float;
  33219. g: float;
  33220. b: float;
  33221. a: float;
  33222. }
  33223. /**
  33224. * Class containing a set of static utilities functions
  33225. */
  33226. export class Tools {
  33227. /**
  33228. * Gets or sets the base URL to use to load assets
  33229. */
  33230. static BaseUrl: string;
  33231. /**
  33232. * Enable/Disable Custom HTTP Request Headers globally.
  33233. * default = false
  33234. * @see CustomRequestHeaders
  33235. */
  33236. static UseCustomRequestHeaders: boolean;
  33237. /**
  33238. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33239. * i.e. when loading files, where the server/service expects an Authorization header
  33240. */
  33241. static CustomRequestHeaders: {
  33242. [key: string]: string;
  33243. };
  33244. /**
  33245. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33246. */
  33247. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33248. /**
  33249. * Default behaviour for cors in the application.
  33250. * It can be a string if the expected behavior is identical in the entire app.
  33251. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33252. */
  33253. static CorsBehavior: string | ((url: string | string[]) => string);
  33254. /**
  33255. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33256. * @ignorenaming
  33257. */
  33258. static UseFallbackTexture: boolean;
  33259. /**
  33260. * Use this object to register external classes like custom textures or material
  33261. * to allow the laoders to instantiate them
  33262. */
  33263. static RegisteredExternalClasses: {
  33264. [key: string]: Object;
  33265. };
  33266. /**
  33267. * Texture content used if a texture cannot loaded
  33268. * @ignorenaming
  33269. */
  33270. static fallbackTexture: string;
  33271. /**
  33272. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33273. * @param u defines the coordinate on X axis
  33274. * @param v defines the coordinate on Y axis
  33275. * @param width defines the width of the source data
  33276. * @param height defines the height of the source data
  33277. * @param pixels defines the source byte array
  33278. * @param color defines the output color
  33279. */
  33280. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33281. /**
  33282. * Interpolates between a and b via alpha
  33283. * @param a The lower value (returned when alpha = 0)
  33284. * @param b The upper value (returned when alpha = 1)
  33285. * @param alpha The interpolation-factor
  33286. * @return The mixed value
  33287. */
  33288. static Mix(a: number, b: number, alpha: number): number;
  33289. /**
  33290. * Tries to instantiate a new object from a given class name
  33291. * @param className defines the class name to instantiate
  33292. * @returns the new object or null if the system was not able to do the instantiation
  33293. */
  33294. static Instantiate(className: string): any;
  33295. /**
  33296. * Provides a slice function that will work even on IE
  33297. * @param data defines the array to slice
  33298. * @param start defines the start of the data (optional)
  33299. * @param end defines the end of the data (optional)
  33300. * @returns the new sliced array
  33301. */
  33302. static Slice<T>(data: T, start?: number, end?: number): T;
  33303. /**
  33304. * Polyfill for setImmediate
  33305. * @param action defines the action to execute after the current execution block
  33306. */
  33307. static SetImmediate(action: () => void): void;
  33308. /**
  33309. * Function indicating if a number is an exponent of 2
  33310. * @param value defines the value to test
  33311. * @returns true if the value is an exponent of 2
  33312. */
  33313. static IsExponentOfTwo(value: number): boolean;
  33314. private static _tmpFloatArray;
  33315. /**
  33316. * Returns the nearest 32-bit single precision float representation of a Number
  33317. * @param value A Number. If the parameter is of a different type, it will get converted
  33318. * to a number or to NaN if it cannot be converted
  33319. * @returns number
  33320. */
  33321. static FloatRound(value: number): number;
  33322. /**
  33323. * Extracts the filename from a path
  33324. * @param path defines the path to use
  33325. * @returns the filename
  33326. */
  33327. static GetFilename(path: string): string;
  33328. /**
  33329. * Extracts the "folder" part of a path (everything before the filename).
  33330. * @param uri The URI to extract the info from
  33331. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33332. * @returns The "folder" part of the path
  33333. */
  33334. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33335. /**
  33336. * Extracts text content from a DOM element hierarchy
  33337. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33338. */
  33339. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33340. /**
  33341. * Convert an angle in radians to degrees
  33342. * @param angle defines the angle to convert
  33343. * @returns the angle in degrees
  33344. */
  33345. static ToDegrees(angle: number): number;
  33346. /**
  33347. * Convert an angle in degrees to radians
  33348. * @param angle defines the angle to convert
  33349. * @returns the angle in radians
  33350. */
  33351. static ToRadians(angle: number): number;
  33352. /**
  33353. * Returns an array if obj is not an array
  33354. * @param obj defines the object to evaluate as an array
  33355. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33356. * @returns either obj directly if obj is an array or a new array containing obj
  33357. */
  33358. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33359. /**
  33360. * Gets the pointer prefix to use
  33361. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33362. */
  33363. static GetPointerPrefix(): string;
  33364. /**
  33365. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33366. * @param url define the url we are trying
  33367. * @param element define the dom element where to configure the cors policy
  33368. */
  33369. static SetCorsBehavior(url: string | string[], element: {
  33370. crossOrigin: string | null;
  33371. }): void;
  33372. /**
  33373. * Removes unwanted characters from an url
  33374. * @param url defines the url to clean
  33375. * @returns the cleaned url
  33376. */
  33377. static CleanUrl(url: string): string;
  33378. /**
  33379. * Gets or sets a function used to pre-process url before using them to load assets
  33380. */
  33381. static PreprocessUrl: (url: string) => string;
  33382. /**
  33383. * Loads an image as an HTMLImageElement.
  33384. * @param input url string, ArrayBuffer, or Blob to load
  33385. * @param onLoad callback called when the image successfully loads
  33386. * @param onError callback called when the image fails to load
  33387. * @param offlineProvider offline provider for caching
  33388. * @param mimeType optional mime type
  33389. * @returns the HTMLImageElement of the loaded image
  33390. */
  33391. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33392. /**
  33393. * Loads a file from a url
  33394. * @param url url string, ArrayBuffer, or Blob to load
  33395. * @param onSuccess callback called when the file successfully loads
  33396. * @param onProgress callback called while file is loading (if the server supports this mode)
  33397. * @param offlineProvider defines the offline provider for caching
  33398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33399. * @param onError callback called when the file fails to load
  33400. * @returns a file request object
  33401. */
  33402. 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;
  33403. /**
  33404. * Loads a file from a url
  33405. * @param url the file url to load
  33406. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33407. */
  33408. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33409. /**
  33410. * Load a script (identified by an url). When the url returns, the
  33411. * content of this file is added into a new script element, attached to the DOM (body element)
  33412. * @param scriptUrl defines the url of the script to laod
  33413. * @param onSuccess defines the callback called when the script is loaded
  33414. * @param onError defines the callback to call if an error occurs
  33415. * @param scriptId defines the id of the script element
  33416. */
  33417. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33418. /**
  33419. * Load an asynchronous script (identified by an url). When the url returns, the
  33420. * content of this file is added into a new script element, attached to the DOM (body element)
  33421. * @param scriptUrl defines the url of the script to laod
  33422. * @param scriptId defines the id of the script element
  33423. * @returns a promise request object
  33424. */
  33425. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33426. /**
  33427. * Loads a file from a blob
  33428. * @param fileToLoad defines the blob to use
  33429. * @param callback defines the callback to call when data is loaded
  33430. * @param progressCallback defines the callback to call during loading process
  33431. * @returns a file request object
  33432. */
  33433. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33434. /**
  33435. * Reads a file from a File object
  33436. * @param file defines the file to load
  33437. * @param onSuccess defines the callback to call when data is loaded
  33438. * @param onProgress defines the callback to call during loading process
  33439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33440. * @param onError defines the callback to call when an error occurs
  33441. * @returns a file request object
  33442. */
  33443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33444. /**
  33445. * Creates a data url from a given string content
  33446. * @param content defines the content to convert
  33447. * @returns the new data url link
  33448. */
  33449. static FileAsURL(content: string): string;
  33450. /**
  33451. * Format the given number to a specific decimal format
  33452. * @param value defines the number to format
  33453. * @param decimals defines the number of decimals to use
  33454. * @returns the formatted string
  33455. */
  33456. static Format(value: number, decimals?: number): string;
  33457. /**
  33458. * Tries to copy an object by duplicating every property
  33459. * @param source defines the source object
  33460. * @param destination defines the target object
  33461. * @param doNotCopyList defines a list of properties to avoid
  33462. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33463. */
  33464. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33465. /**
  33466. * Gets a boolean indicating if the given object has no own property
  33467. * @param obj defines the object to test
  33468. * @returns true if object has no own property
  33469. */
  33470. static IsEmpty(obj: any): boolean;
  33471. /**
  33472. * Function used to register events at window level
  33473. * @param windowElement defines the Window object to use
  33474. * @param events defines the events to register
  33475. */
  33476. static RegisterTopRootEvents(windowElement: Window, events: {
  33477. name: string;
  33478. handler: Nullable<(e: FocusEvent) => any>;
  33479. }[]): void;
  33480. /**
  33481. * Function used to unregister events from window level
  33482. * @param windowElement defines the Window object to use
  33483. * @param events defines the events to unregister
  33484. */
  33485. static UnregisterTopRootEvents(windowElement: Window, events: {
  33486. name: string;
  33487. handler: Nullable<(e: FocusEvent) => any>;
  33488. }[]): void;
  33489. /**
  33490. * @ignore
  33491. */
  33492. static _ScreenshotCanvas: HTMLCanvasElement;
  33493. /**
  33494. * Dumps the current bound framebuffer
  33495. * @param width defines the rendering width
  33496. * @param height defines the rendering height
  33497. * @param engine defines the hosting engine
  33498. * @param successCallback defines the callback triggered once the data are available
  33499. * @param mimeType defines the mime type of the result
  33500. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33501. */
  33502. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33503. /**
  33504. * Converts the canvas data to blob.
  33505. * This acts as a polyfill for browsers not supporting the to blob function.
  33506. * @param canvas Defines the canvas to extract the data from
  33507. * @param successCallback Defines the callback triggered once the data are available
  33508. * @param mimeType Defines the mime type of the result
  33509. */
  33510. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33511. /**
  33512. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33513. * @param successCallback defines the callback triggered once the data are available
  33514. * @param mimeType defines the mime type of the result
  33515. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33516. */
  33517. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33518. /**
  33519. * Downloads a blob in the browser
  33520. * @param blob defines the blob to download
  33521. * @param fileName defines the name of the downloaded file
  33522. */
  33523. static Download(blob: Blob, fileName: string): void;
  33524. /**
  33525. * Captures a screenshot of the current rendering
  33526. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33527. * @param engine defines the rendering engine
  33528. * @param camera defines the source camera
  33529. * @param size This parameter can be set to a single number or to an object with the
  33530. * following (optional) properties: precision, width, height. If a single number is passed,
  33531. * it will be used for both width and height. If an object is passed, the screenshot size
  33532. * will be derived from the parameters. The precision property is a multiplier allowing
  33533. * rendering at a higher or lower resolution
  33534. * @param successCallback defines the callback receives a single parameter which contains the
  33535. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33536. * src parameter of an <img> to display it
  33537. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33538. * Check your browser for supported MIME types
  33539. */
  33540. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33541. /**
  33542. * Captures a screenshot of the current rendering
  33543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33544. * @param engine defines the rendering engine
  33545. * @param camera defines the source camera
  33546. * @param size This parameter can be set to a single number or to an object with the
  33547. * following (optional) properties: precision, width, height. If a single number is passed,
  33548. * it will be used for both width and height. If an object is passed, the screenshot size
  33549. * will be derived from the parameters. The precision property is a multiplier allowing
  33550. * rendering at a higher or lower resolution
  33551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33552. * Check your browser for supported MIME types
  33553. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33554. * to the src parameter of an <img> to display it
  33555. */
  33556. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33557. /**
  33558. * Generates an image screenshot from the specified camera.
  33559. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33560. * @param engine The engine to use for rendering
  33561. * @param camera The camera to use for rendering
  33562. * @param size This parameter can be set to a single number or to an object with the
  33563. * following (optional) properties: precision, width, height. If a single number is passed,
  33564. * it will be used for both width and height. If an object is passed, the screenshot size
  33565. * will be derived from the parameters. The precision property is a multiplier allowing
  33566. * rendering at a higher or lower resolution
  33567. * @param successCallback The callback receives a single parameter which contains the
  33568. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33569. * src parameter of an <img> to display it
  33570. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33571. * Check your browser for supported MIME types
  33572. * @param samples Texture samples (default: 1)
  33573. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33574. * @param fileName A name for for the downloaded file.
  33575. */
  33576. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33577. /**
  33578. * Generates an image screenshot from the specified camera.
  33579. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33580. * @param engine The engine to use for rendering
  33581. * @param camera The camera to use for rendering
  33582. * @param size This parameter can be set to a single number or to an object with the
  33583. * following (optional) properties: precision, width, height. If a single number is passed,
  33584. * it will be used for both width and height. If an object is passed, the screenshot size
  33585. * will be derived from the parameters. The precision property is a multiplier allowing
  33586. * rendering at a higher or lower resolution
  33587. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33588. * Check your browser for supported MIME types
  33589. * @param samples Texture samples (default: 1)
  33590. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33591. * @param fileName A name for for the downloaded file.
  33592. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33593. * to the src parameter of an <img> to display it
  33594. */
  33595. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33596. /**
  33597. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33598. * Be aware Math.random() could cause collisions, but:
  33599. * "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"
  33600. * @returns a pseudo random id
  33601. */
  33602. static RandomId(): string;
  33603. /**
  33604. * Test if the given uri is a base64 string
  33605. * @param uri The uri to test
  33606. * @return True if the uri is a base64 string or false otherwise
  33607. */
  33608. static IsBase64(uri: string): boolean;
  33609. /**
  33610. * Decode the given base64 uri.
  33611. * @param uri The uri to decode
  33612. * @return The decoded base64 data.
  33613. */
  33614. static DecodeBase64(uri: string): ArrayBuffer;
  33615. /**
  33616. * Gets the absolute url.
  33617. * @param url the input url
  33618. * @return the absolute url
  33619. */
  33620. static GetAbsoluteUrl(url: string): string;
  33621. /**
  33622. * No log
  33623. */
  33624. static readonly NoneLogLevel: number;
  33625. /**
  33626. * Only message logs
  33627. */
  33628. static readonly MessageLogLevel: number;
  33629. /**
  33630. * Only warning logs
  33631. */
  33632. static readonly WarningLogLevel: number;
  33633. /**
  33634. * Only error logs
  33635. */
  33636. static readonly ErrorLogLevel: number;
  33637. /**
  33638. * All logs
  33639. */
  33640. static readonly AllLogLevel: number;
  33641. /**
  33642. * Gets a value indicating the number of loading errors
  33643. * @ignorenaming
  33644. */
  33645. static readonly errorsCount: number;
  33646. /**
  33647. * Callback called when a new log is added
  33648. */
  33649. static OnNewCacheEntry: (entry: string) => void;
  33650. /**
  33651. * Log a message to the console
  33652. * @param message defines the message to log
  33653. */
  33654. static Log(message: string): void;
  33655. /**
  33656. * Write a warning message to the console
  33657. * @param message defines the message to log
  33658. */
  33659. static Warn(message: string): void;
  33660. /**
  33661. * Write an error message to the console
  33662. * @param message defines the message to log
  33663. */
  33664. static Error(message: string): void;
  33665. /**
  33666. * Gets current log cache (list of logs)
  33667. */
  33668. static readonly LogCache: string;
  33669. /**
  33670. * Clears the log cache
  33671. */
  33672. static ClearLogCache(): void;
  33673. /**
  33674. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33675. */
  33676. static LogLevels: number;
  33677. /**
  33678. * Checks if the window object exists
  33679. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33680. */
  33681. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33682. /**
  33683. * No performance log
  33684. */
  33685. static readonly PerformanceNoneLogLevel: number;
  33686. /**
  33687. * Use user marks to log performance
  33688. */
  33689. static readonly PerformanceUserMarkLogLevel: number;
  33690. /**
  33691. * Log performance to the console
  33692. */
  33693. static readonly PerformanceConsoleLogLevel: number;
  33694. private static _performance;
  33695. /**
  33696. * Sets the current performance log level
  33697. */
  33698. static PerformanceLogLevel: number;
  33699. private static _StartPerformanceCounterDisabled;
  33700. private static _EndPerformanceCounterDisabled;
  33701. private static _StartUserMark;
  33702. private static _EndUserMark;
  33703. private static _StartPerformanceConsole;
  33704. private static _EndPerformanceConsole;
  33705. /**
  33706. * Starts a performance counter
  33707. */
  33708. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33709. /**
  33710. * Ends a specific performance coutner
  33711. */
  33712. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33713. /**
  33714. * Gets either window.performance.now() if supported or Date.now() else
  33715. */
  33716. static readonly Now: number;
  33717. /**
  33718. * This method will return the name of the class used to create the instance of the given object.
  33719. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33720. * @param object the object to get the class name from
  33721. * @param isType defines if the object is actually a type
  33722. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33723. */
  33724. static GetClassName(object: any, isType?: boolean): string;
  33725. /**
  33726. * Gets the first element of an array satisfying a given predicate
  33727. * @param array defines the array to browse
  33728. * @param predicate defines the predicate to use
  33729. * @returns null if not found or the element
  33730. */
  33731. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33732. /**
  33733. * This method will return the name of the full name of the class, including its owning module (if any).
  33734. * 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).
  33735. * @param object the object to get the class name from
  33736. * @param isType defines if the object is actually a type
  33737. * @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.
  33738. * @ignorenaming
  33739. */
  33740. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33741. /**
  33742. * Returns a promise that resolves after the given amount of time.
  33743. * @param delay Number of milliseconds to delay
  33744. * @returns Promise that resolves after the given amount of time
  33745. */
  33746. static DelayAsync(delay: number): Promise<void>;
  33747. }
  33748. /**
  33749. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33750. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33751. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33752. * @param name The name of the class, case should be preserved
  33753. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33754. */
  33755. export function className(name: string, module?: string): (target: Object) => void;
  33756. /**
  33757. * An implementation of a loop for asynchronous functions.
  33758. */
  33759. export class AsyncLoop {
  33760. /**
  33761. * Defines the number of iterations for the loop
  33762. */
  33763. iterations: number;
  33764. /**
  33765. * Defines the current index of the loop.
  33766. */
  33767. index: number;
  33768. private _done;
  33769. private _fn;
  33770. private _successCallback;
  33771. /**
  33772. * Constructor.
  33773. * @param iterations the number of iterations.
  33774. * @param func the function to run each iteration
  33775. * @param successCallback the callback that will be called upon succesful execution
  33776. * @param offset starting offset.
  33777. */
  33778. constructor(
  33779. /**
  33780. * Defines the number of iterations for the loop
  33781. */
  33782. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33783. /**
  33784. * Execute the next iteration. Must be called after the last iteration was finished.
  33785. */
  33786. executeNext(): void;
  33787. /**
  33788. * Break the loop and run the success callback.
  33789. */
  33790. breakLoop(): void;
  33791. /**
  33792. * Create and run an async loop.
  33793. * @param iterations the number of iterations.
  33794. * @param fn the function to run each iteration
  33795. * @param successCallback the callback that will be called upon succesful execution
  33796. * @param offset starting offset.
  33797. * @returns the created async loop object
  33798. */
  33799. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33800. /**
  33801. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33802. * @param iterations total number of iterations
  33803. * @param syncedIterations number of synchronous iterations in each async iteration.
  33804. * @param fn the function to call each iteration.
  33805. * @param callback a success call back that will be called when iterating stops.
  33806. * @param breakFunction a break condition (optional)
  33807. * @param timeout timeout settings for the setTimeout function. default - 0.
  33808. * @returns the created async loop object
  33809. */
  33810. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33811. }
  33812. }
  33813. declare module "babylonjs/Misc/stringDictionary" {
  33814. import { Nullable } from "babylonjs/types";
  33815. /**
  33816. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33817. * The underlying implementation relies on an associative array to ensure the best performances.
  33818. * The value can be anything including 'null' but except 'undefined'
  33819. */
  33820. export class StringDictionary<T> {
  33821. /**
  33822. * This will clear this dictionary and copy the content from the 'source' one.
  33823. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33824. * @param source the dictionary to take the content from and copy to this dictionary
  33825. */
  33826. copyFrom(source: StringDictionary<T>): void;
  33827. /**
  33828. * Get a value based from its key
  33829. * @param key the given key to get the matching value from
  33830. * @return the value if found, otherwise undefined is returned
  33831. */
  33832. get(key: string): T | undefined;
  33833. /**
  33834. * Get a value from its key or add it if it doesn't exist.
  33835. * This method will ensure you that a given key/data will be present in the dictionary.
  33836. * @param key the given key to get the matching value from
  33837. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33838. * The factory will only be invoked if there's no data for the given key.
  33839. * @return the value corresponding to the key.
  33840. */
  33841. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33842. /**
  33843. * Get a value from its key if present in the dictionary otherwise add it
  33844. * @param key the key to get the value from
  33845. * @param val if there's no such key/value pair in the dictionary add it with this value
  33846. * @return the value corresponding to the key
  33847. */
  33848. getOrAdd(key: string, val: T): T;
  33849. /**
  33850. * Check if there's a given key in the dictionary
  33851. * @param key the key to check for
  33852. * @return true if the key is present, false otherwise
  33853. */
  33854. contains(key: string): boolean;
  33855. /**
  33856. * Add a new key and its corresponding value
  33857. * @param key the key to add
  33858. * @param value the value corresponding to the key
  33859. * @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
  33860. */
  33861. add(key: string, value: T): boolean;
  33862. /**
  33863. * Update a specific value associated to a key
  33864. * @param key defines the key to use
  33865. * @param value defines the value to store
  33866. * @returns true if the value was updated (or false if the key was not found)
  33867. */
  33868. set(key: string, value: T): boolean;
  33869. /**
  33870. * Get the element of the given key and remove it from the dictionary
  33871. * @param key defines the key to search
  33872. * @returns the value associated with the key or null if not found
  33873. */
  33874. getAndRemove(key: string): Nullable<T>;
  33875. /**
  33876. * Remove a key/value from the dictionary.
  33877. * @param key the key to remove
  33878. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33879. */
  33880. remove(key: string): boolean;
  33881. /**
  33882. * Clear the whole content of the dictionary
  33883. */
  33884. clear(): void;
  33885. /**
  33886. * Gets the current count
  33887. */
  33888. readonly count: number;
  33889. /**
  33890. * Execute a callback on each key/val of the dictionary.
  33891. * Note that you can remove any element in this dictionary in the callback implementation
  33892. * @param callback the callback to execute on a given key/value pair
  33893. */
  33894. forEach(callback: (key: string, val: T) => void): void;
  33895. /**
  33896. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33897. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33898. * Note that you can remove any element in this dictionary in the callback implementation
  33899. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33900. * @returns the first item
  33901. */
  33902. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33903. private _count;
  33904. private _data;
  33905. }
  33906. }
  33907. declare module "babylonjs/Collisions/collisionCoordinator" {
  33908. import { Nullable } from "babylonjs/types";
  33909. import { Scene } from "babylonjs/scene";
  33910. import { Vector3 } from "babylonjs/Maths/math.vector";
  33911. import { Collider } from "babylonjs/Collisions/collider";
  33912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33913. /** @hidden */
  33914. export interface ICollisionCoordinator {
  33915. createCollider(): Collider;
  33916. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33917. init(scene: Scene): void;
  33918. }
  33919. /** @hidden */
  33920. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33921. private _scene;
  33922. private _scaledPosition;
  33923. private _scaledVelocity;
  33924. private _finalPosition;
  33925. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33926. createCollider(): Collider;
  33927. init(scene: Scene): void;
  33928. private _collideWithWorld;
  33929. }
  33930. }
  33931. declare module "babylonjs/Inputs/scene.inputManager" {
  33932. import { Nullable } from "babylonjs/types";
  33933. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33934. import { Vector2 } from "babylonjs/Maths/math.vector";
  33935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33936. import { Scene } from "babylonjs/scene";
  33937. /**
  33938. * Class used to manage all inputs for the scene.
  33939. */
  33940. export class InputManager {
  33941. /** The distance in pixel that you have to move to prevent some events */
  33942. static DragMovementThreshold: number;
  33943. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33944. static LongPressDelay: number;
  33945. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33946. static DoubleClickDelay: number;
  33947. /** If you need to check double click without raising a single click at first click, enable this flag */
  33948. static ExclusiveDoubleClickMode: boolean;
  33949. private _wheelEventName;
  33950. private _onPointerMove;
  33951. private _onPointerDown;
  33952. private _onPointerUp;
  33953. private _initClickEvent;
  33954. private _initActionManager;
  33955. private _delayedSimpleClick;
  33956. private _delayedSimpleClickTimeout;
  33957. private _previousDelayedSimpleClickTimeout;
  33958. private _meshPickProceed;
  33959. private _previousButtonPressed;
  33960. private _currentPickResult;
  33961. private _previousPickResult;
  33962. private _totalPointersPressed;
  33963. private _doubleClickOccured;
  33964. private _pointerOverMesh;
  33965. private _pickedDownMesh;
  33966. private _pickedUpMesh;
  33967. private _pointerX;
  33968. private _pointerY;
  33969. private _unTranslatedPointerX;
  33970. private _unTranslatedPointerY;
  33971. private _startingPointerPosition;
  33972. private _previousStartingPointerPosition;
  33973. private _startingPointerTime;
  33974. private _previousStartingPointerTime;
  33975. private _pointerCaptures;
  33976. private _onKeyDown;
  33977. private _onKeyUp;
  33978. private _onCanvasFocusObserver;
  33979. private _onCanvasBlurObserver;
  33980. private _scene;
  33981. /**
  33982. * Creates a new InputManager
  33983. * @param scene defines the hosting scene
  33984. */
  33985. constructor(scene: Scene);
  33986. /**
  33987. * Gets the mesh that is currently under the pointer
  33988. */
  33989. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33990. /**
  33991. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33992. */
  33993. readonly unTranslatedPointer: Vector2;
  33994. /**
  33995. * Gets or sets the current on-screen X position of the pointer
  33996. */
  33997. pointerX: number;
  33998. /**
  33999. * Gets or sets the current on-screen Y position of the pointer
  34000. */
  34001. pointerY: number;
  34002. private _updatePointerPosition;
  34003. private _processPointerMove;
  34004. private _setRayOnPointerInfo;
  34005. private _checkPrePointerObservable;
  34006. /**
  34007. * Use this method to simulate a pointer move on a mesh
  34008. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34009. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34010. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34011. */
  34012. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34013. /**
  34014. * Use this method to simulate a pointer down on a mesh
  34015. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34016. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34017. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34018. */
  34019. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34020. private _processPointerDown;
  34021. /** @hidden */
  34022. _isPointerSwiping(): boolean;
  34023. /**
  34024. * Use this method to simulate a pointer up on a mesh
  34025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34028. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34029. */
  34030. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34031. private _processPointerUp;
  34032. /**
  34033. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34034. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34035. * @returns true if the pointer was captured
  34036. */
  34037. isPointerCaptured(pointerId?: number): boolean;
  34038. /**
  34039. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34040. * @param attachUp defines if you want to attach events to pointerup
  34041. * @param attachDown defines if you want to attach events to pointerdown
  34042. * @param attachMove defines if you want to attach events to pointermove
  34043. */
  34044. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34045. /**
  34046. * Detaches all event handlers
  34047. */
  34048. detachControl(): void;
  34049. /**
  34050. * Force the value of meshUnderPointer
  34051. * @param mesh defines the mesh to use
  34052. */
  34053. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34054. /**
  34055. * Gets the mesh under the pointer
  34056. * @returns a Mesh or null if no mesh is under the pointer
  34057. */
  34058. getPointerOverMesh(): Nullable<AbstractMesh>;
  34059. }
  34060. }
  34061. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34062. /**
  34063. * Helper class used to generate session unique ID
  34064. */
  34065. export class UniqueIdGenerator {
  34066. private static _UniqueIdCounter;
  34067. /**
  34068. * Gets an unique (relatively to the current scene) Id
  34069. */
  34070. static readonly UniqueId: number;
  34071. }
  34072. }
  34073. declare module "babylonjs/Animations/animationGroup" {
  34074. import { Animatable } from "babylonjs/Animations/animatable";
  34075. import { Animation } from "babylonjs/Animations/animation";
  34076. import { Scene, IDisposable } from "babylonjs/scene";
  34077. import { Observable } from "babylonjs/Misc/observable";
  34078. import { Nullable } from "babylonjs/types";
  34079. import "babylonjs/Animations/animatable";
  34080. /**
  34081. * This class defines the direct association between an animation and a target
  34082. */
  34083. export class TargetedAnimation {
  34084. /**
  34085. * Animation to perform
  34086. */
  34087. animation: Animation;
  34088. /**
  34089. * Target to animate
  34090. */
  34091. target: any;
  34092. /**
  34093. * Serialize the object
  34094. * @returns the JSON object representing the current entity
  34095. */
  34096. serialize(): any;
  34097. }
  34098. /**
  34099. * Use this class to create coordinated animations on multiple targets
  34100. */
  34101. export class AnimationGroup implements IDisposable {
  34102. /** The name of the animation group */
  34103. name: string;
  34104. private _scene;
  34105. private _targetedAnimations;
  34106. private _animatables;
  34107. private _from;
  34108. private _to;
  34109. private _isStarted;
  34110. private _isPaused;
  34111. private _speedRatio;
  34112. private _loopAnimation;
  34113. /**
  34114. * Gets or sets the unique id of the node
  34115. */
  34116. uniqueId: number;
  34117. /**
  34118. * This observable will notify when one animation have ended
  34119. */
  34120. onAnimationEndObservable: Observable<TargetedAnimation>;
  34121. /**
  34122. * Observer raised when one animation loops
  34123. */
  34124. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34125. /**
  34126. * Observer raised when all animations have looped
  34127. */
  34128. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34129. /**
  34130. * This observable will notify when all animations have ended.
  34131. */
  34132. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34133. /**
  34134. * This observable will notify when all animations have paused.
  34135. */
  34136. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34137. /**
  34138. * This observable will notify when all animations are playing.
  34139. */
  34140. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34141. /**
  34142. * Gets the first frame
  34143. */
  34144. readonly from: number;
  34145. /**
  34146. * Gets the last frame
  34147. */
  34148. readonly to: number;
  34149. /**
  34150. * Define if the animations are started
  34151. */
  34152. readonly isStarted: boolean;
  34153. /**
  34154. * Gets a value indicating that the current group is playing
  34155. */
  34156. readonly isPlaying: boolean;
  34157. /**
  34158. * Gets or sets the speed ratio to use for all animations
  34159. */
  34160. /**
  34161. * Gets or sets the speed ratio to use for all animations
  34162. */
  34163. speedRatio: number;
  34164. /**
  34165. * Gets or sets if all animations should loop or not
  34166. */
  34167. loopAnimation: boolean;
  34168. /**
  34169. * Gets the targeted animations for this animation group
  34170. */
  34171. readonly targetedAnimations: Array<TargetedAnimation>;
  34172. /**
  34173. * returning the list of animatables controlled by this animation group.
  34174. */
  34175. readonly animatables: Array<Animatable>;
  34176. /**
  34177. * Instantiates a new Animation Group.
  34178. * This helps managing several animations at once.
  34179. * @see http://doc.babylonjs.com/how_to/group
  34180. * @param name Defines the name of the group
  34181. * @param scene Defines the scene the group belongs to
  34182. */
  34183. constructor(
  34184. /** The name of the animation group */
  34185. name: string, scene?: Nullable<Scene>);
  34186. /**
  34187. * Add an animation (with its target) in the group
  34188. * @param animation defines the animation we want to add
  34189. * @param target defines the target of the animation
  34190. * @returns the TargetedAnimation object
  34191. */
  34192. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34193. /**
  34194. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34195. * It can add constant keys at begin or end
  34196. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34197. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34198. * @returns the animation group
  34199. */
  34200. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34201. private _animationLoopCount;
  34202. private _animationLoopFlags;
  34203. private _processLoop;
  34204. /**
  34205. * Start all animations on given targets
  34206. * @param loop defines if animations must loop
  34207. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34208. * @param from defines the from key (optional)
  34209. * @param to defines the to key (optional)
  34210. * @returns the current animation group
  34211. */
  34212. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34213. /**
  34214. * Pause all animations
  34215. * @returns the animation group
  34216. */
  34217. pause(): AnimationGroup;
  34218. /**
  34219. * Play all animations to initial state
  34220. * This function will start() the animations if they were not started or will restart() them if they were paused
  34221. * @param loop defines if animations must loop
  34222. * @returns the animation group
  34223. */
  34224. play(loop?: boolean): AnimationGroup;
  34225. /**
  34226. * Reset all animations to initial state
  34227. * @returns the animation group
  34228. */
  34229. reset(): AnimationGroup;
  34230. /**
  34231. * Restart animations from key 0
  34232. * @returns the animation group
  34233. */
  34234. restart(): AnimationGroup;
  34235. /**
  34236. * Stop all animations
  34237. * @returns the animation group
  34238. */
  34239. stop(): AnimationGroup;
  34240. /**
  34241. * Set animation weight for all animatables
  34242. * @param weight defines the weight to use
  34243. * @return the animationGroup
  34244. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34245. */
  34246. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34247. /**
  34248. * Synchronize and normalize all animatables with a source animatable
  34249. * @param root defines the root animatable to synchronize with
  34250. * @return the animationGroup
  34251. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34252. */
  34253. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34254. /**
  34255. * Goes to a specific frame in this animation group
  34256. * @param frame the frame number to go to
  34257. * @return the animationGroup
  34258. */
  34259. goToFrame(frame: number): AnimationGroup;
  34260. /**
  34261. * Dispose all associated resources
  34262. */
  34263. dispose(): void;
  34264. private _checkAnimationGroupEnded;
  34265. /**
  34266. * Clone the current animation group and returns a copy
  34267. * @param newName defines the name of the new group
  34268. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34269. * @returns the new aniamtion group
  34270. */
  34271. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34272. /**
  34273. * Serializes the animationGroup to an object
  34274. * @returns Serialized object
  34275. */
  34276. serialize(): any;
  34277. /**
  34278. * Returns a new AnimationGroup object parsed from the source provided.
  34279. * @param parsedAnimationGroup defines the source
  34280. * @param scene defines the scene that will receive the animationGroup
  34281. * @returns a new AnimationGroup
  34282. */
  34283. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34284. /**
  34285. * Returns the string "AnimationGroup"
  34286. * @returns "AnimationGroup"
  34287. */
  34288. getClassName(): string;
  34289. /**
  34290. * Creates a detailled string about the object
  34291. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34292. * @returns a string representing the object
  34293. */
  34294. toString(fullDetails?: boolean): string;
  34295. }
  34296. }
  34297. declare module "babylonjs/scene" {
  34298. import { Nullable } from "babylonjs/types";
  34299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34300. import { Observable } from "babylonjs/Misc/observable";
  34301. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34302. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34303. import { Geometry } from "babylonjs/Meshes/geometry";
  34304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34307. import { Mesh } from "babylonjs/Meshes/mesh";
  34308. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34309. import { Bone } from "babylonjs/Bones/bone";
  34310. import { Skeleton } from "babylonjs/Bones/skeleton";
  34311. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34312. import { Camera } from "babylonjs/Cameras/camera";
  34313. import { AbstractScene } from "babylonjs/abstractScene";
  34314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34316. import { Material } from "babylonjs/Materials/material";
  34317. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34318. import { Effect } from "babylonjs/Materials/effect";
  34319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34320. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34321. import { Light } from "babylonjs/Lights/light";
  34322. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34323. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34324. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34325. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34326. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34327. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34328. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34329. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34330. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34331. import { Engine } from "babylonjs/Engines/engine";
  34332. import { Node } from "babylonjs/node";
  34333. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34334. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34335. import { WebRequest } from "babylonjs/Misc/webRequest";
  34336. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34337. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34338. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34339. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34340. import { Plane } from "babylonjs/Maths/math.plane";
  34341. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34342. import { Ray } from "babylonjs/Culling/ray";
  34343. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34344. import { Animation } from "babylonjs/Animations/animation";
  34345. import { Animatable } from "babylonjs/Animations/animatable";
  34346. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34347. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34348. import { Collider } from "babylonjs/Collisions/collider";
  34349. /**
  34350. * Define an interface for all classes that will hold resources
  34351. */
  34352. export interface IDisposable {
  34353. /**
  34354. * Releases all held resources
  34355. */
  34356. dispose(): void;
  34357. }
  34358. /** Interface defining initialization parameters for Scene class */
  34359. export interface SceneOptions {
  34360. /**
  34361. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34362. * It will improve performance when the number of geometries becomes important.
  34363. */
  34364. useGeometryUniqueIdsMap?: boolean;
  34365. /**
  34366. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34367. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34368. */
  34369. useMaterialMeshMap?: boolean;
  34370. /**
  34371. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34372. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34373. */
  34374. useClonedMeshhMap?: boolean;
  34375. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34376. virtual?: boolean;
  34377. }
  34378. /**
  34379. * Represents a scene to be rendered by the engine.
  34380. * @see http://doc.babylonjs.com/features/scene
  34381. */
  34382. export class Scene extends AbstractScene implements IAnimatable {
  34383. /** The fog is deactivated */
  34384. static readonly FOGMODE_NONE: number;
  34385. /** The fog density is following an exponential function */
  34386. static readonly FOGMODE_EXP: number;
  34387. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34388. static readonly FOGMODE_EXP2: number;
  34389. /** The fog density is following a linear function. */
  34390. static readonly FOGMODE_LINEAR: number;
  34391. /**
  34392. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34393. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34394. */
  34395. static MinDeltaTime: number;
  34396. /**
  34397. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34398. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34399. */
  34400. static MaxDeltaTime: number;
  34401. /**
  34402. * Factory used to create the default material.
  34403. * @param name The name of the material to create
  34404. * @param scene The scene to create the material for
  34405. * @returns The default material
  34406. */
  34407. static DefaultMaterialFactory(scene: Scene): Material;
  34408. /**
  34409. * Factory used to create the a collision coordinator.
  34410. * @returns The collision coordinator
  34411. */
  34412. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34413. /** @hidden */
  34414. _inputManager: InputManager;
  34415. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34416. cameraToUseForPointers: Nullable<Camera>;
  34417. /** @hidden */
  34418. readonly _isScene: boolean;
  34419. /**
  34420. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34421. */
  34422. autoClear: boolean;
  34423. /**
  34424. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34425. */
  34426. autoClearDepthAndStencil: boolean;
  34427. /**
  34428. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34429. */
  34430. clearColor: Color4;
  34431. /**
  34432. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34433. */
  34434. ambientColor: Color3;
  34435. /**
  34436. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34437. * It should only be one of the following (if not the default embedded one):
  34438. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34439. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34440. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34441. * The material properties need to be setup according to the type of texture in use.
  34442. */
  34443. environmentBRDFTexture: BaseTexture;
  34444. /** @hidden */
  34445. protected _environmentTexture: Nullable<BaseTexture>;
  34446. /**
  34447. * Texture used in all pbr material as the reflection texture.
  34448. * As in the majority of the scene they are the same (exception for multi room and so on),
  34449. * this is easier to reference from here than from all the materials.
  34450. */
  34451. /**
  34452. * Texture used in all pbr material as the reflection texture.
  34453. * As in the majority of the scene they are the same (exception for multi room and so on),
  34454. * this is easier to set here than in all the materials.
  34455. */
  34456. environmentTexture: Nullable<BaseTexture>;
  34457. /** @hidden */
  34458. protected _environmentIntensity: number;
  34459. /**
  34460. * Intensity of the environment in all pbr material.
  34461. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34462. * As in the majority of the scene they are the same (exception for multi room and so on),
  34463. * this is easier to reference from here than from all the materials.
  34464. */
  34465. /**
  34466. * Intensity of the environment in all pbr material.
  34467. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34468. * As in the majority of the scene they are the same (exception for multi room and so on),
  34469. * this is easier to set here than in all the materials.
  34470. */
  34471. environmentIntensity: number;
  34472. /** @hidden */
  34473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34474. /**
  34475. * Default image processing configuration used either in the rendering
  34476. * Forward main pass or through the imageProcessingPostProcess if present.
  34477. * As in the majority of the scene they are the same (exception for multi camera),
  34478. * this is easier to reference from here than from all the materials and post process.
  34479. *
  34480. * No setter as we it is a shared configuration, you can set the values instead.
  34481. */
  34482. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34483. private _forceWireframe;
  34484. /**
  34485. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34486. */
  34487. forceWireframe: boolean;
  34488. private _forcePointsCloud;
  34489. /**
  34490. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34491. */
  34492. forcePointsCloud: boolean;
  34493. /**
  34494. * Gets or sets the active clipplane 1
  34495. */
  34496. clipPlane: Nullable<Plane>;
  34497. /**
  34498. * Gets or sets the active clipplane 2
  34499. */
  34500. clipPlane2: Nullable<Plane>;
  34501. /**
  34502. * Gets or sets the active clipplane 3
  34503. */
  34504. clipPlane3: Nullable<Plane>;
  34505. /**
  34506. * Gets or sets the active clipplane 4
  34507. */
  34508. clipPlane4: Nullable<Plane>;
  34509. /**
  34510. * Gets or sets a boolean indicating if animations are enabled
  34511. */
  34512. animationsEnabled: boolean;
  34513. private _animationPropertiesOverride;
  34514. /**
  34515. * Gets or sets the animation properties override
  34516. */
  34517. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34518. /**
  34519. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34520. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34521. */
  34522. useConstantAnimationDeltaTime: boolean;
  34523. /**
  34524. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34525. * Please note that it requires to run a ray cast through the scene on every frame
  34526. */
  34527. constantlyUpdateMeshUnderPointer: boolean;
  34528. /**
  34529. * Defines the HTML cursor to use when hovering over interactive elements
  34530. */
  34531. hoverCursor: string;
  34532. /**
  34533. * Defines the HTML default cursor to use (empty by default)
  34534. */
  34535. defaultCursor: string;
  34536. /**
  34537. * Defines wether cursors are handled by the scene.
  34538. */
  34539. doNotHandleCursors: boolean;
  34540. /**
  34541. * This is used to call preventDefault() on pointer down
  34542. * in order to block unwanted artifacts like system double clicks
  34543. */
  34544. preventDefaultOnPointerDown: boolean;
  34545. /**
  34546. * This is used to call preventDefault() on pointer up
  34547. * in order to block unwanted artifacts like system double clicks
  34548. */
  34549. preventDefaultOnPointerUp: boolean;
  34550. /**
  34551. * Gets or sets user defined metadata
  34552. */
  34553. metadata: any;
  34554. /**
  34555. * For internal use only. Please do not use.
  34556. */
  34557. reservedDataStore: any;
  34558. /**
  34559. * Gets the name of the plugin used to load this scene (null by default)
  34560. */
  34561. loadingPluginName: string;
  34562. /**
  34563. * Use this array to add regular expressions used to disable offline support for specific urls
  34564. */
  34565. disableOfflineSupportExceptionRules: RegExp[];
  34566. /**
  34567. * An event triggered when the scene is disposed.
  34568. */
  34569. onDisposeObservable: Observable<Scene>;
  34570. private _onDisposeObserver;
  34571. /** Sets a function to be executed when this scene is disposed. */
  34572. onDispose: () => void;
  34573. /**
  34574. * An event triggered before rendering the scene (right after animations and physics)
  34575. */
  34576. onBeforeRenderObservable: Observable<Scene>;
  34577. private _onBeforeRenderObserver;
  34578. /** Sets a function to be executed before rendering this scene */
  34579. beforeRender: Nullable<() => void>;
  34580. /**
  34581. * An event triggered after rendering the scene
  34582. */
  34583. onAfterRenderObservable: Observable<Scene>;
  34584. /**
  34585. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34586. */
  34587. onAfterRenderCameraObservable: Observable<Camera>;
  34588. private _onAfterRenderObserver;
  34589. /** Sets a function to be executed after rendering this scene */
  34590. afterRender: Nullable<() => void>;
  34591. /**
  34592. * An event triggered before animating the scene
  34593. */
  34594. onBeforeAnimationsObservable: Observable<Scene>;
  34595. /**
  34596. * An event triggered after animations processing
  34597. */
  34598. onAfterAnimationsObservable: Observable<Scene>;
  34599. /**
  34600. * An event triggered before draw calls are ready to be sent
  34601. */
  34602. onBeforeDrawPhaseObservable: Observable<Scene>;
  34603. /**
  34604. * An event triggered after draw calls have been sent
  34605. */
  34606. onAfterDrawPhaseObservable: Observable<Scene>;
  34607. /**
  34608. * An event triggered when the scene is ready
  34609. */
  34610. onReadyObservable: Observable<Scene>;
  34611. /**
  34612. * An event triggered before rendering a camera
  34613. */
  34614. onBeforeCameraRenderObservable: Observable<Camera>;
  34615. private _onBeforeCameraRenderObserver;
  34616. /** Sets a function to be executed before rendering a camera*/
  34617. beforeCameraRender: () => void;
  34618. /**
  34619. * An event triggered after rendering a camera
  34620. */
  34621. onAfterCameraRenderObservable: Observable<Camera>;
  34622. private _onAfterCameraRenderObserver;
  34623. /** Sets a function to be executed after rendering a camera*/
  34624. afterCameraRender: () => void;
  34625. /**
  34626. * An event triggered when active meshes evaluation is about to start
  34627. */
  34628. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34629. /**
  34630. * An event triggered when active meshes evaluation is done
  34631. */
  34632. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34633. /**
  34634. * An event triggered when particles rendering is about to start
  34635. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34636. */
  34637. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34638. /**
  34639. * An event triggered when particles rendering is done
  34640. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34641. */
  34642. onAfterParticlesRenderingObservable: Observable<Scene>;
  34643. /**
  34644. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34645. */
  34646. onDataLoadedObservable: Observable<Scene>;
  34647. /**
  34648. * An event triggered when a camera is created
  34649. */
  34650. onNewCameraAddedObservable: Observable<Camera>;
  34651. /**
  34652. * An event triggered when a camera is removed
  34653. */
  34654. onCameraRemovedObservable: Observable<Camera>;
  34655. /**
  34656. * An event triggered when a light is created
  34657. */
  34658. onNewLightAddedObservable: Observable<Light>;
  34659. /**
  34660. * An event triggered when a light is removed
  34661. */
  34662. onLightRemovedObservable: Observable<Light>;
  34663. /**
  34664. * An event triggered when a geometry is created
  34665. */
  34666. onNewGeometryAddedObservable: Observable<Geometry>;
  34667. /**
  34668. * An event triggered when a geometry is removed
  34669. */
  34670. onGeometryRemovedObservable: Observable<Geometry>;
  34671. /**
  34672. * An event triggered when a transform node is created
  34673. */
  34674. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34675. /**
  34676. * An event triggered when a transform node is removed
  34677. */
  34678. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34679. /**
  34680. * An event triggered when a mesh is created
  34681. */
  34682. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34683. /**
  34684. * An event triggered when a mesh is removed
  34685. */
  34686. onMeshRemovedObservable: Observable<AbstractMesh>;
  34687. /**
  34688. * An event triggered when a skeleton is created
  34689. */
  34690. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34691. /**
  34692. * An event triggered when a skeleton is removed
  34693. */
  34694. onSkeletonRemovedObservable: Observable<Skeleton>;
  34695. /**
  34696. * An event triggered when a material is created
  34697. */
  34698. onNewMaterialAddedObservable: Observable<Material>;
  34699. /**
  34700. * An event triggered when a material is removed
  34701. */
  34702. onMaterialRemovedObservable: Observable<Material>;
  34703. /**
  34704. * An event triggered when a texture is created
  34705. */
  34706. onNewTextureAddedObservable: Observable<BaseTexture>;
  34707. /**
  34708. * An event triggered when a texture is removed
  34709. */
  34710. onTextureRemovedObservable: Observable<BaseTexture>;
  34711. /**
  34712. * An event triggered when render targets are about to be rendered
  34713. * Can happen multiple times per frame.
  34714. */
  34715. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34716. /**
  34717. * An event triggered when render targets were rendered.
  34718. * Can happen multiple times per frame.
  34719. */
  34720. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34721. /**
  34722. * An event triggered before calculating deterministic simulation step
  34723. */
  34724. onBeforeStepObservable: Observable<Scene>;
  34725. /**
  34726. * An event triggered after calculating deterministic simulation step
  34727. */
  34728. onAfterStepObservable: Observable<Scene>;
  34729. /**
  34730. * An event triggered when the activeCamera property is updated
  34731. */
  34732. onActiveCameraChanged: Observable<Scene>;
  34733. /**
  34734. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34735. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34736. * 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)
  34737. */
  34738. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34739. /**
  34740. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34741. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34742. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34743. */
  34744. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34745. /**
  34746. * This Observable will when a mesh has been imported into the scene.
  34747. */
  34748. onMeshImportedObservable: Observable<AbstractMesh>;
  34749. /**
  34750. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34751. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34752. */
  34753. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34754. /** @hidden */
  34755. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34756. /**
  34757. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34758. */
  34759. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34760. /**
  34761. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34762. */
  34763. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34764. /**
  34765. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34766. */
  34767. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34768. /** Callback called when a pointer move is detected */
  34769. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34770. /** Callback called when a pointer down is detected */
  34771. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34772. /** Callback called when a pointer up is detected */
  34773. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34774. /** Callback called when a pointer pick is detected */
  34775. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34776. /**
  34777. * 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).
  34778. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34779. */
  34780. onPrePointerObservable: Observable<PointerInfoPre>;
  34781. /**
  34782. * Observable event triggered each time an input event is received from the rendering canvas
  34783. */
  34784. onPointerObservable: Observable<PointerInfo>;
  34785. /**
  34786. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34787. */
  34788. readonly unTranslatedPointer: Vector2;
  34789. /**
  34790. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34791. */
  34792. static DragMovementThreshold: number;
  34793. /**
  34794. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34795. */
  34796. static LongPressDelay: number;
  34797. /**
  34798. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34799. */
  34800. static DoubleClickDelay: number;
  34801. /** If you need to check double click without raising a single click at first click, enable this flag */
  34802. static ExclusiveDoubleClickMode: boolean;
  34803. /** @hidden */
  34804. _mirroredCameraPosition: Nullable<Vector3>;
  34805. /**
  34806. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34807. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34808. */
  34809. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34810. /**
  34811. * Observable event triggered each time an keyboard event is received from the hosting window
  34812. */
  34813. onKeyboardObservable: Observable<KeyboardInfo>;
  34814. private _useRightHandedSystem;
  34815. /**
  34816. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34817. */
  34818. useRightHandedSystem: boolean;
  34819. private _timeAccumulator;
  34820. private _currentStepId;
  34821. private _currentInternalStep;
  34822. /**
  34823. * Sets the step Id used by deterministic lock step
  34824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34825. * @param newStepId defines the step Id
  34826. */
  34827. setStepId(newStepId: number): void;
  34828. /**
  34829. * Gets the step Id used by deterministic lock step
  34830. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34831. * @returns the step Id
  34832. */
  34833. getStepId(): number;
  34834. /**
  34835. * Gets the internal step used by deterministic lock step
  34836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34837. * @returns the internal step
  34838. */
  34839. getInternalStep(): number;
  34840. private _fogEnabled;
  34841. /**
  34842. * Gets or sets a boolean indicating if fog is enabled on this scene
  34843. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34844. * (Default is true)
  34845. */
  34846. fogEnabled: boolean;
  34847. private _fogMode;
  34848. /**
  34849. * Gets or sets the fog mode to use
  34850. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34851. * | mode | value |
  34852. * | --- | --- |
  34853. * | FOGMODE_NONE | 0 |
  34854. * | FOGMODE_EXP | 1 |
  34855. * | FOGMODE_EXP2 | 2 |
  34856. * | FOGMODE_LINEAR | 3 |
  34857. */
  34858. fogMode: number;
  34859. /**
  34860. * Gets or sets the fog color to use
  34861. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34862. * (Default is Color3(0.2, 0.2, 0.3))
  34863. */
  34864. fogColor: Color3;
  34865. /**
  34866. * Gets or sets the fog density to use
  34867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34868. * (Default is 0.1)
  34869. */
  34870. fogDensity: number;
  34871. /**
  34872. * Gets or sets the fog start distance to use
  34873. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34874. * (Default is 0)
  34875. */
  34876. fogStart: number;
  34877. /**
  34878. * Gets or sets the fog end distance to use
  34879. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34880. * (Default is 1000)
  34881. */
  34882. fogEnd: number;
  34883. private _shadowsEnabled;
  34884. /**
  34885. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34886. */
  34887. shadowsEnabled: boolean;
  34888. private _lightsEnabled;
  34889. /**
  34890. * Gets or sets a boolean indicating if lights are enabled on this scene
  34891. */
  34892. lightsEnabled: boolean;
  34893. /** All of the active cameras added to this scene. */
  34894. activeCameras: Camera[];
  34895. /** @hidden */
  34896. _activeCamera: Nullable<Camera>;
  34897. /** Gets or sets the current active camera */
  34898. activeCamera: Nullable<Camera>;
  34899. private _defaultMaterial;
  34900. /** The default material used on meshes when no material is affected */
  34901. /** The default material used on meshes when no material is affected */
  34902. defaultMaterial: Material;
  34903. private _texturesEnabled;
  34904. /**
  34905. * Gets or sets a boolean indicating if textures are enabled on this scene
  34906. */
  34907. texturesEnabled: boolean;
  34908. /**
  34909. * Gets or sets a boolean indicating if particles are enabled on this scene
  34910. */
  34911. particlesEnabled: boolean;
  34912. /**
  34913. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34914. */
  34915. spritesEnabled: boolean;
  34916. private _skeletonsEnabled;
  34917. /**
  34918. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34919. */
  34920. skeletonsEnabled: boolean;
  34921. /**
  34922. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34923. */
  34924. lensFlaresEnabled: boolean;
  34925. /**
  34926. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34927. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34928. */
  34929. collisionsEnabled: boolean;
  34930. private _collisionCoordinator;
  34931. /** @hidden */
  34932. readonly collisionCoordinator: ICollisionCoordinator;
  34933. /**
  34934. * Defines the gravity applied to this scene (used only for collisions)
  34935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34936. */
  34937. gravity: Vector3;
  34938. /**
  34939. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34940. */
  34941. postProcessesEnabled: boolean;
  34942. /**
  34943. * The list of postprocesses added to the scene
  34944. */
  34945. postProcesses: PostProcess[];
  34946. /**
  34947. * Gets the current postprocess manager
  34948. */
  34949. postProcessManager: PostProcessManager;
  34950. /**
  34951. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34952. */
  34953. renderTargetsEnabled: boolean;
  34954. /**
  34955. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34956. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34957. */
  34958. dumpNextRenderTargets: boolean;
  34959. /**
  34960. * The list of user defined render targets added to the scene
  34961. */
  34962. customRenderTargets: RenderTargetTexture[];
  34963. /**
  34964. * Defines if texture loading must be delayed
  34965. * If true, textures will only be loaded when they need to be rendered
  34966. */
  34967. useDelayedTextureLoading: boolean;
  34968. /**
  34969. * Gets the list of meshes imported to the scene through SceneLoader
  34970. */
  34971. importedMeshesFiles: String[];
  34972. /**
  34973. * Gets or sets a boolean indicating if probes are enabled on this scene
  34974. */
  34975. probesEnabled: boolean;
  34976. /**
  34977. * Gets or sets the current offline provider to use to store scene data
  34978. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34979. */
  34980. offlineProvider: IOfflineProvider;
  34981. /**
  34982. * Gets or sets the action manager associated with the scene
  34983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34984. */
  34985. actionManager: AbstractActionManager;
  34986. private _meshesForIntersections;
  34987. /**
  34988. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34989. */
  34990. proceduralTexturesEnabled: boolean;
  34991. private _engine;
  34992. private _totalVertices;
  34993. /** @hidden */
  34994. _activeIndices: PerfCounter;
  34995. /** @hidden */
  34996. _activeParticles: PerfCounter;
  34997. /** @hidden */
  34998. _activeBones: PerfCounter;
  34999. private _animationRatio;
  35000. /** @hidden */
  35001. _animationTimeLast: number;
  35002. /** @hidden */
  35003. _animationTime: number;
  35004. /**
  35005. * Gets or sets a general scale for animation speed
  35006. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35007. */
  35008. animationTimeScale: number;
  35009. /** @hidden */
  35010. _cachedMaterial: Nullable<Material>;
  35011. /** @hidden */
  35012. _cachedEffect: Nullable<Effect>;
  35013. /** @hidden */
  35014. _cachedVisibility: Nullable<number>;
  35015. private _renderId;
  35016. private _frameId;
  35017. private _executeWhenReadyTimeoutId;
  35018. private _intermediateRendering;
  35019. private _viewUpdateFlag;
  35020. private _projectionUpdateFlag;
  35021. /** @hidden */
  35022. _toBeDisposed: Nullable<IDisposable>[];
  35023. private _activeRequests;
  35024. /** @hidden */
  35025. _pendingData: any[];
  35026. private _isDisposed;
  35027. /**
  35028. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35029. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35030. */
  35031. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35032. private _activeMeshes;
  35033. private _processedMaterials;
  35034. private _renderTargets;
  35035. /** @hidden */
  35036. _activeParticleSystems: SmartArray<IParticleSystem>;
  35037. private _activeSkeletons;
  35038. private _softwareSkinnedMeshes;
  35039. private _renderingManager;
  35040. /** @hidden */
  35041. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35042. private _transformMatrix;
  35043. private _sceneUbo;
  35044. /** @hidden */
  35045. _viewMatrix: Matrix;
  35046. private _projectionMatrix;
  35047. /** @hidden */
  35048. _forcedViewPosition: Nullable<Vector3>;
  35049. /** @hidden */
  35050. _frustumPlanes: Plane[];
  35051. /**
  35052. * Gets the list of frustum planes (built from the active camera)
  35053. */
  35054. readonly frustumPlanes: Plane[];
  35055. /**
  35056. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35057. * This is useful if there are more lights that the maximum simulteanous authorized
  35058. */
  35059. requireLightSorting: boolean;
  35060. /** @hidden */
  35061. readonly useMaterialMeshMap: boolean;
  35062. /** @hidden */
  35063. readonly useClonedMeshhMap: boolean;
  35064. private _externalData;
  35065. private _uid;
  35066. /**
  35067. * @hidden
  35068. * Backing store of defined scene components.
  35069. */
  35070. _components: ISceneComponent[];
  35071. /**
  35072. * @hidden
  35073. * Backing store of defined scene components.
  35074. */
  35075. _serializableComponents: ISceneSerializableComponent[];
  35076. /**
  35077. * List of components to register on the next registration step.
  35078. */
  35079. private _transientComponents;
  35080. /**
  35081. * Registers the transient components if needed.
  35082. */
  35083. private _registerTransientComponents;
  35084. /**
  35085. * @hidden
  35086. * Add a component to the scene.
  35087. * Note that the ccomponent could be registered on th next frame if this is called after
  35088. * the register component stage.
  35089. * @param component Defines the component to add to the scene
  35090. */
  35091. _addComponent(component: ISceneComponent): void;
  35092. /**
  35093. * @hidden
  35094. * Gets a component from the scene.
  35095. * @param name defines the name of the component to retrieve
  35096. * @returns the component or null if not present
  35097. */
  35098. _getComponent(name: string): Nullable<ISceneComponent>;
  35099. /**
  35100. * @hidden
  35101. * Defines the actions happening before camera updates.
  35102. */
  35103. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35104. /**
  35105. * @hidden
  35106. * Defines the actions happening before clear the canvas.
  35107. */
  35108. _beforeClearStage: Stage<SimpleStageAction>;
  35109. /**
  35110. * @hidden
  35111. * Defines the actions when collecting render targets for the frame.
  35112. */
  35113. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35114. /**
  35115. * @hidden
  35116. * Defines the actions happening for one camera in the frame.
  35117. */
  35118. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35119. /**
  35120. * @hidden
  35121. * Defines the actions happening during the per mesh ready checks.
  35122. */
  35123. _isReadyForMeshStage: Stage<MeshStageAction>;
  35124. /**
  35125. * @hidden
  35126. * Defines the actions happening before evaluate active mesh checks.
  35127. */
  35128. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35129. /**
  35130. * @hidden
  35131. * Defines the actions happening during the evaluate sub mesh checks.
  35132. */
  35133. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35134. /**
  35135. * @hidden
  35136. * Defines the actions happening during the active mesh stage.
  35137. */
  35138. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35139. /**
  35140. * @hidden
  35141. * Defines the actions happening during the per camera render target step.
  35142. */
  35143. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35144. /**
  35145. * @hidden
  35146. * Defines the actions happening just before the active camera is drawing.
  35147. */
  35148. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35149. /**
  35150. * @hidden
  35151. * Defines the actions happening just before a render target is drawing.
  35152. */
  35153. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35154. /**
  35155. * @hidden
  35156. * Defines the actions happening just before a rendering group is drawing.
  35157. */
  35158. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35159. /**
  35160. * @hidden
  35161. * Defines the actions happening just before a mesh is drawing.
  35162. */
  35163. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35164. /**
  35165. * @hidden
  35166. * Defines the actions happening just after a mesh has been drawn.
  35167. */
  35168. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35169. /**
  35170. * @hidden
  35171. * Defines the actions happening just after a rendering group has been drawn.
  35172. */
  35173. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35174. /**
  35175. * @hidden
  35176. * Defines the actions happening just after the active camera has been drawn.
  35177. */
  35178. _afterCameraDrawStage: Stage<CameraStageAction>;
  35179. /**
  35180. * @hidden
  35181. * Defines the actions happening just after a render target has been drawn.
  35182. */
  35183. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35184. /**
  35185. * @hidden
  35186. * Defines the actions happening just after rendering all cameras and computing intersections.
  35187. */
  35188. _afterRenderStage: Stage<SimpleStageAction>;
  35189. /**
  35190. * @hidden
  35191. * Defines the actions happening when a pointer move event happens.
  35192. */
  35193. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35194. /**
  35195. * @hidden
  35196. * Defines the actions happening when a pointer down event happens.
  35197. */
  35198. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35199. /**
  35200. * @hidden
  35201. * Defines the actions happening when a pointer up event happens.
  35202. */
  35203. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35204. /**
  35205. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35206. */
  35207. private geometriesByUniqueId;
  35208. /**
  35209. * Creates a new Scene
  35210. * @param engine defines the engine to use to render this scene
  35211. * @param options defines the scene options
  35212. */
  35213. constructor(engine: Engine, options?: SceneOptions);
  35214. /**
  35215. * Gets a string idenfifying the name of the class
  35216. * @returns "Scene" string
  35217. */
  35218. getClassName(): string;
  35219. private _defaultMeshCandidates;
  35220. /**
  35221. * @hidden
  35222. */
  35223. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35224. private _defaultSubMeshCandidates;
  35225. /**
  35226. * @hidden
  35227. */
  35228. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35229. /**
  35230. * Sets the default candidate providers for the scene.
  35231. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35232. * and getCollidingSubMeshCandidates to their default function
  35233. */
  35234. setDefaultCandidateProviders(): void;
  35235. /**
  35236. * Gets the mesh that is currently under the pointer
  35237. */
  35238. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35239. /**
  35240. * Gets or sets the current on-screen X position of the pointer
  35241. */
  35242. pointerX: number;
  35243. /**
  35244. * Gets or sets the current on-screen Y position of the pointer
  35245. */
  35246. pointerY: number;
  35247. /**
  35248. * Gets the cached material (ie. the latest rendered one)
  35249. * @returns the cached material
  35250. */
  35251. getCachedMaterial(): Nullable<Material>;
  35252. /**
  35253. * Gets the cached effect (ie. the latest rendered one)
  35254. * @returns the cached effect
  35255. */
  35256. getCachedEffect(): Nullable<Effect>;
  35257. /**
  35258. * Gets the cached visibility state (ie. the latest rendered one)
  35259. * @returns the cached visibility state
  35260. */
  35261. getCachedVisibility(): Nullable<number>;
  35262. /**
  35263. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35264. * @param material defines the current material
  35265. * @param effect defines the current effect
  35266. * @param visibility defines the current visibility state
  35267. * @returns true if one parameter is not cached
  35268. */
  35269. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35270. /**
  35271. * Gets the engine associated with the scene
  35272. * @returns an Engine
  35273. */
  35274. getEngine(): Engine;
  35275. /**
  35276. * Gets the total number of vertices rendered per frame
  35277. * @returns the total number of vertices rendered per frame
  35278. */
  35279. getTotalVertices(): number;
  35280. /**
  35281. * Gets the performance counter for total vertices
  35282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35283. */
  35284. readonly totalVerticesPerfCounter: PerfCounter;
  35285. /**
  35286. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35287. * @returns the total number of active indices rendered per frame
  35288. */
  35289. getActiveIndices(): number;
  35290. /**
  35291. * Gets the performance counter for active indices
  35292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35293. */
  35294. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35295. /**
  35296. * Gets the total number of active particles rendered per frame
  35297. * @returns the total number of active particles rendered per frame
  35298. */
  35299. getActiveParticles(): number;
  35300. /**
  35301. * Gets the performance counter for active particles
  35302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35303. */
  35304. readonly activeParticlesPerfCounter: PerfCounter;
  35305. /**
  35306. * Gets the total number of active bones rendered per frame
  35307. * @returns the total number of active bones rendered per frame
  35308. */
  35309. getActiveBones(): number;
  35310. /**
  35311. * Gets the performance counter for active bones
  35312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35313. */
  35314. readonly activeBonesPerfCounter: PerfCounter;
  35315. /**
  35316. * Gets the array of active meshes
  35317. * @returns an array of AbstractMesh
  35318. */
  35319. getActiveMeshes(): SmartArray<AbstractMesh>;
  35320. /**
  35321. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35322. * @returns a number
  35323. */
  35324. getAnimationRatio(): number;
  35325. /**
  35326. * Gets an unique Id for the current render phase
  35327. * @returns a number
  35328. */
  35329. getRenderId(): number;
  35330. /**
  35331. * Gets an unique Id for the current frame
  35332. * @returns a number
  35333. */
  35334. getFrameId(): number;
  35335. /** Call this function if you want to manually increment the render Id*/
  35336. incrementRenderId(): void;
  35337. private _createUbo;
  35338. /**
  35339. * Use this method to simulate a pointer move on a mesh
  35340. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35341. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35342. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35343. * @returns the current scene
  35344. */
  35345. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35346. /**
  35347. * Use this method to simulate a pointer down on a mesh
  35348. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35349. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35350. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35351. * @returns the current scene
  35352. */
  35353. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35354. /**
  35355. * Use this method to simulate a pointer up on a mesh
  35356. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35357. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35358. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35359. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35360. * @returns the current scene
  35361. */
  35362. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35363. /**
  35364. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35365. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35366. * @returns true if the pointer was captured
  35367. */
  35368. isPointerCaptured(pointerId?: number): boolean;
  35369. /**
  35370. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35371. * @param attachUp defines if you want to attach events to pointerup
  35372. * @param attachDown defines if you want to attach events to pointerdown
  35373. * @param attachMove defines if you want to attach events to pointermove
  35374. */
  35375. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35376. /** Detaches all event handlers*/
  35377. detachControl(): void;
  35378. /**
  35379. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35380. * Delay loaded resources are not taking in account
  35381. * @return true if all required resources are ready
  35382. */
  35383. isReady(): boolean;
  35384. /** Resets all cached information relative to material (including effect and visibility) */
  35385. resetCachedMaterial(): void;
  35386. /**
  35387. * Registers a function to be called before every frame render
  35388. * @param func defines the function to register
  35389. */
  35390. registerBeforeRender(func: () => void): void;
  35391. /**
  35392. * Unregisters a function called before every frame render
  35393. * @param func defines the function to unregister
  35394. */
  35395. unregisterBeforeRender(func: () => void): void;
  35396. /**
  35397. * Registers a function to be called after every frame render
  35398. * @param func defines the function to register
  35399. */
  35400. registerAfterRender(func: () => void): void;
  35401. /**
  35402. * Unregisters a function called after every frame render
  35403. * @param func defines the function to unregister
  35404. */
  35405. unregisterAfterRender(func: () => void): void;
  35406. private _executeOnceBeforeRender;
  35407. /**
  35408. * The provided function will run before render once and will be disposed afterwards.
  35409. * A timeout delay can be provided so that the function will be executed in N ms.
  35410. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35411. * @param func The function to be executed.
  35412. * @param timeout optional delay in ms
  35413. */
  35414. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35415. /** @hidden */
  35416. _addPendingData(data: any): void;
  35417. /** @hidden */
  35418. _removePendingData(data: any): void;
  35419. /**
  35420. * Returns the number of items waiting to be loaded
  35421. * @returns the number of items waiting to be loaded
  35422. */
  35423. getWaitingItemsCount(): number;
  35424. /**
  35425. * Returns a boolean indicating if the scene is still loading data
  35426. */
  35427. readonly isLoading: boolean;
  35428. /**
  35429. * Registers a function to be executed when the scene is ready
  35430. * @param {Function} func - the function to be executed
  35431. */
  35432. executeWhenReady(func: () => void): void;
  35433. /**
  35434. * Returns a promise that resolves when the scene is ready
  35435. * @returns A promise that resolves when the scene is ready
  35436. */
  35437. whenReadyAsync(): Promise<void>;
  35438. /** @hidden */
  35439. _checkIsReady(): void;
  35440. /**
  35441. * Gets all animatable attached to the scene
  35442. */
  35443. readonly animatables: Animatable[];
  35444. /**
  35445. * Resets the last animation time frame.
  35446. * Useful to override when animations start running when loading a scene for the first time.
  35447. */
  35448. resetLastAnimationTimeFrame(): void;
  35449. /**
  35450. * Gets the current view matrix
  35451. * @returns a Matrix
  35452. */
  35453. getViewMatrix(): Matrix;
  35454. /**
  35455. * Gets the current projection matrix
  35456. * @returns a Matrix
  35457. */
  35458. getProjectionMatrix(): Matrix;
  35459. /**
  35460. * Gets the current transform matrix
  35461. * @returns a Matrix made of View * Projection
  35462. */
  35463. getTransformMatrix(): Matrix;
  35464. /**
  35465. * Sets the current transform matrix
  35466. * @param viewL defines the View matrix to use
  35467. * @param projectionL defines the Projection matrix to use
  35468. * @param viewR defines the right View matrix to use (if provided)
  35469. * @param projectionR defines the right Projection matrix to use (if provided)
  35470. */
  35471. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35472. /**
  35473. * Gets the uniform buffer used to store scene data
  35474. * @returns a UniformBuffer
  35475. */
  35476. getSceneUniformBuffer(): UniformBuffer;
  35477. /**
  35478. * Gets an unique (relatively to the current scene) Id
  35479. * @returns an unique number for the scene
  35480. */
  35481. getUniqueId(): number;
  35482. /**
  35483. * Add a mesh to the list of scene's meshes
  35484. * @param newMesh defines the mesh to add
  35485. * @param recursive if all child meshes should also be added to the scene
  35486. */
  35487. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35488. /**
  35489. * Remove a mesh for the list of scene's meshes
  35490. * @param toRemove defines the mesh to remove
  35491. * @param recursive if all child meshes should also be removed from the scene
  35492. * @returns the index where the mesh was in the mesh list
  35493. */
  35494. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35495. /**
  35496. * Add a transform node to the list of scene's transform nodes
  35497. * @param newTransformNode defines the transform node to add
  35498. */
  35499. addTransformNode(newTransformNode: TransformNode): void;
  35500. /**
  35501. * Remove a transform node for the list of scene's transform nodes
  35502. * @param toRemove defines the transform node to remove
  35503. * @returns the index where the transform node was in the transform node list
  35504. */
  35505. removeTransformNode(toRemove: TransformNode): number;
  35506. /**
  35507. * Remove a skeleton for the list of scene's skeletons
  35508. * @param toRemove defines the skeleton to remove
  35509. * @returns the index where the skeleton was in the skeleton list
  35510. */
  35511. removeSkeleton(toRemove: Skeleton): number;
  35512. /**
  35513. * Remove a morph target for the list of scene's morph targets
  35514. * @param toRemove defines the morph target to remove
  35515. * @returns the index where the morph target was in the morph target list
  35516. */
  35517. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35518. /**
  35519. * Remove a light for the list of scene's lights
  35520. * @param toRemove defines the light to remove
  35521. * @returns the index where the light was in the light list
  35522. */
  35523. removeLight(toRemove: Light): number;
  35524. /**
  35525. * Remove a camera for the list of scene's cameras
  35526. * @param toRemove defines the camera to remove
  35527. * @returns the index where the camera was in the camera list
  35528. */
  35529. removeCamera(toRemove: Camera): number;
  35530. /**
  35531. * Remove a particle system for the list of scene's particle systems
  35532. * @param toRemove defines the particle system to remove
  35533. * @returns the index where the particle system was in the particle system list
  35534. */
  35535. removeParticleSystem(toRemove: IParticleSystem): number;
  35536. /**
  35537. * Remove a animation for the list of scene's animations
  35538. * @param toRemove defines the animation to remove
  35539. * @returns the index where the animation was in the animation list
  35540. */
  35541. removeAnimation(toRemove: Animation): number;
  35542. /**
  35543. * Will stop the animation of the given target
  35544. * @param target - the target
  35545. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35546. * @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)
  35547. */
  35548. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35549. /**
  35550. * Removes the given animation group from this scene.
  35551. * @param toRemove The animation group to remove
  35552. * @returns The index of the removed animation group
  35553. */
  35554. removeAnimationGroup(toRemove: AnimationGroup): number;
  35555. /**
  35556. * Removes the given multi-material from this scene.
  35557. * @param toRemove The multi-material to remove
  35558. * @returns The index of the removed multi-material
  35559. */
  35560. removeMultiMaterial(toRemove: MultiMaterial): number;
  35561. /**
  35562. * Removes the given material from this scene.
  35563. * @param toRemove The material to remove
  35564. * @returns The index of the removed material
  35565. */
  35566. removeMaterial(toRemove: Material): number;
  35567. /**
  35568. * Removes the given action manager from this scene.
  35569. * @param toRemove The action manager to remove
  35570. * @returns The index of the removed action manager
  35571. */
  35572. removeActionManager(toRemove: AbstractActionManager): number;
  35573. /**
  35574. * Removes the given texture from this scene.
  35575. * @param toRemove The texture to remove
  35576. * @returns The index of the removed texture
  35577. */
  35578. removeTexture(toRemove: BaseTexture): number;
  35579. /**
  35580. * Adds the given light to this scene
  35581. * @param newLight The light to add
  35582. */
  35583. addLight(newLight: Light): void;
  35584. /**
  35585. * Sorts the list list based on light priorities
  35586. */
  35587. sortLightsByPriority(): void;
  35588. /**
  35589. * Adds the given camera to this scene
  35590. * @param newCamera The camera to add
  35591. */
  35592. addCamera(newCamera: Camera): void;
  35593. /**
  35594. * Adds the given skeleton to this scene
  35595. * @param newSkeleton The skeleton to add
  35596. */
  35597. addSkeleton(newSkeleton: Skeleton): void;
  35598. /**
  35599. * Adds the given particle system to this scene
  35600. * @param newParticleSystem The particle system to add
  35601. */
  35602. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35603. /**
  35604. * Adds the given animation to this scene
  35605. * @param newAnimation The animation to add
  35606. */
  35607. addAnimation(newAnimation: Animation): void;
  35608. /**
  35609. * Adds the given animation group to this scene.
  35610. * @param newAnimationGroup The animation group to add
  35611. */
  35612. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35613. /**
  35614. * Adds the given multi-material to this scene
  35615. * @param newMultiMaterial The multi-material to add
  35616. */
  35617. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35618. /**
  35619. * Adds the given material to this scene
  35620. * @param newMaterial The material to add
  35621. */
  35622. addMaterial(newMaterial: Material): void;
  35623. /**
  35624. * Adds the given morph target to this scene
  35625. * @param newMorphTargetManager The morph target to add
  35626. */
  35627. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35628. /**
  35629. * Adds the given geometry to this scene
  35630. * @param newGeometry The geometry to add
  35631. */
  35632. addGeometry(newGeometry: Geometry): void;
  35633. /**
  35634. * Adds the given action manager to this scene
  35635. * @param newActionManager The action manager to add
  35636. */
  35637. addActionManager(newActionManager: AbstractActionManager): void;
  35638. /**
  35639. * Adds the given texture to this scene.
  35640. * @param newTexture The texture to add
  35641. */
  35642. addTexture(newTexture: BaseTexture): void;
  35643. /**
  35644. * Switch active camera
  35645. * @param newCamera defines the new active camera
  35646. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35647. */
  35648. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35649. /**
  35650. * sets the active camera of the scene using its ID
  35651. * @param id defines the camera's ID
  35652. * @return the new active camera or null if none found.
  35653. */
  35654. setActiveCameraByID(id: string): Nullable<Camera>;
  35655. /**
  35656. * sets the active camera of the scene using its name
  35657. * @param name defines the camera's name
  35658. * @returns the new active camera or null if none found.
  35659. */
  35660. setActiveCameraByName(name: string): Nullable<Camera>;
  35661. /**
  35662. * get an animation group using its name
  35663. * @param name defines the material's name
  35664. * @return the animation group or null if none found.
  35665. */
  35666. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35667. /**
  35668. * Get a material using its unique id
  35669. * @param uniqueId defines the material's unique id
  35670. * @return the material or null if none found.
  35671. */
  35672. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35673. /**
  35674. * get a material using its id
  35675. * @param id defines the material's ID
  35676. * @return the material or null if none found.
  35677. */
  35678. getMaterialByID(id: string): Nullable<Material>;
  35679. /**
  35680. * Gets a the last added material using a given id
  35681. * @param id defines the material's ID
  35682. * @return the last material with the given id or null if none found.
  35683. */
  35684. getLastMaterialByID(id: string): Nullable<Material>;
  35685. /**
  35686. * Gets a material using its name
  35687. * @param name defines the material's name
  35688. * @return the material or null if none found.
  35689. */
  35690. getMaterialByName(name: string): Nullable<Material>;
  35691. /**
  35692. * Get a texture using its unique id
  35693. * @param uniqueId defines the texture's unique id
  35694. * @return the texture or null if none found.
  35695. */
  35696. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35697. /**
  35698. * Gets a camera using its id
  35699. * @param id defines the id to look for
  35700. * @returns the camera or null if not found
  35701. */
  35702. getCameraByID(id: string): Nullable<Camera>;
  35703. /**
  35704. * Gets a camera using its unique id
  35705. * @param uniqueId defines the unique id to look for
  35706. * @returns the camera or null if not found
  35707. */
  35708. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35709. /**
  35710. * Gets a camera using its name
  35711. * @param name defines the camera's name
  35712. * @return the camera or null if none found.
  35713. */
  35714. getCameraByName(name: string): Nullable<Camera>;
  35715. /**
  35716. * Gets a bone using its id
  35717. * @param id defines the bone's id
  35718. * @return the bone or null if not found
  35719. */
  35720. getBoneByID(id: string): Nullable<Bone>;
  35721. /**
  35722. * Gets a bone using its id
  35723. * @param name defines the bone's name
  35724. * @return the bone or null if not found
  35725. */
  35726. getBoneByName(name: string): Nullable<Bone>;
  35727. /**
  35728. * Gets a light node using its name
  35729. * @param name defines the the light's name
  35730. * @return the light or null if none found.
  35731. */
  35732. getLightByName(name: string): Nullable<Light>;
  35733. /**
  35734. * Gets a light node using its id
  35735. * @param id defines the light's id
  35736. * @return the light or null if none found.
  35737. */
  35738. getLightByID(id: string): Nullable<Light>;
  35739. /**
  35740. * Gets a light node using its scene-generated unique ID
  35741. * @param uniqueId defines the light's unique id
  35742. * @return the light or null if none found.
  35743. */
  35744. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35745. /**
  35746. * Gets a particle system by id
  35747. * @param id defines the particle system id
  35748. * @return the corresponding system or null if none found
  35749. */
  35750. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35751. /**
  35752. * Gets a geometry using its ID
  35753. * @param id defines the geometry's id
  35754. * @return the geometry or null if none found.
  35755. */
  35756. getGeometryByID(id: string): Nullable<Geometry>;
  35757. private _getGeometryByUniqueID;
  35758. /**
  35759. * Add a new geometry to this scene
  35760. * @param geometry defines the geometry to be added to the scene.
  35761. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35762. * @return a boolean defining if the geometry was added or not
  35763. */
  35764. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35765. /**
  35766. * Removes an existing geometry
  35767. * @param geometry defines the geometry to be removed from the scene
  35768. * @return a boolean defining if the geometry was removed or not
  35769. */
  35770. removeGeometry(geometry: Geometry): boolean;
  35771. /**
  35772. * Gets the list of geometries attached to the scene
  35773. * @returns an array of Geometry
  35774. */
  35775. getGeometries(): Geometry[];
  35776. /**
  35777. * Gets the first added mesh found of a given ID
  35778. * @param id defines the id to search for
  35779. * @return the mesh found or null if not found at all
  35780. */
  35781. getMeshByID(id: string): Nullable<AbstractMesh>;
  35782. /**
  35783. * Gets a list of meshes using their id
  35784. * @param id defines the id to search for
  35785. * @returns a list of meshes
  35786. */
  35787. getMeshesByID(id: string): Array<AbstractMesh>;
  35788. /**
  35789. * Gets the first added transform node found of a given ID
  35790. * @param id defines the id to search for
  35791. * @return the found transform node or null if not found at all.
  35792. */
  35793. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35794. /**
  35795. * Gets a transform node with its auto-generated unique id
  35796. * @param uniqueId efines the unique id to search for
  35797. * @return the found transform node or null if not found at all.
  35798. */
  35799. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35800. /**
  35801. * Gets a list of transform nodes using their id
  35802. * @param id defines the id to search for
  35803. * @returns a list of transform nodes
  35804. */
  35805. getTransformNodesByID(id: string): Array<TransformNode>;
  35806. /**
  35807. * Gets a mesh with its auto-generated unique id
  35808. * @param uniqueId defines the unique id to search for
  35809. * @return the found mesh or null if not found at all.
  35810. */
  35811. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35812. /**
  35813. * Gets a the last added mesh using a given id
  35814. * @param id defines the id to search for
  35815. * @return the found mesh or null if not found at all.
  35816. */
  35817. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35818. /**
  35819. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35820. * @param id defines the id to search for
  35821. * @return the found node or null if not found at all
  35822. */
  35823. getLastEntryByID(id: string): Nullable<Node>;
  35824. /**
  35825. * Gets a node (Mesh, Camera, Light) using a given id
  35826. * @param id defines the id to search for
  35827. * @return the found node or null if not found at all
  35828. */
  35829. getNodeByID(id: string): Nullable<Node>;
  35830. /**
  35831. * Gets a node (Mesh, Camera, Light) using a given name
  35832. * @param name defines the name to search for
  35833. * @return the found node or null if not found at all.
  35834. */
  35835. getNodeByName(name: string): Nullable<Node>;
  35836. /**
  35837. * Gets a mesh using a given name
  35838. * @param name defines the name to search for
  35839. * @return the found mesh or null if not found at all.
  35840. */
  35841. getMeshByName(name: string): Nullable<AbstractMesh>;
  35842. /**
  35843. * Gets a transform node using a given name
  35844. * @param name defines the name to search for
  35845. * @return the found transform node or null if not found at all.
  35846. */
  35847. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35848. /**
  35849. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35850. * @param id defines the id to search for
  35851. * @return the found skeleton or null if not found at all.
  35852. */
  35853. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35854. /**
  35855. * Gets a skeleton using a given auto generated unique id
  35856. * @param uniqueId defines the unique id to search for
  35857. * @return the found skeleton or null if not found at all.
  35858. */
  35859. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35860. /**
  35861. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35862. * @param id defines the id to search for
  35863. * @return the found skeleton or null if not found at all.
  35864. */
  35865. getSkeletonById(id: string): Nullable<Skeleton>;
  35866. /**
  35867. * Gets a skeleton using a given name
  35868. * @param name defines the name to search for
  35869. * @return the found skeleton or null if not found at all.
  35870. */
  35871. getSkeletonByName(name: string): Nullable<Skeleton>;
  35872. /**
  35873. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35874. * @param id defines the id to search for
  35875. * @return the found morph target manager or null if not found at all.
  35876. */
  35877. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35878. /**
  35879. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35880. * @param id defines the id to search for
  35881. * @return the found morph target or null if not found at all.
  35882. */
  35883. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35884. /**
  35885. * Gets a boolean indicating if the given mesh is active
  35886. * @param mesh defines the mesh to look for
  35887. * @returns true if the mesh is in the active list
  35888. */
  35889. isActiveMesh(mesh: AbstractMesh): boolean;
  35890. /**
  35891. * Return a unique id as a string which can serve as an identifier for the scene
  35892. */
  35893. readonly uid: string;
  35894. /**
  35895. * Add an externaly attached data from its key.
  35896. * This method call will fail and return false, if such key already exists.
  35897. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35898. * @param key the unique key that identifies the data
  35899. * @param data the data object to associate to the key for this Engine instance
  35900. * @return true if no such key were already present and the data was added successfully, false otherwise
  35901. */
  35902. addExternalData<T>(key: string, data: T): boolean;
  35903. /**
  35904. * Get an externaly attached data from its key
  35905. * @param key the unique key that identifies the data
  35906. * @return the associated data, if present (can be null), or undefined if not present
  35907. */
  35908. getExternalData<T>(key: string): Nullable<T>;
  35909. /**
  35910. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35911. * @param key the unique key that identifies the data
  35912. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35913. * @return the associated data, can be null if the factory returned null.
  35914. */
  35915. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35916. /**
  35917. * Remove an externaly attached data from the Engine instance
  35918. * @param key the unique key that identifies the data
  35919. * @return true if the data was successfully removed, false if it doesn't exist
  35920. */
  35921. removeExternalData(key: string): boolean;
  35922. private _evaluateSubMesh;
  35923. /**
  35924. * Clear the processed materials smart array preventing retention point in material dispose.
  35925. */
  35926. freeProcessedMaterials(): void;
  35927. private _preventFreeActiveMeshesAndRenderingGroups;
  35928. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35929. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35930. * when disposing several meshes in a row or a hierarchy of meshes.
  35931. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35932. */
  35933. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35934. /**
  35935. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35936. */
  35937. freeActiveMeshes(): void;
  35938. /**
  35939. * Clear the info related to rendering groups preventing retention points during dispose.
  35940. */
  35941. freeRenderingGroups(): void;
  35942. /** @hidden */
  35943. _isInIntermediateRendering(): boolean;
  35944. /**
  35945. * Lambda returning the list of potentially active meshes.
  35946. */
  35947. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35948. /**
  35949. * Lambda returning the list of potentially active sub meshes.
  35950. */
  35951. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35952. /**
  35953. * Lambda returning the list of potentially intersecting sub meshes.
  35954. */
  35955. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35956. /**
  35957. * Lambda returning the list of potentially colliding sub meshes.
  35958. */
  35959. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35960. private _activeMeshesFrozen;
  35961. private _skipEvaluateActiveMeshesCompletely;
  35962. /**
  35963. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35964. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  35965. * @returns the current scene
  35966. */
  35967. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  35968. /**
  35969. * Use this function to restart evaluating active meshes on every frame
  35970. * @returns the current scene
  35971. */
  35972. unfreezeActiveMeshes(): Scene;
  35973. private _evaluateActiveMeshes;
  35974. private _activeMesh;
  35975. /**
  35976. * Update the transform matrix to update from the current active camera
  35977. * @param force defines a boolean used to force the update even if cache is up to date
  35978. */
  35979. updateTransformMatrix(force?: boolean): void;
  35980. private _bindFrameBuffer;
  35981. /** @hidden */
  35982. _allowPostProcessClearColor: boolean;
  35983. /** @hidden */
  35984. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35985. private _processSubCameras;
  35986. private _checkIntersections;
  35987. /** @hidden */
  35988. _advancePhysicsEngineStep(step: number): void;
  35989. /**
  35990. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35991. */
  35992. getDeterministicFrameTime: () => number;
  35993. /** @hidden */
  35994. _animate(): void;
  35995. /** Execute all animations (for a frame) */
  35996. animate(): void;
  35997. /**
  35998. * Render the scene
  35999. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36000. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36001. */
  36002. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36003. /**
  36004. * Freeze all materials
  36005. * A frozen material will not be updatable but should be faster to render
  36006. */
  36007. freezeMaterials(): void;
  36008. /**
  36009. * Unfreeze all materials
  36010. * A frozen material will not be updatable but should be faster to render
  36011. */
  36012. unfreezeMaterials(): void;
  36013. /**
  36014. * Releases all held ressources
  36015. */
  36016. dispose(): void;
  36017. /**
  36018. * Gets if the scene is already disposed
  36019. */
  36020. readonly isDisposed: boolean;
  36021. /**
  36022. * Call this function to reduce memory footprint of the scene.
  36023. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36024. */
  36025. clearCachedVertexData(): void;
  36026. /**
  36027. * This function will remove the local cached buffer data from texture.
  36028. * It will save memory but will prevent the texture from being rebuilt
  36029. */
  36030. cleanCachedTextureBuffer(): void;
  36031. /**
  36032. * Get the world extend vectors with an optional filter
  36033. *
  36034. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36035. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36036. */
  36037. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36038. min: Vector3;
  36039. max: Vector3;
  36040. };
  36041. /**
  36042. * Creates a ray that can be used to pick in the scene
  36043. * @param x defines the x coordinate of the origin (on-screen)
  36044. * @param y defines the y coordinate of the origin (on-screen)
  36045. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36046. * @param camera defines the camera to use for the picking
  36047. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36048. * @returns a Ray
  36049. */
  36050. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36051. /**
  36052. * Creates a ray that can be used to pick in the scene
  36053. * @param x defines the x coordinate of the origin (on-screen)
  36054. * @param y defines the y coordinate of the origin (on-screen)
  36055. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36056. * @param result defines the ray where to store the picking ray
  36057. * @param camera defines the camera to use for the picking
  36058. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36059. * @returns the current scene
  36060. */
  36061. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36062. /**
  36063. * Creates a ray that can be used to pick in the scene
  36064. * @param x defines the x coordinate of the origin (on-screen)
  36065. * @param y defines the y coordinate of the origin (on-screen)
  36066. * @param camera defines the camera to use for the picking
  36067. * @returns a Ray
  36068. */
  36069. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36070. /**
  36071. * Creates a ray that can be used to pick in the scene
  36072. * @param x defines the x coordinate of the origin (on-screen)
  36073. * @param y defines the y coordinate of the origin (on-screen)
  36074. * @param result defines the ray where to store the picking ray
  36075. * @param camera defines the camera to use for the picking
  36076. * @returns the current scene
  36077. */
  36078. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36079. /** Launch a ray to try to pick a mesh in the scene
  36080. * @param x position on screen
  36081. * @param y position on screen
  36082. * @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
  36083. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36084. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36085. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36086. * @returns a PickingInfo
  36087. */
  36088. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36089. /** Use the given ray to pick a mesh in the scene
  36090. * @param ray The ray to use to pick meshes
  36091. * @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
  36092. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36093. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36094. * @returns a PickingInfo
  36095. */
  36096. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36097. /**
  36098. * Launch a ray to try to pick a mesh in the scene
  36099. * @param x X position on screen
  36100. * @param y Y position on screen
  36101. * @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
  36102. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36103. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36104. * @returns an array of PickingInfo
  36105. */
  36106. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36107. /**
  36108. * Launch a ray to try to pick a mesh in the scene
  36109. * @param ray Ray to use
  36110. * @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
  36111. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36112. * @returns an array of PickingInfo
  36113. */
  36114. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36115. /**
  36116. * Force the value of meshUnderPointer
  36117. * @param mesh defines the mesh to use
  36118. */
  36119. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36120. /**
  36121. * Gets the mesh under the pointer
  36122. * @returns a Mesh or null if no mesh is under the pointer
  36123. */
  36124. getPointerOverMesh(): Nullable<AbstractMesh>;
  36125. /** @hidden */
  36126. _rebuildGeometries(): void;
  36127. /** @hidden */
  36128. _rebuildTextures(): void;
  36129. private _getByTags;
  36130. /**
  36131. * Get a list of meshes by tags
  36132. * @param tagsQuery defines the tags query to use
  36133. * @param forEach defines a predicate used to filter results
  36134. * @returns an array of Mesh
  36135. */
  36136. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36137. /**
  36138. * Get a list of cameras by tags
  36139. * @param tagsQuery defines the tags query to use
  36140. * @param forEach defines a predicate used to filter results
  36141. * @returns an array of Camera
  36142. */
  36143. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36144. /**
  36145. * Get a list of lights by tags
  36146. * @param tagsQuery defines the tags query to use
  36147. * @param forEach defines a predicate used to filter results
  36148. * @returns an array of Light
  36149. */
  36150. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36151. /**
  36152. * Get a list of materials by tags
  36153. * @param tagsQuery defines the tags query to use
  36154. * @param forEach defines a predicate used to filter results
  36155. * @returns an array of Material
  36156. */
  36157. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36158. /**
  36159. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36160. * This allowed control for front to back rendering or reversly depending of the special needs.
  36161. *
  36162. * @param renderingGroupId The rendering group id corresponding to its index
  36163. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36164. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36165. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36166. */
  36167. 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;
  36168. /**
  36169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36170. *
  36171. * @param renderingGroupId The rendering group id corresponding to its index
  36172. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36173. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36174. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36175. */
  36176. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36177. /**
  36178. * Gets the current auto clear configuration for one rendering group of the rendering
  36179. * manager.
  36180. * @param index the rendering group index to get the information for
  36181. * @returns The auto clear setup for the requested rendering group
  36182. */
  36183. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36184. private _blockMaterialDirtyMechanism;
  36185. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36186. blockMaterialDirtyMechanism: boolean;
  36187. /**
  36188. * Will flag all materials as dirty to trigger new shader compilation
  36189. * @param flag defines the flag used to specify which material part must be marked as dirty
  36190. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36191. */
  36192. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36193. /** @hidden */
  36194. _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;
  36195. /** @hidden */
  36196. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36197. /** @hidden */
  36198. _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;
  36199. /** @hidden */
  36200. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36201. /** @hidden */
  36202. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36203. /** @hidden */
  36204. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36205. }
  36206. }
  36207. declare module "babylonjs/assetContainer" {
  36208. import { AbstractScene } from "babylonjs/abstractScene";
  36209. import { Scene } from "babylonjs/scene";
  36210. import { Mesh } from "babylonjs/Meshes/mesh";
  36211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36212. import { Skeleton } from "babylonjs/Bones/skeleton";
  36213. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36214. /**
  36215. * Set of assets to keep when moving a scene into an asset container.
  36216. */
  36217. export class KeepAssets extends AbstractScene {
  36218. }
  36219. /**
  36220. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36221. */
  36222. export class InstantiatedEntries {
  36223. /**
  36224. * List of new root nodes (eg. nodes with no parent)
  36225. */
  36226. rootNodes: TransformNode[];
  36227. /**
  36228. * List of new skeletons
  36229. */
  36230. skeletons: Skeleton[];
  36231. /**
  36232. * List of new animation groups
  36233. */
  36234. animationGroups: AnimationGroup[];
  36235. }
  36236. /**
  36237. * Container with a set of assets that can be added or removed from a scene.
  36238. */
  36239. export class AssetContainer extends AbstractScene {
  36240. /**
  36241. * The scene the AssetContainer belongs to.
  36242. */
  36243. scene: Scene;
  36244. /**
  36245. * Instantiates an AssetContainer.
  36246. * @param scene The scene the AssetContainer belongs to.
  36247. */
  36248. constructor(scene: Scene);
  36249. /**
  36250. * Instantiate or clone all meshes and add the new ones to the scene.
  36251. * Skeletons and animation groups will all be cloned
  36252. * @param nameFunction defines an optional function used to get new names for clones
  36253. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36254. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36255. */
  36256. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36257. /**
  36258. * Adds all the assets from the container to the scene.
  36259. */
  36260. addAllToScene(): void;
  36261. /**
  36262. * Removes all the assets in the container from the scene
  36263. */
  36264. removeAllFromScene(): void;
  36265. /**
  36266. * Disposes all the assets in the container
  36267. */
  36268. dispose(): void;
  36269. private _moveAssets;
  36270. /**
  36271. * Removes all the assets contained in the scene and adds them to the container.
  36272. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36273. */
  36274. moveAllFromScene(keepAssets?: KeepAssets): void;
  36275. /**
  36276. * 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.
  36277. * @returns the root mesh
  36278. */
  36279. createRootMesh(): Mesh;
  36280. }
  36281. }
  36282. declare module "babylonjs/abstractScene" {
  36283. import { Scene } from "babylonjs/scene";
  36284. import { Nullable } from "babylonjs/types";
  36285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36286. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36287. import { Geometry } from "babylonjs/Meshes/geometry";
  36288. import { Skeleton } from "babylonjs/Bones/skeleton";
  36289. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36290. import { AssetContainer } from "babylonjs/assetContainer";
  36291. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36292. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36294. import { Material } from "babylonjs/Materials/material";
  36295. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36296. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36297. import { Camera } from "babylonjs/Cameras/camera";
  36298. import { Light } from "babylonjs/Lights/light";
  36299. import { Node } from "babylonjs/node";
  36300. import { Animation } from "babylonjs/Animations/animation";
  36301. /**
  36302. * Defines how the parser contract is defined.
  36303. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36304. */
  36305. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36306. /**
  36307. * Defines how the individual parser contract is defined.
  36308. * These parser can parse an individual asset
  36309. */
  36310. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36311. /**
  36312. * Base class of the scene acting as a container for the different elements composing a scene.
  36313. * This class is dynamically extended by the different components of the scene increasing
  36314. * flexibility and reducing coupling
  36315. */
  36316. export abstract class AbstractScene {
  36317. /**
  36318. * Stores the list of available parsers in the application.
  36319. */
  36320. private static _BabylonFileParsers;
  36321. /**
  36322. * Stores the list of available individual parsers in the application.
  36323. */
  36324. private static _IndividualBabylonFileParsers;
  36325. /**
  36326. * Adds a parser in the list of available ones
  36327. * @param name Defines the name of the parser
  36328. * @param parser Defines the parser to add
  36329. */
  36330. static AddParser(name: string, parser: BabylonFileParser): void;
  36331. /**
  36332. * Gets a general parser from the list of avaialble ones
  36333. * @param name Defines the name of the parser
  36334. * @returns the requested parser or null
  36335. */
  36336. static GetParser(name: string): Nullable<BabylonFileParser>;
  36337. /**
  36338. * Adds n individual parser in the list of available ones
  36339. * @param name Defines the name of the parser
  36340. * @param parser Defines the parser to add
  36341. */
  36342. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36343. /**
  36344. * Gets an individual parser from the list of avaialble ones
  36345. * @param name Defines the name of the parser
  36346. * @returns the requested parser or null
  36347. */
  36348. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36349. /**
  36350. * Parser json data and populate both a scene and its associated container object
  36351. * @param jsonData Defines the data to parse
  36352. * @param scene Defines the scene to parse the data for
  36353. * @param container Defines the container attached to the parsing sequence
  36354. * @param rootUrl Defines the root url of the data
  36355. */
  36356. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36357. /**
  36358. * Gets the list of root nodes (ie. nodes with no parent)
  36359. */
  36360. rootNodes: Node[];
  36361. /** All of the cameras added to this scene
  36362. * @see http://doc.babylonjs.com/babylon101/cameras
  36363. */
  36364. cameras: Camera[];
  36365. /**
  36366. * All of the lights added to this scene
  36367. * @see http://doc.babylonjs.com/babylon101/lights
  36368. */
  36369. lights: Light[];
  36370. /**
  36371. * All of the (abstract) meshes added to this scene
  36372. */
  36373. meshes: AbstractMesh[];
  36374. /**
  36375. * The list of skeletons added to the scene
  36376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36377. */
  36378. skeletons: Skeleton[];
  36379. /**
  36380. * All of the particle systems added to this scene
  36381. * @see http://doc.babylonjs.com/babylon101/particles
  36382. */
  36383. particleSystems: IParticleSystem[];
  36384. /**
  36385. * Gets a list of Animations associated with the scene
  36386. */
  36387. animations: Animation[];
  36388. /**
  36389. * All of the animation groups added to this scene
  36390. * @see http://doc.babylonjs.com/how_to/group
  36391. */
  36392. animationGroups: AnimationGroup[];
  36393. /**
  36394. * All of the multi-materials added to this scene
  36395. * @see http://doc.babylonjs.com/how_to/multi_materials
  36396. */
  36397. multiMaterials: MultiMaterial[];
  36398. /**
  36399. * All of the materials added to this scene
  36400. * In the context of a Scene, it is not supposed to be modified manually.
  36401. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36402. * Note also that the order of the Material within the array is not significant and might change.
  36403. * @see http://doc.babylonjs.com/babylon101/materials
  36404. */
  36405. materials: Material[];
  36406. /**
  36407. * The list of morph target managers added to the scene
  36408. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36409. */
  36410. morphTargetManagers: MorphTargetManager[];
  36411. /**
  36412. * The list of geometries used in the scene.
  36413. */
  36414. geometries: Geometry[];
  36415. /**
  36416. * All of the tranform nodes added to this scene
  36417. * In the context of a Scene, it is not supposed to be modified manually.
  36418. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36419. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36420. * @see http://doc.babylonjs.com/how_to/transformnode
  36421. */
  36422. transformNodes: TransformNode[];
  36423. /**
  36424. * ActionManagers available on the scene.
  36425. */
  36426. actionManagers: AbstractActionManager[];
  36427. /**
  36428. * Textures to keep.
  36429. */
  36430. textures: BaseTexture[];
  36431. /**
  36432. * Environment texture for the scene
  36433. */
  36434. environmentTexture: Nullable<BaseTexture>;
  36435. }
  36436. }
  36437. declare module "babylonjs/Audio/sound" {
  36438. import { Observable } from "babylonjs/Misc/observable";
  36439. import { Vector3 } from "babylonjs/Maths/math.vector";
  36440. import { Nullable } from "babylonjs/types";
  36441. import { Scene } from "babylonjs/scene";
  36442. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36443. /**
  36444. * Interface used to define options for Sound class
  36445. */
  36446. export interface ISoundOptions {
  36447. /**
  36448. * Does the sound autoplay once loaded.
  36449. */
  36450. autoplay?: boolean;
  36451. /**
  36452. * Does the sound loop after it finishes playing once.
  36453. */
  36454. loop?: boolean;
  36455. /**
  36456. * Sound's volume
  36457. */
  36458. volume?: number;
  36459. /**
  36460. * Is it a spatial sound?
  36461. */
  36462. spatialSound?: boolean;
  36463. /**
  36464. * Maximum distance to hear that sound
  36465. */
  36466. maxDistance?: number;
  36467. /**
  36468. * Uses user defined attenuation function
  36469. */
  36470. useCustomAttenuation?: boolean;
  36471. /**
  36472. * Define the roll off factor of spatial sounds.
  36473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36474. */
  36475. rolloffFactor?: number;
  36476. /**
  36477. * Define the reference distance the sound should be heard perfectly.
  36478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36479. */
  36480. refDistance?: number;
  36481. /**
  36482. * Define the distance attenuation model the sound will follow.
  36483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36484. */
  36485. distanceModel?: string;
  36486. /**
  36487. * Defines the playback speed (1 by default)
  36488. */
  36489. playbackRate?: number;
  36490. /**
  36491. * Defines if the sound is from a streaming source
  36492. */
  36493. streaming?: boolean;
  36494. /**
  36495. * Defines an optional length (in seconds) inside the sound file
  36496. */
  36497. length?: number;
  36498. /**
  36499. * Defines an optional offset (in seconds) inside the sound file
  36500. */
  36501. offset?: number;
  36502. /**
  36503. * If true, URLs will not be required to state the audio file codec to use.
  36504. */
  36505. skipCodecCheck?: boolean;
  36506. }
  36507. /**
  36508. * Defines a sound that can be played in the application.
  36509. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36511. */
  36512. export class Sound {
  36513. /**
  36514. * The name of the sound in the scene.
  36515. */
  36516. name: string;
  36517. /**
  36518. * Does the sound autoplay once loaded.
  36519. */
  36520. autoplay: boolean;
  36521. /**
  36522. * Does the sound loop after it finishes playing once.
  36523. */
  36524. loop: boolean;
  36525. /**
  36526. * Does the sound use a custom attenuation curve to simulate the falloff
  36527. * happening when the source gets further away from the camera.
  36528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36529. */
  36530. useCustomAttenuation: boolean;
  36531. /**
  36532. * The sound track id this sound belongs to.
  36533. */
  36534. soundTrackId: number;
  36535. /**
  36536. * Is this sound currently played.
  36537. */
  36538. isPlaying: boolean;
  36539. /**
  36540. * Is this sound currently paused.
  36541. */
  36542. isPaused: boolean;
  36543. /**
  36544. * Does this sound enables spatial sound.
  36545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36546. */
  36547. spatialSound: boolean;
  36548. /**
  36549. * Define the reference distance the sound should be heard perfectly.
  36550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36551. */
  36552. refDistance: number;
  36553. /**
  36554. * Define the roll off factor of spatial sounds.
  36555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36556. */
  36557. rolloffFactor: number;
  36558. /**
  36559. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36561. */
  36562. maxDistance: number;
  36563. /**
  36564. * Define the distance attenuation model the sound will follow.
  36565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36566. */
  36567. distanceModel: string;
  36568. /**
  36569. * @hidden
  36570. * Back Compat
  36571. **/
  36572. onended: () => any;
  36573. /**
  36574. * Observable event when the current playing sound finishes.
  36575. */
  36576. onEndedObservable: Observable<Sound>;
  36577. private _panningModel;
  36578. private _playbackRate;
  36579. private _streaming;
  36580. private _startTime;
  36581. private _startOffset;
  36582. private _position;
  36583. /** @hidden */
  36584. _positionInEmitterSpace: boolean;
  36585. private _localDirection;
  36586. private _volume;
  36587. private _isReadyToPlay;
  36588. private _isDirectional;
  36589. private _readyToPlayCallback;
  36590. private _audioBuffer;
  36591. private _soundSource;
  36592. private _streamingSource;
  36593. private _soundPanner;
  36594. private _soundGain;
  36595. private _inputAudioNode;
  36596. private _outputAudioNode;
  36597. private _coneInnerAngle;
  36598. private _coneOuterAngle;
  36599. private _coneOuterGain;
  36600. private _scene;
  36601. private _connectedTransformNode;
  36602. private _customAttenuationFunction;
  36603. private _registerFunc;
  36604. private _isOutputConnected;
  36605. private _htmlAudioElement;
  36606. private _urlType;
  36607. private _length?;
  36608. private _offset?;
  36609. /** @hidden */
  36610. static _SceneComponentInitialization: (scene: Scene) => void;
  36611. /**
  36612. * Create a sound and attach it to a scene
  36613. * @param name Name of your sound
  36614. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36615. * @param scene defines the scene the sound belongs to
  36616. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36617. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36618. */
  36619. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36620. /**
  36621. * Release the sound and its associated resources
  36622. */
  36623. dispose(): void;
  36624. /**
  36625. * Gets if the sounds is ready to be played or not.
  36626. * @returns true if ready, otherwise false
  36627. */
  36628. isReady(): boolean;
  36629. private _soundLoaded;
  36630. /**
  36631. * Sets the data of the sound from an audiobuffer
  36632. * @param audioBuffer The audioBuffer containing the data
  36633. */
  36634. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36635. /**
  36636. * Updates the current sounds options such as maxdistance, loop...
  36637. * @param options A JSON object containing values named as the object properties
  36638. */
  36639. updateOptions(options: ISoundOptions): void;
  36640. private _createSpatialParameters;
  36641. private _updateSpatialParameters;
  36642. /**
  36643. * Switch the panning model to HRTF:
  36644. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36646. */
  36647. switchPanningModelToHRTF(): void;
  36648. /**
  36649. * Switch the panning model to Equal Power:
  36650. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36652. */
  36653. switchPanningModelToEqualPower(): void;
  36654. private _switchPanningModel;
  36655. /**
  36656. * Connect this sound to a sound track audio node like gain...
  36657. * @param soundTrackAudioNode the sound track audio node to connect to
  36658. */
  36659. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36660. /**
  36661. * Transform this sound into a directional source
  36662. * @param coneInnerAngle Size of the inner cone in degree
  36663. * @param coneOuterAngle Size of the outer cone in degree
  36664. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36665. */
  36666. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36667. /**
  36668. * Gets or sets the inner angle for the directional cone.
  36669. */
  36670. /**
  36671. * Gets or sets the inner angle for the directional cone.
  36672. */
  36673. directionalConeInnerAngle: number;
  36674. /**
  36675. * Gets or sets the outer angle for the directional cone.
  36676. */
  36677. /**
  36678. * Gets or sets the outer angle for the directional cone.
  36679. */
  36680. directionalConeOuterAngle: number;
  36681. /**
  36682. * Sets the position of the emitter if spatial sound is enabled
  36683. * @param newPosition Defines the new posisiton
  36684. */
  36685. setPosition(newPosition: Vector3): void;
  36686. /**
  36687. * Sets the local direction of the emitter if spatial sound is enabled
  36688. * @param newLocalDirection Defines the new local direction
  36689. */
  36690. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36691. private _updateDirection;
  36692. /** @hidden */
  36693. updateDistanceFromListener(): void;
  36694. /**
  36695. * Sets a new custom attenuation function for the sound.
  36696. * @param callback Defines the function used for the attenuation
  36697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36698. */
  36699. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36700. /**
  36701. * Play the sound
  36702. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36703. * @param offset (optional) Start the sound at a specific time in seconds
  36704. * @param length (optional) Sound duration (in seconds)
  36705. */
  36706. play(time?: number, offset?: number, length?: number): void;
  36707. private _onended;
  36708. /**
  36709. * Stop the sound
  36710. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36711. */
  36712. stop(time?: number): void;
  36713. /**
  36714. * Put the sound in pause
  36715. */
  36716. pause(): void;
  36717. /**
  36718. * Sets a dedicated volume for this sounds
  36719. * @param newVolume Define the new volume of the sound
  36720. * @param time Define time for gradual change to new volume
  36721. */
  36722. setVolume(newVolume: number, time?: number): void;
  36723. /**
  36724. * Set the sound play back rate
  36725. * @param newPlaybackRate Define the playback rate the sound should be played at
  36726. */
  36727. setPlaybackRate(newPlaybackRate: number): void;
  36728. /**
  36729. * Gets the volume of the sound.
  36730. * @returns the volume of the sound
  36731. */
  36732. getVolume(): number;
  36733. /**
  36734. * Attach the sound to a dedicated mesh
  36735. * @param transformNode The transform node to connect the sound with
  36736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36737. */
  36738. attachToMesh(transformNode: TransformNode): void;
  36739. /**
  36740. * Detach the sound from the previously attached mesh
  36741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36742. */
  36743. detachFromMesh(): void;
  36744. private _onRegisterAfterWorldMatrixUpdate;
  36745. /**
  36746. * Clone the current sound in the scene.
  36747. * @returns the new sound clone
  36748. */
  36749. clone(): Nullable<Sound>;
  36750. /**
  36751. * Gets the current underlying audio buffer containing the data
  36752. * @returns the audio buffer
  36753. */
  36754. getAudioBuffer(): Nullable<AudioBuffer>;
  36755. /**
  36756. * Serializes the Sound in a JSON representation
  36757. * @returns the JSON representation of the sound
  36758. */
  36759. serialize(): any;
  36760. /**
  36761. * Parse a JSON representation of a sound to innstantiate in a given scene
  36762. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36763. * @param scene Define the scene the new parsed sound should be created in
  36764. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36765. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36766. * @returns the newly parsed sound
  36767. */
  36768. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36769. }
  36770. }
  36771. declare module "babylonjs/Actions/directAudioActions" {
  36772. import { Action } from "babylonjs/Actions/action";
  36773. import { Condition } from "babylonjs/Actions/condition";
  36774. import { Sound } from "babylonjs/Audio/sound";
  36775. /**
  36776. * This defines an action helpful to play a defined sound on a triggered action.
  36777. */
  36778. export class PlaySoundAction extends Action {
  36779. private _sound;
  36780. /**
  36781. * Instantiate the action
  36782. * @param triggerOptions defines the trigger options
  36783. * @param sound defines the sound to play
  36784. * @param condition defines the trigger related conditions
  36785. */
  36786. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36787. /** @hidden */
  36788. _prepare(): void;
  36789. /**
  36790. * Execute the action and play the sound.
  36791. */
  36792. execute(): void;
  36793. /**
  36794. * Serializes the actions and its related information.
  36795. * @param parent defines the object to serialize in
  36796. * @returns the serialized object
  36797. */
  36798. serialize(parent: any): any;
  36799. }
  36800. /**
  36801. * This defines an action helpful to stop a defined sound on a triggered action.
  36802. */
  36803. export class StopSoundAction extends Action {
  36804. private _sound;
  36805. /**
  36806. * Instantiate the action
  36807. * @param triggerOptions defines the trigger options
  36808. * @param sound defines the sound to stop
  36809. * @param condition defines the trigger related conditions
  36810. */
  36811. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36812. /** @hidden */
  36813. _prepare(): void;
  36814. /**
  36815. * Execute the action and stop the sound.
  36816. */
  36817. execute(): void;
  36818. /**
  36819. * Serializes the actions and its related information.
  36820. * @param parent defines the object to serialize in
  36821. * @returns the serialized object
  36822. */
  36823. serialize(parent: any): any;
  36824. }
  36825. }
  36826. declare module "babylonjs/Actions/interpolateValueAction" {
  36827. import { Action } from "babylonjs/Actions/action";
  36828. import { Condition } from "babylonjs/Actions/condition";
  36829. import { Observable } from "babylonjs/Misc/observable";
  36830. /**
  36831. * This defines an action responsible to change the value of a property
  36832. * by interpolating between its current value and the newly set one once triggered.
  36833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36834. */
  36835. export class InterpolateValueAction extends Action {
  36836. /**
  36837. * Defines the path of the property where the value should be interpolated
  36838. */
  36839. propertyPath: string;
  36840. /**
  36841. * Defines the target value at the end of the interpolation.
  36842. */
  36843. value: any;
  36844. /**
  36845. * Defines the time it will take for the property to interpolate to the value.
  36846. */
  36847. duration: number;
  36848. /**
  36849. * Defines if the other scene animations should be stopped when the action has been triggered
  36850. */
  36851. stopOtherAnimations?: boolean;
  36852. /**
  36853. * Defines a callback raised once the interpolation animation has been done.
  36854. */
  36855. onInterpolationDone?: () => void;
  36856. /**
  36857. * Observable triggered once the interpolation animation has been done.
  36858. */
  36859. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36860. private _target;
  36861. private _effectiveTarget;
  36862. private _property;
  36863. /**
  36864. * Instantiate the action
  36865. * @param triggerOptions defines the trigger options
  36866. * @param target defines the object containing the value to interpolate
  36867. * @param propertyPath defines the path to the property in the target object
  36868. * @param value defines the target value at the end of the interpolation
  36869. * @param duration deines the time it will take for the property to interpolate to the value.
  36870. * @param condition defines the trigger related conditions
  36871. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36872. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36873. */
  36874. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36875. /** @hidden */
  36876. _prepare(): void;
  36877. /**
  36878. * Execute the action starts the value interpolation.
  36879. */
  36880. execute(): void;
  36881. /**
  36882. * Serializes the actions and its related information.
  36883. * @param parent defines the object to serialize in
  36884. * @returns the serialized object
  36885. */
  36886. serialize(parent: any): any;
  36887. }
  36888. }
  36889. declare module "babylonjs/Actions/index" {
  36890. export * from "babylonjs/Actions/abstractActionManager";
  36891. export * from "babylonjs/Actions/action";
  36892. export * from "babylonjs/Actions/actionEvent";
  36893. export * from "babylonjs/Actions/actionManager";
  36894. export * from "babylonjs/Actions/condition";
  36895. export * from "babylonjs/Actions/directActions";
  36896. export * from "babylonjs/Actions/directAudioActions";
  36897. export * from "babylonjs/Actions/interpolateValueAction";
  36898. }
  36899. declare module "babylonjs/Animations/index" {
  36900. export * from "babylonjs/Animations/animatable";
  36901. export * from "babylonjs/Animations/animation";
  36902. export * from "babylonjs/Animations/animationGroup";
  36903. export * from "babylonjs/Animations/animationPropertiesOverride";
  36904. export * from "babylonjs/Animations/easing";
  36905. export * from "babylonjs/Animations/runtimeAnimation";
  36906. export * from "babylonjs/Animations/animationEvent";
  36907. export * from "babylonjs/Animations/animationGroup";
  36908. export * from "babylonjs/Animations/animationKey";
  36909. export * from "babylonjs/Animations/animationRange";
  36910. export * from "babylonjs/Animations/animatable.interface";
  36911. }
  36912. declare module "babylonjs/Audio/soundTrack" {
  36913. import { Sound } from "babylonjs/Audio/sound";
  36914. import { Analyser } from "babylonjs/Audio/analyser";
  36915. import { Scene } from "babylonjs/scene";
  36916. /**
  36917. * Options allowed during the creation of a sound track.
  36918. */
  36919. export interface ISoundTrackOptions {
  36920. /**
  36921. * The volume the sound track should take during creation
  36922. */
  36923. volume?: number;
  36924. /**
  36925. * Define if the sound track is the main sound track of the scene
  36926. */
  36927. mainTrack?: boolean;
  36928. }
  36929. /**
  36930. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36931. * It will be also used in a future release to apply effects on a specific track.
  36932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36933. */
  36934. export class SoundTrack {
  36935. /**
  36936. * The unique identifier of the sound track in the scene.
  36937. */
  36938. id: number;
  36939. /**
  36940. * The list of sounds included in the sound track.
  36941. */
  36942. soundCollection: Array<Sound>;
  36943. private _outputAudioNode;
  36944. private _scene;
  36945. private _connectedAnalyser;
  36946. private _options;
  36947. private _isInitialized;
  36948. /**
  36949. * Creates a new sound track.
  36950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36951. * @param scene Define the scene the sound track belongs to
  36952. * @param options
  36953. */
  36954. constructor(scene: Scene, options?: ISoundTrackOptions);
  36955. private _initializeSoundTrackAudioGraph;
  36956. /**
  36957. * Release the sound track and its associated resources
  36958. */
  36959. dispose(): void;
  36960. /**
  36961. * Adds a sound to this sound track
  36962. * @param sound define the cound to add
  36963. * @ignoreNaming
  36964. */
  36965. AddSound(sound: Sound): void;
  36966. /**
  36967. * Removes a sound to this sound track
  36968. * @param sound define the cound to remove
  36969. * @ignoreNaming
  36970. */
  36971. RemoveSound(sound: Sound): void;
  36972. /**
  36973. * Set a global volume for the full sound track.
  36974. * @param newVolume Define the new volume of the sound track
  36975. */
  36976. setVolume(newVolume: number): void;
  36977. /**
  36978. * Switch the panning model to HRTF:
  36979. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36981. */
  36982. switchPanningModelToHRTF(): void;
  36983. /**
  36984. * Switch the panning model to Equal Power:
  36985. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36987. */
  36988. switchPanningModelToEqualPower(): void;
  36989. /**
  36990. * Connect the sound track to an audio analyser allowing some amazing
  36991. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36993. * @param analyser The analyser to connect to the engine
  36994. */
  36995. connectToAnalyser(analyser: Analyser): void;
  36996. }
  36997. }
  36998. declare module "babylonjs/Audio/audioSceneComponent" {
  36999. import { Sound } from "babylonjs/Audio/sound";
  37000. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  37001. import { Nullable } from "babylonjs/types";
  37002. import { Vector3 } from "babylonjs/Maths/math.vector";
  37003. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  37004. import { Scene } from "babylonjs/scene";
  37005. import { AbstractScene } from "babylonjs/abstractScene";
  37006. import "babylonjs/Audio/audioEngine";
  37007. module "babylonjs/abstractScene" {
  37008. interface AbstractScene {
  37009. /**
  37010. * The list of sounds used in the scene.
  37011. */
  37012. sounds: Nullable<Array<Sound>>;
  37013. }
  37014. }
  37015. module "babylonjs/scene" {
  37016. interface Scene {
  37017. /**
  37018. * @hidden
  37019. * Backing field
  37020. */
  37021. _mainSoundTrack: SoundTrack;
  37022. /**
  37023. * The main sound track played by the scene.
  37024. * It cotains your primary collection of sounds.
  37025. */
  37026. mainSoundTrack: SoundTrack;
  37027. /**
  37028. * The list of sound tracks added to the scene
  37029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37030. */
  37031. soundTracks: Nullable<Array<SoundTrack>>;
  37032. /**
  37033. * Gets a sound using a given name
  37034. * @param name defines the name to search for
  37035. * @return the found sound or null if not found at all.
  37036. */
  37037. getSoundByName(name: string): Nullable<Sound>;
  37038. /**
  37039. * Gets or sets if audio support is enabled
  37040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37041. */
  37042. audioEnabled: boolean;
  37043. /**
  37044. * Gets or sets if audio will be output to headphones
  37045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37046. */
  37047. headphone: boolean;
  37048. /**
  37049. * Gets or sets custom audio listener position provider
  37050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37051. */
  37052. audioListenerPositionProvider: Nullable<() => Vector3>;
  37053. /**
  37054. * Gets or sets a refresh rate when using 3D audio positioning
  37055. */
  37056. audioPositioningRefreshRate: number;
  37057. }
  37058. }
  37059. /**
  37060. * Defines the sound scene component responsible to manage any sounds
  37061. * in a given scene.
  37062. */
  37063. export class AudioSceneComponent implements ISceneSerializableComponent {
  37064. /**
  37065. * The component name helpfull to identify the component in the list of scene components.
  37066. */
  37067. readonly name: string;
  37068. /**
  37069. * The scene the component belongs to.
  37070. */
  37071. scene: Scene;
  37072. private _audioEnabled;
  37073. /**
  37074. * Gets whether audio is enabled or not.
  37075. * Please use related enable/disable method to switch state.
  37076. */
  37077. readonly audioEnabled: boolean;
  37078. private _headphone;
  37079. /**
  37080. * Gets whether audio is outputing to headphone or not.
  37081. * Please use the according Switch methods to change output.
  37082. */
  37083. readonly headphone: boolean;
  37084. /**
  37085. * Gets or sets a refresh rate when using 3D audio positioning
  37086. */
  37087. audioPositioningRefreshRate: number;
  37088. private _audioListenerPositionProvider;
  37089. /**
  37090. * Gets the current audio listener position provider
  37091. */
  37092. /**
  37093. * Sets a custom listener position for all sounds in the scene
  37094. * By default, this is the position of the first active camera
  37095. */
  37096. audioListenerPositionProvider: Nullable<() => Vector3>;
  37097. /**
  37098. * Creates a new instance of the component for the given scene
  37099. * @param scene Defines the scene to register the component in
  37100. */
  37101. constructor(scene: Scene);
  37102. /**
  37103. * Registers the component in a given scene
  37104. */
  37105. register(): void;
  37106. /**
  37107. * Rebuilds the elements related to this component in case of
  37108. * context lost for instance.
  37109. */
  37110. rebuild(): void;
  37111. /**
  37112. * Serializes the component data to the specified json object
  37113. * @param serializationObject The object to serialize to
  37114. */
  37115. serialize(serializationObject: any): void;
  37116. /**
  37117. * Adds all the elements from the container to the scene
  37118. * @param container the container holding the elements
  37119. */
  37120. addFromContainer(container: AbstractScene): void;
  37121. /**
  37122. * Removes all the elements in the container from the scene
  37123. * @param container contains the elements to remove
  37124. * @param dispose if the removed element should be disposed (default: false)
  37125. */
  37126. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37127. /**
  37128. * Disposes the component and the associated ressources.
  37129. */
  37130. dispose(): void;
  37131. /**
  37132. * Disables audio in the associated scene.
  37133. */
  37134. disableAudio(): void;
  37135. /**
  37136. * Enables audio in the associated scene.
  37137. */
  37138. enableAudio(): void;
  37139. /**
  37140. * Switch audio to headphone output.
  37141. */
  37142. switchAudioModeForHeadphones(): void;
  37143. /**
  37144. * Switch audio to normal speakers.
  37145. */
  37146. switchAudioModeForNormalSpeakers(): void;
  37147. private _cachedCameraDirection;
  37148. private _cachedCameraPosition;
  37149. private _lastCheck;
  37150. private _afterRender;
  37151. }
  37152. }
  37153. declare module "babylonjs/Audio/weightedsound" {
  37154. import { Sound } from "babylonjs/Audio/sound";
  37155. /**
  37156. * Wraps one or more Sound objects and selects one with random weight for playback.
  37157. */
  37158. export class WeightedSound {
  37159. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37160. loop: boolean;
  37161. private _coneInnerAngle;
  37162. private _coneOuterAngle;
  37163. private _volume;
  37164. /** A Sound is currently playing. */
  37165. isPlaying: boolean;
  37166. /** A Sound is currently paused. */
  37167. isPaused: boolean;
  37168. private _sounds;
  37169. private _weights;
  37170. private _currentIndex?;
  37171. /**
  37172. * Creates a new WeightedSound from the list of sounds given.
  37173. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37174. * @param sounds Array of Sounds that will be selected from.
  37175. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37176. */
  37177. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37178. /**
  37179. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37180. */
  37181. /**
  37182. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37183. */
  37184. directionalConeInnerAngle: number;
  37185. /**
  37186. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37187. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37188. */
  37189. /**
  37190. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37191. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37192. */
  37193. directionalConeOuterAngle: number;
  37194. /**
  37195. * Playback volume.
  37196. */
  37197. /**
  37198. * Playback volume.
  37199. */
  37200. volume: number;
  37201. private _onended;
  37202. /**
  37203. * Suspend playback
  37204. */
  37205. pause(): void;
  37206. /**
  37207. * Stop playback
  37208. */
  37209. stop(): void;
  37210. /**
  37211. * Start playback.
  37212. * @param startOffset Position the clip head at a specific time in seconds.
  37213. */
  37214. play(startOffset?: number): void;
  37215. }
  37216. }
  37217. declare module "babylonjs/Audio/index" {
  37218. export * from "babylonjs/Audio/analyser";
  37219. export * from "babylonjs/Audio/audioEngine";
  37220. export * from "babylonjs/Audio/audioSceneComponent";
  37221. export * from "babylonjs/Audio/sound";
  37222. export * from "babylonjs/Audio/soundTrack";
  37223. export * from "babylonjs/Audio/weightedsound";
  37224. }
  37225. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37226. import { Behavior } from "babylonjs/Behaviors/behavior";
  37227. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37228. import { BackEase } from "babylonjs/Animations/easing";
  37229. /**
  37230. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37232. */
  37233. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37234. /**
  37235. * Gets the name of the behavior.
  37236. */
  37237. readonly name: string;
  37238. /**
  37239. * The easing function used by animations
  37240. */
  37241. static EasingFunction: BackEase;
  37242. /**
  37243. * The easing mode used by animations
  37244. */
  37245. static EasingMode: number;
  37246. /**
  37247. * The duration of the animation, in milliseconds
  37248. */
  37249. transitionDuration: number;
  37250. /**
  37251. * Length of the distance animated by the transition when lower radius is reached
  37252. */
  37253. lowerRadiusTransitionRange: number;
  37254. /**
  37255. * Length of the distance animated by the transition when upper radius is reached
  37256. */
  37257. upperRadiusTransitionRange: number;
  37258. private _autoTransitionRange;
  37259. /**
  37260. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37261. */
  37262. /**
  37263. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37264. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37265. */
  37266. autoTransitionRange: boolean;
  37267. private _attachedCamera;
  37268. private _onAfterCheckInputsObserver;
  37269. private _onMeshTargetChangedObserver;
  37270. /**
  37271. * Initializes the behavior.
  37272. */
  37273. init(): void;
  37274. /**
  37275. * Attaches the behavior to its arc rotate camera.
  37276. * @param camera Defines the camera to attach the behavior to
  37277. */
  37278. attach(camera: ArcRotateCamera): void;
  37279. /**
  37280. * Detaches the behavior from its current arc rotate camera.
  37281. */
  37282. detach(): void;
  37283. private _radiusIsAnimating;
  37284. private _radiusBounceTransition;
  37285. private _animatables;
  37286. private _cachedWheelPrecision;
  37287. /**
  37288. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37289. * @param radiusLimit The limit to check against.
  37290. * @return Bool to indicate if at limit.
  37291. */
  37292. private _isRadiusAtLimit;
  37293. /**
  37294. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37295. * @param radiusDelta The delta by which to animate to. Can be negative.
  37296. */
  37297. private _applyBoundRadiusAnimation;
  37298. /**
  37299. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37300. */
  37301. protected _clearAnimationLocks(): void;
  37302. /**
  37303. * Stops and removes all animations that have been applied to the camera
  37304. */
  37305. stopAllAnimations(): void;
  37306. }
  37307. }
  37308. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37309. import { Behavior } from "babylonjs/Behaviors/behavior";
  37310. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37311. import { ExponentialEase } from "babylonjs/Animations/easing";
  37312. import { Nullable } from "babylonjs/types";
  37313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37314. import { Vector3 } from "babylonjs/Maths/math.vector";
  37315. /**
  37316. * 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.
  37317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37318. */
  37319. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37320. /**
  37321. * Gets the name of the behavior.
  37322. */
  37323. readonly name: string;
  37324. private _mode;
  37325. private _radiusScale;
  37326. private _positionScale;
  37327. private _defaultElevation;
  37328. private _elevationReturnTime;
  37329. private _elevationReturnWaitTime;
  37330. private _zoomStopsAnimation;
  37331. private _framingTime;
  37332. /**
  37333. * The easing function used by animations
  37334. */
  37335. static EasingFunction: ExponentialEase;
  37336. /**
  37337. * The easing mode used by animations
  37338. */
  37339. static EasingMode: number;
  37340. /**
  37341. * Sets the current mode used by the behavior
  37342. */
  37343. /**
  37344. * Gets current mode used by the behavior.
  37345. */
  37346. mode: number;
  37347. /**
  37348. * Sets the scale applied to the radius (1 by default)
  37349. */
  37350. /**
  37351. * Gets the scale applied to the radius
  37352. */
  37353. radiusScale: number;
  37354. /**
  37355. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37356. */
  37357. /**
  37358. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37359. */
  37360. positionScale: number;
  37361. /**
  37362. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37363. * behaviour is triggered, in radians.
  37364. */
  37365. /**
  37366. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37367. * behaviour is triggered, in radians.
  37368. */
  37369. defaultElevation: number;
  37370. /**
  37371. * Sets the time (in milliseconds) taken to return to the default beta position.
  37372. * Negative value indicates camera should not return to default.
  37373. */
  37374. /**
  37375. * Gets the time (in milliseconds) taken to return to the default beta position.
  37376. * Negative value indicates camera should not return to default.
  37377. */
  37378. elevationReturnTime: number;
  37379. /**
  37380. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37381. */
  37382. /**
  37383. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37384. */
  37385. elevationReturnWaitTime: number;
  37386. /**
  37387. * Sets the flag that indicates if user zooming should stop animation.
  37388. */
  37389. /**
  37390. * Gets the flag that indicates if user zooming should stop animation.
  37391. */
  37392. zoomStopsAnimation: boolean;
  37393. /**
  37394. * Sets the transition time when framing the mesh, in milliseconds
  37395. */
  37396. /**
  37397. * Gets the transition time when framing the mesh, in milliseconds
  37398. */
  37399. framingTime: number;
  37400. /**
  37401. * Define if the behavior should automatically change the configured
  37402. * camera limits and sensibilities.
  37403. */
  37404. autoCorrectCameraLimitsAndSensibility: boolean;
  37405. private _onPrePointerObservableObserver;
  37406. private _onAfterCheckInputsObserver;
  37407. private _onMeshTargetChangedObserver;
  37408. private _attachedCamera;
  37409. private _isPointerDown;
  37410. private _lastInteractionTime;
  37411. /**
  37412. * Initializes the behavior.
  37413. */
  37414. init(): void;
  37415. /**
  37416. * Attaches the behavior to its arc rotate camera.
  37417. * @param camera Defines the camera to attach the behavior to
  37418. */
  37419. attach(camera: ArcRotateCamera): void;
  37420. /**
  37421. * Detaches the behavior from its current arc rotate camera.
  37422. */
  37423. detach(): void;
  37424. private _animatables;
  37425. private _betaIsAnimating;
  37426. private _betaTransition;
  37427. private _radiusTransition;
  37428. private _vectorTransition;
  37429. /**
  37430. * Targets the given mesh and updates zoom level accordingly.
  37431. * @param mesh The mesh to target.
  37432. * @param radius Optional. If a cached radius position already exists, overrides default.
  37433. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37434. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37435. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37436. */
  37437. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37438. /**
  37439. * Targets the given mesh with its children and updates zoom level accordingly.
  37440. * @param mesh The mesh to target.
  37441. * @param radius Optional. If a cached radius position already exists, overrides default.
  37442. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37443. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37444. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37445. */
  37446. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37447. /**
  37448. * Targets the given meshes with their children and updates zoom level accordingly.
  37449. * @param meshes The mesh to target.
  37450. * @param radius Optional. If a cached radius position already exists, overrides default.
  37451. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37452. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37453. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37454. */
  37455. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37456. /**
  37457. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37458. * @param minimumWorld Determines the smaller position of the bounding box extend
  37459. * @param maximumWorld Determines the bigger position of the bounding box extend
  37460. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37461. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37462. */
  37463. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37464. /**
  37465. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37466. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37467. * frustum width.
  37468. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37469. * to fully enclose the mesh in the viewing frustum.
  37470. */
  37471. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37472. /**
  37473. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37474. * is automatically returned to its default position (expected to be above ground plane).
  37475. */
  37476. private _maintainCameraAboveGround;
  37477. /**
  37478. * Returns the frustum slope based on the canvas ratio and camera FOV
  37479. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37480. */
  37481. private _getFrustumSlope;
  37482. /**
  37483. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37484. */
  37485. private _clearAnimationLocks;
  37486. /**
  37487. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37488. */
  37489. private _applyUserInteraction;
  37490. /**
  37491. * Stops and removes all animations that have been applied to the camera
  37492. */
  37493. stopAllAnimations(): void;
  37494. /**
  37495. * Gets a value indicating if the user is moving the camera
  37496. */
  37497. readonly isUserIsMoving: boolean;
  37498. /**
  37499. * The camera can move all the way towards the mesh.
  37500. */
  37501. static IgnoreBoundsSizeMode: number;
  37502. /**
  37503. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37504. */
  37505. static FitFrustumSidesMode: number;
  37506. }
  37507. }
  37508. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37509. import { Nullable } from "babylonjs/types";
  37510. import { Camera } from "babylonjs/Cameras/camera";
  37511. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37512. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37513. /**
  37514. * Base class for Camera Pointer Inputs.
  37515. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37516. * for example usage.
  37517. */
  37518. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37519. /**
  37520. * Defines the camera the input is attached to.
  37521. */
  37522. abstract camera: Camera;
  37523. /**
  37524. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37525. */
  37526. protected _altKey: boolean;
  37527. protected _ctrlKey: boolean;
  37528. protected _metaKey: boolean;
  37529. protected _shiftKey: boolean;
  37530. /**
  37531. * Which mouse buttons were pressed at time of last mouse event.
  37532. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37533. */
  37534. protected _buttonsPressed: number;
  37535. /**
  37536. * Defines the buttons associated with the input to handle camera move.
  37537. */
  37538. buttons: number[];
  37539. /**
  37540. * Attach the input controls to a specific dom element to get the input from.
  37541. * @param element Defines the element the controls should be listened from
  37542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37543. */
  37544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37545. /**
  37546. * Detach the current controls from the specified dom element.
  37547. * @param element Defines the element to stop listening the inputs from
  37548. */
  37549. detachControl(element: Nullable<HTMLElement>): void;
  37550. /**
  37551. * Gets the class name of the current input.
  37552. * @returns the class name
  37553. */
  37554. getClassName(): string;
  37555. /**
  37556. * Get the friendly name associated with the input class.
  37557. * @returns the input friendly name
  37558. */
  37559. getSimpleName(): string;
  37560. /**
  37561. * Called on pointer POINTERDOUBLETAP event.
  37562. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37563. */
  37564. protected onDoubleTap(type: string): void;
  37565. /**
  37566. * Called on pointer POINTERMOVE event if only a single touch is active.
  37567. * Override this method to provide functionality.
  37568. */
  37569. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37570. /**
  37571. * Called on pointer POINTERMOVE event if multiple touches are active.
  37572. * Override this method to provide functionality.
  37573. */
  37574. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37575. /**
  37576. * Called on JS contextmenu event.
  37577. * Override this method to provide functionality.
  37578. */
  37579. protected onContextMenu(evt: PointerEvent): void;
  37580. /**
  37581. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37582. * press.
  37583. * Override this method to provide functionality.
  37584. */
  37585. protected onButtonDown(evt: PointerEvent): void;
  37586. /**
  37587. * Called each time a new POINTERUP event occurs. Ie, for each button
  37588. * release.
  37589. * Override this method to provide functionality.
  37590. */
  37591. protected onButtonUp(evt: PointerEvent): void;
  37592. /**
  37593. * Called when window becomes inactive.
  37594. * Override this method to provide functionality.
  37595. */
  37596. protected onLostFocus(): void;
  37597. private _pointerInput;
  37598. private _observer;
  37599. private _onLostFocus;
  37600. private pointA;
  37601. private pointB;
  37602. }
  37603. }
  37604. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37605. import { Nullable } from "babylonjs/types";
  37606. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37607. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37608. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37609. /**
  37610. * Manage the pointers inputs to control an arc rotate camera.
  37611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37612. */
  37613. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37614. /**
  37615. * Defines the camera the input is attached to.
  37616. */
  37617. camera: ArcRotateCamera;
  37618. /**
  37619. * Gets the class name of the current input.
  37620. * @returns the class name
  37621. */
  37622. getClassName(): string;
  37623. /**
  37624. * Defines the buttons associated with the input to handle camera move.
  37625. */
  37626. buttons: number[];
  37627. /**
  37628. * Defines the pointer angular sensibility along the X axis or how fast is
  37629. * the camera rotating.
  37630. */
  37631. angularSensibilityX: number;
  37632. /**
  37633. * Defines the pointer angular sensibility along the Y axis or how fast is
  37634. * the camera rotating.
  37635. */
  37636. angularSensibilityY: number;
  37637. /**
  37638. * Defines the pointer pinch precision or how fast is the camera zooming.
  37639. */
  37640. pinchPrecision: number;
  37641. /**
  37642. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37643. * from 0.
  37644. * It defines the percentage of current camera.radius to use as delta when
  37645. * pinch zoom is used.
  37646. */
  37647. pinchDeltaPercentage: number;
  37648. /**
  37649. * Defines the pointer panning sensibility or how fast is the camera moving.
  37650. */
  37651. panningSensibility: number;
  37652. /**
  37653. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37654. */
  37655. multiTouchPanning: boolean;
  37656. /**
  37657. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37658. * zoom (pinch) through multitouch.
  37659. */
  37660. multiTouchPanAndZoom: boolean;
  37661. /**
  37662. * Revers pinch action direction.
  37663. */
  37664. pinchInwards: boolean;
  37665. private _isPanClick;
  37666. private _twoFingerActivityCount;
  37667. private _isPinching;
  37668. /**
  37669. * Called on pointer POINTERMOVE event if only a single touch is active.
  37670. */
  37671. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37672. /**
  37673. * Called on pointer POINTERDOUBLETAP event.
  37674. */
  37675. protected onDoubleTap(type: string): void;
  37676. /**
  37677. * Called on pointer POINTERMOVE event if multiple touches are active.
  37678. */
  37679. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37680. /**
  37681. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37682. * press.
  37683. */
  37684. protected onButtonDown(evt: PointerEvent): void;
  37685. /**
  37686. * Called each time a new POINTERUP event occurs. Ie, for each button
  37687. * release.
  37688. */
  37689. protected onButtonUp(evt: PointerEvent): void;
  37690. /**
  37691. * Called when window becomes inactive.
  37692. */
  37693. protected onLostFocus(): void;
  37694. }
  37695. }
  37696. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37697. import { Nullable } from "babylonjs/types";
  37698. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37699. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37700. /**
  37701. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37703. */
  37704. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37705. /**
  37706. * Defines the camera the input is attached to.
  37707. */
  37708. camera: ArcRotateCamera;
  37709. /**
  37710. * Defines the list of key codes associated with the up action (increase alpha)
  37711. */
  37712. keysUp: number[];
  37713. /**
  37714. * Defines the list of key codes associated with the down action (decrease alpha)
  37715. */
  37716. keysDown: number[];
  37717. /**
  37718. * Defines the list of key codes associated with the left action (increase beta)
  37719. */
  37720. keysLeft: number[];
  37721. /**
  37722. * Defines the list of key codes associated with the right action (decrease beta)
  37723. */
  37724. keysRight: number[];
  37725. /**
  37726. * Defines the list of key codes associated with the reset action.
  37727. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37728. */
  37729. keysReset: number[];
  37730. /**
  37731. * Defines the panning sensibility of the inputs.
  37732. * (How fast is the camera paning)
  37733. */
  37734. panningSensibility: number;
  37735. /**
  37736. * Defines the zooming sensibility of the inputs.
  37737. * (How fast is the camera zooming)
  37738. */
  37739. zoomingSensibility: number;
  37740. /**
  37741. * Defines wether maintaining the alt key down switch the movement mode from
  37742. * orientation to zoom.
  37743. */
  37744. useAltToZoom: boolean;
  37745. /**
  37746. * Rotation speed of the camera
  37747. */
  37748. angularSpeed: number;
  37749. private _keys;
  37750. private _ctrlPressed;
  37751. private _altPressed;
  37752. private _onCanvasBlurObserver;
  37753. private _onKeyboardObserver;
  37754. private _engine;
  37755. private _scene;
  37756. /**
  37757. * Attach the input controls to a specific dom element to get the input from.
  37758. * @param element Defines the element the controls should be listened from
  37759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37760. */
  37761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37762. /**
  37763. * Detach the current controls from the specified dom element.
  37764. * @param element Defines the element to stop listening the inputs from
  37765. */
  37766. detachControl(element: Nullable<HTMLElement>): void;
  37767. /**
  37768. * Update the current camera state depending on the inputs that have been used this frame.
  37769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37770. */
  37771. checkInputs(): void;
  37772. /**
  37773. * Gets the class name of the current intput.
  37774. * @returns the class name
  37775. */
  37776. getClassName(): string;
  37777. /**
  37778. * Get the friendly name associated with the input class.
  37779. * @returns the input friendly name
  37780. */
  37781. getSimpleName(): string;
  37782. }
  37783. }
  37784. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37785. import { Nullable } from "babylonjs/types";
  37786. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37787. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37788. /**
  37789. * Manage the mouse wheel inputs to control an arc rotate camera.
  37790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37791. */
  37792. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37793. /**
  37794. * Defines the camera the input is attached to.
  37795. */
  37796. camera: ArcRotateCamera;
  37797. /**
  37798. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37799. */
  37800. wheelPrecision: number;
  37801. /**
  37802. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37803. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37804. */
  37805. wheelDeltaPercentage: number;
  37806. private _wheel;
  37807. private _observer;
  37808. private computeDeltaFromMouseWheelLegacyEvent;
  37809. /**
  37810. * Attach the input controls to a specific dom element to get the input from.
  37811. * @param element Defines the element the controls should be listened from
  37812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37813. */
  37814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37815. /**
  37816. * Detach the current controls from the specified dom element.
  37817. * @param element Defines the element to stop listening the inputs from
  37818. */
  37819. detachControl(element: Nullable<HTMLElement>): void;
  37820. /**
  37821. * Gets the class name of the current intput.
  37822. * @returns the class name
  37823. */
  37824. getClassName(): string;
  37825. /**
  37826. * Get the friendly name associated with the input class.
  37827. * @returns the input friendly name
  37828. */
  37829. getSimpleName(): string;
  37830. }
  37831. }
  37832. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37833. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37834. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37835. /**
  37836. * Default Inputs manager for the ArcRotateCamera.
  37837. * It groups all the default supported inputs for ease of use.
  37838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37839. */
  37840. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37841. /**
  37842. * Instantiates a new ArcRotateCameraInputsManager.
  37843. * @param camera Defines the camera the inputs belong to
  37844. */
  37845. constructor(camera: ArcRotateCamera);
  37846. /**
  37847. * Add mouse wheel input support to the input manager.
  37848. * @returns the current input manager
  37849. */
  37850. addMouseWheel(): ArcRotateCameraInputsManager;
  37851. /**
  37852. * Add pointers input support to the input manager.
  37853. * @returns the current input manager
  37854. */
  37855. addPointers(): ArcRotateCameraInputsManager;
  37856. /**
  37857. * Add keyboard input support to the input manager.
  37858. * @returns the current input manager
  37859. */
  37860. addKeyboard(): ArcRotateCameraInputsManager;
  37861. }
  37862. }
  37863. declare module "babylonjs/Cameras/arcRotateCamera" {
  37864. import { Observable } from "babylonjs/Misc/observable";
  37865. import { Nullable } from "babylonjs/types";
  37866. import { Scene } from "babylonjs/scene";
  37867. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37869. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37870. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37871. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37872. import { Camera } from "babylonjs/Cameras/camera";
  37873. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37874. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37875. import { Collider } from "babylonjs/Collisions/collider";
  37876. /**
  37877. * This represents an orbital type of camera.
  37878. *
  37879. * 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.
  37880. * 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.
  37881. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37882. */
  37883. export class ArcRotateCamera extends TargetCamera {
  37884. /**
  37885. * Defines the rotation angle of the camera along the longitudinal axis.
  37886. */
  37887. alpha: number;
  37888. /**
  37889. * Defines the rotation angle of the camera along the latitudinal axis.
  37890. */
  37891. beta: number;
  37892. /**
  37893. * Defines the radius of the camera from it s target point.
  37894. */
  37895. radius: number;
  37896. protected _target: Vector3;
  37897. protected _targetHost: Nullable<AbstractMesh>;
  37898. /**
  37899. * Defines the target point of the camera.
  37900. * The camera looks towards it form the radius distance.
  37901. */
  37902. target: Vector3;
  37903. /**
  37904. * Define the current local position of the camera in the scene
  37905. */
  37906. position: Vector3;
  37907. protected _upVector: Vector3;
  37908. protected _upToYMatrix: Matrix;
  37909. protected _YToUpMatrix: Matrix;
  37910. /**
  37911. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37912. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37913. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37914. */
  37915. upVector: Vector3;
  37916. /**
  37917. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37918. */
  37919. setMatUp(): void;
  37920. /**
  37921. * Current inertia value on the longitudinal axis.
  37922. * The bigger this number the longer it will take for the camera to stop.
  37923. */
  37924. inertialAlphaOffset: number;
  37925. /**
  37926. * Current inertia value on the latitudinal axis.
  37927. * The bigger this number the longer it will take for the camera to stop.
  37928. */
  37929. inertialBetaOffset: number;
  37930. /**
  37931. * Current inertia value on the radius axis.
  37932. * The bigger this number the longer it will take for the camera to stop.
  37933. */
  37934. inertialRadiusOffset: number;
  37935. /**
  37936. * Minimum allowed angle on the longitudinal axis.
  37937. * This can help limiting how the Camera is able to move in the scene.
  37938. */
  37939. lowerAlphaLimit: Nullable<number>;
  37940. /**
  37941. * Maximum allowed angle on the longitudinal axis.
  37942. * This can help limiting how the Camera is able to move in the scene.
  37943. */
  37944. upperAlphaLimit: Nullable<number>;
  37945. /**
  37946. * Minimum allowed angle on the latitudinal axis.
  37947. * This can help limiting how the Camera is able to move in the scene.
  37948. */
  37949. lowerBetaLimit: number;
  37950. /**
  37951. * Maximum allowed angle on the latitudinal axis.
  37952. * This can help limiting how the Camera is able to move in the scene.
  37953. */
  37954. upperBetaLimit: number;
  37955. /**
  37956. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37957. * This can help limiting how the Camera is able to move in the scene.
  37958. */
  37959. lowerRadiusLimit: Nullable<number>;
  37960. /**
  37961. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37962. * This can help limiting how the Camera is able to move in the scene.
  37963. */
  37964. upperRadiusLimit: Nullable<number>;
  37965. /**
  37966. * Defines the current inertia value used during panning of the camera along the X axis.
  37967. */
  37968. inertialPanningX: number;
  37969. /**
  37970. * Defines the current inertia value used during panning of the camera along the Y axis.
  37971. */
  37972. inertialPanningY: number;
  37973. /**
  37974. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37975. * Basically if your fingers moves away from more than this distance you will be considered
  37976. * in pinch mode.
  37977. */
  37978. pinchToPanMaxDistance: number;
  37979. /**
  37980. * Defines the maximum distance the camera can pan.
  37981. * This could help keeping the cammera always in your scene.
  37982. */
  37983. panningDistanceLimit: Nullable<number>;
  37984. /**
  37985. * Defines the target of the camera before paning.
  37986. */
  37987. panningOriginTarget: Vector3;
  37988. /**
  37989. * Defines the value of the inertia used during panning.
  37990. * 0 would mean stop inertia and one would mean no decelleration at all.
  37991. */
  37992. panningInertia: number;
  37993. /**
  37994. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37995. */
  37996. angularSensibilityX: number;
  37997. /**
  37998. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37999. */
  38000. angularSensibilityY: number;
  38001. /**
  38002. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38003. */
  38004. pinchPrecision: number;
  38005. /**
  38006. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38007. * It will be used instead of pinchDeltaPrecision if different from 0.
  38008. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38009. */
  38010. pinchDeltaPercentage: number;
  38011. /**
  38012. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38013. */
  38014. panningSensibility: number;
  38015. /**
  38016. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38017. */
  38018. keysUp: number[];
  38019. /**
  38020. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38021. */
  38022. keysDown: number[];
  38023. /**
  38024. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38025. */
  38026. keysLeft: number[];
  38027. /**
  38028. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38029. */
  38030. keysRight: number[];
  38031. /**
  38032. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38033. */
  38034. wheelPrecision: number;
  38035. /**
  38036. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38037. * It will be used instead of pinchDeltaPrecision if different from 0.
  38038. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38039. */
  38040. wheelDeltaPercentage: number;
  38041. /**
  38042. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38043. */
  38044. zoomOnFactor: number;
  38045. /**
  38046. * Defines a screen offset for the camera position.
  38047. */
  38048. targetScreenOffset: Vector2;
  38049. /**
  38050. * Allows the camera to be completely reversed.
  38051. * If false the camera can not arrive upside down.
  38052. */
  38053. allowUpsideDown: boolean;
  38054. /**
  38055. * Define if double tap/click is used to restore the previously saved state of the camera.
  38056. */
  38057. useInputToRestoreState: boolean;
  38058. /** @hidden */
  38059. _viewMatrix: Matrix;
  38060. /** @hidden */
  38061. _useCtrlForPanning: boolean;
  38062. /** @hidden */
  38063. _panningMouseButton: number;
  38064. /**
  38065. * Defines the input associated to the camera.
  38066. */
  38067. inputs: ArcRotateCameraInputsManager;
  38068. /** @hidden */
  38069. _reset: () => void;
  38070. /**
  38071. * Defines the allowed panning axis.
  38072. */
  38073. panningAxis: Vector3;
  38074. protected _localDirection: Vector3;
  38075. protected _transformedDirection: Vector3;
  38076. private _bouncingBehavior;
  38077. /**
  38078. * Gets the bouncing behavior of the camera if it has been enabled.
  38079. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38080. */
  38081. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38082. /**
  38083. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38084. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38085. */
  38086. useBouncingBehavior: boolean;
  38087. private _framingBehavior;
  38088. /**
  38089. * Gets the framing behavior of the camera if it has been enabled.
  38090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38091. */
  38092. readonly framingBehavior: Nullable<FramingBehavior>;
  38093. /**
  38094. * Defines if the framing behavior of the camera is enabled on the camera.
  38095. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38096. */
  38097. useFramingBehavior: boolean;
  38098. private _autoRotationBehavior;
  38099. /**
  38100. * Gets the auto rotation behavior of the camera if it has been enabled.
  38101. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38102. */
  38103. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38104. /**
  38105. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38107. */
  38108. useAutoRotationBehavior: boolean;
  38109. /**
  38110. * Observable triggered when the mesh target has been changed on the camera.
  38111. */
  38112. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38113. /**
  38114. * Event raised when the camera is colliding with a mesh.
  38115. */
  38116. onCollide: (collidedMesh: AbstractMesh) => void;
  38117. /**
  38118. * Defines whether the camera should check collision with the objects oh the scene.
  38119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38120. */
  38121. checkCollisions: boolean;
  38122. /**
  38123. * Defines the collision radius of the camera.
  38124. * This simulates a sphere around the camera.
  38125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38126. */
  38127. collisionRadius: Vector3;
  38128. protected _collider: Collider;
  38129. protected _previousPosition: Vector3;
  38130. protected _collisionVelocity: Vector3;
  38131. protected _newPosition: Vector3;
  38132. protected _previousAlpha: number;
  38133. protected _previousBeta: number;
  38134. protected _previousRadius: number;
  38135. protected _collisionTriggered: boolean;
  38136. protected _targetBoundingCenter: Nullable<Vector3>;
  38137. private _computationVector;
  38138. /**
  38139. * Instantiates a new ArcRotateCamera in a given scene
  38140. * @param name Defines the name of the camera
  38141. * @param alpha Defines the camera rotation along the logitudinal axis
  38142. * @param beta Defines the camera rotation along the latitudinal axis
  38143. * @param radius Defines the camera distance from its target
  38144. * @param target Defines the camera target
  38145. * @param scene Defines the scene the camera belongs to
  38146. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38147. */
  38148. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38149. /** @hidden */
  38150. _initCache(): void;
  38151. /** @hidden */
  38152. _updateCache(ignoreParentClass?: boolean): void;
  38153. protected _getTargetPosition(): Vector3;
  38154. private _storedAlpha;
  38155. private _storedBeta;
  38156. private _storedRadius;
  38157. private _storedTarget;
  38158. private _storedTargetScreenOffset;
  38159. /**
  38160. * Stores the current state of the camera (alpha, beta, radius and target)
  38161. * @returns the camera itself
  38162. */
  38163. storeState(): Camera;
  38164. /**
  38165. * @hidden
  38166. * Restored camera state. You must call storeState() first
  38167. */
  38168. _restoreStateValues(): boolean;
  38169. /** @hidden */
  38170. _isSynchronizedViewMatrix(): boolean;
  38171. /**
  38172. * Attached controls to the current camera.
  38173. * @param element Defines the element the controls should be listened from
  38174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38175. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38176. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38177. */
  38178. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38179. /**
  38180. * Detach the current controls from the camera.
  38181. * The camera will stop reacting to inputs.
  38182. * @param element Defines the element to stop listening the inputs from
  38183. */
  38184. detachControl(element: HTMLElement): void;
  38185. /** @hidden */
  38186. _checkInputs(): void;
  38187. protected _checkLimits(): void;
  38188. /**
  38189. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38190. */
  38191. rebuildAnglesAndRadius(): void;
  38192. /**
  38193. * Use a position to define the current camera related information like alpha, beta and radius
  38194. * @param position Defines the position to set the camera at
  38195. */
  38196. setPosition(position: Vector3): void;
  38197. /**
  38198. * Defines the target the camera should look at.
  38199. * This will automatically adapt alpha beta and radius to fit within the new target.
  38200. * @param target Defines the new target as a Vector or a mesh
  38201. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38202. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38203. */
  38204. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38205. /** @hidden */
  38206. _getViewMatrix(): Matrix;
  38207. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38208. /**
  38209. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38210. * @param meshes Defines the mesh to zoom on
  38211. * @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)
  38212. */
  38213. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38214. /**
  38215. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38216. * The target will be changed but the radius
  38217. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38218. * @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)
  38219. */
  38220. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38221. min: Vector3;
  38222. max: Vector3;
  38223. distance: number;
  38224. }, doNotUpdateMaxZ?: boolean): void;
  38225. /**
  38226. * @override
  38227. * Override Camera.createRigCamera
  38228. */
  38229. createRigCamera(name: string, cameraIndex: number): Camera;
  38230. /**
  38231. * @hidden
  38232. * @override
  38233. * Override Camera._updateRigCameras
  38234. */
  38235. _updateRigCameras(): void;
  38236. /**
  38237. * Destroy the camera and release the current resources hold by it.
  38238. */
  38239. dispose(): void;
  38240. /**
  38241. * Gets the current object class name.
  38242. * @return the class name
  38243. */
  38244. getClassName(): string;
  38245. }
  38246. }
  38247. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38248. import { Behavior } from "babylonjs/Behaviors/behavior";
  38249. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38250. /**
  38251. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38253. */
  38254. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38255. /**
  38256. * Gets the name of the behavior.
  38257. */
  38258. readonly name: string;
  38259. private _zoomStopsAnimation;
  38260. private _idleRotationSpeed;
  38261. private _idleRotationWaitTime;
  38262. private _idleRotationSpinupTime;
  38263. /**
  38264. * Sets the flag that indicates if user zooming should stop animation.
  38265. */
  38266. /**
  38267. * Gets the flag that indicates if user zooming should stop animation.
  38268. */
  38269. zoomStopsAnimation: boolean;
  38270. /**
  38271. * Sets the default speed at which the camera rotates around the model.
  38272. */
  38273. /**
  38274. * Gets the default speed at which the camera rotates around the model.
  38275. */
  38276. idleRotationSpeed: number;
  38277. /**
  38278. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38279. */
  38280. /**
  38281. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38282. */
  38283. idleRotationWaitTime: number;
  38284. /**
  38285. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38286. */
  38287. /**
  38288. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38289. */
  38290. idleRotationSpinupTime: number;
  38291. /**
  38292. * Gets a value indicating if the camera is currently rotating because of this behavior
  38293. */
  38294. readonly rotationInProgress: boolean;
  38295. private _onPrePointerObservableObserver;
  38296. private _onAfterCheckInputsObserver;
  38297. private _attachedCamera;
  38298. private _isPointerDown;
  38299. private _lastFrameTime;
  38300. private _lastInteractionTime;
  38301. private _cameraRotationSpeed;
  38302. /**
  38303. * Initializes the behavior.
  38304. */
  38305. init(): void;
  38306. /**
  38307. * Attaches the behavior to its arc rotate camera.
  38308. * @param camera Defines the camera to attach the behavior to
  38309. */
  38310. attach(camera: ArcRotateCamera): void;
  38311. /**
  38312. * Detaches the behavior from its current arc rotate camera.
  38313. */
  38314. detach(): void;
  38315. /**
  38316. * Returns true if user is scrolling.
  38317. * @return true if user is scrolling.
  38318. */
  38319. private _userIsZooming;
  38320. private _lastFrameRadius;
  38321. private _shouldAnimationStopForInteraction;
  38322. /**
  38323. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38324. */
  38325. private _applyUserInteraction;
  38326. private _userIsMoving;
  38327. }
  38328. }
  38329. declare module "babylonjs/Behaviors/Cameras/index" {
  38330. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38331. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38332. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38333. }
  38334. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38335. import { Mesh } from "babylonjs/Meshes/mesh";
  38336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38337. import { Behavior } from "babylonjs/Behaviors/behavior";
  38338. /**
  38339. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38340. */
  38341. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38342. private ui;
  38343. /**
  38344. * The name of the behavior
  38345. */
  38346. name: string;
  38347. /**
  38348. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38349. */
  38350. distanceAwayFromFace: number;
  38351. /**
  38352. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38353. */
  38354. distanceAwayFromBottomOfFace: number;
  38355. private _faceVectors;
  38356. private _target;
  38357. private _scene;
  38358. private _onRenderObserver;
  38359. private _tmpMatrix;
  38360. private _tmpVector;
  38361. /**
  38362. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38363. * @param ui The transform node that should be attched to the mesh
  38364. */
  38365. constructor(ui: TransformNode);
  38366. /**
  38367. * Initializes the behavior
  38368. */
  38369. init(): void;
  38370. private _closestFace;
  38371. private _zeroVector;
  38372. private _lookAtTmpMatrix;
  38373. private _lookAtToRef;
  38374. /**
  38375. * Attaches the AttachToBoxBehavior to the passed in mesh
  38376. * @param target The mesh that the specified node will be attached to
  38377. */
  38378. attach(target: Mesh): void;
  38379. /**
  38380. * Detaches the behavior from the mesh
  38381. */
  38382. detach(): void;
  38383. }
  38384. }
  38385. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38386. import { Behavior } from "babylonjs/Behaviors/behavior";
  38387. import { Mesh } from "babylonjs/Meshes/mesh";
  38388. /**
  38389. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38390. */
  38391. export class FadeInOutBehavior implements Behavior<Mesh> {
  38392. /**
  38393. * Time in milliseconds to delay before fading in (Default: 0)
  38394. */
  38395. delay: number;
  38396. /**
  38397. * Time in milliseconds for the mesh to fade in (Default: 300)
  38398. */
  38399. fadeInTime: number;
  38400. private _millisecondsPerFrame;
  38401. private _hovered;
  38402. private _hoverValue;
  38403. private _ownerNode;
  38404. /**
  38405. * Instatiates the FadeInOutBehavior
  38406. */
  38407. constructor();
  38408. /**
  38409. * The name of the behavior
  38410. */
  38411. readonly name: string;
  38412. /**
  38413. * Initializes the behavior
  38414. */
  38415. init(): void;
  38416. /**
  38417. * Attaches the fade behavior on the passed in mesh
  38418. * @param ownerNode The mesh that will be faded in/out once attached
  38419. */
  38420. attach(ownerNode: Mesh): void;
  38421. /**
  38422. * Detaches the behavior from the mesh
  38423. */
  38424. detach(): void;
  38425. /**
  38426. * Triggers the mesh to begin fading in or out
  38427. * @param value if the object should fade in or out (true to fade in)
  38428. */
  38429. fadeIn(value: boolean): void;
  38430. private _update;
  38431. private _setAllVisibility;
  38432. }
  38433. }
  38434. declare module "babylonjs/Misc/pivotTools" {
  38435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38436. /**
  38437. * Class containing a set of static utilities functions for managing Pivots
  38438. * @hidden
  38439. */
  38440. export class PivotTools {
  38441. private static _PivotCached;
  38442. private static _OldPivotPoint;
  38443. private static _PivotTranslation;
  38444. private static _PivotTmpVector;
  38445. /** @hidden */
  38446. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38447. /** @hidden */
  38448. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38449. }
  38450. }
  38451. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38452. import { Scene } from "babylonjs/scene";
  38453. import { Vector4 } from "babylonjs/Maths/math.vector";
  38454. import { Mesh } from "babylonjs/Meshes/mesh";
  38455. import { Nullable } from "babylonjs/types";
  38456. import { Plane } from "babylonjs/Maths/math.plane";
  38457. /**
  38458. * Class containing static functions to help procedurally build meshes
  38459. */
  38460. export class PlaneBuilder {
  38461. /**
  38462. * Creates a plane mesh
  38463. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38464. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38465. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38469. * @param name defines the name of the mesh
  38470. * @param options defines the options used to create the mesh
  38471. * @param scene defines the hosting scene
  38472. * @returns the plane mesh
  38473. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38474. */
  38475. static CreatePlane(name: string, options: {
  38476. size?: number;
  38477. width?: number;
  38478. height?: number;
  38479. sideOrientation?: number;
  38480. frontUVs?: Vector4;
  38481. backUVs?: Vector4;
  38482. updatable?: boolean;
  38483. sourcePlane?: Plane;
  38484. }, scene?: Nullable<Scene>): Mesh;
  38485. }
  38486. }
  38487. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38488. import { Behavior } from "babylonjs/Behaviors/behavior";
  38489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38490. import { Observable } from "babylonjs/Misc/observable";
  38491. import { Vector3 } from "babylonjs/Maths/math.vector";
  38492. import { Ray } from "babylonjs/Culling/ray";
  38493. import "babylonjs/Meshes/Builders/planeBuilder";
  38494. /**
  38495. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38496. */
  38497. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38498. private static _AnyMouseID;
  38499. /**
  38500. * Abstract mesh the behavior is set on
  38501. */
  38502. attachedNode: AbstractMesh;
  38503. private _dragPlane;
  38504. private _scene;
  38505. private _pointerObserver;
  38506. private _beforeRenderObserver;
  38507. private static _planeScene;
  38508. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38509. /**
  38510. * 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)
  38511. */
  38512. maxDragAngle: number;
  38513. /**
  38514. * @hidden
  38515. */
  38516. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38517. /**
  38518. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38519. */
  38520. currentDraggingPointerID: number;
  38521. /**
  38522. * The last position where the pointer hit the drag plane in world space
  38523. */
  38524. lastDragPosition: Vector3;
  38525. /**
  38526. * If the behavior is currently in a dragging state
  38527. */
  38528. dragging: boolean;
  38529. /**
  38530. * 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)
  38531. */
  38532. dragDeltaRatio: number;
  38533. /**
  38534. * If the drag plane orientation should be updated during the dragging (Default: true)
  38535. */
  38536. updateDragPlane: boolean;
  38537. private _debugMode;
  38538. private _moving;
  38539. /**
  38540. * Fires each time the attached mesh is dragged with the pointer
  38541. * * delta between last drag position and current drag position in world space
  38542. * * dragDistance along the drag axis
  38543. * * dragPlaneNormal normal of the current drag plane used during the drag
  38544. * * dragPlanePoint in world space where the drag intersects the drag plane
  38545. */
  38546. onDragObservable: Observable<{
  38547. delta: Vector3;
  38548. dragPlanePoint: Vector3;
  38549. dragPlaneNormal: Vector3;
  38550. dragDistance: number;
  38551. pointerId: number;
  38552. }>;
  38553. /**
  38554. * Fires each time a drag begins (eg. mouse down on mesh)
  38555. */
  38556. onDragStartObservable: Observable<{
  38557. dragPlanePoint: Vector3;
  38558. pointerId: number;
  38559. }>;
  38560. /**
  38561. * Fires each time a drag ends (eg. mouse release after drag)
  38562. */
  38563. onDragEndObservable: Observable<{
  38564. dragPlanePoint: Vector3;
  38565. pointerId: number;
  38566. }>;
  38567. /**
  38568. * If the attached mesh should be moved when dragged
  38569. */
  38570. moveAttached: boolean;
  38571. /**
  38572. * If the drag behavior will react to drag events (Default: true)
  38573. */
  38574. enabled: boolean;
  38575. /**
  38576. * If pointer events should start and release the drag (Default: true)
  38577. */
  38578. startAndReleaseDragOnPointerEvents: boolean;
  38579. /**
  38580. * If camera controls should be detached during the drag
  38581. */
  38582. detachCameraControls: boolean;
  38583. /**
  38584. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38585. */
  38586. useObjectOrienationForDragging: boolean;
  38587. private _options;
  38588. /**
  38589. * Creates a pointer drag behavior that can be attached to a mesh
  38590. * @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)
  38591. */
  38592. constructor(options?: {
  38593. dragAxis?: Vector3;
  38594. dragPlaneNormal?: Vector3;
  38595. });
  38596. /**
  38597. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38598. */
  38599. validateDrag: (targetPosition: Vector3) => boolean;
  38600. /**
  38601. * The name of the behavior
  38602. */
  38603. readonly name: string;
  38604. /**
  38605. * Initializes the behavior
  38606. */
  38607. init(): void;
  38608. private _tmpVector;
  38609. private _alternatePickedPoint;
  38610. private _worldDragAxis;
  38611. private _targetPosition;
  38612. private _attachedElement;
  38613. /**
  38614. * Attaches the drag behavior the passed in mesh
  38615. * @param ownerNode The mesh that will be dragged around once attached
  38616. * @param predicate Predicate to use for pick filtering
  38617. */
  38618. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38619. /**
  38620. * Force relase the drag action by code.
  38621. */
  38622. releaseDrag(): void;
  38623. private _startDragRay;
  38624. private _lastPointerRay;
  38625. /**
  38626. * Simulates the start of a pointer drag event on the behavior
  38627. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38628. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38629. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38630. */
  38631. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38632. private _startDrag;
  38633. private _dragDelta;
  38634. private _moveDrag;
  38635. private _pickWithRayOnDragPlane;
  38636. private _pointA;
  38637. private _pointB;
  38638. private _pointC;
  38639. private _lineA;
  38640. private _lineB;
  38641. private _localAxis;
  38642. private _lookAt;
  38643. private _updateDragPlanePosition;
  38644. /**
  38645. * Detaches the behavior from the mesh
  38646. */
  38647. detach(): void;
  38648. }
  38649. }
  38650. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38651. import { Mesh } from "babylonjs/Meshes/mesh";
  38652. import { Behavior } from "babylonjs/Behaviors/behavior";
  38653. /**
  38654. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38655. */
  38656. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38657. private _dragBehaviorA;
  38658. private _dragBehaviorB;
  38659. private _startDistance;
  38660. private _initialScale;
  38661. private _targetScale;
  38662. private _ownerNode;
  38663. private _sceneRenderObserver;
  38664. /**
  38665. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38666. */
  38667. constructor();
  38668. /**
  38669. * The name of the behavior
  38670. */
  38671. readonly name: string;
  38672. /**
  38673. * Initializes the behavior
  38674. */
  38675. init(): void;
  38676. private _getCurrentDistance;
  38677. /**
  38678. * Attaches the scale behavior the passed in mesh
  38679. * @param ownerNode The mesh that will be scaled around once attached
  38680. */
  38681. attach(ownerNode: Mesh): void;
  38682. /**
  38683. * Detaches the behavior from the mesh
  38684. */
  38685. detach(): void;
  38686. }
  38687. }
  38688. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38689. import { Behavior } from "babylonjs/Behaviors/behavior";
  38690. import { Mesh } from "babylonjs/Meshes/mesh";
  38691. import { Observable } from "babylonjs/Misc/observable";
  38692. /**
  38693. * 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
  38694. */
  38695. export class SixDofDragBehavior implements Behavior<Mesh> {
  38696. private static _virtualScene;
  38697. private _ownerNode;
  38698. private _sceneRenderObserver;
  38699. private _scene;
  38700. private _targetPosition;
  38701. private _virtualOriginMesh;
  38702. private _virtualDragMesh;
  38703. private _pointerObserver;
  38704. private _moving;
  38705. private _startingOrientation;
  38706. /**
  38707. * 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)
  38708. */
  38709. private zDragFactor;
  38710. /**
  38711. * If the object should rotate to face the drag origin
  38712. */
  38713. rotateDraggedObject: boolean;
  38714. /**
  38715. * If the behavior is currently in a dragging state
  38716. */
  38717. dragging: boolean;
  38718. /**
  38719. * 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)
  38720. */
  38721. dragDeltaRatio: number;
  38722. /**
  38723. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38724. */
  38725. currentDraggingPointerID: number;
  38726. /**
  38727. * If camera controls should be detached during the drag
  38728. */
  38729. detachCameraControls: boolean;
  38730. /**
  38731. * Fires each time a drag starts
  38732. */
  38733. onDragStartObservable: Observable<{}>;
  38734. /**
  38735. * Fires each time a drag ends (eg. mouse release after drag)
  38736. */
  38737. onDragEndObservable: Observable<{}>;
  38738. /**
  38739. * 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
  38740. */
  38741. constructor();
  38742. /**
  38743. * The name of the behavior
  38744. */
  38745. readonly name: string;
  38746. /**
  38747. * Initializes the behavior
  38748. */
  38749. init(): void;
  38750. /**
  38751. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38752. */
  38753. private readonly _pointerCamera;
  38754. /**
  38755. * Attaches the scale behavior the passed in mesh
  38756. * @param ownerNode The mesh that will be scaled around once attached
  38757. */
  38758. attach(ownerNode: Mesh): void;
  38759. /**
  38760. * Detaches the behavior from the mesh
  38761. */
  38762. detach(): void;
  38763. }
  38764. }
  38765. declare module "babylonjs/Behaviors/Meshes/index" {
  38766. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38767. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38768. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38769. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38770. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38771. }
  38772. declare module "babylonjs/Behaviors/index" {
  38773. export * from "babylonjs/Behaviors/behavior";
  38774. export * from "babylonjs/Behaviors/Cameras/index";
  38775. export * from "babylonjs/Behaviors/Meshes/index";
  38776. }
  38777. declare module "babylonjs/Bones/boneIKController" {
  38778. import { Bone } from "babylonjs/Bones/bone";
  38779. import { Vector3 } from "babylonjs/Maths/math.vector";
  38780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38781. import { Nullable } from "babylonjs/types";
  38782. /**
  38783. * Class used to apply inverse kinematics to bones
  38784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38785. */
  38786. export class BoneIKController {
  38787. private static _tmpVecs;
  38788. private static _tmpQuat;
  38789. private static _tmpMats;
  38790. /**
  38791. * Gets or sets the target mesh
  38792. */
  38793. targetMesh: AbstractMesh;
  38794. /** Gets or sets the mesh used as pole */
  38795. poleTargetMesh: AbstractMesh;
  38796. /**
  38797. * Gets or sets the bone used as pole
  38798. */
  38799. poleTargetBone: Nullable<Bone>;
  38800. /**
  38801. * Gets or sets the target position
  38802. */
  38803. targetPosition: Vector3;
  38804. /**
  38805. * Gets or sets the pole target position
  38806. */
  38807. poleTargetPosition: Vector3;
  38808. /**
  38809. * Gets or sets the pole target local offset
  38810. */
  38811. poleTargetLocalOffset: Vector3;
  38812. /**
  38813. * Gets or sets the pole angle
  38814. */
  38815. poleAngle: number;
  38816. /**
  38817. * Gets or sets the mesh associated with the controller
  38818. */
  38819. mesh: AbstractMesh;
  38820. /**
  38821. * 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)
  38822. */
  38823. slerpAmount: number;
  38824. private _bone1Quat;
  38825. private _bone1Mat;
  38826. private _bone2Ang;
  38827. private _bone1;
  38828. private _bone2;
  38829. private _bone1Length;
  38830. private _bone2Length;
  38831. private _maxAngle;
  38832. private _maxReach;
  38833. private _rightHandedSystem;
  38834. private _bendAxis;
  38835. private _slerping;
  38836. private _adjustRoll;
  38837. /**
  38838. * Gets or sets maximum allowed angle
  38839. */
  38840. maxAngle: number;
  38841. /**
  38842. * Creates a new BoneIKController
  38843. * @param mesh defines the mesh to control
  38844. * @param bone defines the bone to control
  38845. * @param options defines options to set up the controller
  38846. */
  38847. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38848. targetMesh?: AbstractMesh;
  38849. poleTargetMesh?: AbstractMesh;
  38850. poleTargetBone?: Bone;
  38851. poleTargetLocalOffset?: Vector3;
  38852. poleAngle?: number;
  38853. bendAxis?: Vector3;
  38854. maxAngle?: number;
  38855. slerpAmount?: number;
  38856. });
  38857. private _setMaxAngle;
  38858. /**
  38859. * Force the controller to update the bones
  38860. */
  38861. update(): void;
  38862. }
  38863. }
  38864. declare module "babylonjs/Bones/boneLookController" {
  38865. import { Vector3 } from "babylonjs/Maths/math.vector";
  38866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38867. import { Bone } from "babylonjs/Bones/bone";
  38868. import { Space } from "babylonjs/Maths/math.axis";
  38869. /**
  38870. * Class used to make a bone look toward a point in space
  38871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38872. */
  38873. export class BoneLookController {
  38874. private static _tmpVecs;
  38875. private static _tmpQuat;
  38876. private static _tmpMats;
  38877. /**
  38878. * The target Vector3 that the bone will look at
  38879. */
  38880. target: Vector3;
  38881. /**
  38882. * The mesh that the bone is attached to
  38883. */
  38884. mesh: AbstractMesh;
  38885. /**
  38886. * The bone that will be looking to the target
  38887. */
  38888. bone: Bone;
  38889. /**
  38890. * The up axis of the coordinate system that is used when the bone is rotated
  38891. */
  38892. upAxis: Vector3;
  38893. /**
  38894. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38895. */
  38896. upAxisSpace: Space;
  38897. /**
  38898. * Used to make an adjustment to the yaw of the bone
  38899. */
  38900. adjustYaw: number;
  38901. /**
  38902. * Used to make an adjustment to the pitch of the bone
  38903. */
  38904. adjustPitch: number;
  38905. /**
  38906. * Used to make an adjustment to the roll of the bone
  38907. */
  38908. adjustRoll: number;
  38909. /**
  38910. * 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)
  38911. */
  38912. slerpAmount: number;
  38913. private _minYaw;
  38914. private _maxYaw;
  38915. private _minPitch;
  38916. private _maxPitch;
  38917. private _minYawSin;
  38918. private _minYawCos;
  38919. private _maxYawSin;
  38920. private _maxYawCos;
  38921. private _midYawConstraint;
  38922. private _minPitchTan;
  38923. private _maxPitchTan;
  38924. private _boneQuat;
  38925. private _slerping;
  38926. private _transformYawPitch;
  38927. private _transformYawPitchInv;
  38928. private _firstFrameSkipped;
  38929. private _yawRange;
  38930. private _fowardAxis;
  38931. /**
  38932. * Gets or sets the minimum yaw angle that the bone can look to
  38933. */
  38934. minYaw: number;
  38935. /**
  38936. * Gets or sets the maximum yaw angle that the bone can look to
  38937. */
  38938. maxYaw: number;
  38939. /**
  38940. * Gets or sets the minimum pitch angle that the bone can look to
  38941. */
  38942. minPitch: number;
  38943. /**
  38944. * Gets or sets the maximum pitch angle that the bone can look to
  38945. */
  38946. maxPitch: number;
  38947. /**
  38948. * Create a BoneLookController
  38949. * @param mesh the mesh that the bone belongs to
  38950. * @param bone the bone that will be looking to the target
  38951. * @param target the target Vector3 to look at
  38952. * @param options optional settings:
  38953. * * maxYaw: the maximum angle the bone will yaw to
  38954. * * minYaw: the minimum angle the bone will yaw to
  38955. * * maxPitch: the maximum angle the bone will pitch to
  38956. * * minPitch: the minimum angle the bone will yaw to
  38957. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38958. * * upAxis: the up axis of the coordinate system
  38959. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38960. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38961. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38962. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38963. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38964. * * adjustRoll: used to make an adjustment to the roll of the bone
  38965. **/
  38966. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38967. maxYaw?: number;
  38968. minYaw?: number;
  38969. maxPitch?: number;
  38970. minPitch?: number;
  38971. slerpAmount?: number;
  38972. upAxis?: Vector3;
  38973. upAxisSpace?: Space;
  38974. yawAxis?: Vector3;
  38975. pitchAxis?: Vector3;
  38976. adjustYaw?: number;
  38977. adjustPitch?: number;
  38978. adjustRoll?: number;
  38979. });
  38980. /**
  38981. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38982. */
  38983. update(): void;
  38984. private _getAngleDiff;
  38985. private _getAngleBetween;
  38986. private _isAngleBetween;
  38987. }
  38988. }
  38989. declare module "babylonjs/Bones/index" {
  38990. export * from "babylonjs/Bones/bone";
  38991. export * from "babylonjs/Bones/boneIKController";
  38992. export * from "babylonjs/Bones/boneLookController";
  38993. export * from "babylonjs/Bones/skeleton";
  38994. }
  38995. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38996. import { Nullable } from "babylonjs/types";
  38997. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38999. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39000. /**
  39001. * Manage the gamepad inputs to control an arc rotate camera.
  39002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39003. */
  39004. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39005. /**
  39006. * Defines the camera the input is attached to.
  39007. */
  39008. camera: ArcRotateCamera;
  39009. /**
  39010. * Defines the gamepad the input is gathering event from.
  39011. */
  39012. gamepad: Nullable<Gamepad>;
  39013. /**
  39014. * Defines the gamepad rotation sensiblity.
  39015. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39016. */
  39017. gamepadRotationSensibility: number;
  39018. /**
  39019. * Defines the gamepad move sensiblity.
  39020. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39021. */
  39022. gamepadMoveSensibility: number;
  39023. private _yAxisScale;
  39024. /**
  39025. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39026. */
  39027. invertYAxis: boolean;
  39028. private _onGamepadConnectedObserver;
  39029. private _onGamepadDisconnectedObserver;
  39030. /**
  39031. * Attach the input controls to a specific dom element to get the input from.
  39032. * @param element Defines the element the controls should be listened from
  39033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39034. */
  39035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39036. /**
  39037. * Detach the current controls from the specified dom element.
  39038. * @param element Defines the element to stop listening the inputs from
  39039. */
  39040. detachControl(element: Nullable<HTMLElement>): void;
  39041. /**
  39042. * Update the current camera state depending on the inputs that have been used this frame.
  39043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39044. */
  39045. checkInputs(): void;
  39046. /**
  39047. * Gets the class name of the current intput.
  39048. * @returns the class name
  39049. */
  39050. getClassName(): string;
  39051. /**
  39052. * Get the friendly name associated with the input class.
  39053. * @returns the input friendly name
  39054. */
  39055. getSimpleName(): string;
  39056. }
  39057. }
  39058. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39059. import { Nullable } from "babylonjs/types";
  39060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39061. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39062. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39063. interface ArcRotateCameraInputsManager {
  39064. /**
  39065. * Add orientation input support to the input manager.
  39066. * @returns the current input manager
  39067. */
  39068. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39069. }
  39070. }
  39071. /**
  39072. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39074. */
  39075. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39076. /**
  39077. * Defines the camera the input is attached to.
  39078. */
  39079. camera: ArcRotateCamera;
  39080. /**
  39081. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39082. */
  39083. alphaCorrection: number;
  39084. /**
  39085. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39086. */
  39087. gammaCorrection: number;
  39088. private _alpha;
  39089. private _gamma;
  39090. private _dirty;
  39091. private _deviceOrientationHandler;
  39092. /**
  39093. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39094. */
  39095. constructor();
  39096. /**
  39097. * Attach the input controls to a specific dom element to get the input from.
  39098. * @param element Defines the element the controls should be listened from
  39099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39100. */
  39101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39102. /** @hidden */
  39103. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39104. /**
  39105. * Update the current camera state depending on the inputs that have been used this frame.
  39106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39107. */
  39108. checkInputs(): void;
  39109. /**
  39110. * Detach the current controls from the specified dom element.
  39111. * @param element Defines the element to stop listening the inputs from
  39112. */
  39113. detachControl(element: Nullable<HTMLElement>): void;
  39114. /**
  39115. * Gets the class name of the current intput.
  39116. * @returns the class name
  39117. */
  39118. getClassName(): string;
  39119. /**
  39120. * Get the friendly name associated with the input class.
  39121. * @returns the input friendly name
  39122. */
  39123. getSimpleName(): string;
  39124. }
  39125. }
  39126. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39127. import { Nullable } from "babylonjs/types";
  39128. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39129. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39130. /**
  39131. * Listen to mouse events to control the camera.
  39132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39133. */
  39134. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39135. /**
  39136. * Defines the camera the input is attached to.
  39137. */
  39138. camera: FlyCamera;
  39139. /**
  39140. * Defines if touch is enabled. (Default is true.)
  39141. */
  39142. touchEnabled: boolean;
  39143. /**
  39144. * Defines the buttons associated with the input to handle camera rotation.
  39145. */
  39146. buttons: number[];
  39147. /**
  39148. * Assign buttons for Yaw control.
  39149. */
  39150. buttonsYaw: number[];
  39151. /**
  39152. * Assign buttons for Pitch control.
  39153. */
  39154. buttonsPitch: number[];
  39155. /**
  39156. * Assign buttons for Roll control.
  39157. */
  39158. buttonsRoll: number[];
  39159. /**
  39160. * Detect if any button is being pressed while mouse is moved.
  39161. * -1 = Mouse locked.
  39162. * 0 = Left button.
  39163. * 1 = Middle Button.
  39164. * 2 = Right Button.
  39165. */
  39166. activeButton: number;
  39167. /**
  39168. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39169. * Higher values reduce its sensitivity.
  39170. */
  39171. angularSensibility: number;
  39172. private _mousemoveCallback;
  39173. private _observer;
  39174. private _rollObserver;
  39175. private previousPosition;
  39176. private noPreventDefault;
  39177. private element;
  39178. /**
  39179. * Listen to mouse events to control the camera.
  39180. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39182. */
  39183. constructor(touchEnabled?: boolean);
  39184. /**
  39185. * Attach the mouse control to the HTML DOM element.
  39186. * @param element Defines the element that listens to the input events.
  39187. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39188. */
  39189. attachControl(element: HTMLElement, noPreventDefault?: boolean): 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 input.
  39197. * @returns the class name.
  39198. */
  39199. getClassName(): string;
  39200. /**
  39201. * Get the friendly name associated with the input class.
  39202. * @returns the input's friendly name.
  39203. */
  39204. getSimpleName(): string;
  39205. private _pointerInput;
  39206. private _onMouseMove;
  39207. /**
  39208. * Rotate camera by mouse offset.
  39209. */
  39210. private rotateCamera;
  39211. }
  39212. }
  39213. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39214. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39215. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39216. /**
  39217. * Default Inputs manager for the FlyCamera.
  39218. * It groups all the default supported inputs for ease of use.
  39219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39220. */
  39221. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39222. /**
  39223. * Instantiates a new FlyCameraInputsManager.
  39224. * @param camera Defines the camera the inputs belong to.
  39225. */
  39226. constructor(camera: FlyCamera);
  39227. /**
  39228. * Add keyboard input support to the input manager.
  39229. * @returns the new FlyCameraKeyboardMoveInput().
  39230. */
  39231. addKeyboard(): FlyCameraInputsManager;
  39232. /**
  39233. * Add mouse input support to the input manager.
  39234. * @param touchEnabled Enable touch screen support.
  39235. * @returns the new FlyCameraMouseInput().
  39236. */
  39237. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39238. }
  39239. }
  39240. declare module "babylonjs/Cameras/flyCamera" {
  39241. import { Scene } from "babylonjs/scene";
  39242. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39244. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39245. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39246. /**
  39247. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39248. * such as in a 3D Space Shooter or a Flight Simulator.
  39249. */
  39250. export class FlyCamera extends TargetCamera {
  39251. /**
  39252. * Define the collision ellipsoid of the camera.
  39253. * This is helpful for simulating a camera body, like a player's body.
  39254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39255. */
  39256. ellipsoid: Vector3;
  39257. /**
  39258. * Define an offset for the position of the ellipsoid around the camera.
  39259. * This can be helpful if the camera is attached away from the player's body center,
  39260. * such as at its head.
  39261. */
  39262. ellipsoidOffset: Vector3;
  39263. /**
  39264. * Enable or disable collisions of the camera with the rest of the scene objects.
  39265. */
  39266. checkCollisions: boolean;
  39267. /**
  39268. * Enable or disable gravity on the camera.
  39269. */
  39270. applyGravity: boolean;
  39271. /**
  39272. * Define the current direction the camera is moving to.
  39273. */
  39274. cameraDirection: Vector3;
  39275. /**
  39276. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39277. * This overrides and empties cameraRotation.
  39278. */
  39279. rotationQuaternion: Quaternion;
  39280. /**
  39281. * Track Roll to maintain the wanted Rolling when looking around.
  39282. */
  39283. _trackRoll: number;
  39284. /**
  39285. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39286. */
  39287. rollCorrect: number;
  39288. /**
  39289. * Mimic a banked turn, Rolling the camera when Yawing.
  39290. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39291. */
  39292. bankedTurn: boolean;
  39293. /**
  39294. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39295. */
  39296. bankedTurnLimit: number;
  39297. /**
  39298. * Value of 0 disables the banked Roll.
  39299. * Value of 1 is equal to the Yaw angle in radians.
  39300. */
  39301. bankedTurnMultiplier: number;
  39302. /**
  39303. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39304. */
  39305. inputs: FlyCameraInputsManager;
  39306. /**
  39307. * Gets the input sensibility for mouse input.
  39308. * Higher values reduce sensitivity.
  39309. */
  39310. /**
  39311. * Sets the input sensibility for a mouse input.
  39312. * Higher values reduce sensitivity.
  39313. */
  39314. angularSensibility: number;
  39315. /**
  39316. * Get the keys for camera movement forward.
  39317. */
  39318. /**
  39319. * Set the keys for camera movement forward.
  39320. */
  39321. keysForward: number[];
  39322. /**
  39323. * Get the keys for camera movement backward.
  39324. */
  39325. keysBackward: number[];
  39326. /**
  39327. * Get the keys for camera movement up.
  39328. */
  39329. /**
  39330. * Set the keys for camera movement up.
  39331. */
  39332. keysUp: number[];
  39333. /**
  39334. * Get the keys for camera movement down.
  39335. */
  39336. /**
  39337. * Set the keys for camera movement down.
  39338. */
  39339. keysDown: number[];
  39340. /**
  39341. * Get the keys for camera movement left.
  39342. */
  39343. /**
  39344. * Set the keys for camera movement left.
  39345. */
  39346. keysLeft: number[];
  39347. /**
  39348. * Set the keys for camera movement right.
  39349. */
  39350. /**
  39351. * Set the keys for camera movement right.
  39352. */
  39353. keysRight: number[];
  39354. /**
  39355. * Event raised when the camera collides with a mesh in the scene.
  39356. */
  39357. onCollide: (collidedMesh: AbstractMesh) => void;
  39358. private _collider;
  39359. private _needMoveForGravity;
  39360. private _oldPosition;
  39361. private _diffPosition;
  39362. private _newPosition;
  39363. /** @hidden */
  39364. _localDirection: Vector3;
  39365. /** @hidden */
  39366. _transformedDirection: Vector3;
  39367. /**
  39368. * Instantiates a FlyCamera.
  39369. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39370. * such as in a 3D Space Shooter or a Flight Simulator.
  39371. * @param name Define the name of the camera in the scene.
  39372. * @param position Define the starting position of the camera in the scene.
  39373. * @param scene Define the scene the camera belongs to.
  39374. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39375. */
  39376. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39377. /**
  39378. * Attach a control to the HTML DOM element.
  39379. * @param element Defines the element that listens to the input events.
  39380. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39381. */
  39382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39383. /**
  39384. * Detach a control from the HTML DOM element.
  39385. * The camera will stop reacting to that input.
  39386. * @param element Defines the element that listens to the input events.
  39387. */
  39388. detachControl(element: HTMLElement): void;
  39389. private _collisionMask;
  39390. /**
  39391. * Get the mask that the camera ignores in collision events.
  39392. */
  39393. /**
  39394. * Set the mask that the camera ignores in collision events.
  39395. */
  39396. collisionMask: number;
  39397. /** @hidden */
  39398. _collideWithWorld(displacement: Vector3): void;
  39399. /** @hidden */
  39400. private _onCollisionPositionChange;
  39401. /** @hidden */
  39402. _checkInputs(): void;
  39403. /** @hidden */
  39404. _decideIfNeedsToMove(): boolean;
  39405. /** @hidden */
  39406. _updatePosition(): void;
  39407. /**
  39408. * Restore the Roll to its target value at the rate specified.
  39409. * @param rate - Higher means slower restoring.
  39410. * @hidden
  39411. */
  39412. restoreRoll(rate: number): void;
  39413. /**
  39414. * Destroy the camera and release the current resources held by it.
  39415. */
  39416. dispose(): void;
  39417. /**
  39418. * Get the current object class name.
  39419. * @returns the class name.
  39420. */
  39421. getClassName(): string;
  39422. }
  39423. }
  39424. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39425. import { Nullable } from "babylonjs/types";
  39426. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39427. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39428. /**
  39429. * Listen to keyboard events to control the camera.
  39430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39431. */
  39432. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39433. /**
  39434. * Defines the camera the input is attached to.
  39435. */
  39436. camera: FlyCamera;
  39437. /**
  39438. * The list of keyboard keys used to control the forward move of the camera.
  39439. */
  39440. keysForward: number[];
  39441. /**
  39442. * The list of keyboard keys used to control the backward move of the camera.
  39443. */
  39444. keysBackward: number[];
  39445. /**
  39446. * The list of keyboard keys used to control the forward move of the camera.
  39447. */
  39448. keysUp: number[];
  39449. /**
  39450. * The list of keyboard keys used to control the backward move of the camera.
  39451. */
  39452. keysDown: number[];
  39453. /**
  39454. * The list of keyboard keys used to control the right strafe move of the camera.
  39455. */
  39456. keysRight: number[];
  39457. /**
  39458. * The list of keyboard keys used to control the left strafe move of the camera.
  39459. */
  39460. keysLeft: number[];
  39461. private _keys;
  39462. private _onCanvasBlurObserver;
  39463. private _onKeyboardObserver;
  39464. private _engine;
  39465. private _scene;
  39466. /**
  39467. * Attach the input controls to a specific dom element to get the input from.
  39468. * @param element Defines the element the controls should be listened from
  39469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39470. */
  39471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39472. /**
  39473. * Detach the current controls from the specified dom element.
  39474. * @param element Defines the element to stop listening the inputs from
  39475. */
  39476. detachControl(element: Nullable<HTMLElement>): void;
  39477. /**
  39478. * Gets the class name of the current intput.
  39479. * @returns the class name
  39480. */
  39481. getClassName(): string;
  39482. /** @hidden */
  39483. _onLostFocus(e: FocusEvent): void;
  39484. /**
  39485. * Get the friendly name associated with the input class.
  39486. * @returns the input friendly name
  39487. */
  39488. getSimpleName(): string;
  39489. /**
  39490. * Update the current camera state depending on the inputs that have been used this frame.
  39491. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39492. */
  39493. checkInputs(): void;
  39494. }
  39495. }
  39496. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39497. import { Nullable } from "babylonjs/types";
  39498. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39500. /**
  39501. * Manage the mouse wheel inputs to control a follow camera.
  39502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39503. */
  39504. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39505. /**
  39506. * Defines the camera the input is attached to.
  39507. */
  39508. camera: FollowCamera;
  39509. /**
  39510. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39511. */
  39512. axisControlRadius: boolean;
  39513. /**
  39514. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39515. */
  39516. axisControlHeight: boolean;
  39517. /**
  39518. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39519. */
  39520. axisControlRotation: boolean;
  39521. /**
  39522. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39523. * relation to mouseWheel events.
  39524. */
  39525. wheelPrecision: number;
  39526. /**
  39527. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39528. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39529. */
  39530. wheelDeltaPercentage: number;
  39531. private _wheel;
  39532. private _observer;
  39533. /**
  39534. * Attach the input controls to a specific dom element to get the input from.
  39535. * @param element Defines the element the controls should be listened from
  39536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39537. */
  39538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39539. /**
  39540. * Detach the current controls from the specified dom element.
  39541. * @param element Defines the element to stop listening the inputs from
  39542. */
  39543. detachControl(element: Nullable<HTMLElement>): void;
  39544. /**
  39545. * Gets the class name of the current intput.
  39546. * @returns the class name
  39547. */
  39548. getClassName(): string;
  39549. /**
  39550. * Get the friendly name associated with the input class.
  39551. * @returns the input friendly name
  39552. */
  39553. getSimpleName(): string;
  39554. }
  39555. }
  39556. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39557. import { Nullable } from "babylonjs/types";
  39558. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39559. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39560. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39561. /**
  39562. * Manage the pointers inputs to control an follow camera.
  39563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39564. */
  39565. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39566. /**
  39567. * Defines the camera the input is attached to.
  39568. */
  39569. camera: FollowCamera;
  39570. /**
  39571. * Gets the class name of the current input.
  39572. * @returns the class name
  39573. */
  39574. getClassName(): string;
  39575. /**
  39576. * Defines the pointer angular sensibility along the X axis or how fast is
  39577. * the camera rotating.
  39578. * A negative number will reverse the axis direction.
  39579. */
  39580. angularSensibilityX: number;
  39581. /**
  39582. * Defines the pointer angular sensibility along the Y axis or how fast is
  39583. * the camera rotating.
  39584. * A negative number will reverse the axis direction.
  39585. */
  39586. angularSensibilityY: number;
  39587. /**
  39588. * Defines the pointer pinch precision or how fast is the camera zooming.
  39589. * A negative number will reverse the axis direction.
  39590. */
  39591. pinchPrecision: number;
  39592. /**
  39593. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39594. * from 0.
  39595. * It defines the percentage of current camera.radius to use as delta when
  39596. * pinch zoom is used.
  39597. */
  39598. pinchDeltaPercentage: number;
  39599. /**
  39600. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39601. */
  39602. axisXControlRadius: boolean;
  39603. /**
  39604. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39605. */
  39606. axisXControlHeight: boolean;
  39607. /**
  39608. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39609. */
  39610. axisXControlRotation: boolean;
  39611. /**
  39612. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39613. */
  39614. axisYControlRadius: boolean;
  39615. /**
  39616. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39617. */
  39618. axisYControlHeight: boolean;
  39619. /**
  39620. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39621. */
  39622. axisYControlRotation: boolean;
  39623. /**
  39624. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39625. */
  39626. axisPinchControlRadius: boolean;
  39627. /**
  39628. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39629. */
  39630. axisPinchControlHeight: boolean;
  39631. /**
  39632. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39633. */
  39634. axisPinchControlRotation: boolean;
  39635. /**
  39636. * Log error messages if basic misconfiguration has occurred.
  39637. */
  39638. warningEnable: boolean;
  39639. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39640. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39641. private _warningCounter;
  39642. private _warning;
  39643. }
  39644. }
  39645. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39646. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39647. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39648. /**
  39649. * Default Inputs manager for the FollowCamera.
  39650. * It groups all the default supported inputs for ease of use.
  39651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39652. */
  39653. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39654. /**
  39655. * Instantiates a new FollowCameraInputsManager.
  39656. * @param camera Defines the camera the inputs belong to
  39657. */
  39658. constructor(camera: FollowCamera);
  39659. /**
  39660. * Add keyboard input support to the input manager.
  39661. * @returns the current input manager
  39662. */
  39663. addKeyboard(): FollowCameraInputsManager;
  39664. /**
  39665. * Add mouse wheel input support to the input manager.
  39666. * @returns the current input manager
  39667. */
  39668. addMouseWheel(): FollowCameraInputsManager;
  39669. /**
  39670. * Add pointers input support to the input manager.
  39671. * @returns the current input manager
  39672. */
  39673. addPointers(): FollowCameraInputsManager;
  39674. /**
  39675. * Add orientation input support to the input manager.
  39676. * @returns the current input manager
  39677. */
  39678. addVRDeviceOrientation(): FollowCameraInputsManager;
  39679. }
  39680. }
  39681. declare module "babylonjs/Cameras/followCamera" {
  39682. import { Nullable } from "babylonjs/types";
  39683. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39684. import { Scene } from "babylonjs/scene";
  39685. import { Vector3 } from "babylonjs/Maths/math.vector";
  39686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39687. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39688. /**
  39689. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39690. * an arc rotate version arcFollowCamera are available.
  39691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39692. */
  39693. export class FollowCamera extends TargetCamera {
  39694. /**
  39695. * Distance the follow camera should follow an object at
  39696. */
  39697. radius: number;
  39698. /**
  39699. * Minimum allowed distance of the camera to the axis of rotation
  39700. * (The camera can not get closer).
  39701. * This can help limiting how the Camera is able to move in the scene.
  39702. */
  39703. lowerRadiusLimit: Nullable<number>;
  39704. /**
  39705. * Maximum allowed distance of the camera to the axis of rotation
  39706. * (The camera can not get further).
  39707. * This can help limiting how the Camera is able to move in the scene.
  39708. */
  39709. upperRadiusLimit: Nullable<number>;
  39710. /**
  39711. * Define a rotation offset between the camera and the object it follows
  39712. */
  39713. rotationOffset: number;
  39714. /**
  39715. * Minimum allowed angle to camera position relative to target object.
  39716. * This can help limiting how the Camera is able to move in the scene.
  39717. */
  39718. lowerRotationOffsetLimit: Nullable<number>;
  39719. /**
  39720. * Maximum allowed angle to camera position relative to target object.
  39721. * This can help limiting how the Camera is able to move in the scene.
  39722. */
  39723. upperRotationOffsetLimit: Nullable<number>;
  39724. /**
  39725. * Define a height offset between the camera and the object it follows.
  39726. * It can help following an object from the top (like a car chaing a plane)
  39727. */
  39728. heightOffset: number;
  39729. /**
  39730. * Minimum allowed height of camera position relative to target object.
  39731. * This can help limiting how the Camera is able to move in the scene.
  39732. */
  39733. lowerHeightOffsetLimit: Nullable<number>;
  39734. /**
  39735. * Maximum allowed height of camera position relative to target object.
  39736. * This can help limiting how the Camera is able to move in the scene.
  39737. */
  39738. upperHeightOffsetLimit: Nullable<number>;
  39739. /**
  39740. * Define how fast the camera can accelerate to follow it s target.
  39741. */
  39742. cameraAcceleration: number;
  39743. /**
  39744. * Define the speed limit of the camera following an object.
  39745. */
  39746. maxCameraSpeed: number;
  39747. /**
  39748. * Define the target of the camera.
  39749. */
  39750. lockedTarget: Nullable<AbstractMesh>;
  39751. /**
  39752. * Defines the input associated with the camera.
  39753. */
  39754. inputs: FollowCameraInputsManager;
  39755. /**
  39756. * Instantiates the follow camera.
  39757. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39758. * @param name Define the name of the camera in the scene
  39759. * @param position Define the position of the camera
  39760. * @param scene Define the scene the camera belong to
  39761. * @param lockedTarget Define the target of the camera
  39762. */
  39763. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39764. private _follow;
  39765. /**
  39766. * Attached controls to the current camera.
  39767. * @param element Defines the element the controls should be listened from
  39768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39769. */
  39770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39771. /**
  39772. * Detach the current controls from the camera.
  39773. * The camera will stop reacting to inputs.
  39774. * @param element Defines the element to stop listening the inputs from
  39775. */
  39776. detachControl(element: HTMLElement): void;
  39777. /** @hidden */
  39778. _checkInputs(): void;
  39779. private _checkLimits;
  39780. /**
  39781. * Gets the camera class name.
  39782. * @returns the class name
  39783. */
  39784. getClassName(): string;
  39785. }
  39786. /**
  39787. * Arc Rotate version of the follow camera.
  39788. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39789. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39790. */
  39791. export class ArcFollowCamera extends TargetCamera {
  39792. /** The longitudinal angle of the camera */
  39793. alpha: number;
  39794. /** The latitudinal angle of the camera */
  39795. beta: number;
  39796. /** The radius of the camera from its target */
  39797. radius: number;
  39798. /** Define the camera target (the messh it should follow) */
  39799. target: Nullable<AbstractMesh>;
  39800. private _cartesianCoordinates;
  39801. /**
  39802. * Instantiates a new ArcFollowCamera
  39803. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39804. * @param name Define the name of the camera
  39805. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39806. * @param beta Define the rotation angle of the camera around the elevation axis
  39807. * @param radius Define the radius of the camera from its target point
  39808. * @param target Define the target of the camera
  39809. * @param scene Define the scene the camera belongs to
  39810. */
  39811. constructor(name: string,
  39812. /** The longitudinal angle of the camera */
  39813. alpha: number,
  39814. /** The latitudinal angle of the camera */
  39815. beta: number,
  39816. /** The radius of the camera from its target */
  39817. radius: number,
  39818. /** Define the camera target (the messh it should follow) */
  39819. target: Nullable<AbstractMesh>, scene: Scene);
  39820. private _follow;
  39821. /** @hidden */
  39822. _checkInputs(): void;
  39823. /**
  39824. * Returns the class name of the object.
  39825. * It is mostly used internally for serialization purposes.
  39826. */
  39827. getClassName(): string;
  39828. }
  39829. }
  39830. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39831. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39832. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39833. import { Nullable } from "babylonjs/types";
  39834. /**
  39835. * Manage the keyboard inputs to control the movement of a follow camera.
  39836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39837. */
  39838. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39839. /**
  39840. * Defines the camera the input is attached to.
  39841. */
  39842. camera: FollowCamera;
  39843. /**
  39844. * Defines the list of key codes associated with the up action (increase heightOffset)
  39845. */
  39846. keysHeightOffsetIncr: number[];
  39847. /**
  39848. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39849. */
  39850. keysHeightOffsetDecr: number[];
  39851. /**
  39852. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39853. */
  39854. keysHeightOffsetModifierAlt: boolean;
  39855. /**
  39856. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39857. */
  39858. keysHeightOffsetModifierCtrl: boolean;
  39859. /**
  39860. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39861. */
  39862. keysHeightOffsetModifierShift: boolean;
  39863. /**
  39864. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39865. */
  39866. keysRotationOffsetIncr: number[];
  39867. /**
  39868. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39869. */
  39870. keysRotationOffsetDecr: number[];
  39871. /**
  39872. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39873. */
  39874. keysRotationOffsetModifierAlt: boolean;
  39875. /**
  39876. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39877. */
  39878. keysRotationOffsetModifierCtrl: boolean;
  39879. /**
  39880. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39881. */
  39882. keysRotationOffsetModifierShift: boolean;
  39883. /**
  39884. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39885. */
  39886. keysRadiusIncr: number[];
  39887. /**
  39888. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39889. */
  39890. keysRadiusDecr: number[];
  39891. /**
  39892. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39893. */
  39894. keysRadiusModifierAlt: boolean;
  39895. /**
  39896. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39897. */
  39898. keysRadiusModifierCtrl: boolean;
  39899. /**
  39900. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39901. */
  39902. keysRadiusModifierShift: boolean;
  39903. /**
  39904. * Defines the rate of change of heightOffset.
  39905. */
  39906. heightSensibility: number;
  39907. /**
  39908. * Defines the rate of change of rotationOffset.
  39909. */
  39910. rotationSensibility: number;
  39911. /**
  39912. * Defines the rate of change of radius.
  39913. */
  39914. radiusSensibility: number;
  39915. private _keys;
  39916. private _ctrlPressed;
  39917. private _altPressed;
  39918. private _shiftPressed;
  39919. private _onCanvasBlurObserver;
  39920. private _onKeyboardObserver;
  39921. private _engine;
  39922. private _scene;
  39923. /**
  39924. * Attach the input controls to a specific dom element to get the input from.
  39925. * @param element Defines the element the controls should be listened from
  39926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39927. */
  39928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39929. /**
  39930. * Detach the current controls from the specified dom element.
  39931. * @param element Defines the element to stop listening the inputs from
  39932. */
  39933. detachControl(element: Nullable<HTMLElement>): void;
  39934. /**
  39935. * Update the current camera state depending on the inputs that have been used this frame.
  39936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39937. */
  39938. checkInputs(): void;
  39939. /**
  39940. * Gets the class name of the current input.
  39941. * @returns the class name
  39942. */
  39943. getClassName(): string;
  39944. /**
  39945. * Get the friendly name associated with the input class.
  39946. * @returns the input friendly name
  39947. */
  39948. getSimpleName(): string;
  39949. /**
  39950. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39951. * allow modification of the heightOffset value.
  39952. */
  39953. private _modifierHeightOffset;
  39954. /**
  39955. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39956. * allow modification of the rotationOffset value.
  39957. */
  39958. private _modifierRotationOffset;
  39959. /**
  39960. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39961. * allow modification of the radius value.
  39962. */
  39963. private _modifierRadius;
  39964. }
  39965. }
  39966. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39967. import { Nullable } from "babylonjs/types";
  39968. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39969. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39970. import { Observable } from "babylonjs/Misc/observable";
  39971. module "babylonjs/Cameras/freeCameraInputsManager" {
  39972. interface FreeCameraInputsManager {
  39973. /**
  39974. * @hidden
  39975. */
  39976. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39977. /**
  39978. * Add orientation input support to the input manager.
  39979. * @returns the current input manager
  39980. */
  39981. addDeviceOrientation(): FreeCameraInputsManager;
  39982. }
  39983. }
  39984. /**
  39985. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39986. * Screen rotation is taken into account.
  39987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39988. */
  39989. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39990. private _camera;
  39991. private _screenOrientationAngle;
  39992. private _constantTranform;
  39993. private _screenQuaternion;
  39994. private _alpha;
  39995. private _beta;
  39996. private _gamma;
  39997. /**
  39998. * Can be used to detect if a device orientation sensor is availible on a device
  39999. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40000. * @returns a promise that will resolve on orientation change
  40001. */
  40002. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40003. /**
  40004. * @hidden
  40005. */
  40006. _onDeviceOrientationChangedObservable: Observable<void>;
  40007. /**
  40008. * Instantiates a new input
  40009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40010. */
  40011. constructor();
  40012. /**
  40013. * Define the camera controlled by the input.
  40014. */
  40015. camera: FreeCamera;
  40016. /**
  40017. * Attach the input controls to a specific dom element to get the input from.
  40018. * @param element Defines the element the controls should be listened from
  40019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40020. */
  40021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40022. private _orientationChanged;
  40023. private _deviceOrientation;
  40024. /**
  40025. * Detach the current controls from the specified dom element.
  40026. * @param element Defines the element to stop listening the inputs from
  40027. */
  40028. detachControl(element: Nullable<HTMLElement>): void;
  40029. /**
  40030. * Update the current camera state depending on the inputs that have been used this frame.
  40031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40032. */
  40033. checkInputs(): void;
  40034. /**
  40035. * Gets the class name of the current intput.
  40036. * @returns the class name
  40037. */
  40038. getClassName(): string;
  40039. /**
  40040. * Get the friendly name associated with the input class.
  40041. * @returns the input friendly name
  40042. */
  40043. getSimpleName(): string;
  40044. }
  40045. }
  40046. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40047. import { Nullable } from "babylonjs/types";
  40048. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40049. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40050. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40051. /**
  40052. * Manage the gamepad inputs to control a free camera.
  40053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40054. */
  40055. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40056. /**
  40057. * Define the camera the input is attached to.
  40058. */
  40059. camera: FreeCamera;
  40060. /**
  40061. * Define the Gamepad controlling the input
  40062. */
  40063. gamepad: Nullable<Gamepad>;
  40064. /**
  40065. * Defines the gamepad rotation sensiblity.
  40066. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40067. */
  40068. gamepadAngularSensibility: number;
  40069. /**
  40070. * Defines the gamepad move sensiblity.
  40071. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40072. */
  40073. gamepadMoveSensibility: number;
  40074. private _yAxisScale;
  40075. /**
  40076. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40077. */
  40078. invertYAxis: boolean;
  40079. private _onGamepadConnectedObserver;
  40080. private _onGamepadDisconnectedObserver;
  40081. private _cameraTransform;
  40082. private _deltaTransform;
  40083. private _vector3;
  40084. private _vector2;
  40085. /**
  40086. * Attach the input controls to a specific dom element to get the input from.
  40087. * @param element Defines the element the controls should be listened from
  40088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40089. */
  40090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40091. /**
  40092. * Detach the current controls from the specified dom element.
  40093. * @param element Defines the element to stop listening the inputs from
  40094. */
  40095. detachControl(element: Nullable<HTMLElement>): void;
  40096. /**
  40097. * Update the current camera state depending on the inputs that have been used this frame.
  40098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40099. */
  40100. checkInputs(): void;
  40101. /**
  40102. * Gets the class name of the current intput.
  40103. * @returns the class name
  40104. */
  40105. getClassName(): string;
  40106. /**
  40107. * Get the friendly name associated with the input class.
  40108. * @returns the input friendly name
  40109. */
  40110. getSimpleName(): string;
  40111. }
  40112. }
  40113. declare module "babylonjs/Misc/virtualJoystick" {
  40114. import { Nullable } from "babylonjs/types";
  40115. import { Vector3 } from "babylonjs/Maths/math.vector";
  40116. /**
  40117. * Defines the potential axis of a Joystick
  40118. */
  40119. export enum JoystickAxis {
  40120. /** X axis */
  40121. X = 0,
  40122. /** Y axis */
  40123. Y = 1,
  40124. /** Z axis */
  40125. Z = 2
  40126. }
  40127. /**
  40128. * Class used to define virtual joystick (used in touch mode)
  40129. */
  40130. export class VirtualJoystick {
  40131. /**
  40132. * Gets or sets a boolean indicating that left and right values must be inverted
  40133. */
  40134. reverseLeftRight: boolean;
  40135. /**
  40136. * Gets or sets a boolean indicating that up and down values must be inverted
  40137. */
  40138. reverseUpDown: boolean;
  40139. /**
  40140. * Gets the offset value for the position (ie. the change of the position value)
  40141. */
  40142. deltaPosition: Vector3;
  40143. /**
  40144. * Gets a boolean indicating if the virtual joystick was pressed
  40145. */
  40146. pressed: boolean;
  40147. /**
  40148. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40149. */
  40150. static Canvas: Nullable<HTMLCanvasElement>;
  40151. private static _globalJoystickIndex;
  40152. private static vjCanvasContext;
  40153. private static vjCanvasWidth;
  40154. private static vjCanvasHeight;
  40155. private static halfWidth;
  40156. private _action;
  40157. private _axisTargetedByLeftAndRight;
  40158. private _axisTargetedByUpAndDown;
  40159. private _joystickSensibility;
  40160. private _inversedSensibility;
  40161. private _joystickPointerID;
  40162. private _joystickColor;
  40163. private _joystickPointerPos;
  40164. private _joystickPreviousPointerPos;
  40165. private _joystickPointerStartPos;
  40166. private _deltaJoystickVector;
  40167. private _leftJoystick;
  40168. private _touches;
  40169. private _onPointerDownHandlerRef;
  40170. private _onPointerMoveHandlerRef;
  40171. private _onPointerUpHandlerRef;
  40172. private _onResize;
  40173. /**
  40174. * Creates a new virtual joystick
  40175. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40176. */
  40177. constructor(leftJoystick?: boolean);
  40178. /**
  40179. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40180. * @param newJoystickSensibility defines the new sensibility
  40181. */
  40182. setJoystickSensibility(newJoystickSensibility: number): void;
  40183. private _onPointerDown;
  40184. private _onPointerMove;
  40185. private _onPointerUp;
  40186. /**
  40187. * Change the color of the virtual joystick
  40188. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40189. */
  40190. setJoystickColor(newColor: string): void;
  40191. /**
  40192. * Defines a callback to call when the joystick is touched
  40193. * @param action defines the callback
  40194. */
  40195. setActionOnTouch(action: () => any): void;
  40196. /**
  40197. * Defines which axis you'd like to control for left & right
  40198. * @param axis defines the axis to use
  40199. */
  40200. setAxisForLeftRight(axis: JoystickAxis): void;
  40201. /**
  40202. * Defines which axis you'd like to control for up & down
  40203. * @param axis defines the axis to use
  40204. */
  40205. setAxisForUpDown(axis: JoystickAxis): void;
  40206. private _drawVirtualJoystick;
  40207. /**
  40208. * Release internal HTML canvas
  40209. */
  40210. releaseCanvas(): void;
  40211. }
  40212. }
  40213. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40214. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40215. import { Nullable } from "babylonjs/types";
  40216. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40217. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40218. module "babylonjs/Cameras/freeCameraInputsManager" {
  40219. interface FreeCameraInputsManager {
  40220. /**
  40221. * Add virtual joystick input support to the input manager.
  40222. * @returns the current input manager
  40223. */
  40224. addVirtualJoystick(): FreeCameraInputsManager;
  40225. }
  40226. }
  40227. /**
  40228. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40230. */
  40231. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40232. /**
  40233. * Defines the camera the input is attached to.
  40234. */
  40235. camera: FreeCamera;
  40236. private _leftjoystick;
  40237. private _rightjoystick;
  40238. /**
  40239. * Gets the left stick of the virtual joystick.
  40240. * @returns The virtual Joystick
  40241. */
  40242. getLeftJoystick(): VirtualJoystick;
  40243. /**
  40244. * Gets the right stick of the virtual joystick.
  40245. * @returns The virtual Joystick
  40246. */
  40247. getRightJoystick(): VirtualJoystick;
  40248. /**
  40249. * Update the current camera state depending on the inputs that have been used this frame.
  40250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40251. */
  40252. checkInputs(): void;
  40253. /**
  40254. * Attach the input controls to a specific dom element to get the input from.
  40255. * @param element Defines the element the controls should be listened from
  40256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40257. */
  40258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40259. /**
  40260. * Detach the current controls from the specified dom element.
  40261. * @param element Defines the element to stop listening the inputs from
  40262. */
  40263. detachControl(element: Nullable<HTMLElement>): void;
  40264. /**
  40265. * Gets the class name of the current intput.
  40266. * @returns the class name
  40267. */
  40268. getClassName(): string;
  40269. /**
  40270. * Get the friendly name associated with the input class.
  40271. * @returns the input friendly name
  40272. */
  40273. getSimpleName(): string;
  40274. }
  40275. }
  40276. declare module "babylonjs/Cameras/Inputs/index" {
  40277. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40278. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40279. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40280. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40281. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40282. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40283. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40284. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40285. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40286. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40287. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40288. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40289. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40290. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40291. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40292. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40293. }
  40294. declare module "babylonjs/Cameras/touchCamera" {
  40295. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40296. import { Scene } from "babylonjs/scene";
  40297. import { Vector3 } from "babylonjs/Maths/math.vector";
  40298. /**
  40299. * This represents a FPS type of camera controlled by touch.
  40300. * This is like a universal camera minus the Gamepad controls.
  40301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40302. */
  40303. export class TouchCamera extends FreeCamera {
  40304. /**
  40305. * Defines the touch sensibility for rotation.
  40306. * The higher the faster.
  40307. */
  40308. touchAngularSensibility: number;
  40309. /**
  40310. * Defines the touch sensibility for move.
  40311. * The higher the faster.
  40312. */
  40313. touchMoveSensibility: number;
  40314. /**
  40315. * Instantiates a new touch camera.
  40316. * This represents a FPS type of camera controlled by touch.
  40317. * This is like a universal camera minus the Gamepad controls.
  40318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40319. * @param name Define the name of the camera in the scene
  40320. * @param position Define the start position of the camera in the scene
  40321. * @param scene Define the scene the camera belongs to
  40322. */
  40323. constructor(name: string, position: Vector3, scene: Scene);
  40324. /**
  40325. * Gets the current object class name.
  40326. * @return the class name
  40327. */
  40328. getClassName(): string;
  40329. /** @hidden */
  40330. _setupInputs(): void;
  40331. }
  40332. }
  40333. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40335. import { Scene } from "babylonjs/scene";
  40336. import { Vector3 } from "babylonjs/Maths/math.vector";
  40337. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40338. import { Axis } from "babylonjs/Maths/math.axis";
  40339. /**
  40340. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40341. * being tilted forward or back and left or right.
  40342. */
  40343. export class DeviceOrientationCamera extends FreeCamera {
  40344. private _initialQuaternion;
  40345. private _quaternionCache;
  40346. private _tmpDragQuaternion;
  40347. private _disablePointerInputWhenUsingDeviceOrientation;
  40348. /**
  40349. * Creates a new device orientation camera
  40350. * @param name The name of the camera
  40351. * @param position The start position camera
  40352. * @param scene The scene the camera belongs to
  40353. */
  40354. constructor(name: string, position: Vector3, scene: Scene);
  40355. /**
  40356. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40357. */
  40358. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40359. private _dragFactor;
  40360. /**
  40361. * Enabled turning on the y axis when the orientation sensor is active
  40362. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40363. */
  40364. enableHorizontalDragging(dragFactor?: number): void;
  40365. /**
  40366. * Gets the current instance class name ("DeviceOrientationCamera").
  40367. * This helps avoiding instanceof at run time.
  40368. * @returns the class name
  40369. */
  40370. getClassName(): string;
  40371. /**
  40372. * @hidden
  40373. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40374. */
  40375. _checkInputs(): void;
  40376. /**
  40377. * Reset the camera to its default orientation on the specified axis only.
  40378. * @param axis The axis to reset
  40379. */
  40380. resetToCurrentRotation(axis?: Axis): void;
  40381. }
  40382. }
  40383. declare module "babylonjs/Gamepads/xboxGamepad" {
  40384. import { Observable } from "babylonjs/Misc/observable";
  40385. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40386. /**
  40387. * Defines supported buttons for XBox360 compatible gamepads
  40388. */
  40389. export enum Xbox360Button {
  40390. /** A */
  40391. A = 0,
  40392. /** B */
  40393. B = 1,
  40394. /** X */
  40395. X = 2,
  40396. /** Y */
  40397. Y = 3,
  40398. /** Start */
  40399. Start = 4,
  40400. /** Back */
  40401. Back = 5,
  40402. /** Left button */
  40403. LB = 6,
  40404. /** Right button */
  40405. RB = 7,
  40406. /** Left stick */
  40407. LeftStick = 8,
  40408. /** Right stick */
  40409. RightStick = 9
  40410. }
  40411. /** Defines values for XBox360 DPad */
  40412. export enum Xbox360Dpad {
  40413. /** Up */
  40414. Up = 0,
  40415. /** Down */
  40416. Down = 1,
  40417. /** Left */
  40418. Left = 2,
  40419. /** Right */
  40420. Right = 3
  40421. }
  40422. /**
  40423. * Defines a XBox360 gamepad
  40424. */
  40425. export class Xbox360Pad extends Gamepad {
  40426. private _leftTrigger;
  40427. private _rightTrigger;
  40428. private _onlefttriggerchanged;
  40429. private _onrighttriggerchanged;
  40430. private _onbuttondown;
  40431. private _onbuttonup;
  40432. private _ondpaddown;
  40433. private _ondpadup;
  40434. /** Observable raised when a button is pressed */
  40435. onButtonDownObservable: Observable<Xbox360Button>;
  40436. /** Observable raised when a button is released */
  40437. onButtonUpObservable: Observable<Xbox360Button>;
  40438. /** Observable raised when a pad is pressed */
  40439. onPadDownObservable: Observable<Xbox360Dpad>;
  40440. /** Observable raised when a pad is released */
  40441. onPadUpObservable: Observable<Xbox360Dpad>;
  40442. private _buttonA;
  40443. private _buttonB;
  40444. private _buttonX;
  40445. private _buttonY;
  40446. private _buttonBack;
  40447. private _buttonStart;
  40448. private _buttonLB;
  40449. private _buttonRB;
  40450. private _buttonLeftStick;
  40451. private _buttonRightStick;
  40452. private _dPadUp;
  40453. private _dPadDown;
  40454. private _dPadLeft;
  40455. private _dPadRight;
  40456. private _isXboxOnePad;
  40457. /**
  40458. * Creates a new XBox360 gamepad object
  40459. * @param id defines the id of this gamepad
  40460. * @param index defines its index
  40461. * @param gamepad defines the internal HTML gamepad object
  40462. * @param xboxOne defines if it is a XBox One gamepad
  40463. */
  40464. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40465. /**
  40466. * Defines the callback to call when left trigger is pressed
  40467. * @param callback defines the callback to use
  40468. */
  40469. onlefttriggerchanged(callback: (value: number) => void): void;
  40470. /**
  40471. * Defines the callback to call when right trigger is pressed
  40472. * @param callback defines the callback to use
  40473. */
  40474. onrighttriggerchanged(callback: (value: number) => void): void;
  40475. /**
  40476. * Gets the left trigger value
  40477. */
  40478. /**
  40479. * Sets the left trigger value
  40480. */
  40481. leftTrigger: number;
  40482. /**
  40483. * Gets the right trigger value
  40484. */
  40485. /**
  40486. * Sets the right trigger value
  40487. */
  40488. rightTrigger: number;
  40489. /**
  40490. * Defines the callback to call when a button is pressed
  40491. * @param callback defines the callback to use
  40492. */
  40493. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40494. /**
  40495. * Defines the callback to call when a button is released
  40496. * @param callback defines the callback to use
  40497. */
  40498. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40499. /**
  40500. * Defines the callback to call when a pad is pressed
  40501. * @param callback defines the callback to use
  40502. */
  40503. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40504. /**
  40505. * Defines the callback to call when a pad is released
  40506. * @param callback defines the callback to use
  40507. */
  40508. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40509. private _setButtonValue;
  40510. private _setDPadValue;
  40511. /**
  40512. * Gets the value of the `A` button
  40513. */
  40514. /**
  40515. * Sets the value of the `A` button
  40516. */
  40517. buttonA: number;
  40518. /**
  40519. * Gets the value of the `B` button
  40520. */
  40521. /**
  40522. * Sets the value of the `B` button
  40523. */
  40524. buttonB: number;
  40525. /**
  40526. * Gets the value of the `X` button
  40527. */
  40528. /**
  40529. * Sets the value of the `X` button
  40530. */
  40531. buttonX: number;
  40532. /**
  40533. * Gets the value of the `Y` button
  40534. */
  40535. /**
  40536. * Sets the value of the `Y` button
  40537. */
  40538. buttonY: number;
  40539. /**
  40540. * Gets the value of the `Start` button
  40541. */
  40542. /**
  40543. * Sets the value of the `Start` button
  40544. */
  40545. buttonStart: number;
  40546. /**
  40547. * Gets the value of the `Back` button
  40548. */
  40549. /**
  40550. * Sets the value of the `Back` button
  40551. */
  40552. buttonBack: number;
  40553. /**
  40554. * Gets the value of the `Left` button
  40555. */
  40556. /**
  40557. * Sets the value of the `Left` button
  40558. */
  40559. buttonLB: number;
  40560. /**
  40561. * Gets the value of the `Right` button
  40562. */
  40563. /**
  40564. * Sets the value of the `Right` button
  40565. */
  40566. buttonRB: number;
  40567. /**
  40568. * Gets the value of the Left joystick
  40569. */
  40570. /**
  40571. * Sets the value of the Left joystick
  40572. */
  40573. buttonLeftStick: number;
  40574. /**
  40575. * Gets the value of the Right joystick
  40576. */
  40577. /**
  40578. * Sets the value of the Right joystick
  40579. */
  40580. buttonRightStick: number;
  40581. /**
  40582. * Gets the value of D-pad up
  40583. */
  40584. /**
  40585. * Sets the value of D-pad up
  40586. */
  40587. dPadUp: number;
  40588. /**
  40589. * Gets the value of D-pad down
  40590. */
  40591. /**
  40592. * Sets the value of D-pad down
  40593. */
  40594. dPadDown: number;
  40595. /**
  40596. * Gets the value of D-pad left
  40597. */
  40598. /**
  40599. * Sets the value of D-pad left
  40600. */
  40601. dPadLeft: number;
  40602. /**
  40603. * Gets the value of D-pad right
  40604. */
  40605. /**
  40606. * Sets the value of D-pad right
  40607. */
  40608. dPadRight: number;
  40609. /**
  40610. * Force the gamepad to synchronize with device values
  40611. */
  40612. update(): void;
  40613. /**
  40614. * Disposes the gamepad
  40615. */
  40616. dispose(): void;
  40617. }
  40618. }
  40619. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40620. import { Observable } from "babylonjs/Misc/observable";
  40621. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40622. /**
  40623. * Defines supported buttons for DualShock compatible gamepads
  40624. */
  40625. export enum DualShockButton {
  40626. /** Cross */
  40627. Cross = 0,
  40628. /** Circle */
  40629. Circle = 1,
  40630. /** Square */
  40631. Square = 2,
  40632. /** Triangle */
  40633. Triangle = 3,
  40634. /** Options */
  40635. Options = 4,
  40636. /** Share */
  40637. Share = 5,
  40638. /** L1 */
  40639. L1 = 6,
  40640. /** R1 */
  40641. R1 = 7,
  40642. /** Left stick */
  40643. LeftStick = 8,
  40644. /** Right stick */
  40645. RightStick = 9
  40646. }
  40647. /** Defines values for DualShock DPad */
  40648. export enum DualShockDpad {
  40649. /** Up */
  40650. Up = 0,
  40651. /** Down */
  40652. Down = 1,
  40653. /** Left */
  40654. Left = 2,
  40655. /** Right */
  40656. Right = 3
  40657. }
  40658. /**
  40659. * Defines a DualShock gamepad
  40660. */
  40661. export class DualShockPad extends Gamepad {
  40662. private _leftTrigger;
  40663. private _rightTrigger;
  40664. private _onlefttriggerchanged;
  40665. private _onrighttriggerchanged;
  40666. private _onbuttondown;
  40667. private _onbuttonup;
  40668. private _ondpaddown;
  40669. private _ondpadup;
  40670. /** Observable raised when a button is pressed */
  40671. onButtonDownObservable: Observable<DualShockButton>;
  40672. /** Observable raised when a button is released */
  40673. onButtonUpObservable: Observable<DualShockButton>;
  40674. /** Observable raised when a pad is pressed */
  40675. onPadDownObservable: Observable<DualShockDpad>;
  40676. /** Observable raised when a pad is released */
  40677. onPadUpObservable: Observable<DualShockDpad>;
  40678. private _buttonCross;
  40679. private _buttonCircle;
  40680. private _buttonSquare;
  40681. private _buttonTriangle;
  40682. private _buttonShare;
  40683. private _buttonOptions;
  40684. private _buttonL1;
  40685. private _buttonR1;
  40686. private _buttonLeftStick;
  40687. private _buttonRightStick;
  40688. private _dPadUp;
  40689. private _dPadDown;
  40690. private _dPadLeft;
  40691. private _dPadRight;
  40692. /**
  40693. * Creates a new DualShock gamepad object
  40694. * @param id defines the id of this gamepad
  40695. * @param index defines its index
  40696. * @param gamepad defines the internal HTML gamepad object
  40697. */
  40698. constructor(id: string, index: number, gamepad: any);
  40699. /**
  40700. * Defines the callback to call when left trigger is pressed
  40701. * @param callback defines the callback to use
  40702. */
  40703. onlefttriggerchanged(callback: (value: number) => void): void;
  40704. /**
  40705. * Defines the callback to call when right trigger is pressed
  40706. * @param callback defines the callback to use
  40707. */
  40708. onrighttriggerchanged(callback: (value: number) => void): void;
  40709. /**
  40710. * Gets the left trigger value
  40711. */
  40712. /**
  40713. * Sets the left trigger value
  40714. */
  40715. leftTrigger: number;
  40716. /**
  40717. * Gets the right trigger value
  40718. */
  40719. /**
  40720. * Sets the right trigger value
  40721. */
  40722. rightTrigger: number;
  40723. /**
  40724. * Defines the callback to call when a button is pressed
  40725. * @param callback defines the callback to use
  40726. */
  40727. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40728. /**
  40729. * Defines the callback to call when a button is released
  40730. * @param callback defines the callback to use
  40731. */
  40732. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40733. /**
  40734. * Defines the callback to call when a pad is pressed
  40735. * @param callback defines the callback to use
  40736. */
  40737. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40738. /**
  40739. * Defines the callback to call when a pad is released
  40740. * @param callback defines the callback to use
  40741. */
  40742. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40743. private _setButtonValue;
  40744. private _setDPadValue;
  40745. /**
  40746. * Gets the value of the `Cross` button
  40747. */
  40748. /**
  40749. * Sets the value of the `Cross` button
  40750. */
  40751. buttonCross: number;
  40752. /**
  40753. * Gets the value of the `Circle` button
  40754. */
  40755. /**
  40756. * Sets the value of the `Circle` button
  40757. */
  40758. buttonCircle: number;
  40759. /**
  40760. * Gets the value of the `Square` button
  40761. */
  40762. /**
  40763. * Sets the value of the `Square` button
  40764. */
  40765. buttonSquare: number;
  40766. /**
  40767. * Gets the value of the `Triangle` button
  40768. */
  40769. /**
  40770. * Sets the value of the `Triangle` button
  40771. */
  40772. buttonTriangle: number;
  40773. /**
  40774. * Gets the value of the `Options` button
  40775. */
  40776. /**
  40777. * Sets the value of the `Options` button
  40778. */
  40779. buttonOptions: number;
  40780. /**
  40781. * Gets the value of the `Share` button
  40782. */
  40783. /**
  40784. * Sets the value of the `Share` button
  40785. */
  40786. buttonShare: number;
  40787. /**
  40788. * Gets the value of the `L1` button
  40789. */
  40790. /**
  40791. * Sets the value of the `L1` button
  40792. */
  40793. buttonL1: number;
  40794. /**
  40795. * Gets the value of the `R1` button
  40796. */
  40797. /**
  40798. * Sets the value of the `R1` button
  40799. */
  40800. buttonR1: number;
  40801. /**
  40802. * Gets the value of the Left joystick
  40803. */
  40804. /**
  40805. * Sets the value of the Left joystick
  40806. */
  40807. buttonLeftStick: number;
  40808. /**
  40809. * Gets the value of the Right joystick
  40810. */
  40811. /**
  40812. * Sets the value of the Right joystick
  40813. */
  40814. buttonRightStick: number;
  40815. /**
  40816. * Gets the value of D-pad up
  40817. */
  40818. /**
  40819. * Sets the value of D-pad up
  40820. */
  40821. dPadUp: number;
  40822. /**
  40823. * Gets the value of D-pad down
  40824. */
  40825. /**
  40826. * Sets the value of D-pad down
  40827. */
  40828. dPadDown: number;
  40829. /**
  40830. * Gets the value of D-pad left
  40831. */
  40832. /**
  40833. * Sets the value of D-pad left
  40834. */
  40835. dPadLeft: number;
  40836. /**
  40837. * Gets the value of D-pad right
  40838. */
  40839. /**
  40840. * Sets the value of D-pad right
  40841. */
  40842. dPadRight: number;
  40843. /**
  40844. * Force the gamepad to synchronize with device values
  40845. */
  40846. update(): void;
  40847. /**
  40848. * Disposes the gamepad
  40849. */
  40850. dispose(): void;
  40851. }
  40852. }
  40853. declare module "babylonjs/Gamepads/gamepadManager" {
  40854. import { Observable } from "babylonjs/Misc/observable";
  40855. import { Nullable } from "babylonjs/types";
  40856. import { Scene } from "babylonjs/scene";
  40857. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40858. /**
  40859. * Manager for handling gamepads
  40860. */
  40861. export class GamepadManager {
  40862. private _scene?;
  40863. private _babylonGamepads;
  40864. private _oneGamepadConnected;
  40865. /** @hidden */
  40866. _isMonitoring: boolean;
  40867. private _gamepadEventSupported;
  40868. private _gamepadSupport;
  40869. /**
  40870. * observable to be triggered when the gamepad controller has been connected
  40871. */
  40872. onGamepadConnectedObservable: Observable<Gamepad>;
  40873. /**
  40874. * observable to be triggered when the gamepad controller has been disconnected
  40875. */
  40876. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40877. private _onGamepadConnectedEvent;
  40878. private _onGamepadDisconnectedEvent;
  40879. /**
  40880. * Initializes the gamepad manager
  40881. * @param _scene BabylonJS scene
  40882. */
  40883. constructor(_scene?: Scene | undefined);
  40884. /**
  40885. * The gamepads in the game pad manager
  40886. */
  40887. readonly gamepads: Gamepad[];
  40888. /**
  40889. * Get the gamepad controllers based on type
  40890. * @param type The type of gamepad controller
  40891. * @returns Nullable gamepad
  40892. */
  40893. getGamepadByType(type?: number): Nullable<Gamepad>;
  40894. /**
  40895. * Disposes the gamepad manager
  40896. */
  40897. dispose(): void;
  40898. private _addNewGamepad;
  40899. private _startMonitoringGamepads;
  40900. private _stopMonitoringGamepads;
  40901. /** @hidden */
  40902. _checkGamepadsStatus(): void;
  40903. private _updateGamepadObjects;
  40904. }
  40905. }
  40906. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40907. import { Nullable } from "babylonjs/types";
  40908. import { Scene } from "babylonjs/scene";
  40909. import { ISceneComponent } from "babylonjs/sceneComponent";
  40910. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40911. module "babylonjs/scene" {
  40912. interface Scene {
  40913. /** @hidden */
  40914. _gamepadManager: Nullable<GamepadManager>;
  40915. /**
  40916. * Gets the gamepad manager associated with the scene
  40917. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40918. */
  40919. gamepadManager: GamepadManager;
  40920. }
  40921. }
  40922. module "babylonjs/Cameras/freeCameraInputsManager" {
  40923. /**
  40924. * Interface representing a free camera inputs manager
  40925. */
  40926. interface FreeCameraInputsManager {
  40927. /**
  40928. * Adds gamepad input support to the FreeCameraInputsManager.
  40929. * @returns the FreeCameraInputsManager
  40930. */
  40931. addGamepad(): FreeCameraInputsManager;
  40932. }
  40933. }
  40934. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40935. /**
  40936. * Interface representing an arc rotate camera inputs manager
  40937. */
  40938. interface ArcRotateCameraInputsManager {
  40939. /**
  40940. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40941. * @returns the camera inputs manager
  40942. */
  40943. addGamepad(): ArcRotateCameraInputsManager;
  40944. }
  40945. }
  40946. /**
  40947. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40948. */
  40949. export class GamepadSystemSceneComponent implements ISceneComponent {
  40950. /**
  40951. * The component name helpfull to identify the component in the list of scene components.
  40952. */
  40953. readonly name: string;
  40954. /**
  40955. * The scene the component belongs to.
  40956. */
  40957. scene: Scene;
  40958. /**
  40959. * Creates a new instance of the component for the given scene
  40960. * @param scene Defines the scene to register the component in
  40961. */
  40962. constructor(scene: Scene);
  40963. /**
  40964. * Registers the component in a given scene
  40965. */
  40966. register(): void;
  40967. /**
  40968. * Rebuilds the elements related to this component in case of
  40969. * context lost for instance.
  40970. */
  40971. rebuild(): void;
  40972. /**
  40973. * Disposes the component and the associated ressources
  40974. */
  40975. dispose(): void;
  40976. private _beforeCameraUpdate;
  40977. }
  40978. }
  40979. declare module "babylonjs/Cameras/universalCamera" {
  40980. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40981. import { Scene } from "babylonjs/scene";
  40982. import { Vector3 } from "babylonjs/Maths/math.vector";
  40983. import "babylonjs/Gamepads/gamepadSceneComponent";
  40984. /**
  40985. * 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,
  40986. * which still works and will still be found in many Playgrounds.
  40987. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40988. */
  40989. export class UniversalCamera extends TouchCamera {
  40990. /**
  40991. * Defines the gamepad rotation sensiblity.
  40992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40993. */
  40994. gamepadAngularSensibility: number;
  40995. /**
  40996. * Defines the gamepad move sensiblity.
  40997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40998. */
  40999. gamepadMoveSensibility: number;
  41000. /**
  41001. * 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,
  41002. * which still works and will still be found in many Playgrounds.
  41003. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41004. * @param name Define the name of the camera in the scene
  41005. * @param position Define the start position of the camera in the scene
  41006. * @param scene Define the scene the camera belongs to
  41007. */
  41008. constructor(name: string, position: Vector3, scene: Scene);
  41009. /**
  41010. * Gets the current object class name.
  41011. * @return the class name
  41012. */
  41013. getClassName(): string;
  41014. }
  41015. }
  41016. declare module "babylonjs/Cameras/gamepadCamera" {
  41017. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41018. import { Scene } from "babylonjs/scene";
  41019. import { Vector3 } from "babylonjs/Maths/math.vector";
  41020. /**
  41021. * This represents a FPS type of camera. This is only here for back compat purpose.
  41022. * Please use the UniversalCamera instead as both are identical.
  41023. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41024. */
  41025. export class GamepadCamera extends UniversalCamera {
  41026. /**
  41027. * Instantiates a new Gamepad Camera
  41028. * This represents a FPS type of camera. This is only here for back compat purpose.
  41029. * Please use the UniversalCamera instead as both are identical.
  41030. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41031. * @param name Define the name of the camera in the scene
  41032. * @param position Define the start position of the camera in the scene
  41033. * @param scene Define the scene the camera belongs to
  41034. */
  41035. constructor(name: string, position: Vector3, scene: Scene);
  41036. /**
  41037. * Gets the current object class name.
  41038. * @return the class name
  41039. */
  41040. getClassName(): string;
  41041. }
  41042. }
  41043. declare module "babylonjs/Shaders/pass.fragment" {
  41044. /** @hidden */
  41045. export var passPixelShader: {
  41046. name: string;
  41047. shader: string;
  41048. };
  41049. }
  41050. declare module "babylonjs/Shaders/passCube.fragment" {
  41051. /** @hidden */
  41052. export var passCubePixelShader: {
  41053. name: string;
  41054. shader: string;
  41055. };
  41056. }
  41057. declare module "babylonjs/PostProcesses/passPostProcess" {
  41058. import { Nullable } from "babylonjs/types";
  41059. import { Camera } from "babylonjs/Cameras/camera";
  41060. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41061. import { Engine } from "babylonjs/Engines/engine";
  41062. import "babylonjs/Shaders/pass.fragment";
  41063. import "babylonjs/Shaders/passCube.fragment";
  41064. /**
  41065. * PassPostProcess which produces an output the same as it's input
  41066. */
  41067. export class PassPostProcess extends PostProcess {
  41068. /**
  41069. * Creates the PassPostProcess
  41070. * @param name The name of the effect.
  41071. * @param options The required width/height ratio to downsize to before computing the render pass.
  41072. * @param camera The camera to apply the render pass to.
  41073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41074. * @param engine The engine which the post process will be applied. (default: current engine)
  41075. * @param reusable If the post process can be reused on the same frame. (default: false)
  41076. * @param textureType The type of texture to be used when performing the post processing.
  41077. * @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)
  41078. */
  41079. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41080. }
  41081. /**
  41082. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41083. */
  41084. export class PassCubePostProcess extends PostProcess {
  41085. private _face;
  41086. /**
  41087. * Gets or sets the cube face to display.
  41088. * * 0 is +X
  41089. * * 1 is -X
  41090. * * 2 is +Y
  41091. * * 3 is -Y
  41092. * * 4 is +Z
  41093. * * 5 is -Z
  41094. */
  41095. face: number;
  41096. /**
  41097. * Creates the PassCubePostProcess
  41098. * @param name The name of the effect.
  41099. * @param options The required width/height ratio to downsize to before computing the render pass.
  41100. * @param camera The camera to apply the render pass to.
  41101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41102. * @param engine The engine which the post process will be applied. (default: current engine)
  41103. * @param reusable If the post process can be reused on the same frame. (default: false)
  41104. * @param textureType The type of texture to be used when performing the post processing.
  41105. * @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)
  41106. */
  41107. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41108. }
  41109. }
  41110. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41111. /** @hidden */
  41112. export var anaglyphPixelShader: {
  41113. name: string;
  41114. shader: string;
  41115. };
  41116. }
  41117. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41118. import { Engine } from "babylonjs/Engines/engine";
  41119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41120. import { Camera } from "babylonjs/Cameras/camera";
  41121. import "babylonjs/Shaders/anaglyph.fragment";
  41122. /**
  41123. * Postprocess used to generate anaglyphic rendering
  41124. */
  41125. export class AnaglyphPostProcess extends PostProcess {
  41126. private _passedProcess;
  41127. /**
  41128. * Creates a new AnaglyphPostProcess
  41129. * @param name defines postprocess name
  41130. * @param options defines creation options or target ratio scale
  41131. * @param rigCameras defines cameras using this postprocess
  41132. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41133. * @param engine defines hosting engine
  41134. * @param reusable defines if the postprocess will be reused multiple times per frame
  41135. */
  41136. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41137. }
  41138. }
  41139. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41140. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41141. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41142. import { Scene } from "babylonjs/scene";
  41143. import { Vector3 } from "babylonjs/Maths/math.vector";
  41144. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41145. /**
  41146. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41147. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41148. */
  41149. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41150. /**
  41151. * Creates a new AnaglyphArcRotateCamera
  41152. * @param name defines camera name
  41153. * @param alpha defines alpha angle (in radians)
  41154. * @param beta defines beta angle (in radians)
  41155. * @param radius defines radius
  41156. * @param target defines camera target
  41157. * @param interaxialDistance defines distance between each color axis
  41158. * @param scene defines the hosting scene
  41159. */
  41160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41161. /**
  41162. * Gets camera class name
  41163. * @returns AnaglyphArcRotateCamera
  41164. */
  41165. getClassName(): string;
  41166. }
  41167. }
  41168. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41170. import { Scene } from "babylonjs/scene";
  41171. import { Vector3 } from "babylonjs/Maths/math.vector";
  41172. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41173. /**
  41174. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41175. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41176. */
  41177. export class AnaglyphFreeCamera extends FreeCamera {
  41178. /**
  41179. * Creates a new AnaglyphFreeCamera
  41180. * @param name defines camera name
  41181. * @param position defines initial position
  41182. * @param interaxialDistance defines distance between each color axis
  41183. * @param scene defines the hosting scene
  41184. */
  41185. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41186. /**
  41187. * Gets camera class name
  41188. * @returns AnaglyphFreeCamera
  41189. */
  41190. getClassName(): string;
  41191. }
  41192. }
  41193. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41194. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41195. import { Scene } from "babylonjs/scene";
  41196. import { Vector3 } from "babylonjs/Maths/math.vector";
  41197. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41198. /**
  41199. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41200. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41201. */
  41202. export class AnaglyphGamepadCamera extends GamepadCamera {
  41203. /**
  41204. * Creates a new AnaglyphGamepadCamera
  41205. * @param name defines camera name
  41206. * @param position defines initial position
  41207. * @param interaxialDistance defines distance between each color axis
  41208. * @param scene defines the hosting scene
  41209. */
  41210. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41211. /**
  41212. * Gets camera class name
  41213. * @returns AnaglyphGamepadCamera
  41214. */
  41215. getClassName(): string;
  41216. }
  41217. }
  41218. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41219. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41220. import { Scene } from "babylonjs/scene";
  41221. import { Vector3 } from "babylonjs/Maths/math.vector";
  41222. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41223. /**
  41224. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41225. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41226. */
  41227. export class AnaglyphUniversalCamera extends UniversalCamera {
  41228. /**
  41229. * Creates a new AnaglyphUniversalCamera
  41230. * @param name defines camera name
  41231. * @param position defines initial position
  41232. * @param interaxialDistance defines distance between each color axis
  41233. * @param scene defines the hosting scene
  41234. */
  41235. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41236. /**
  41237. * Gets camera class name
  41238. * @returns AnaglyphUniversalCamera
  41239. */
  41240. getClassName(): string;
  41241. }
  41242. }
  41243. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41244. /** @hidden */
  41245. export var stereoscopicInterlacePixelShader: {
  41246. name: string;
  41247. shader: string;
  41248. };
  41249. }
  41250. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41251. import { Camera } from "babylonjs/Cameras/camera";
  41252. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41253. import { Engine } from "babylonjs/Engines/engine";
  41254. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41255. /**
  41256. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41257. */
  41258. export class StereoscopicInterlacePostProcess extends PostProcess {
  41259. private _stepSize;
  41260. private _passedProcess;
  41261. /**
  41262. * Initializes a StereoscopicInterlacePostProcess
  41263. * @param name The name of the effect.
  41264. * @param rigCameras The rig cameras to be appled to the post process
  41265. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41267. * @param engine The engine which the post process will be applied. (default: current engine)
  41268. * @param reusable If the post process can be reused on the same frame. (default: false)
  41269. */
  41270. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41271. }
  41272. }
  41273. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41274. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41275. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41276. import { Scene } from "babylonjs/scene";
  41277. import { Vector3 } from "babylonjs/Maths/math.vector";
  41278. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41279. /**
  41280. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41281. * @see http://doc.babylonjs.com/features/cameras
  41282. */
  41283. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41284. /**
  41285. * Creates a new StereoscopicArcRotateCamera
  41286. * @param name defines camera name
  41287. * @param alpha defines alpha angle (in radians)
  41288. * @param beta defines beta angle (in radians)
  41289. * @param radius defines radius
  41290. * @param target defines camera target
  41291. * @param interaxialDistance defines distance between each color axis
  41292. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41293. * @param scene defines the hosting scene
  41294. */
  41295. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41296. /**
  41297. * Gets camera class name
  41298. * @returns StereoscopicArcRotateCamera
  41299. */
  41300. getClassName(): string;
  41301. }
  41302. }
  41303. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41304. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41305. import { Scene } from "babylonjs/scene";
  41306. import { Vector3 } from "babylonjs/Maths/math.vector";
  41307. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41308. /**
  41309. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41310. * @see http://doc.babylonjs.com/features/cameras
  41311. */
  41312. export class StereoscopicFreeCamera extends FreeCamera {
  41313. /**
  41314. * Creates a new StereoscopicFreeCamera
  41315. * @param name defines camera name
  41316. * @param position defines initial position
  41317. * @param interaxialDistance defines distance between each color axis
  41318. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41319. * @param scene defines the hosting scene
  41320. */
  41321. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41322. /**
  41323. * Gets camera class name
  41324. * @returns StereoscopicFreeCamera
  41325. */
  41326. getClassName(): string;
  41327. }
  41328. }
  41329. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41330. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41331. import { Scene } from "babylonjs/scene";
  41332. import { Vector3 } from "babylonjs/Maths/math.vector";
  41333. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41334. /**
  41335. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41336. * @see http://doc.babylonjs.com/features/cameras
  41337. */
  41338. export class StereoscopicGamepadCamera extends GamepadCamera {
  41339. /**
  41340. * Creates a new StereoscopicGamepadCamera
  41341. * @param name defines camera name
  41342. * @param position defines initial position
  41343. * @param interaxialDistance defines distance between each color axis
  41344. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41345. * @param scene defines the hosting scene
  41346. */
  41347. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41348. /**
  41349. * Gets camera class name
  41350. * @returns StereoscopicGamepadCamera
  41351. */
  41352. getClassName(): string;
  41353. }
  41354. }
  41355. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41356. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  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 UniversalCamera)
  41362. * @see http://doc.babylonjs.com/features/cameras
  41363. */
  41364. export class StereoscopicUniversalCamera extends UniversalCamera {
  41365. /**
  41366. * Creates a new StereoscopicUniversalCamera
  41367. * @param name defines camera name
  41368. * @param position defines initial position
  41369. * @param interaxialDistance defines distance between each color axis
  41370. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41371. * @param scene defines the hosting scene
  41372. */
  41373. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41374. /**
  41375. * Gets camera class name
  41376. * @returns StereoscopicUniversalCamera
  41377. */
  41378. getClassName(): string;
  41379. }
  41380. }
  41381. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41382. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41383. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41384. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41385. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41386. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41387. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41388. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41389. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41390. }
  41391. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41392. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41393. import { Scene } from "babylonjs/scene";
  41394. import { Vector3 } from "babylonjs/Maths/math.vector";
  41395. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41396. /**
  41397. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41398. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41399. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41400. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41401. */
  41402. export class VirtualJoysticksCamera extends FreeCamera {
  41403. /**
  41404. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41405. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41406. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41407. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41408. * @param name Define the name of the camera in the scene
  41409. * @param position Define the start position of the camera in the scene
  41410. * @param scene Define the scene the camera belongs to
  41411. */
  41412. constructor(name: string, position: Vector3, scene: Scene);
  41413. /**
  41414. * Gets the current object class name.
  41415. * @return the class name
  41416. */
  41417. getClassName(): string;
  41418. }
  41419. }
  41420. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41421. import { Matrix } from "babylonjs/Maths/math.vector";
  41422. /**
  41423. * This represents all the required metrics to create a VR camera.
  41424. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41425. */
  41426. export class VRCameraMetrics {
  41427. /**
  41428. * Define the horizontal resolution off the screen.
  41429. */
  41430. hResolution: number;
  41431. /**
  41432. * Define the vertical resolution off the screen.
  41433. */
  41434. vResolution: number;
  41435. /**
  41436. * Define the horizontal screen size.
  41437. */
  41438. hScreenSize: number;
  41439. /**
  41440. * Define the vertical screen size.
  41441. */
  41442. vScreenSize: number;
  41443. /**
  41444. * Define the vertical screen center position.
  41445. */
  41446. vScreenCenter: number;
  41447. /**
  41448. * Define the distance of the eyes to the screen.
  41449. */
  41450. eyeToScreenDistance: number;
  41451. /**
  41452. * Define the distance between both lenses
  41453. */
  41454. lensSeparationDistance: number;
  41455. /**
  41456. * Define the distance between both viewer's eyes.
  41457. */
  41458. interpupillaryDistance: number;
  41459. /**
  41460. * Define the distortion factor of the VR postprocess.
  41461. * Please, touch with care.
  41462. */
  41463. distortionK: number[];
  41464. /**
  41465. * Define the chromatic aberration correction factors for the VR post process.
  41466. */
  41467. chromaAbCorrection: number[];
  41468. /**
  41469. * Define the scale factor of the post process.
  41470. * The smaller the better but the slower.
  41471. */
  41472. postProcessScaleFactor: number;
  41473. /**
  41474. * Define an offset for the lens center.
  41475. */
  41476. lensCenterOffset: number;
  41477. /**
  41478. * Define if the current vr camera should compensate the distortion of the lense or not.
  41479. */
  41480. compensateDistortion: boolean;
  41481. /**
  41482. * Defines if multiview should be enabled when rendering (Default: false)
  41483. */
  41484. multiviewEnabled: boolean;
  41485. /**
  41486. * Gets the rendering aspect ratio based on the provided resolutions.
  41487. */
  41488. readonly aspectRatio: number;
  41489. /**
  41490. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41491. */
  41492. readonly aspectRatioFov: number;
  41493. /**
  41494. * @hidden
  41495. */
  41496. readonly leftHMatrix: Matrix;
  41497. /**
  41498. * @hidden
  41499. */
  41500. readonly rightHMatrix: Matrix;
  41501. /**
  41502. * @hidden
  41503. */
  41504. readonly leftPreViewMatrix: Matrix;
  41505. /**
  41506. * @hidden
  41507. */
  41508. readonly rightPreViewMatrix: Matrix;
  41509. /**
  41510. * Get the default VRMetrics based on the most generic setup.
  41511. * @returns the default vr metrics
  41512. */
  41513. static GetDefault(): VRCameraMetrics;
  41514. }
  41515. }
  41516. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41517. /** @hidden */
  41518. export var vrDistortionCorrectionPixelShader: {
  41519. name: string;
  41520. shader: string;
  41521. };
  41522. }
  41523. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41524. import { Camera } from "babylonjs/Cameras/camera";
  41525. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41526. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41527. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41528. /**
  41529. * VRDistortionCorrectionPostProcess used for mobile VR
  41530. */
  41531. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41532. private _isRightEye;
  41533. private _distortionFactors;
  41534. private _postProcessScaleFactor;
  41535. private _lensCenterOffset;
  41536. private _scaleIn;
  41537. private _scaleFactor;
  41538. private _lensCenter;
  41539. /**
  41540. * Initializes the VRDistortionCorrectionPostProcess
  41541. * @param name The name of the effect.
  41542. * @param camera The camera to apply the render pass to.
  41543. * @param isRightEye If this is for the right eye distortion
  41544. * @param vrMetrics All the required metrics for the VR camera
  41545. */
  41546. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41547. }
  41548. }
  41549. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41550. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41551. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41552. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41553. import { Scene } from "babylonjs/scene";
  41554. import { Vector3 } from "babylonjs/Maths/math.vector";
  41555. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41556. import "babylonjs/Cameras/RigModes/vrRigMode";
  41557. /**
  41558. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41559. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41560. */
  41561. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41562. /**
  41563. * Creates a new VRDeviceOrientationArcRotateCamera
  41564. * @param name defines camera name
  41565. * @param alpha defines the camera rotation along the logitudinal axis
  41566. * @param beta defines the camera rotation along the latitudinal axis
  41567. * @param radius defines the camera distance from its target
  41568. * @param target defines the camera target
  41569. * @param scene defines the scene the camera belongs to
  41570. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41571. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41572. */
  41573. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41574. /**
  41575. * Gets camera class name
  41576. * @returns VRDeviceOrientationArcRotateCamera
  41577. */
  41578. getClassName(): string;
  41579. }
  41580. }
  41581. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41582. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41583. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41584. import { Scene } from "babylonjs/scene";
  41585. import { Vector3 } from "babylonjs/Maths/math.vector";
  41586. import "babylonjs/Cameras/RigModes/vrRigMode";
  41587. /**
  41588. * Camera used to simulate VR rendering (based on FreeCamera)
  41589. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41590. */
  41591. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41592. /**
  41593. * Creates a new VRDeviceOrientationFreeCamera
  41594. * @param name defines camera name
  41595. * @param position defines the start position of the camera
  41596. * @param scene defines the scene the camera belongs to
  41597. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41598. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41599. */
  41600. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41601. /**
  41602. * Gets camera class name
  41603. * @returns VRDeviceOrientationFreeCamera
  41604. */
  41605. getClassName(): string;
  41606. }
  41607. }
  41608. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41609. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41610. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41611. import { Scene } from "babylonjs/scene";
  41612. import { Vector3 } from "babylonjs/Maths/math.vector";
  41613. import "babylonjs/Gamepads/gamepadSceneComponent";
  41614. /**
  41615. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41616. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41617. */
  41618. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41619. /**
  41620. * Creates a new VRDeviceOrientationGamepadCamera
  41621. * @param name defines camera name
  41622. * @param position defines the start position of the camera
  41623. * @param scene defines the scene the camera belongs to
  41624. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41625. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41626. */
  41627. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41628. /**
  41629. * Gets camera class name
  41630. * @returns VRDeviceOrientationGamepadCamera
  41631. */
  41632. getClassName(): string;
  41633. }
  41634. }
  41635. declare module "babylonjs/Materials/pushMaterial" {
  41636. import { Nullable } from "babylonjs/types";
  41637. import { Scene } from "babylonjs/scene";
  41638. import { Matrix } from "babylonjs/Maths/math.vector";
  41639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41640. import { Mesh } from "babylonjs/Meshes/mesh";
  41641. import { Material } from "babylonjs/Materials/material";
  41642. import { Effect } from "babylonjs/Materials/effect";
  41643. /**
  41644. * Base class of materials working in push mode in babylon JS
  41645. * @hidden
  41646. */
  41647. export class PushMaterial extends Material {
  41648. protected _activeEffect: Effect;
  41649. protected _normalMatrix: Matrix;
  41650. /**
  41651. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41652. * This means that the material can keep using a previous shader while a new one is being compiled.
  41653. * This is mostly used when shader parallel compilation is supported (true by default)
  41654. */
  41655. allowShaderHotSwapping: boolean;
  41656. constructor(name: string, scene: Scene);
  41657. getEffect(): Effect;
  41658. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41659. /**
  41660. * Binds the given world matrix to the active effect
  41661. *
  41662. * @param world the matrix to bind
  41663. */
  41664. bindOnlyWorldMatrix(world: Matrix): void;
  41665. /**
  41666. * Binds the given normal matrix to the active effect
  41667. *
  41668. * @param normalMatrix the matrix to bind
  41669. */
  41670. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41671. bind(world: Matrix, mesh?: Mesh): void;
  41672. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41673. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41674. }
  41675. }
  41676. declare module "babylonjs/Materials/materialFlags" {
  41677. /**
  41678. * This groups all the flags used to control the materials channel.
  41679. */
  41680. export class MaterialFlags {
  41681. private static _DiffuseTextureEnabled;
  41682. /**
  41683. * Are diffuse textures enabled in the application.
  41684. */
  41685. static DiffuseTextureEnabled: boolean;
  41686. private static _AmbientTextureEnabled;
  41687. /**
  41688. * Are ambient textures enabled in the application.
  41689. */
  41690. static AmbientTextureEnabled: boolean;
  41691. private static _OpacityTextureEnabled;
  41692. /**
  41693. * Are opacity textures enabled in the application.
  41694. */
  41695. static OpacityTextureEnabled: boolean;
  41696. private static _ReflectionTextureEnabled;
  41697. /**
  41698. * Are reflection textures enabled in the application.
  41699. */
  41700. static ReflectionTextureEnabled: boolean;
  41701. private static _EmissiveTextureEnabled;
  41702. /**
  41703. * Are emissive textures enabled in the application.
  41704. */
  41705. static EmissiveTextureEnabled: boolean;
  41706. private static _SpecularTextureEnabled;
  41707. /**
  41708. * Are specular textures enabled in the application.
  41709. */
  41710. static SpecularTextureEnabled: boolean;
  41711. private static _BumpTextureEnabled;
  41712. /**
  41713. * Are bump textures enabled in the application.
  41714. */
  41715. static BumpTextureEnabled: boolean;
  41716. private static _LightmapTextureEnabled;
  41717. /**
  41718. * Are lightmap textures enabled in the application.
  41719. */
  41720. static LightmapTextureEnabled: boolean;
  41721. private static _RefractionTextureEnabled;
  41722. /**
  41723. * Are refraction textures enabled in the application.
  41724. */
  41725. static RefractionTextureEnabled: boolean;
  41726. private static _ColorGradingTextureEnabled;
  41727. /**
  41728. * Are color grading textures enabled in the application.
  41729. */
  41730. static ColorGradingTextureEnabled: boolean;
  41731. private static _FresnelEnabled;
  41732. /**
  41733. * Are fresnels enabled in the application.
  41734. */
  41735. static FresnelEnabled: boolean;
  41736. private static _ClearCoatTextureEnabled;
  41737. /**
  41738. * Are clear coat textures enabled in the application.
  41739. */
  41740. static ClearCoatTextureEnabled: boolean;
  41741. private static _ClearCoatBumpTextureEnabled;
  41742. /**
  41743. * Are clear coat bump textures enabled in the application.
  41744. */
  41745. static ClearCoatBumpTextureEnabled: boolean;
  41746. private static _ClearCoatTintTextureEnabled;
  41747. /**
  41748. * Are clear coat tint textures enabled in the application.
  41749. */
  41750. static ClearCoatTintTextureEnabled: boolean;
  41751. private static _SheenTextureEnabled;
  41752. /**
  41753. * Are sheen textures enabled in the application.
  41754. */
  41755. static SheenTextureEnabled: boolean;
  41756. private static _AnisotropicTextureEnabled;
  41757. /**
  41758. * Are anisotropic textures enabled in the application.
  41759. */
  41760. static AnisotropicTextureEnabled: boolean;
  41761. private static _ThicknessTextureEnabled;
  41762. /**
  41763. * Are thickness textures enabled in the application.
  41764. */
  41765. static ThicknessTextureEnabled: boolean;
  41766. }
  41767. }
  41768. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41769. /** @hidden */
  41770. export var defaultFragmentDeclaration: {
  41771. name: string;
  41772. shader: string;
  41773. };
  41774. }
  41775. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41776. /** @hidden */
  41777. export var defaultUboDeclaration: {
  41778. name: string;
  41779. shader: string;
  41780. };
  41781. }
  41782. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41783. /** @hidden */
  41784. export var lightFragmentDeclaration: {
  41785. name: string;
  41786. shader: string;
  41787. };
  41788. }
  41789. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41790. /** @hidden */
  41791. export var lightUboDeclaration: {
  41792. name: string;
  41793. shader: string;
  41794. };
  41795. }
  41796. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41797. /** @hidden */
  41798. export var lightsFragmentFunctions: {
  41799. name: string;
  41800. shader: string;
  41801. };
  41802. }
  41803. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41804. /** @hidden */
  41805. export var shadowsFragmentFunctions: {
  41806. name: string;
  41807. shader: string;
  41808. };
  41809. }
  41810. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41811. /** @hidden */
  41812. export var fresnelFunction: {
  41813. name: string;
  41814. shader: string;
  41815. };
  41816. }
  41817. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41818. /** @hidden */
  41819. export var reflectionFunction: {
  41820. name: string;
  41821. shader: string;
  41822. };
  41823. }
  41824. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41825. /** @hidden */
  41826. export var bumpFragmentFunctions: {
  41827. name: string;
  41828. shader: string;
  41829. };
  41830. }
  41831. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41832. /** @hidden */
  41833. export var logDepthDeclaration: {
  41834. name: string;
  41835. shader: string;
  41836. };
  41837. }
  41838. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41839. /** @hidden */
  41840. export var bumpFragment: {
  41841. name: string;
  41842. shader: string;
  41843. };
  41844. }
  41845. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41846. /** @hidden */
  41847. export var depthPrePass: {
  41848. name: string;
  41849. shader: string;
  41850. };
  41851. }
  41852. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41853. /** @hidden */
  41854. export var lightFragment: {
  41855. name: string;
  41856. shader: string;
  41857. };
  41858. }
  41859. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41860. /** @hidden */
  41861. export var logDepthFragment: {
  41862. name: string;
  41863. shader: string;
  41864. };
  41865. }
  41866. declare module "babylonjs/Shaders/default.fragment" {
  41867. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41868. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41869. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41870. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41871. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41872. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41873. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41874. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41875. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41876. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41877. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41878. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41879. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41880. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41881. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41882. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41883. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41884. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41885. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41886. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41887. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41888. /** @hidden */
  41889. export var defaultPixelShader: {
  41890. name: string;
  41891. shader: string;
  41892. };
  41893. }
  41894. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41895. /** @hidden */
  41896. export var defaultVertexDeclaration: {
  41897. name: string;
  41898. shader: string;
  41899. };
  41900. }
  41901. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41902. /** @hidden */
  41903. export var bumpVertexDeclaration: {
  41904. name: string;
  41905. shader: string;
  41906. };
  41907. }
  41908. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41909. /** @hidden */
  41910. export var bumpVertex: {
  41911. name: string;
  41912. shader: string;
  41913. };
  41914. }
  41915. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41916. /** @hidden */
  41917. export var fogVertex: {
  41918. name: string;
  41919. shader: string;
  41920. };
  41921. }
  41922. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41923. /** @hidden */
  41924. export var shadowsVertex: {
  41925. name: string;
  41926. shader: string;
  41927. };
  41928. }
  41929. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41930. /** @hidden */
  41931. export var pointCloudVertex: {
  41932. name: string;
  41933. shader: string;
  41934. };
  41935. }
  41936. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41937. /** @hidden */
  41938. export var logDepthVertex: {
  41939. name: string;
  41940. shader: string;
  41941. };
  41942. }
  41943. declare module "babylonjs/Shaders/default.vertex" {
  41944. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41945. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41947. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41948. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41949. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41950. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41951. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41952. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41953. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41954. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41956. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41957. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41958. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41959. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41960. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41961. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41962. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41963. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41964. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41965. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41966. /** @hidden */
  41967. export var defaultVertexShader: {
  41968. name: string;
  41969. shader: string;
  41970. };
  41971. }
  41972. declare module "babylonjs/Materials/standardMaterial" {
  41973. import { SmartArray } from "babylonjs/Misc/smartArray";
  41974. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41975. import { Nullable } from "babylonjs/types";
  41976. import { Scene } from "babylonjs/scene";
  41977. import { Matrix } from "babylonjs/Maths/math.vector";
  41978. import { Color3 } from "babylonjs/Maths/math.color";
  41979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41981. import { Mesh } from "babylonjs/Meshes/mesh";
  41982. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41983. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41984. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41985. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41986. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41988. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41989. import "babylonjs/Shaders/default.fragment";
  41990. import "babylonjs/Shaders/default.vertex";
  41991. /** @hidden */
  41992. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41993. MAINUV1: boolean;
  41994. MAINUV2: boolean;
  41995. DIFFUSE: boolean;
  41996. DIFFUSEDIRECTUV: number;
  41997. AMBIENT: boolean;
  41998. AMBIENTDIRECTUV: number;
  41999. OPACITY: boolean;
  42000. OPACITYDIRECTUV: number;
  42001. OPACITYRGB: boolean;
  42002. REFLECTION: boolean;
  42003. EMISSIVE: boolean;
  42004. EMISSIVEDIRECTUV: number;
  42005. SPECULAR: boolean;
  42006. SPECULARDIRECTUV: number;
  42007. BUMP: boolean;
  42008. BUMPDIRECTUV: number;
  42009. PARALLAX: boolean;
  42010. PARALLAXOCCLUSION: boolean;
  42011. SPECULAROVERALPHA: boolean;
  42012. CLIPPLANE: boolean;
  42013. CLIPPLANE2: boolean;
  42014. CLIPPLANE3: boolean;
  42015. CLIPPLANE4: boolean;
  42016. ALPHATEST: boolean;
  42017. DEPTHPREPASS: boolean;
  42018. ALPHAFROMDIFFUSE: boolean;
  42019. POINTSIZE: boolean;
  42020. FOG: boolean;
  42021. SPECULARTERM: boolean;
  42022. DIFFUSEFRESNEL: boolean;
  42023. OPACITYFRESNEL: boolean;
  42024. REFLECTIONFRESNEL: boolean;
  42025. REFRACTIONFRESNEL: boolean;
  42026. EMISSIVEFRESNEL: boolean;
  42027. FRESNEL: boolean;
  42028. NORMAL: boolean;
  42029. UV1: boolean;
  42030. UV2: boolean;
  42031. VERTEXCOLOR: boolean;
  42032. VERTEXALPHA: boolean;
  42033. NUM_BONE_INFLUENCERS: number;
  42034. BonesPerMesh: number;
  42035. BONETEXTURE: boolean;
  42036. INSTANCES: boolean;
  42037. GLOSSINESS: boolean;
  42038. ROUGHNESS: boolean;
  42039. EMISSIVEASILLUMINATION: boolean;
  42040. LINKEMISSIVEWITHDIFFUSE: boolean;
  42041. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42042. LIGHTMAP: boolean;
  42043. LIGHTMAPDIRECTUV: number;
  42044. OBJECTSPACE_NORMALMAP: boolean;
  42045. USELIGHTMAPASSHADOWMAP: boolean;
  42046. REFLECTIONMAP_3D: boolean;
  42047. REFLECTIONMAP_SPHERICAL: boolean;
  42048. REFLECTIONMAP_PLANAR: boolean;
  42049. REFLECTIONMAP_CUBIC: boolean;
  42050. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42051. REFLECTIONMAP_PROJECTION: boolean;
  42052. REFLECTIONMAP_SKYBOX: boolean;
  42053. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42054. REFLECTIONMAP_EXPLICIT: boolean;
  42055. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42056. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42057. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42058. INVERTCUBICMAP: boolean;
  42059. LOGARITHMICDEPTH: boolean;
  42060. REFRACTION: boolean;
  42061. REFRACTIONMAP_3D: boolean;
  42062. REFLECTIONOVERALPHA: boolean;
  42063. TWOSIDEDLIGHTING: boolean;
  42064. SHADOWFLOAT: boolean;
  42065. MORPHTARGETS: boolean;
  42066. MORPHTARGETS_NORMAL: boolean;
  42067. MORPHTARGETS_TANGENT: boolean;
  42068. MORPHTARGETS_UV: boolean;
  42069. NUM_MORPH_INFLUENCERS: number;
  42070. NONUNIFORMSCALING: boolean;
  42071. PREMULTIPLYALPHA: boolean;
  42072. IMAGEPROCESSING: boolean;
  42073. VIGNETTE: boolean;
  42074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42075. VIGNETTEBLENDMODEOPAQUE: boolean;
  42076. TONEMAPPING: boolean;
  42077. TONEMAPPING_ACES: boolean;
  42078. CONTRAST: boolean;
  42079. COLORCURVES: boolean;
  42080. COLORGRADING: boolean;
  42081. COLORGRADING3D: boolean;
  42082. SAMPLER3DGREENDEPTH: boolean;
  42083. SAMPLER3DBGRMAP: boolean;
  42084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42085. MULTIVIEW: boolean;
  42086. /**
  42087. * If the reflection texture on this material is in linear color space
  42088. * @hidden
  42089. */
  42090. IS_REFLECTION_LINEAR: boolean;
  42091. /**
  42092. * If the refraction texture on this material is in linear color space
  42093. * @hidden
  42094. */
  42095. IS_REFRACTION_LINEAR: boolean;
  42096. EXPOSURE: boolean;
  42097. constructor();
  42098. setReflectionMode(modeToEnable: string): void;
  42099. }
  42100. /**
  42101. * This is the default material used in Babylon. It is the best trade off between quality
  42102. * and performances.
  42103. * @see http://doc.babylonjs.com/babylon101/materials
  42104. */
  42105. export class StandardMaterial extends PushMaterial {
  42106. private _diffuseTexture;
  42107. /**
  42108. * The basic texture of the material as viewed under a light.
  42109. */
  42110. diffuseTexture: Nullable<BaseTexture>;
  42111. private _ambientTexture;
  42112. /**
  42113. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42114. */
  42115. ambientTexture: Nullable<BaseTexture>;
  42116. private _opacityTexture;
  42117. /**
  42118. * Define the transparency of the material from a texture.
  42119. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42120. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42121. */
  42122. opacityTexture: Nullable<BaseTexture>;
  42123. private _reflectionTexture;
  42124. /**
  42125. * Define the texture used to display the reflection.
  42126. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42127. */
  42128. reflectionTexture: Nullable<BaseTexture>;
  42129. private _emissiveTexture;
  42130. /**
  42131. * Define texture of the material as if self lit.
  42132. * This will be mixed in the final result even in the absence of light.
  42133. */
  42134. emissiveTexture: Nullable<BaseTexture>;
  42135. private _specularTexture;
  42136. /**
  42137. * Define how the color and intensity of the highlight given by the light in the material.
  42138. */
  42139. specularTexture: Nullable<BaseTexture>;
  42140. private _bumpTexture;
  42141. /**
  42142. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42143. * 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.
  42144. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42145. */
  42146. bumpTexture: Nullable<BaseTexture>;
  42147. private _lightmapTexture;
  42148. /**
  42149. * Complex lighting can be computationally expensive to compute at runtime.
  42150. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42151. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42152. */
  42153. lightmapTexture: Nullable<BaseTexture>;
  42154. private _refractionTexture;
  42155. /**
  42156. * Define the texture used to display the refraction.
  42157. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42158. */
  42159. refractionTexture: Nullable<BaseTexture>;
  42160. /**
  42161. * The color of the material lit by the environmental background lighting.
  42162. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42163. */
  42164. ambientColor: Color3;
  42165. /**
  42166. * The basic color of the material as viewed under a light.
  42167. */
  42168. diffuseColor: Color3;
  42169. /**
  42170. * Define how the color and intensity of the highlight given by the light in the material.
  42171. */
  42172. specularColor: Color3;
  42173. /**
  42174. * Define the color of the material as if self lit.
  42175. * This will be mixed in the final result even in the absence of light.
  42176. */
  42177. emissiveColor: Color3;
  42178. /**
  42179. * Defines how sharp are the highlights in the material.
  42180. * The bigger the value the sharper giving a more glossy feeling to the result.
  42181. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42182. */
  42183. specularPower: number;
  42184. private _useAlphaFromDiffuseTexture;
  42185. /**
  42186. * Does the transparency come from the diffuse texture alpha channel.
  42187. */
  42188. useAlphaFromDiffuseTexture: boolean;
  42189. private _useEmissiveAsIllumination;
  42190. /**
  42191. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42192. */
  42193. useEmissiveAsIllumination: boolean;
  42194. private _linkEmissiveWithDiffuse;
  42195. /**
  42196. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42197. * the emissive level when the final color is close to one.
  42198. */
  42199. linkEmissiveWithDiffuse: boolean;
  42200. private _useSpecularOverAlpha;
  42201. /**
  42202. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42203. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42204. */
  42205. useSpecularOverAlpha: boolean;
  42206. private _useReflectionOverAlpha;
  42207. /**
  42208. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42209. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42210. */
  42211. useReflectionOverAlpha: boolean;
  42212. private _disableLighting;
  42213. /**
  42214. * Does lights from the scene impacts this material.
  42215. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42216. */
  42217. disableLighting: boolean;
  42218. private _useObjectSpaceNormalMap;
  42219. /**
  42220. * Allows using an object space normal map (instead of tangent space).
  42221. */
  42222. useObjectSpaceNormalMap: boolean;
  42223. private _useParallax;
  42224. /**
  42225. * Is parallax enabled or not.
  42226. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42227. */
  42228. useParallax: boolean;
  42229. private _useParallaxOcclusion;
  42230. /**
  42231. * Is parallax occlusion enabled or not.
  42232. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42233. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42234. */
  42235. useParallaxOcclusion: boolean;
  42236. /**
  42237. * 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.
  42238. */
  42239. parallaxScaleBias: number;
  42240. private _roughness;
  42241. /**
  42242. * Helps to define how blurry the reflections should appears in the material.
  42243. */
  42244. roughness: number;
  42245. /**
  42246. * In case of refraction, define the value of the index of refraction.
  42247. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42248. */
  42249. indexOfRefraction: number;
  42250. /**
  42251. * Invert the refraction texture alongside the y axis.
  42252. * It can be useful with procedural textures or probe for instance.
  42253. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42254. */
  42255. invertRefractionY: boolean;
  42256. /**
  42257. * Defines the alpha limits in alpha test mode.
  42258. */
  42259. alphaCutOff: number;
  42260. private _useLightmapAsShadowmap;
  42261. /**
  42262. * In case of light mapping, define whether the map contains light or shadow informations.
  42263. */
  42264. useLightmapAsShadowmap: boolean;
  42265. private _diffuseFresnelParameters;
  42266. /**
  42267. * Define the diffuse fresnel parameters of the material.
  42268. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42269. */
  42270. diffuseFresnelParameters: FresnelParameters;
  42271. private _opacityFresnelParameters;
  42272. /**
  42273. * Define the opacity fresnel parameters of the material.
  42274. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42275. */
  42276. opacityFresnelParameters: FresnelParameters;
  42277. private _reflectionFresnelParameters;
  42278. /**
  42279. * Define the reflection fresnel parameters of the material.
  42280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42281. */
  42282. reflectionFresnelParameters: FresnelParameters;
  42283. private _refractionFresnelParameters;
  42284. /**
  42285. * Define the refraction fresnel parameters of the material.
  42286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42287. */
  42288. refractionFresnelParameters: FresnelParameters;
  42289. private _emissiveFresnelParameters;
  42290. /**
  42291. * Define the emissive fresnel parameters of the material.
  42292. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42293. */
  42294. emissiveFresnelParameters: FresnelParameters;
  42295. private _useReflectionFresnelFromSpecular;
  42296. /**
  42297. * If true automatically deducts the fresnels values from the material specularity.
  42298. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42299. */
  42300. useReflectionFresnelFromSpecular: boolean;
  42301. private _useGlossinessFromSpecularMapAlpha;
  42302. /**
  42303. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42304. */
  42305. useGlossinessFromSpecularMapAlpha: boolean;
  42306. private _maxSimultaneousLights;
  42307. /**
  42308. * Defines the maximum number of lights that can be used in the material
  42309. */
  42310. maxSimultaneousLights: number;
  42311. private _invertNormalMapX;
  42312. /**
  42313. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42314. */
  42315. invertNormalMapX: boolean;
  42316. private _invertNormalMapY;
  42317. /**
  42318. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42319. */
  42320. invertNormalMapY: boolean;
  42321. private _twoSidedLighting;
  42322. /**
  42323. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42324. */
  42325. twoSidedLighting: boolean;
  42326. /**
  42327. * Default configuration related to image processing available in the standard Material.
  42328. */
  42329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42330. /**
  42331. * Gets the image processing configuration used either in this material.
  42332. */
  42333. /**
  42334. * Sets the Default image processing configuration used either in the this material.
  42335. *
  42336. * If sets to null, the scene one is in use.
  42337. */
  42338. imageProcessingConfiguration: ImageProcessingConfiguration;
  42339. /**
  42340. * Keep track of the image processing observer to allow dispose and replace.
  42341. */
  42342. private _imageProcessingObserver;
  42343. /**
  42344. * Attaches a new image processing configuration to the Standard Material.
  42345. * @param configuration
  42346. */
  42347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42348. /**
  42349. * Gets wether the color curves effect is enabled.
  42350. */
  42351. /**
  42352. * Sets wether the color curves effect is enabled.
  42353. */
  42354. cameraColorCurvesEnabled: boolean;
  42355. /**
  42356. * Gets wether the color grading effect is enabled.
  42357. */
  42358. /**
  42359. * Gets wether the color grading effect is enabled.
  42360. */
  42361. cameraColorGradingEnabled: boolean;
  42362. /**
  42363. * Gets wether tonemapping is enabled or not.
  42364. */
  42365. /**
  42366. * Sets wether tonemapping is enabled or not
  42367. */
  42368. cameraToneMappingEnabled: boolean;
  42369. /**
  42370. * The camera exposure used on this material.
  42371. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42372. * This corresponds to a photographic exposure.
  42373. */
  42374. /**
  42375. * The camera exposure used on this material.
  42376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42377. * This corresponds to a photographic exposure.
  42378. */
  42379. cameraExposure: number;
  42380. /**
  42381. * Gets The camera contrast used on this material.
  42382. */
  42383. /**
  42384. * Sets The camera contrast used on this material.
  42385. */
  42386. cameraContrast: number;
  42387. /**
  42388. * Gets the Color Grading 2D Lookup Texture.
  42389. */
  42390. /**
  42391. * Sets the Color Grading 2D Lookup Texture.
  42392. */
  42393. cameraColorGradingTexture: Nullable<BaseTexture>;
  42394. /**
  42395. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42396. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42397. * 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;
  42398. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42399. */
  42400. /**
  42401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42403. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  42404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42405. */
  42406. cameraColorCurves: Nullable<ColorCurves>;
  42407. /**
  42408. * Custom callback helping to override the default shader used in the material.
  42409. */
  42410. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42411. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42412. protected _worldViewProjectionMatrix: Matrix;
  42413. protected _globalAmbientColor: Color3;
  42414. protected _useLogarithmicDepth: boolean;
  42415. protected _rebuildInParallel: boolean;
  42416. /**
  42417. * Instantiates a new standard material.
  42418. * This is the default material used in Babylon. It is the best trade off between quality
  42419. * and performances.
  42420. * @see http://doc.babylonjs.com/babylon101/materials
  42421. * @param name Define the name of the material in the scene
  42422. * @param scene Define the scene the material belong to
  42423. */
  42424. constructor(name: string, scene: Scene);
  42425. /**
  42426. * Gets a boolean indicating that current material needs to register RTT
  42427. */
  42428. readonly hasRenderTargetTextures: boolean;
  42429. /**
  42430. * Gets the current class name of the material e.g. "StandardMaterial"
  42431. * Mainly use in serialization.
  42432. * @returns the class name
  42433. */
  42434. getClassName(): string;
  42435. /**
  42436. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42437. * You can try switching to logarithmic depth.
  42438. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42439. */
  42440. useLogarithmicDepth: boolean;
  42441. /**
  42442. * Specifies if the material will require alpha blending
  42443. * @returns a boolean specifying if alpha blending is needed
  42444. */
  42445. needAlphaBlending(): boolean;
  42446. /**
  42447. * Specifies if this material should be rendered in alpha test mode
  42448. * @returns a boolean specifying if an alpha test is needed.
  42449. */
  42450. needAlphaTesting(): boolean;
  42451. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42452. /**
  42453. * Get the texture used for alpha test purpose.
  42454. * @returns the diffuse texture in case of the standard material.
  42455. */
  42456. getAlphaTestTexture(): Nullable<BaseTexture>;
  42457. /**
  42458. * Get if the submesh is ready to be used and all its information available.
  42459. * Child classes can use it to update shaders
  42460. * @param mesh defines the mesh to check
  42461. * @param subMesh defines which submesh to check
  42462. * @param useInstances specifies that instances should be used
  42463. * @returns a boolean indicating that the submesh is ready or not
  42464. */
  42465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42466. /**
  42467. * Builds the material UBO layouts.
  42468. * Used internally during the effect preparation.
  42469. */
  42470. buildUniformLayout(): void;
  42471. /**
  42472. * Unbinds the material from the mesh
  42473. */
  42474. unbind(): void;
  42475. /**
  42476. * Binds the submesh to this material by preparing the effect and shader to draw
  42477. * @param world defines the world transformation matrix
  42478. * @param mesh defines the mesh containing the submesh
  42479. * @param subMesh defines the submesh to bind the material to
  42480. */
  42481. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42482. /**
  42483. * Get the list of animatables in the material.
  42484. * @returns the list of animatables object used in the material
  42485. */
  42486. getAnimatables(): IAnimatable[];
  42487. /**
  42488. * Gets the active textures from the material
  42489. * @returns an array of textures
  42490. */
  42491. getActiveTextures(): BaseTexture[];
  42492. /**
  42493. * Specifies if the material uses a texture
  42494. * @param texture defines the texture to check against the material
  42495. * @returns a boolean specifying if the material uses the texture
  42496. */
  42497. hasTexture(texture: BaseTexture): boolean;
  42498. /**
  42499. * Disposes the material
  42500. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42501. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42502. */
  42503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42504. /**
  42505. * Makes a duplicate of the material, and gives it a new name
  42506. * @param name defines the new name for the duplicated material
  42507. * @returns the cloned material
  42508. */
  42509. clone(name: string): StandardMaterial;
  42510. /**
  42511. * Serializes this material in a JSON representation
  42512. * @returns the serialized material object
  42513. */
  42514. serialize(): any;
  42515. /**
  42516. * Creates a standard material from parsed material data
  42517. * @param source defines the JSON representation of the material
  42518. * @param scene defines the hosting scene
  42519. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42520. * @returns a new standard material
  42521. */
  42522. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42523. /**
  42524. * Are diffuse textures enabled in the application.
  42525. */
  42526. static DiffuseTextureEnabled: boolean;
  42527. /**
  42528. * Are ambient textures enabled in the application.
  42529. */
  42530. static AmbientTextureEnabled: boolean;
  42531. /**
  42532. * Are opacity textures enabled in the application.
  42533. */
  42534. static OpacityTextureEnabled: boolean;
  42535. /**
  42536. * Are reflection textures enabled in the application.
  42537. */
  42538. static ReflectionTextureEnabled: boolean;
  42539. /**
  42540. * Are emissive textures enabled in the application.
  42541. */
  42542. static EmissiveTextureEnabled: boolean;
  42543. /**
  42544. * Are specular textures enabled in the application.
  42545. */
  42546. static SpecularTextureEnabled: boolean;
  42547. /**
  42548. * Are bump textures enabled in the application.
  42549. */
  42550. static BumpTextureEnabled: boolean;
  42551. /**
  42552. * Are lightmap textures enabled in the application.
  42553. */
  42554. static LightmapTextureEnabled: boolean;
  42555. /**
  42556. * Are refraction textures enabled in the application.
  42557. */
  42558. static RefractionTextureEnabled: boolean;
  42559. /**
  42560. * Are color grading textures enabled in the application.
  42561. */
  42562. static ColorGradingTextureEnabled: boolean;
  42563. /**
  42564. * Are fresnels enabled in the application.
  42565. */
  42566. static FresnelEnabled: boolean;
  42567. }
  42568. }
  42569. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42570. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42572. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42573. /** @hidden */
  42574. export var imageProcessingPixelShader: {
  42575. name: string;
  42576. shader: string;
  42577. };
  42578. }
  42579. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42580. import { Nullable } from "babylonjs/types";
  42581. import { Color4 } from "babylonjs/Maths/math.color";
  42582. import { Camera } from "babylonjs/Cameras/camera";
  42583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42584. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42585. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42587. import { Engine } from "babylonjs/Engines/engine";
  42588. import "babylonjs/Shaders/imageProcessing.fragment";
  42589. import "babylonjs/Shaders/postprocess.vertex";
  42590. /**
  42591. * ImageProcessingPostProcess
  42592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42593. */
  42594. export class ImageProcessingPostProcess extends PostProcess {
  42595. /**
  42596. * Default configuration related to image processing available in the PBR Material.
  42597. */
  42598. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42599. /**
  42600. * Gets the image processing configuration used either in this material.
  42601. */
  42602. /**
  42603. * Sets the Default image processing configuration used either in the this material.
  42604. *
  42605. * If sets to null, the scene one is in use.
  42606. */
  42607. imageProcessingConfiguration: ImageProcessingConfiguration;
  42608. /**
  42609. * Keep track of the image processing observer to allow dispose and replace.
  42610. */
  42611. private _imageProcessingObserver;
  42612. /**
  42613. * Attaches a new image processing configuration to the PBR Material.
  42614. * @param configuration
  42615. */
  42616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42617. /**
  42618. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42619. */
  42620. /**
  42621. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42622. */
  42623. colorCurves: Nullable<ColorCurves>;
  42624. /**
  42625. * Gets wether the color curves effect is enabled.
  42626. */
  42627. /**
  42628. * Sets wether the color curves effect is enabled.
  42629. */
  42630. colorCurvesEnabled: boolean;
  42631. /**
  42632. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42633. */
  42634. /**
  42635. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42636. */
  42637. colorGradingTexture: Nullable<BaseTexture>;
  42638. /**
  42639. * Gets wether the color grading effect is enabled.
  42640. */
  42641. /**
  42642. * Gets wether the color grading effect is enabled.
  42643. */
  42644. colorGradingEnabled: boolean;
  42645. /**
  42646. * Gets exposure used in the effect.
  42647. */
  42648. /**
  42649. * Sets exposure used in the effect.
  42650. */
  42651. exposure: number;
  42652. /**
  42653. * Gets wether tonemapping is enabled or not.
  42654. */
  42655. /**
  42656. * Sets wether tonemapping is enabled or not
  42657. */
  42658. toneMappingEnabled: boolean;
  42659. /**
  42660. * Gets the type of tone mapping effect.
  42661. */
  42662. /**
  42663. * Sets the type of tone mapping effect.
  42664. */
  42665. toneMappingType: number;
  42666. /**
  42667. * Gets contrast used in the effect.
  42668. */
  42669. /**
  42670. * Sets contrast used in the effect.
  42671. */
  42672. contrast: number;
  42673. /**
  42674. * Gets Vignette stretch size.
  42675. */
  42676. /**
  42677. * Sets Vignette stretch size.
  42678. */
  42679. vignetteStretch: number;
  42680. /**
  42681. * Gets Vignette centre X Offset.
  42682. */
  42683. /**
  42684. * Sets Vignette centre X Offset.
  42685. */
  42686. vignetteCentreX: number;
  42687. /**
  42688. * Gets Vignette centre Y Offset.
  42689. */
  42690. /**
  42691. * Sets Vignette centre Y Offset.
  42692. */
  42693. vignetteCentreY: number;
  42694. /**
  42695. * Gets Vignette weight or intensity of the vignette effect.
  42696. */
  42697. /**
  42698. * Sets Vignette weight or intensity of the vignette effect.
  42699. */
  42700. vignetteWeight: number;
  42701. /**
  42702. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42703. * if vignetteEnabled is set to true.
  42704. */
  42705. /**
  42706. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42707. * if vignetteEnabled is set to true.
  42708. */
  42709. vignetteColor: Color4;
  42710. /**
  42711. * Gets Camera field of view used by the Vignette effect.
  42712. */
  42713. /**
  42714. * Sets Camera field of view used by the Vignette effect.
  42715. */
  42716. vignetteCameraFov: number;
  42717. /**
  42718. * Gets the vignette blend mode allowing different kind of effect.
  42719. */
  42720. /**
  42721. * Sets the vignette blend mode allowing different kind of effect.
  42722. */
  42723. vignetteBlendMode: number;
  42724. /**
  42725. * Gets wether the vignette effect is enabled.
  42726. */
  42727. /**
  42728. * Sets wether the vignette effect is enabled.
  42729. */
  42730. vignetteEnabled: boolean;
  42731. private _fromLinearSpace;
  42732. /**
  42733. * Gets wether the input of the processing is in Gamma or Linear Space.
  42734. */
  42735. /**
  42736. * Sets wether the input of the processing is in Gamma or Linear Space.
  42737. */
  42738. fromLinearSpace: boolean;
  42739. /**
  42740. * Defines cache preventing GC.
  42741. */
  42742. private _defines;
  42743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42744. /**
  42745. * "ImageProcessingPostProcess"
  42746. * @returns "ImageProcessingPostProcess"
  42747. */
  42748. getClassName(): string;
  42749. protected _updateParameters(): void;
  42750. dispose(camera?: Camera): void;
  42751. }
  42752. }
  42753. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42754. import { Scene } from "babylonjs/scene";
  42755. import { Color3 } from "babylonjs/Maths/math.color";
  42756. import { Mesh } from "babylonjs/Meshes/mesh";
  42757. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42758. import { Nullable } from "babylonjs/types";
  42759. /**
  42760. * Class containing static functions to help procedurally build meshes
  42761. */
  42762. export class GroundBuilder {
  42763. /**
  42764. * Creates a ground mesh
  42765. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42766. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42768. * @param name defines the name of the mesh
  42769. * @param options defines the options used to create the mesh
  42770. * @param scene defines the hosting scene
  42771. * @returns the ground mesh
  42772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42773. */
  42774. static CreateGround(name: string, options: {
  42775. width?: number;
  42776. height?: number;
  42777. subdivisions?: number;
  42778. subdivisionsX?: number;
  42779. subdivisionsY?: number;
  42780. updatable?: boolean;
  42781. }, scene: any): Mesh;
  42782. /**
  42783. * Creates a tiled ground mesh
  42784. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42785. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42786. * * 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
  42787. * * 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
  42788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42789. * @param name defines the name of the mesh
  42790. * @param options defines the options used to create the mesh
  42791. * @param scene defines the hosting scene
  42792. * @returns the tiled ground mesh
  42793. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42794. */
  42795. static CreateTiledGround(name: string, options: {
  42796. xmin: number;
  42797. zmin: number;
  42798. xmax: number;
  42799. zmax: number;
  42800. subdivisions?: {
  42801. w: number;
  42802. h: number;
  42803. };
  42804. precision?: {
  42805. w: number;
  42806. h: number;
  42807. };
  42808. updatable?: boolean;
  42809. }, scene?: Nullable<Scene>): Mesh;
  42810. /**
  42811. * Creates a ground mesh from a height map
  42812. * * The parameter `url` sets the URL of the height map image resource.
  42813. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42814. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42815. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42816. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42817. * * 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.
  42818. * * 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).
  42819. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42821. * @param name defines the name of the mesh
  42822. * @param url defines the url to the height map
  42823. * @param options defines the options used to create the mesh
  42824. * @param scene defines the hosting scene
  42825. * @returns the ground mesh
  42826. * @see https://doc.babylonjs.com/babylon101/height_map
  42827. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42828. */
  42829. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42830. width?: number;
  42831. height?: number;
  42832. subdivisions?: number;
  42833. minHeight?: number;
  42834. maxHeight?: number;
  42835. colorFilter?: Color3;
  42836. alphaFilter?: number;
  42837. updatable?: boolean;
  42838. onReady?: (mesh: GroundMesh) => void;
  42839. }, scene?: Nullable<Scene>): GroundMesh;
  42840. }
  42841. }
  42842. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42843. import { Vector4 } from "babylonjs/Maths/math.vector";
  42844. import { Mesh } from "babylonjs/Meshes/mesh";
  42845. /**
  42846. * Class containing static functions to help procedurally build meshes
  42847. */
  42848. export class TorusBuilder {
  42849. /**
  42850. * Creates a torus mesh
  42851. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42852. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42853. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42857. * @param name defines the name of the mesh
  42858. * @param options defines the options used to create the mesh
  42859. * @param scene defines the hosting scene
  42860. * @returns the torus mesh
  42861. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42862. */
  42863. static CreateTorus(name: string, options: {
  42864. diameter?: number;
  42865. thickness?: number;
  42866. tessellation?: number;
  42867. updatable?: boolean;
  42868. sideOrientation?: number;
  42869. frontUVs?: Vector4;
  42870. backUVs?: Vector4;
  42871. }, scene: any): Mesh;
  42872. }
  42873. }
  42874. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42875. import { Vector4 } from "babylonjs/Maths/math.vector";
  42876. import { Color4 } from "babylonjs/Maths/math.color";
  42877. import { Mesh } from "babylonjs/Meshes/mesh";
  42878. /**
  42879. * Class containing static functions to help procedurally build meshes
  42880. */
  42881. export class CylinderBuilder {
  42882. /**
  42883. * Creates a cylinder or a cone mesh
  42884. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42885. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42886. * * 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.
  42887. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42888. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42889. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42890. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42891. * * 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).
  42892. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42893. * * 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).
  42894. * * 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
  42895. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42896. * * 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
  42897. * * 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.
  42898. * * If `enclose` is false, a ring surface is one element.
  42899. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42900. * * 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
  42901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42904. * @param name defines the name of the mesh
  42905. * @param options defines the options used to create the mesh
  42906. * @param scene defines the hosting scene
  42907. * @returns the cylinder mesh
  42908. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42909. */
  42910. static CreateCylinder(name: string, options: {
  42911. height?: number;
  42912. diameterTop?: number;
  42913. diameterBottom?: number;
  42914. diameter?: number;
  42915. tessellation?: number;
  42916. subdivisions?: number;
  42917. arc?: number;
  42918. faceColors?: Color4[];
  42919. faceUV?: Vector4[];
  42920. updatable?: boolean;
  42921. hasRings?: boolean;
  42922. enclose?: boolean;
  42923. cap?: number;
  42924. sideOrientation?: number;
  42925. frontUVs?: Vector4;
  42926. backUVs?: Vector4;
  42927. }, scene: any): Mesh;
  42928. }
  42929. }
  42930. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42931. import { Observable } from "babylonjs/Misc/observable";
  42932. import { Nullable } from "babylonjs/types";
  42933. import { Camera } from "babylonjs/Cameras/camera";
  42934. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42935. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42936. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42937. import { Scene } from "babylonjs/scene";
  42938. import { Vector3 } from "babylonjs/Maths/math.vector";
  42939. import { Color3 } from "babylonjs/Maths/math.color";
  42940. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42942. import { Mesh } from "babylonjs/Meshes/mesh";
  42943. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42944. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42945. import "babylonjs/Meshes/Builders/groundBuilder";
  42946. import "babylonjs/Meshes/Builders/torusBuilder";
  42947. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42948. import "babylonjs/Gamepads/gamepadSceneComponent";
  42949. import "babylonjs/Animations/animatable";
  42950. /**
  42951. * Options to modify the vr teleportation behavior.
  42952. */
  42953. export interface VRTeleportationOptions {
  42954. /**
  42955. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42956. */
  42957. floorMeshName?: string;
  42958. /**
  42959. * A list of meshes to be used as the teleportation floor. (default: empty)
  42960. */
  42961. floorMeshes?: Mesh[];
  42962. }
  42963. /**
  42964. * Options to modify the vr experience helper's behavior.
  42965. */
  42966. export interface VRExperienceHelperOptions extends WebVROptions {
  42967. /**
  42968. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42969. */
  42970. createDeviceOrientationCamera?: boolean;
  42971. /**
  42972. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42973. */
  42974. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42975. /**
  42976. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42977. */
  42978. laserToggle?: boolean;
  42979. /**
  42980. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42981. */
  42982. floorMeshes?: Mesh[];
  42983. /**
  42984. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42985. */
  42986. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42987. }
  42988. /**
  42989. * Event containing information after VR has been entered
  42990. */
  42991. export class OnAfterEnteringVRObservableEvent {
  42992. /**
  42993. * If entering vr was successful
  42994. */
  42995. success: boolean;
  42996. }
  42997. /**
  42998. * Helps to quickly add VR support to an existing scene.
  42999. * See http://doc.babylonjs.com/how_to/webvr_helper
  43000. */
  43001. export class VRExperienceHelper {
  43002. /** Options to modify the vr experience helper's behavior. */
  43003. webVROptions: VRExperienceHelperOptions;
  43004. private _scene;
  43005. private _position;
  43006. private _btnVR;
  43007. private _btnVRDisplayed;
  43008. private _webVRsupported;
  43009. private _webVRready;
  43010. private _webVRrequesting;
  43011. private _webVRpresenting;
  43012. private _hasEnteredVR;
  43013. private _fullscreenVRpresenting;
  43014. private _inputElement;
  43015. private _webVRCamera;
  43016. private _vrDeviceOrientationCamera;
  43017. private _deviceOrientationCamera;
  43018. private _existingCamera;
  43019. private _onKeyDown;
  43020. private _onVrDisplayPresentChange;
  43021. private _onVRDisplayChanged;
  43022. private _onVRRequestPresentStart;
  43023. private _onVRRequestPresentComplete;
  43024. /**
  43025. * 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)
  43026. */
  43027. enableGazeEvenWhenNoPointerLock: boolean;
  43028. /**
  43029. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43030. */
  43031. exitVROnDoubleTap: boolean;
  43032. /**
  43033. * Observable raised right before entering VR.
  43034. */
  43035. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43036. /**
  43037. * Observable raised when entering VR has completed.
  43038. */
  43039. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43040. /**
  43041. * Observable raised when exiting VR.
  43042. */
  43043. onExitingVRObservable: Observable<VRExperienceHelper>;
  43044. /**
  43045. * Observable raised when controller mesh is loaded.
  43046. */
  43047. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43048. /** Return this.onEnteringVRObservable
  43049. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43050. */
  43051. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43052. /** Return this.onExitingVRObservable
  43053. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43054. */
  43055. readonly onExitingVR: Observable<VRExperienceHelper>;
  43056. /** Return this.onControllerMeshLoadedObservable
  43057. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43058. */
  43059. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43060. private _rayLength;
  43061. private _useCustomVRButton;
  43062. private _teleportationRequested;
  43063. private _teleportActive;
  43064. private _floorMeshName;
  43065. private _floorMeshesCollection;
  43066. private _rotationAllowed;
  43067. private _teleportBackwardsVector;
  43068. private _teleportationTarget;
  43069. private _isDefaultTeleportationTarget;
  43070. private _postProcessMove;
  43071. private _teleportationFillColor;
  43072. private _teleportationBorderColor;
  43073. private _rotationAngle;
  43074. private _haloCenter;
  43075. private _cameraGazer;
  43076. private _padSensibilityUp;
  43077. private _padSensibilityDown;
  43078. private _leftController;
  43079. private _rightController;
  43080. /**
  43081. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43082. */
  43083. onNewMeshSelected: Observable<AbstractMesh>;
  43084. /**
  43085. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43086. * This observable will provide the mesh and the controller used to select the mesh
  43087. */
  43088. onMeshSelectedWithController: Observable<{
  43089. mesh: AbstractMesh;
  43090. controller: WebVRController;
  43091. }>;
  43092. /**
  43093. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43094. */
  43095. onNewMeshPicked: Observable<PickingInfo>;
  43096. private _circleEase;
  43097. /**
  43098. * Observable raised before camera teleportation
  43099. */
  43100. onBeforeCameraTeleport: Observable<Vector3>;
  43101. /**
  43102. * Observable raised after camera teleportation
  43103. */
  43104. onAfterCameraTeleport: Observable<Vector3>;
  43105. /**
  43106. * Observable raised when current selected mesh gets unselected
  43107. */
  43108. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43109. private _raySelectionPredicate;
  43110. /**
  43111. * To be optionaly changed by user to define custom ray selection
  43112. */
  43113. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43114. /**
  43115. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43116. */
  43117. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43118. /**
  43119. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43120. */
  43121. teleportationEnabled: boolean;
  43122. private _defaultHeight;
  43123. private _teleportationInitialized;
  43124. private _interactionsEnabled;
  43125. private _interactionsRequested;
  43126. private _displayGaze;
  43127. private _displayLaserPointer;
  43128. /**
  43129. * The mesh used to display where the user is going to teleport.
  43130. */
  43131. /**
  43132. * Sets the mesh to be used to display where the user is going to teleport.
  43133. */
  43134. teleportationTarget: Mesh;
  43135. /**
  43136. * 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
  43137. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43138. * See http://doc.babylonjs.com/resources/baking_transformations
  43139. */
  43140. gazeTrackerMesh: Mesh;
  43141. /**
  43142. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43143. */
  43144. updateGazeTrackerScale: boolean;
  43145. /**
  43146. * If the gaze trackers color should be updated when selecting meshes
  43147. */
  43148. updateGazeTrackerColor: boolean;
  43149. /**
  43150. * If the controller laser color should be updated when selecting meshes
  43151. */
  43152. updateControllerLaserColor: boolean;
  43153. /**
  43154. * The gaze tracking mesh corresponding to the left controller
  43155. */
  43156. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43157. /**
  43158. * The gaze tracking mesh corresponding to the right controller
  43159. */
  43160. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43161. /**
  43162. * If the ray of the gaze should be displayed.
  43163. */
  43164. /**
  43165. * Sets if the ray of the gaze should be displayed.
  43166. */
  43167. displayGaze: boolean;
  43168. /**
  43169. * If the ray of the LaserPointer should be displayed.
  43170. */
  43171. /**
  43172. * Sets if the ray of the LaserPointer should be displayed.
  43173. */
  43174. displayLaserPointer: boolean;
  43175. /**
  43176. * The deviceOrientationCamera used as the camera when not in VR.
  43177. */
  43178. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43179. /**
  43180. * Based on the current WebVR support, returns the current VR camera used.
  43181. */
  43182. readonly currentVRCamera: Nullable<Camera>;
  43183. /**
  43184. * The webVRCamera which is used when in VR.
  43185. */
  43186. readonly webVRCamera: WebVRFreeCamera;
  43187. /**
  43188. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43189. */
  43190. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43191. /**
  43192. * The html button that is used to trigger entering into VR.
  43193. */
  43194. readonly vrButton: Nullable<HTMLButtonElement>;
  43195. private readonly _teleportationRequestInitiated;
  43196. /**
  43197. * Defines wether or not Pointer lock should be requested when switching to
  43198. * full screen.
  43199. */
  43200. requestPointerLockOnFullScreen: boolean;
  43201. /**
  43202. * Instantiates a VRExperienceHelper.
  43203. * Helps to quickly add VR support to an existing scene.
  43204. * @param scene The scene the VRExperienceHelper belongs to.
  43205. * @param webVROptions Options to modify the vr experience helper's behavior.
  43206. */
  43207. constructor(scene: Scene,
  43208. /** Options to modify the vr experience helper's behavior. */
  43209. webVROptions?: VRExperienceHelperOptions);
  43210. private _onDefaultMeshLoaded;
  43211. private _onResize;
  43212. private _onFullscreenChange;
  43213. /**
  43214. * Gets a value indicating if we are currently in VR mode.
  43215. */
  43216. readonly isInVRMode: boolean;
  43217. private onVrDisplayPresentChange;
  43218. private onVRDisplayChanged;
  43219. private moveButtonToBottomRight;
  43220. private displayVRButton;
  43221. private updateButtonVisibility;
  43222. private _cachedAngularSensibility;
  43223. /**
  43224. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43225. * Otherwise, will use the fullscreen API.
  43226. */
  43227. enterVR(): void;
  43228. /**
  43229. * Attempt to exit VR, or fullscreen.
  43230. */
  43231. exitVR(): void;
  43232. /**
  43233. * The position of the vr experience helper.
  43234. */
  43235. /**
  43236. * Sets the position of the vr experience helper.
  43237. */
  43238. position: Vector3;
  43239. /**
  43240. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43241. */
  43242. enableInteractions(): void;
  43243. private readonly _noControllerIsActive;
  43244. private beforeRender;
  43245. private _isTeleportationFloor;
  43246. /**
  43247. * Adds a floor mesh to be used for teleportation.
  43248. * @param floorMesh the mesh to be used for teleportation.
  43249. */
  43250. addFloorMesh(floorMesh: Mesh): void;
  43251. /**
  43252. * Removes a floor mesh from being used for teleportation.
  43253. * @param floorMesh the mesh to be removed.
  43254. */
  43255. removeFloorMesh(floorMesh: Mesh): void;
  43256. /**
  43257. * Enables interactions and teleportation using the VR controllers and gaze.
  43258. * @param vrTeleportationOptions options to modify teleportation behavior.
  43259. */
  43260. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43261. private _onNewGamepadConnected;
  43262. private _tryEnableInteractionOnController;
  43263. private _onNewGamepadDisconnected;
  43264. private _enableInteractionOnController;
  43265. private _checkTeleportWithRay;
  43266. private _checkRotate;
  43267. private _checkTeleportBackwards;
  43268. private _enableTeleportationOnController;
  43269. private _createTeleportationCircles;
  43270. private _displayTeleportationTarget;
  43271. private _hideTeleportationTarget;
  43272. private _rotateCamera;
  43273. private _moveTeleportationSelectorTo;
  43274. private _workingVector;
  43275. private _workingQuaternion;
  43276. private _workingMatrix;
  43277. /**
  43278. * Teleports the users feet to the desired location
  43279. * @param location The location where the user's feet should be placed
  43280. */
  43281. teleportCamera(location: Vector3): void;
  43282. private _convertNormalToDirectionOfRay;
  43283. private _castRayAndSelectObject;
  43284. private _notifySelectedMeshUnselected;
  43285. /**
  43286. * Sets the color of the laser ray from the vr controllers.
  43287. * @param color new color for the ray.
  43288. */
  43289. changeLaserColor(color: Color3): void;
  43290. /**
  43291. * Sets the color of the ray from the vr headsets gaze.
  43292. * @param color new color for the ray.
  43293. */
  43294. changeGazeColor(color: Color3): void;
  43295. /**
  43296. * Exits VR and disposes of the vr experience helper
  43297. */
  43298. dispose(): void;
  43299. /**
  43300. * Gets the name of the VRExperienceHelper class
  43301. * @returns "VRExperienceHelper"
  43302. */
  43303. getClassName(): string;
  43304. }
  43305. }
  43306. declare module "babylonjs/Cameras/VR/index" {
  43307. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43308. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43309. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43310. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43311. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43312. export * from "babylonjs/Cameras/VR/webVRCamera";
  43313. }
  43314. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43315. import { Nullable } from "babylonjs/types";
  43316. import { IDisposable } from "babylonjs/scene";
  43317. /**
  43318. * States of the webXR experience
  43319. */
  43320. export enum WebXRState {
  43321. /**
  43322. * Transitioning to being in XR mode
  43323. */
  43324. ENTERING_XR = 0,
  43325. /**
  43326. * Transitioning to non XR mode
  43327. */
  43328. EXITING_XR = 1,
  43329. /**
  43330. * In XR mode and presenting
  43331. */
  43332. IN_XR = 2,
  43333. /**
  43334. * Not entered XR mode
  43335. */
  43336. NOT_IN_XR = 3
  43337. }
  43338. /**
  43339. * Abstraction of the XR render target
  43340. */
  43341. export interface WebXRRenderTarget extends IDisposable {
  43342. /**
  43343. * xrpresent context of the canvas which can be used to display/mirror xr content
  43344. */
  43345. canvasContext: WebGLRenderingContext;
  43346. /**
  43347. * xr layer for the canvas
  43348. */
  43349. xrLayer: Nullable<XRWebGLLayer>;
  43350. /**
  43351. * Initializes the xr layer for the session
  43352. * @param xrSession xr session
  43353. * @returns a promise that will resolve once the XR Layer has been created
  43354. */
  43355. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43356. }
  43357. }
  43358. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43359. import { Nullable } from "babylonjs/types";
  43360. import { Observable } from "babylonjs/Misc/observable";
  43361. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43362. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43363. /**
  43364. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43365. */
  43366. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43367. private _engine;
  43368. private _canvas;
  43369. /**
  43370. * xrpresent context of the canvas which can be used to display/mirror xr content
  43371. */
  43372. canvasContext: WebGLRenderingContext;
  43373. /**
  43374. * xr layer for the canvas
  43375. */
  43376. xrLayer: Nullable<XRWebGLLayer>;
  43377. /**
  43378. * Initializes the xr layer for the session
  43379. * @param xrSession xr session
  43380. * @returns a promise that will resolve once the XR Layer has been created
  43381. */
  43382. initializeXRLayerAsync(xrSession: any): any;
  43383. /**
  43384. * Initializes the canvas to be added/removed upon entering/exiting xr
  43385. * @param engine the Babylon engine
  43386. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43387. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43388. */
  43389. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43390. /**
  43391. * Disposes of the object
  43392. */
  43393. dispose(): void;
  43394. private _setManagedOutputCanvas;
  43395. private _addCanvas;
  43396. private _removeCanvas;
  43397. }
  43398. }
  43399. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43400. import { Observable } from "babylonjs/Misc/observable";
  43401. import { Nullable } from "babylonjs/types";
  43402. import { IDisposable, Scene } from "babylonjs/scene";
  43403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43404. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43405. /**
  43406. * Manages an XRSession to work with Babylon's engine
  43407. * @see https://doc.babylonjs.com/how_to/webxr
  43408. */
  43409. export class WebXRSessionManager implements IDisposable {
  43410. private scene;
  43411. /**
  43412. * Fires every time a new xrFrame arrives which can be used to update the camera
  43413. */
  43414. onXRFrameObservable: Observable<any>;
  43415. /**
  43416. * Fires when the xr session is ended either by the device or manually done
  43417. */
  43418. onXRSessionEnded: Observable<any>;
  43419. /**
  43420. * Underlying xr session
  43421. */
  43422. session: XRSession;
  43423. /**
  43424. * Type of reference space used when creating the session
  43425. */
  43426. referenceSpace: XRReferenceSpace;
  43427. /**
  43428. * Current XR frame
  43429. */
  43430. currentFrame: Nullable<XRFrame>;
  43431. private _xrNavigator;
  43432. private baseLayer;
  43433. private _rttProvider;
  43434. private _sessionEnded;
  43435. /**
  43436. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43437. * @param scene The scene which the session should be created for
  43438. */
  43439. constructor(scene: Scene);
  43440. /**
  43441. * Initializes the manager
  43442. * After initialization enterXR can be called to start an XR session
  43443. * @returns Promise which resolves after it is initialized
  43444. */
  43445. initializeAsync(): Promise<void>;
  43446. /**
  43447. * Initializes an xr session
  43448. * @param xrSessionMode mode to initialize
  43449. * @param optionalFeatures defines optional values to pass to the session builder
  43450. * @returns a promise which will resolve once the session has been initialized
  43451. */
  43452. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43453. /**
  43454. * Sets the reference space on the xr session
  43455. * @param referenceSpace space to set
  43456. * @returns a promise that will resolve once the reference space has been set
  43457. */
  43458. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43459. /**
  43460. * Updates the render state of the session
  43461. * @param state state to set
  43462. * @returns a promise that resolves once the render state has been updated
  43463. */
  43464. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43465. /**
  43466. * Starts rendering to the xr layer
  43467. * @returns a promise that will resolve once rendering has started
  43468. */
  43469. startRenderingToXRAsync(): Promise<void>;
  43470. /**
  43471. * Gets the correct render target texture to be rendered this frame for this eye
  43472. * @param eye the eye for which to get the render target
  43473. * @returns the render target for the specified eye
  43474. */
  43475. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43476. /**
  43477. * Stops the xrSession and restores the renderloop
  43478. * @returns Promise which resolves after it exits XR
  43479. */
  43480. exitXRAsync(): Promise<void>;
  43481. /**
  43482. * Checks if a session would be supported for the creation options specified
  43483. * @param sessionMode session mode to check if supported eg. immersive-vr
  43484. * @returns true if supported
  43485. */
  43486. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43487. /**
  43488. * Creates a WebXRRenderTarget object for the XR session
  43489. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43490. * @returns a WebXR render target to which the session can render
  43491. */
  43492. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43493. /**
  43494. * @hidden
  43495. * Converts the render layer of xrSession to a render target
  43496. * @param session session to create render target for
  43497. * @param scene scene the new render target should be created for
  43498. */
  43499. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43500. /**
  43501. * Disposes of the session manager
  43502. */
  43503. dispose(): void;
  43504. }
  43505. }
  43506. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43507. import { Scene } from "babylonjs/scene";
  43508. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43509. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43510. /**
  43511. * WebXR Camera which holds the views for the xrSession
  43512. * @see https://doc.babylonjs.com/how_to/webxr
  43513. */
  43514. export class WebXRCamera extends FreeCamera {
  43515. private static _TmpMatrix;
  43516. /**
  43517. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43518. * @param name the name of the camera
  43519. * @param scene the scene to add the camera to
  43520. */
  43521. constructor(name: string, scene: Scene);
  43522. private _updateNumberOfRigCameras;
  43523. /** @hidden */
  43524. _updateForDualEyeDebugging(): void;
  43525. /**
  43526. * Updates the cameras position from the current pose information of the XR session
  43527. * @param xrSessionManager the session containing pose information
  43528. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43529. */
  43530. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43531. }
  43532. }
  43533. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43534. import { Observable } from "babylonjs/Misc/observable";
  43535. import { IDisposable, Scene } from "babylonjs/scene";
  43536. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43538. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43539. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43540. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43541. /**
  43542. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43543. * @see https://doc.babylonjs.com/how_to/webxr
  43544. */
  43545. export class WebXRExperienceHelper implements IDisposable {
  43546. private scene;
  43547. /**
  43548. * 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
  43549. */
  43550. container: AbstractMesh;
  43551. /**
  43552. * Camera used to render xr content
  43553. */
  43554. camera: WebXRCamera;
  43555. /**
  43556. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43557. */
  43558. state: WebXRState;
  43559. private _setState;
  43560. private static _TmpVector;
  43561. /**
  43562. * Fires when the state of the experience helper has changed
  43563. */
  43564. onStateChangedObservable: Observable<WebXRState>;
  43565. /** Session manager used to keep track of xr session */
  43566. sessionManager: WebXRSessionManager;
  43567. private _nonVRCamera;
  43568. private _originalSceneAutoClear;
  43569. private _supported;
  43570. /**
  43571. * Creates the experience helper
  43572. * @param scene the scene to attach the experience helper to
  43573. * @returns a promise for the experience helper
  43574. */
  43575. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43576. /**
  43577. * Creates a WebXRExperienceHelper
  43578. * @param scene The scene the helper should be created in
  43579. */
  43580. private constructor();
  43581. /**
  43582. * Exits XR mode and returns the scene to its original state
  43583. * @returns promise that resolves after xr mode has exited
  43584. */
  43585. exitXRAsync(): Promise<void>;
  43586. /**
  43587. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43588. * @param sessionMode options for the XR session
  43589. * @param referenceSpaceType frame of reference of the XR session
  43590. * @param renderTarget the output canvas that will be used to enter XR mode
  43591. * @returns promise that resolves after xr mode has entered
  43592. */
  43593. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43594. /**
  43595. * Updates the global position of the camera by moving the camera's container
  43596. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43597. * @param position The desired global position of the camera
  43598. */
  43599. setPositionOfCameraUsingContainer(position: Vector3): void;
  43600. /**
  43601. * Rotates the xr camera by rotating the camera's container around the camera's position
  43602. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43603. * @param rotation the desired quaternion rotation to apply to the camera
  43604. */
  43605. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43606. /**
  43607. * Disposes of the experience helper
  43608. */
  43609. dispose(): void;
  43610. }
  43611. }
  43612. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43613. import { Nullable } from "babylonjs/types";
  43614. import { Observable } from "babylonjs/Misc/observable";
  43615. import { IDisposable, Scene } from "babylonjs/scene";
  43616. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43617. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43618. /**
  43619. * Button which can be used to enter a different mode of XR
  43620. */
  43621. export class WebXREnterExitUIButton {
  43622. /** button element */
  43623. element: HTMLElement;
  43624. /** XR initialization options for the button */
  43625. sessionMode: XRSessionMode;
  43626. /** Reference space type */
  43627. referenceSpaceType: XRReferenceSpaceType;
  43628. /**
  43629. * Creates a WebXREnterExitUIButton
  43630. * @param element button element
  43631. * @param sessionMode XR initialization session mode
  43632. * @param referenceSpaceType the type of reference space to be used
  43633. */
  43634. constructor(
  43635. /** button element */
  43636. element: HTMLElement,
  43637. /** XR initialization options for the button */
  43638. sessionMode: XRSessionMode,
  43639. /** Reference space type */
  43640. referenceSpaceType: XRReferenceSpaceType);
  43641. /**
  43642. * Overwritable function which can be used to update the button's visuals when the state changes
  43643. * @param activeButton the current active button in the UI
  43644. */
  43645. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43646. }
  43647. /**
  43648. * Options to create the webXR UI
  43649. */
  43650. export class WebXREnterExitUIOptions {
  43651. /**
  43652. * Context to enter xr with
  43653. */
  43654. renderTarget?: Nullable<WebXRRenderTarget>;
  43655. /**
  43656. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43657. */
  43658. customButtons?: Array<WebXREnterExitUIButton>;
  43659. }
  43660. /**
  43661. * UI to allow the user to enter/exit XR mode
  43662. */
  43663. export class WebXREnterExitUI implements IDisposable {
  43664. private scene;
  43665. private _overlay;
  43666. private _buttons;
  43667. private _activeButton;
  43668. /**
  43669. * Fired every time the active button is changed.
  43670. *
  43671. * When xr is entered via a button that launches xr that button will be the callback parameter
  43672. *
  43673. * When exiting xr the callback parameter will be null)
  43674. */
  43675. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43676. /**
  43677. * Creates UI to allow the user to enter/exit XR mode
  43678. * @param scene the scene to add the ui to
  43679. * @param helper the xr experience helper to enter/exit xr with
  43680. * @param options options to configure the UI
  43681. * @returns the created ui
  43682. */
  43683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43684. private constructor();
  43685. private _updateButtons;
  43686. /**
  43687. * Disposes of the object
  43688. */
  43689. dispose(): void;
  43690. }
  43691. }
  43692. declare module "babylonjs/Cameras/XR/webXRController" {
  43693. import { Nullable } from "babylonjs/types";
  43694. import { Observable } from "babylonjs/Misc/observable";
  43695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43696. import { Ray } from "babylonjs/Culling/ray";
  43697. import { Scene } from "babylonjs/scene";
  43698. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43699. /**
  43700. * Represents an XR input
  43701. */
  43702. export class WebXRController {
  43703. private scene;
  43704. /** The underlying input source for the controller */
  43705. inputSource: XRInputSource;
  43706. private parentContainer;
  43707. /**
  43708. * 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
  43709. */
  43710. grip?: AbstractMesh;
  43711. /**
  43712. * Pointer which can be used to select objects or attach a visible laser to
  43713. */
  43714. pointer: AbstractMesh;
  43715. private _gamepadMode;
  43716. /**
  43717. * If available, this is the gamepad object related to this controller.
  43718. * Using this object it is possible to get click events and trackpad changes of the
  43719. * webxr controller that is currently being used.
  43720. */
  43721. gamepadController?: WebVRController;
  43722. /**
  43723. * Event that fires when the controller is removed/disposed
  43724. */
  43725. onDisposeObservable: Observable<{}>;
  43726. private _tmpMatrix;
  43727. private _tmpQuaternion;
  43728. private _tmpVector;
  43729. /**
  43730. * Creates the controller
  43731. * @see https://doc.babylonjs.com/how_to/webxr
  43732. * @param scene the scene which the controller should be associated to
  43733. * @param inputSource the underlying input source for the controller
  43734. * @param parentContainer parent that the controller meshes should be children of
  43735. */
  43736. constructor(scene: Scene,
  43737. /** The underlying input source for the controller */
  43738. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43739. /**
  43740. * Updates the controller pose based on the given XRFrame
  43741. * @param xrFrame xr frame to update the pose with
  43742. * @param referenceSpace reference space to use
  43743. */
  43744. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43745. /**
  43746. * Gets a world space ray coming from the controller
  43747. * @param result the resulting ray
  43748. */
  43749. getWorldPointerRayToRef(result: Ray): void;
  43750. /**
  43751. * Get the scene associated with this controller
  43752. * @returns the scene object
  43753. */
  43754. getScene(): Scene;
  43755. /**
  43756. * Disposes of the object
  43757. */
  43758. dispose(): void;
  43759. }
  43760. }
  43761. declare module "babylonjs/Cameras/XR/webXRInput" {
  43762. import { Observable } from "babylonjs/Misc/observable";
  43763. import { IDisposable } from "babylonjs/scene";
  43764. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43765. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43766. /**
  43767. * XR input used to track XR inputs such as controllers/rays
  43768. */
  43769. export class WebXRInput implements IDisposable {
  43770. /**
  43771. * Base experience the input listens to
  43772. */
  43773. baseExperience: WebXRExperienceHelper;
  43774. /**
  43775. * XR controllers being tracked
  43776. */
  43777. controllers: Array<WebXRController>;
  43778. private _frameObserver;
  43779. private _stateObserver;
  43780. /**
  43781. * Event when a controller has been connected/added
  43782. */
  43783. onControllerAddedObservable: Observable<WebXRController>;
  43784. /**
  43785. * Event when a controller has been removed/disconnected
  43786. */
  43787. onControllerRemovedObservable: Observable<WebXRController>;
  43788. /**
  43789. * Initializes the WebXRInput
  43790. * @param baseExperience experience helper which the input should be created for
  43791. */
  43792. constructor(
  43793. /**
  43794. * Base experience the input listens to
  43795. */
  43796. baseExperience: WebXRExperienceHelper);
  43797. private _onInputSourcesChange;
  43798. private _addAndRemoveControllers;
  43799. /**
  43800. * Disposes of the object
  43801. */
  43802. dispose(): void;
  43803. }
  43804. }
  43805. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43807. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43808. /**
  43809. * Enables teleportation
  43810. */
  43811. export class WebXRControllerTeleportation {
  43812. private _teleportationFillColor;
  43813. private _teleportationBorderColor;
  43814. private _tmpRay;
  43815. private _tmpVector;
  43816. /**
  43817. * Creates a WebXRControllerTeleportation
  43818. * @param input input manager to add teleportation to
  43819. * @param floorMeshes floormeshes which can be teleported to
  43820. */
  43821. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43822. }
  43823. }
  43824. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43825. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43826. /**
  43827. * Handles pointer input automatically for the pointer of XR controllers
  43828. */
  43829. export class WebXRControllerPointerSelection {
  43830. private static _idCounter;
  43831. private _tmpRay;
  43832. /**
  43833. * Creates a WebXRControllerPointerSelection
  43834. * @param input input manager to setup pointer selection
  43835. */
  43836. constructor(input: WebXRInput);
  43837. private _convertNormalToDirectionOfRay;
  43838. private _updatePointerDistance;
  43839. }
  43840. }
  43841. declare module "babylonjs/Loading/sceneLoader" {
  43842. import { Observable } from "babylonjs/Misc/observable";
  43843. import { Nullable } from "babylonjs/types";
  43844. import { Scene } from "babylonjs/scene";
  43845. import { Engine } from "babylonjs/Engines/engine";
  43846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43847. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43848. import { AssetContainer } from "babylonjs/assetContainer";
  43849. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43850. import { Skeleton } from "babylonjs/Bones/skeleton";
  43851. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43852. import { WebRequest } from "babylonjs/Misc/webRequest";
  43853. /**
  43854. * Class used to represent data loading progression
  43855. */
  43856. export class SceneLoaderProgressEvent {
  43857. /** defines if data length to load can be evaluated */
  43858. readonly lengthComputable: boolean;
  43859. /** defines the loaded data length */
  43860. readonly loaded: number;
  43861. /** defines the data length to load */
  43862. readonly total: number;
  43863. /**
  43864. * Create a new progress event
  43865. * @param lengthComputable defines if data length to load can be evaluated
  43866. * @param loaded defines the loaded data length
  43867. * @param total defines the data length to load
  43868. */
  43869. constructor(
  43870. /** defines if data length to load can be evaluated */
  43871. lengthComputable: boolean,
  43872. /** defines the loaded data length */
  43873. loaded: number,
  43874. /** defines the data length to load */
  43875. total: number);
  43876. /**
  43877. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43878. * @param event defines the source event
  43879. * @returns a new SceneLoaderProgressEvent
  43880. */
  43881. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43882. }
  43883. /**
  43884. * Interface used by SceneLoader plugins to define supported file extensions
  43885. */
  43886. export interface ISceneLoaderPluginExtensions {
  43887. /**
  43888. * Defines the list of supported extensions
  43889. */
  43890. [extension: string]: {
  43891. isBinary: boolean;
  43892. };
  43893. }
  43894. /**
  43895. * Interface used by SceneLoader plugin factory
  43896. */
  43897. export interface ISceneLoaderPluginFactory {
  43898. /**
  43899. * Defines the name of the factory
  43900. */
  43901. name: string;
  43902. /**
  43903. * Function called to create a new plugin
  43904. * @return the new plugin
  43905. */
  43906. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43907. /**
  43908. * The callback that returns true if the data can be directly loaded.
  43909. * @param data string containing the file data
  43910. * @returns if the data can be loaded directly
  43911. */
  43912. canDirectLoad?(data: string): boolean;
  43913. }
  43914. /**
  43915. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43916. */
  43917. export interface ISceneLoaderPluginBase {
  43918. /**
  43919. * The friendly name of this plugin.
  43920. */
  43921. name: string;
  43922. /**
  43923. * The file extensions supported by this plugin.
  43924. */
  43925. extensions: string | ISceneLoaderPluginExtensions;
  43926. /**
  43927. * The callback called when loading from a url.
  43928. * @param scene scene loading this url
  43929. * @param url url to load
  43930. * @param onSuccess callback called when the file successfully loads
  43931. * @param onProgress callback called while file is loading (if the server supports this mode)
  43932. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43933. * @param onError callback called when the file fails to load
  43934. * @returns a file request object
  43935. */
  43936. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43937. /**
  43938. * The callback called when loading from a file object.
  43939. * @param scene scene loading this file
  43940. * @param file defines the file to load
  43941. * @param onSuccess defines the callback to call when data is loaded
  43942. * @param onProgress defines the callback to call during loading process
  43943. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43944. * @param onError defines the callback to call when an error occurs
  43945. * @returns a file request object
  43946. */
  43947. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43948. /**
  43949. * The callback that returns true if the data can be directly loaded.
  43950. * @param data string containing the file data
  43951. * @returns if the data can be loaded directly
  43952. */
  43953. canDirectLoad?(data: string): boolean;
  43954. /**
  43955. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43956. * @param scene scene loading this data
  43957. * @param data string containing the data
  43958. * @returns data to pass to the plugin
  43959. */
  43960. directLoad?(scene: Scene, data: string): any;
  43961. /**
  43962. * The callback that allows custom handling of the root url based on the response url.
  43963. * @param rootUrl the original root url
  43964. * @param responseURL the response url if available
  43965. * @returns the new root url
  43966. */
  43967. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43968. }
  43969. /**
  43970. * Interface used to define a SceneLoader plugin
  43971. */
  43972. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43973. /**
  43974. * Import meshes into a scene.
  43975. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43976. * @param scene The scene to import into
  43977. * @param data The data to import
  43978. * @param rootUrl The root url for scene and resources
  43979. * @param meshes The meshes array to import into
  43980. * @param particleSystems The particle systems array to import into
  43981. * @param skeletons The skeletons array to import into
  43982. * @param onError The callback when import fails
  43983. * @returns True if successful or false otherwise
  43984. */
  43985. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43986. /**
  43987. * Load into a scene.
  43988. * @param scene The scene to load into
  43989. * @param data The data to import
  43990. * @param rootUrl The root url for scene and resources
  43991. * @param onError The callback when import fails
  43992. * @returns True if successful or false otherwise
  43993. */
  43994. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43995. /**
  43996. * Load into an asset container.
  43997. * @param scene The scene to load into
  43998. * @param data The data to import
  43999. * @param rootUrl The root url for scene and resources
  44000. * @param onError The callback when import fails
  44001. * @returns The loaded asset container
  44002. */
  44003. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44004. }
  44005. /**
  44006. * Interface used to define an async SceneLoader plugin
  44007. */
  44008. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44009. /**
  44010. * Import meshes into a scene.
  44011. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44012. * @param scene The scene to import into
  44013. * @param data The data to import
  44014. * @param rootUrl The root url for scene and resources
  44015. * @param onProgress The callback when the load progresses
  44016. * @param fileName Defines the name of the file to load
  44017. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44018. */
  44019. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44020. meshes: AbstractMesh[];
  44021. particleSystems: IParticleSystem[];
  44022. skeletons: Skeleton[];
  44023. animationGroups: AnimationGroup[];
  44024. }>;
  44025. /**
  44026. * Load into a scene.
  44027. * @param scene The scene to load into
  44028. * @param data The data to import
  44029. * @param rootUrl The root url for scene and resources
  44030. * @param onProgress The callback when the load progresses
  44031. * @param fileName Defines the name of the file to load
  44032. * @returns Nothing
  44033. */
  44034. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44035. /**
  44036. * Load into an asset container.
  44037. * @param scene The scene to load into
  44038. * @param data The data to import
  44039. * @param rootUrl The root url for scene and resources
  44040. * @param onProgress The callback when the load progresses
  44041. * @param fileName Defines the name of the file to load
  44042. * @returns The loaded asset container
  44043. */
  44044. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44045. }
  44046. /**
  44047. * Class used to load scene from various file formats using registered plugins
  44048. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44049. */
  44050. export class SceneLoader {
  44051. /**
  44052. * No logging while loading
  44053. */
  44054. static readonly NO_LOGGING: number;
  44055. /**
  44056. * Minimal logging while loading
  44057. */
  44058. static readonly MINIMAL_LOGGING: number;
  44059. /**
  44060. * Summary logging while loading
  44061. */
  44062. static readonly SUMMARY_LOGGING: number;
  44063. /**
  44064. * Detailled logging while loading
  44065. */
  44066. static readonly DETAILED_LOGGING: number;
  44067. /**
  44068. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44069. */
  44070. static ForceFullSceneLoadingForIncremental: boolean;
  44071. /**
  44072. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44073. */
  44074. static ShowLoadingScreen: boolean;
  44075. /**
  44076. * Defines the current logging level (while loading the scene)
  44077. * @ignorenaming
  44078. */
  44079. static loggingLevel: number;
  44080. /**
  44081. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44082. */
  44083. static CleanBoneMatrixWeights: boolean;
  44084. /**
  44085. * Event raised when a plugin is used to load a scene
  44086. */
  44087. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44088. private static _registeredPlugins;
  44089. private static _getDefaultPlugin;
  44090. private static _getPluginForExtension;
  44091. private static _getPluginForDirectLoad;
  44092. private static _getPluginForFilename;
  44093. private static _getDirectLoad;
  44094. private static _loadData;
  44095. private static _getFileInfo;
  44096. /**
  44097. * Gets a plugin that can load the given extension
  44098. * @param extension defines the extension to load
  44099. * @returns a plugin or null if none works
  44100. */
  44101. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44102. /**
  44103. * Gets a boolean indicating that the given extension can be loaded
  44104. * @param extension defines the extension to load
  44105. * @returns true if the extension is supported
  44106. */
  44107. static IsPluginForExtensionAvailable(extension: string): boolean;
  44108. /**
  44109. * Adds a new plugin to the list of registered plugins
  44110. * @param plugin defines the plugin to add
  44111. */
  44112. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44113. /**
  44114. * Import meshes into a scene
  44115. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44116. * @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)
  44117. * @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)
  44118. * @param scene the instance of BABYLON.Scene to append to
  44119. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44120. * @param onProgress a callback with a progress event for each file being loaded
  44121. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44122. * @param pluginExtension the extension used to determine the plugin
  44123. * @returns The loaded plugin
  44124. */
  44125. 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>;
  44126. /**
  44127. * Import meshes into a scene
  44128. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44129. * @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)
  44130. * @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)
  44131. * @param scene the instance of BABYLON.Scene to append to
  44132. * @param onProgress a callback with a progress event for each file being loaded
  44133. * @param pluginExtension the extension used to determine the plugin
  44134. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44135. */
  44136. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44137. meshes: AbstractMesh[];
  44138. particleSystems: IParticleSystem[];
  44139. skeletons: Skeleton[];
  44140. animationGroups: AnimationGroup[];
  44141. }>;
  44142. /**
  44143. * Load a scene
  44144. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44145. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44146. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44147. * @param onSuccess a callback with the scene when import succeeds
  44148. * @param onProgress a callback with a progress event for each file being loaded
  44149. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44150. * @param pluginExtension the extension used to determine the plugin
  44151. * @returns The loaded plugin
  44152. */
  44153. static 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>;
  44154. /**
  44155. * Load a scene
  44156. * @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)
  44157. * @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)
  44158. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44159. * @param onProgress a callback with a progress event for each file being loaded
  44160. * @param pluginExtension the extension used to determine the plugin
  44161. * @returns The loaded scene
  44162. */
  44163. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44164. /**
  44165. * Append a scene
  44166. * @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)
  44167. * @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)
  44168. * @param scene is the instance of BABYLON.Scene to append to
  44169. * @param onSuccess a callback with the scene when import succeeds
  44170. * @param onProgress a callback with a progress event for each file being loaded
  44171. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44172. * @param pluginExtension the extension used to determine the plugin
  44173. * @returns The loaded plugin
  44174. */
  44175. 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>;
  44176. /**
  44177. * Append a scene
  44178. * @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)
  44179. * @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)
  44180. * @param scene is the instance of BABYLON.Scene to append to
  44181. * @param onProgress a callback with a progress event for each file being loaded
  44182. * @param pluginExtension the extension used to determine the plugin
  44183. * @returns The given scene
  44184. */
  44185. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44186. /**
  44187. * Load a scene into an asset container
  44188. * @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)
  44189. * @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)
  44190. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44191. * @param onSuccess a callback with the scene when import succeeds
  44192. * @param onProgress a callback with a progress event for each file being loaded
  44193. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44194. * @param pluginExtension the extension used to determine the plugin
  44195. * @returns The loaded plugin
  44196. */
  44197. 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>;
  44198. /**
  44199. * Load a scene into an asset container
  44200. * @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)
  44201. * @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)
  44202. * @param scene is the instance of Scene to append to
  44203. * @param onProgress a callback with a progress event for each file being loaded
  44204. * @param pluginExtension the extension used to determine the plugin
  44205. * @returns The loaded asset container
  44206. */
  44207. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44208. }
  44209. }
  44210. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44211. import { Scene } from "babylonjs/scene";
  44212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44213. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44214. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44215. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44216. /**
  44217. * Generic Controller
  44218. */
  44219. export class GenericController extends WebVRController {
  44220. /**
  44221. * Base Url for the controller model.
  44222. */
  44223. static readonly MODEL_BASE_URL: string;
  44224. /**
  44225. * File name for the controller model.
  44226. */
  44227. static readonly MODEL_FILENAME: string;
  44228. /**
  44229. * Creates a new GenericController from a gamepad
  44230. * @param vrGamepad the gamepad that the controller should be created from
  44231. */
  44232. constructor(vrGamepad: any);
  44233. /**
  44234. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44235. * @param scene scene in which to add meshes
  44236. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44237. */
  44238. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44239. /**
  44240. * Called once for each button that changed state since the last frame
  44241. * @param buttonIdx Which button index changed
  44242. * @param state New state of the button
  44243. * @param changes Which properties on the state changed since last frame
  44244. */
  44245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44246. }
  44247. }
  44248. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44249. import { Observable } from "babylonjs/Misc/observable";
  44250. import { Scene } from "babylonjs/scene";
  44251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44252. import { Ray } from "babylonjs/Culling/ray";
  44253. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44254. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44255. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44256. /**
  44257. * Defines the WindowsMotionController object that the state of the windows motion controller
  44258. */
  44259. export class WindowsMotionController extends WebVRController {
  44260. /**
  44261. * The base url used to load the left and right controller models
  44262. */
  44263. static MODEL_BASE_URL: string;
  44264. /**
  44265. * The name of the left controller model file
  44266. */
  44267. static MODEL_LEFT_FILENAME: string;
  44268. /**
  44269. * The name of the right controller model file
  44270. */
  44271. static MODEL_RIGHT_FILENAME: string;
  44272. /**
  44273. * The controller name prefix for this controller type
  44274. */
  44275. static readonly GAMEPAD_ID_PREFIX: string;
  44276. /**
  44277. * The controller id pattern for this controller type
  44278. */
  44279. private static readonly GAMEPAD_ID_PATTERN;
  44280. private _loadedMeshInfo;
  44281. private readonly _mapping;
  44282. /**
  44283. * Fired when the trackpad on this controller is clicked
  44284. */
  44285. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44286. /**
  44287. * Fired when the trackpad on this controller is modified
  44288. */
  44289. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44290. /**
  44291. * The current x and y values of this controller's trackpad
  44292. */
  44293. trackpad: StickValues;
  44294. /**
  44295. * Creates a new WindowsMotionController from a gamepad
  44296. * @param vrGamepad the gamepad that the controller should be created from
  44297. */
  44298. constructor(vrGamepad: any);
  44299. /**
  44300. * Fired when the trigger on this controller is modified
  44301. */
  44302. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44303. /**
  44304. * Fired when the menu button on this controller is modified
  44305. */
  44306. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44307. /**
  44308. * Fired when the grip button on this controller is modified
  44309. */
  44310. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44311. /**
  44312. * Fired when the thumbstick button on this controller is modified
  44313. */
  44314. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44315. /**
  44316. * Fired when the touchpad button on this controller is modified
  44317. */
  44318. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44319. /**
  44320. * Fired when the touchpad values on this controller are modified
  44321. */
  44322. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44323. private _updateTrackpad;
  44324. /**
  44325. * Called once per frame by the engine.
  44326. */
  44327. update(): void;
  44328. /**
  44329. * Called once for each button that changed state since the last frame
  44330. * @param buttonIdx Which button index changed
  44331. * @param state New state of the button
  44332. * @param changes Which properties on the state changed since last frame
  44333. */
  44334. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44335. /**
  44336. * Moves the buttons on the controller mesh based on their current state
  44337. * @param buttonName the name of the button to move
  44338. * @param buttonValue the value of the button which determines the buttons new position
  44339. */
  44340. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44341. /**
  44342. * Moves the axis on the controller mesh based on its current state
  44343. * @param axis the index of the axis
  44344. * @param axisValue the value of the axis which determines the meshes new position
  44345. * @hidden
  44346. */
  44347. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44348. /**
  44349. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44350. * @param scene scene in which to add meshes
  44351. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44352. */
  44353. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44354. /**
  44355. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44356. * can be transformed by button presses and axes values, based on this._mapping.
  44357. *
  44358. * @param scene scene in which the meshes exist
  44359. * @param meshes list of meshes that make up the controller model to process
  44360. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44361. */
  44362. private processModel;
  44363. private createMeshInfo;
  44364. /**
  44365. * Gets the ray of the controller in the direction the controller is pointing
  44366. * @param length the length the resulting ray should be
  44367. * @returns a ray in the direction the controller is pointing
  44368. */
  44369. getForwardRay(length?: number): Ray;
  44370. /**
  44371. * Disposes of the controller
  44372. */
  44373. dispose(): void;
  44374. }
  44375. }
  44376. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44377. import { Observable } from "babylonjs/Misc/observable";
  44378. import { Scene } from "babylonjs/scene";
  44379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44380. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44381. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44382. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44383. /**
  44384. * Oculus Touch Controller
  44385. */
  44386. export class OculusTouchController extends WebVRController {
  44387. /**
  44388. * Base Url for the controller model.
  44389. */
  44390. static MODEL_BASE_URL: string;
  44391. /**
  44392. * File name for the left controller model.
  44393. */
  44394. static MODEL_LEFT_FILENAME: string;
  44395. /**
  44396. * File name for the right controller model.
  44397. */
  44398. static MODEL_RIGHT_FILENAME: string;
  44399. /**
  44400. * Base Url for the Quest controller model.
  44401. */
  44402. static QUEST_MODEL_BASE_URL: string;
  44403. /**
  44404. * @hidden
  44405. * If the controllers are running on a device that needs the updated Quest controller models
  44406. */
  44407. static _IsQuest: boolean;
  44408. /**
  44409. * Fired when the secondary trigger on this controller is modified
  44410. */
  44411. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44412. /**
  44413. * Fired when the thumb rest on this controller is modified
  44414. */
  44415. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44416. /**
  44417. * Creates a new OculusTouchController from a gamepad
  44418. * @param vrGamepad the gamepad that the controller should be created from
  44419. */
  44420. constructor(vrGamepad: any);
  44421. /**
  44422. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44423. * @param scene scene in which to add meshes
  44424. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44425. */
  44426. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44427. /**
  44428. * Fired when the A button on this controller is modified
  44429. */
  44430. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44431. /**
  44432. * Fired when the B button on this controller is modified
  44433. */
  44434. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44435. /**
  44436. * Fired when the X button on this controller is modified
  44437. */
  44438. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44439. /**
  44440. * Fired when the Y button on this controller is modified
  44441. */
  44442. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44443. /**
  44444. * Called once for each button that changed state since the last frame
  44445. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44446. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44447. * 2) secondary trigger (same)
  44448. * 3) A (right) X (left), touch, pressed = value
  44449. * 4) B / Y
  44450. * 5) thumb rest
  44451. * @param buttonIdx Which button index changed
  44452. * @param state New state of the button
  44453. * @param changes Which properties on the state changed since last frame
  44454. */
  44455. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44456. }
  44457. }
  44458. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44459. import { Scene } from "babylonjs/scene";
  44460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44461. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44462. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44463. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44464. import { Observable } from "babylonjs/Misc/observable";
  44465. /**
  44466. * Vive Controller
  44467. */
  44468. export class ViveController extends WebVRController {
  44469. /**
  44470. * Base Url for the controller model.
  44471. */
  44472. static MODEL_BASE_URL: string;
  44473. /**
  44474. * File name for the controller model.
  44475. */
  44476. static MODEL_FILENAME: string;
  44477. /**
  44478. * Creates a new ViveController from a gamepad
  44479. * @param vrGamepad the gamepad that the controller should be created from
  44480. */
  44481. constructor(vrGamepad: any);
  44482. /**
  44483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44484. * @param scene scene in which to add meshes
  44485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44486. */
  44487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44488. /**
  44489. * Fired when the left button on this controller is modified
  44490. */
  44491. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44492. /**
  44493. * Fired when the right button on this controller is modified
  44494. */
  44495. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44496. /**
  44497. * Fired when the menu button on this controller is modified
  44498. */
  44499. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44500. /**
  44501. * Called once for each button that changed state since the last frame
  44502. * Vive mapping:
  44503. * 0: touchpad
  44504. * 1: trigger
  44505. * 2: left AND right buttons
  44506. * 3: menu button
  44507. * @param buttonIdx Which button index changed
  44508. * @param state New state of the button
  44509. * @param changes Which properties on the state changed since last frame
  44510. */
  44511. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44512. }
  44513. }
  44514. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44515. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44516. /**
  44517. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44518. */
  44519. export class WebXRControllerModelLoader {
  44520. /**
  44521. * Creates the WebXRControllerModelLoader
  44522. * @param input xr input that creates the controllers
  44523. */
  44524. constructor(input: WebXRInput);
  44525. }
  44526. }
  44527. declare module "babylonjs/Cameras/XR/index" {
  44528. export * from "babylonjs/Cameras/XR/webXRCamera";
  44529. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44530. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44531. export * from "babylonjs/Cameras/XR/webXRInput";
  44532. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44533. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44534. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44535. export * from "babylonjs/Cameras/XR/webXRController";
  44536. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44537. export * from "babylonjs/Cameras/XR/webXRTypes";
  44538. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44539. }
  44540. declare module "babylonjs/Cameras/RigModes/index" {
  44541. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44542. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44543. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44544. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44545. }
  44546. declare module "babylonjs/Cameras/index" {
  44547. export * from "babylonjs/Cameras/Inputs/index";
  44548. export * from "babylonjs/Cameras/cameraInputsManager";
  44549. export * from "babylonjs/Cameras/camera";
  44550. export * from "babylonjs/Cameras/targetCamera";
  44551. export * from "babylonjs/Cameras/freeCamera";
  44552. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44553. export * from "babylonjs/Cameras/touchCamera";
  44554. export * from "babylonjs/Cameras/arcRotateCamera";
  44555. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44556. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44557. export * from "babylonjs/Cameras/flyCamera";
  44558. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44559. export * from "babylonjs/Cameras/followCamera";
  44560. export * from "babylonjs/Cameras/followCameraInputsManager";
  44561. export * from "babylonjs/Cameras/gamepadCamera";
  44562. export * from "babylonjs/Cameras/Stereoscopic/index";
  44563. export * from "babylonjs/Cameras/universalCamera";
  44564. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44565. export * from "babylonjs/Cameras/VR/index";
  44566. export * from "babylonjs/Cameras/XR/index";
  44567. export * from "babylonjs/Cameras/RigModes/index";
  44568. }
  44569. declare module "babylonjs/Collisions/index" {
  44570. export * from "babylonjs/Collisions/collider";
  44571. export * from "babylonjs/Collisions/collisionCoordinator";
  44572. export * from "babylonjs/Collisions/pickingInfo";
  44573. export * from "babylonjs/Collisions/intersectionInfo";
  44574. export * from "babylonjs/Collisions/meshCollisionData";
  44575. }
  44576. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44577. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44578. import { Vector3 } from "babylonjs/Maths/math.vector";
  44579. import { Ray } from "babylonjs/Culling/ray";
  44580. import { Plane } from "babylonjs/Maths/math.plane";
  44581. /**
  44582. * Contains an array of blocks representing the octree
  44583. */
  44584. export interface IOctreeContainer<T> {
  44585. /**
  44586. * Blocks within the octree
  44587. */
  44588. blocks: Array<OctreeBlock<T>>;
  44589. }
  44590. /**
  44591. * Class used to store a cell in an octree
  44592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44593. */
  44594. export class OctreeBlock<T> {
  44595. /**
  44596. * Gets the content of the current block
  44597. */
  44598. entries: T[];
  44599. /**
  44600. * Gets the list of block children
  44601. */
  44602. blocks: Array<OctreeBlock<T>>;
  44603. private _depth;
  44604. private _maxDepth;
  44605. private _capacity;
  44606. private _minPoint;
  44607. private _maxPoint;
  44608. private _boundingVectors;
  44609. private _creationFunc;
  44610. /**
  44611. * Creates a new block
  44612. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44613. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44614. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44615. * @param depth defines the current depth of this block in the octree
  44616. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44617. * @param creationFunc defines a callback to call when an element is added to the block
  44618. */
  44619. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44620. /**
  44621. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44622. */
  44623. readonly capacity: number;
  44624. /**
  44625. * Gets the minimum vector (in world space) of the block's bounding box
  44626. */
  44627. readonly minPoint: Vector3;
  44628. /**
  44629. * Gets the maximum vector (in world space) of the block's bounding box
  44630. */
  44631. readonly maxPoint: Vector3;
  44632. /**
  44633. * Add a new element to this block
  44634. * @param entry defines the element to add
  44635. */
  44636. addEntry(entry: T): void;
  44637. /**
  44638. * Remove an element from this block
  44639. * @param entry defines the element to remove
  44640. */
  44641. removeEntry(entry: T): void;
  44642. /**
  44643. * Add an array of elements to this block
  44644. * @param entries defines the array of elements to add
  44645. */
  44646. addEntries(entries: T[]): void;
  44647. /**
  44648. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44649. * @param frustumPlanes defines the frustum planes to test
  44650. * @param selection defines the array to store current content if selection is positive
  44651. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44652. */
  44653. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44654. /**
  44655. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44656. * @param sphereCenter defines the bounding sphere center
  44657. * @param sphereRadius defines the bounding sphere radius
  44658. * @param selection defines the array to store current content if selection is positive
  44659. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44660. */
  44661. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44662. /**
  44663. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44664. * @param ray defines the ray to test with
  44665. * @param selection defines the array to store current content if selection is positive
  44666. */
  44667. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44668. /**
  44669. * Subdivide the content into child blocks (this block will then be empty)
  44670. */
  44671. createInnerBlocks(): void;
  44672. /**
  44673. * @hidden
  44674. */
  44675. 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;
  44676. }
  44677. }
  44678. declare module "babylonjs/Culling/Octrees/octree" {
  44679. import { SmartArray } from "babylonjs/Misc/smartArray";
  44680. import { Vector3 } from "babylonjs/Maths/math.vector";
  44681. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44683. import { Ray } from "babylonjs/Culling/ray";
  44684. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44685. import { Plane } from "babylonjs/Maths/math.plane";
  44686. /**
  44687. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44688. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44689. */
  44690. export class Octree<T> {
  44691. /** 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.) */
  44692. maxDepth: number;
  44693. /**
  44694. * Blocks within the octree containing objects
  44695. */
  44696. blocks: Array<OctreeBlock<T>>;
  44697. /**
  44698. * Content stored in the octree
  44699. */
  44700. dynamicContent: T[];
  44701. private _maxBlockCapacity;
  44702. private _selectionContent;
  44703. private _creationFunc;
  44704. /**
  44705. * Creates a octree
  44706. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44707. * @param creationFunc function to be used to instatiate the octree
  44708. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44709. * @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.)
  44710. */
  44711. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44712. /** 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.) */
  44713. maxDepth?: number);
  44714. /**
  44715. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44716. * @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);
  44717. * @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);
  44718. * @param entries meshes to be added to the octree blocks
  44719. */
  44720. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44721. /**
  44722. * Adds a mesh to the octree
  44723. * @param entry Mesh to add to the octree
  44724. */
  44725. addMesh(entry: T): void;
  44726. /**
  44727. * Remove an element from the octree
  44728. * @param entry defines the element to remove
  44729. */
  44730. removeMesh(entry: T): void;
  44731. /**
  44732. * Selects an array of meshes within the frustum
  44733. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44734. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44735. * @returns array of meshes within the frustum
  44736. */
  44737. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44738. /**
  44739. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44740. * @param sphereCenter defines the bounding sphere center
  44741. * @param sphereRadius defines the bounding sphere radius
  44742. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44743. * @returns an array of objects that intersect the sphere
  44744. */
  44745. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44746. /**
  44747. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44748. * @param ray defines the ray to test with
  44749. * @returns array of intersected objects
  44750. */
  44751. intersectsRay(ray: Ray): SmartArray<T>;
  44752. /**
  44753. * Adds a mesh into the octree block if it intersects the block
  44754. */
  44755. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44756. /**
  44757. * Adds a submesh into the octree block if it intersects the block
  44758. */
  44759. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44760. }
  44761. }
  44762. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44763. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44764. import { Scene } from "babylonjs/scene";
  44765. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44767. import { Ray } from "babylonjs/Culling/ray";
  44768. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44769. import { Collider } from "babylonjs/Collisions/collider";
  44770. module "babylonjs/scene" {
  44771. interface Scene {
  44772. /**
  44773. * @hidden
  44774. * Backing Filed
  44775. */
  44776. _selectionOctree: Octree<AbstractMesh>;
  44777. /**
  44778. * Gets the octree used to boost mesh selection (picking)
  44779. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44780. */
  44781. selectionOctree: Octree<AbstractMesh>;
  44782. /**
  44783. * Creates or updates the octree used to boost selection (picking)
  44784. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44785. * @param maxCapacity defines the maximum capacity per leaf
  44786. * @param maxDepth defines the maximum depth of the octree
  44787. * @returns an octree of AbstractMesh
  44788. */
  44789. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44790. }
  44791. }
  44792. module "babylonjs/Meshes/abstractMesh" {
  44793. interface AbstractMesh {
  44794. /**
  44795. * @hidden
  44796. * Backing Field
  44797. */
  44798. _submeshesOctree: Octree<SubMesh>;
  44799. /**
  44800. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44801. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44802. * @param maxCapacity defines the maximum size of each block (64 by default)
  44803. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44804. * @returns the new octree
  44805. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44807. */
  44808. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44809. }
  44810. }
  44811. /**
  44812. * Defines the octree scene component responsible to manage any octrees
  44813. * in a given scene.
  44814. */
  44815. export class OctreeSceneComponent {
  44816. /**
  44817. * The component name help to identify the component in the list of scene components.
  44818. */
  44819. readonly name: string;
  44820. /**
  44821. * The scene the component belongs to.
  44822. */
  44823. scene: Scene;
  44824. /**
  44825. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44826. */
  44827. readonly checksIsEnabled: boolean;
  44828. /**
  44829. * Creates a new instance of the component for the given scene
  44830. * @param scene Defines the scene to register the component in
  44831. */
  44832. constructor(scene: Scene);
  44833. /**
  44834. * Registers the component in a given scene
  44835. */
  44836. register(): void;
  44837. /**
  44838. * Return the list of active meshes
  44839. * @returns the list of active meshes
  44840. */
  44841. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44842. /**
  44843. * Return the list of active sub meshes
  44844. * @param mesh The mesh to get the candidates sub meshes from
  44845. * @returns the list of active sub meshes
  44846. */
  44847. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44848. private _tempRay;
  44849. /**
  44850. * Return the list of sub meshes intersecting with a given local ray
  44851. * @param mesh defines the mesh to find the submesh for
  44852. * @param localRay defines the ray in local space
  44853. * @returns the list of intersecting sub meshes
  44854. */
  44855. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44856. /**
  44857. * Return the list of sub meshes colliding with a collider
  44858. * @param mesh defines the mesh to find the submesh for
  44859. * @param collider defines the collider to evaluate the collision against
  44860. * @returns the list of colliding sub meshes
  44861. */
  44862. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44863. /**
  44864. * Rebuilds the elements related to this component in case of
  44865. * context lost for instance.
  44866. */
  44867. rebuild(): void;
  44868. /**
  44869. * Disposes the component and the associated ressources.
  44870. */
  44871. dispose(): void;
  44872. }
  44873. }
  44874. declare module "babylonjs/Culling/Octrees/index" {
  44875. export * from "babylonjs/Culling/Octrees/octree";
  44876. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44877. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44878. }
  44879. declare module "babylonjs/Culling/index" {
  44880. export * from "babylonjs/Culling/boundingBox";
  44881. export * from "babylonjs/Culling/boundingInfo";
  44882. export * from "babylonjs/Culling/boundingSphere";
  44883. export * from "babylonjs/Culling/Octrees/index";
  44884. export * from "babylonjs/Culling/ray";
  44885. }
  44886. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44887. import { IDisposable, Scene } from "babylonjs/scene";
  44888. import { Nullable } from "babylonjs/types";
  44889. import { Observable } from "babylonjs/Misc/observable";
  44890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44891. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44892. import { Camera } from "babylonjs/Cameras/camera";
  44893. /**
  44894. * Renders a layer on top of an existing scene
  44895. */
  44896. export class UtilityLayerRenderer implements IDisposable {
  44897. /** the original scene that will be rendered on top of */
  44898. originalScene: Scene;
  44899. private _pointerCaptures;
  44900. private _lastPointerEvents;
  44901. private static _DefaultUtilityLayer;
  44902. private static _DefaultKeepDepthUtilityLayer;
  44903. private _sharedGizmoLight;
  44904. private _renderCamera;
  44905. /**
  44906. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44907. * @returns the camera that is used when rendering the utility layer
  44908. */
  44909. getRenderCamera(): Nullable<Camera>;
  44910. /**
  44911. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44912. * @param cam the camera that should be used when rendering the utility layer
  44913. */
  44914. setRenderCamera(cam: Nullable<Camera>): void;
  44915. /**
  44916. * @hidden
  44917. * Light which used by gizmos to get light shading
  44918. */
  44919. _getSharedGizmoLight(): HemisphericLight;
  44920. /**
  44921. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44922. */
  44923. pickUtilitySceneFirst: boolean;
  44924. /**
  44925. * 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)
  44926. */
  44927. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44928. /**
  44929. * 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)
  44930. */
  44931. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44932. /**
  44933. * The scene that is rendered on top of the original scene
  44934. */
  44935. utilityLayerScene: Scene;
  44936. /**
  44937. * If the utility layer should automatically be rendered on top of existing scene
  44938. */
  44939. shouldRender: boolean;
  44940. /**
  44941. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44942. */
  44943. onlyCheckPointerDownEvents: boolean;
  44944. /**
  44945. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44946. */
  44947. processAllEvents: boolean;
  44948. /**
  44949. * Observable raised when the pointer move from the utility layer scene to the main scene
  44950. */
  44951. onPointerOutObservable: Observable<number>;
  44952. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44953. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44954. private _afterRenderObserver;
  44955. private _sceneDisposeObserver;
  44956. private _originalPointerObserver;
  44957. /**
  44958. * Instantiates a UtilityLayerRenderer
  44959. * @param originalScene the original scene that will be rendered on top of
  44960. * @param handleEvents boolean indicating if the utility layer should handle events
  44961. */
  44962. constructor(
  44963. /** the original scene that will be rendered on top of */
  44964. originalScene: Scene, handleEvents?: boolean);
  44965. private _notifyObservers;
  44966. /**
  44967. * Renders the utility layers scene on top of the original scene
  44968. */
  44969. render(): void;
  44970. /**
  44971. * Disposes of the renderer
  44972. */
  44973. dispose(): void;
  44974. private _updateCamera;
  44975. }
  44976. }
  44977. declare module "babylonjs/Gizmos/gizmo" {
  44978. import { Nullable } from "babylonjs/types";
  44979. import { IDisposable } from "babylonjs/scene";
  44980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44981. import { Mesh } from "babylonjs/Meshes/mesh";
  44982. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44983. /**
  44984. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44985. */
  44986. export class Gizmo implements IDisposable {
  44987. /** The utility layer the gizmo will be added to */
  44988. gizmoLayer: UtilityLayerRenderer;
  44989. /**
  44990. * The root mesh of the gizmo
  44991. */
  44992. _rootMesh: Mesh;
  44993. private _attachedMesh;
  44994. /**
  44995. * Ratio for the scale of the gizmo (Default: 1)
  44996. */
  44997. scaleRatio: number;
  44998. /**
  44999. * If a custom mesh has been set (Default: false)
  45000. */
  45001. protected _customMeshSet: boolean;
  45002. /**
  45003. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45004. * * When set, interactions will be enabled
  45005. */
  45006. attachedMesh: Nullable<AbstractMesh>;
  45007. /**
  45008. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45009. * @param mesh The mesh to replace the default mesh of the gizmo
  45010. */
  45011. setCustomMesh(mesh: Mesh): void;
  45012. /**
  45013. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45014. */
  45015. updateGizmoRotationToMatchAttachedMesh: boolean;
  45016. /**
  45017. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45018. */
  45019. updateGizmoPositionToMatchAttachedMesh: boolean;
  45020. /**
  45021. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45022. */
  45023. updateScale: boolean;
  45024. protected _interactionsEnabled: boolean;
  45025. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45026. private _beforeRenderObserver;
  45027. private _tempVector;
  45028. /**
  45029. * Creates a gizmo
  45030. * @param gizmoLayer The utility layer the gizmo will be added to
  45031. */
  45032. constructor(
  45033. /** The utility layer the gizmo will be added to */
  45034. gizmoLayer?: UtilityLayerRenderer);
  45035. /**
  45036. * Updates the gizmo to match the attached mesh's position/rotation
  45037. */
  45038. protected _update(): void;
  45039. /**
  45040. * Disposes of the gizmo
  45041. */
  45042. dispose(): void;
  45043. }
  45044. }
  45045. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45046. import { Observable } from "babylonjs/Misc/observable";
  45047. import { Nullable } from "babylonjs/types";
  45048. import { Vector3 } from "babylonjs/Maths/math.vector";
  45049. import { Color3 } from "babylonjs/Maths/math.color";
  45050. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45052. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45053. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45054. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45055. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45056. import { Scene } from "babylonjs/scene";
  45057. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45058. /**
  45059. * Single plane drag gizmo
  45060. */
  45061. export class PlaneDragGizmo extends Gizmo {
  45062. /**
  45063. * Drag behavior responsible for the gizmos dragging interactions
  45064. */
  45065. dragBehavior: PointerDragBehavior;
  45066. private _pointerObserver;
  45067. /**
  45068. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45069. */
  45070. snapDistance: number;
  45071. /**
  45072. * Event that fires each time the gizmo snaps to a new location.
  45073. * * snapDistance is the the change in distance
  45074. */
  45075. onSnapObservable: Observable<{
  45076. snapDistance: number;
  45077. }>;
  45078. private _plane;
  45079. private _coloredMaterial;
  45080. private _hoverMaterial;
  45081. private _isEnabled;
  45082. private _parent;
  45083. /** @hidden */
  45084. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45085. /** @hidden */
  45086. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45087. /**
  45088. * Creates a PlaneDragGizmo
  45089. * @param gizmoLayer The utility layer the gizmo will be added to
  45090. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45091. * @param color The color of the gizmo
  45092. */
  45093. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45094. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45095. /**
  45096. * If the gizmo is enabled
  45097. */
  45098. isEnabled: boolean;
  45099. /**
  45100. * Disposes of the gizmo
  45101. */
  45102. dispose(): void;
  45103. }
  45104. }
  45105. declare module "babylonjs/Gizmos/positionGizmo" {
  45106. import { Observable } from "babylonjs/Misc/observable";
  45107. import { Nullable } from "babylonjs/types";
  45108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45109. import { Mesh } from "babylonjs/Meshes/mesh";
  45110. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45111. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45112. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45113. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45114. /**
  45115. * Gizmo that enables dragging a mesh along 3 axis
  45116. */
  45117. export class PositionGizmo extends Gizmo {
  45118. /**
  45119. * Internal gizmo used for interactions on the x axis
  45120. */
  45121. xGizmo: AxisDragGizmo;
  45122. /**
  45123. * Internal gizmo used for interactions on the y axis
  45124. */
  45125. yGizmo: AxisDragGizmo;
  45126. /**
  45127. * Internal gizmo used for interactions on the z axis
  45128. */
  45129. zGizmo: AxisDragGizmo;
  45130. /**
  45131. * Internal gizmo used for interactions on the yz plane
  45132. */
  45133. xPlaneGizmo: PlaneDragGizmo;
  45134. /**
  45135. * Internal gizmo used for interactions on the xz plane
  45136. */
  45137. yPlaneGizmo: PlaneDragGizmo;
  45138. /**
  45139. * Internal gizmo used for interactions on the xy plane
  45140. */
  45141. zPlaneGizmo: PlaneDragGizmo;
  45142. /**
  45143. * private variables
  45144. */
  45145. private _meshAttached;
  45146. private _updateGizmoRotationToMatchAttachedMesh;
  45147. private _snapDistance;
  45148. private _scaleRatio;
  45149. /** Fires an event when any of it's sub gizmos are dragged */
  45150. onDragStartObservable: Observable<unknown>;
  45151. /** Fires an event when any of it's sub gizmos are released from dragging */
  45152. onDragEndObservable: Observable<unknown>;
  45153. /**
  45154. * If set to true, planar drag is enabled
  45155. */
  45156. private _planarGizmoEnabled;
  45157. attachedMesh: Nullable<AbstractMesh>;
  45158. /**
  45159. * Creates a PositionGizmo
  45160. * @param gizmoLayer The utility layer the gizmo will be added to
  45161. */
  45162. constructor(gizmoLayer?: UtilityLayerRenderer);
  45163. /**
  45164. * If the planar drag gizmo is enabled
  45165. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45166. */
  45167. planarGizmoEnabled: boolean;
  45168. updateGizmoRotationToMatchAttachedMesh: boolean;
  45169. /**
  45170. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45171. */
  45172. snapDistance: number;
  45173. /**
  45174. * Ratio for the scale of the gizmo (Default: 1)
  45175. */
  45176. scaleRatio: number;
  45177. /**
  45178. * Disposes of the gizmo
  45179. */
  45180. dispose(): void;
  45181. /**
  45182. * CustomMeshes are not supported by this gizmo
  45183. * @param mesh The mesh to replace the default mesh of the gizmo
  45184. */
  45185. setCustomMesh(mesh: Mesh): void;
  45186. }
  45187. }
  45188. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45189. import { Observable } from "babylonjs/Misc/observable";
  45190. import { Nullable } from "babylonjs/types";
  45191. import { Vector3 } from "babylonjs/Maths/math.vector";
  45192. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45194. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45195. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45196. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45197. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45198. import { Scene } from "babylonjs/scene";
  45199. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45200. import { Color3 } from "babylonjs/Maths/math.color";
  45201. /**
  45202. * Single axis drag gizmo
  45203. */
  45204. export class AxisDragGizmo extends Gizmo {
  45205. /**
  45206. * Drag behavior responsible for the gizmos dragging interactions
  45207. */
  45208. dragBehavior: PointerDragBehavior;
  45209. private _pointerObserver;
  45210. /**
  45211. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45212. */
  45213. snapDistance: number;
  45214. /**
  45215. * Event that fires each time the gizmo snaps to a new location.
  45216. * * snapDistance is the the change in distance
  45217. */
  45218. onSnapObservable: Observable<{
  45219. snapDistance: number;
  45220. }>;
  45221. private _isEnabled;
  45222. private _parent;
  45223. private _arrow;
  45224. private _coloredMaterial;
  45225. private _hoverMaterial;
  45226. /** @hidden */
  45227. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45228. /** @hidden */
  45229. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45230. /**
  45231. * Creates an AxisDragGizmo
  45232. * @param gizmoLayer The utility layer the gizmo will be added to
  45233. * @param dragAxis The axis which the gizmo will be able to drag on
  45234. * @param color The color of the gizmo
  45235. */
  45236. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45237. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45238. /**
  45239. * If the gizmo is enabled
  45240. */
  45241. isEnabled: boolean;
  45242. /**
  45243. * Disposes of the gizmo
  45244. */
  45245. dispose(): void;
  45246. }
  45247. }
  45248. declare module "babylonjs/Debug/axesViewer" {
  45249. import { Vector3 } from "babylonjs/Maths/math.vector";
  45250. import { Nullable } from "babylonjs/types";
  45251. import { Scene } from "babylonjs/scene";
  45252. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45253. /**
  45254. * The Axes viewer will show 3 axes in a specific point in space
  45255. */
  45256. export class AxesViewer {
  45257. private _xAxis;
  45258. private _yAxis;
  45259. private _zAxis;
  45260. private _scaleLinesFactor;
  45261. private _instanced;
  45262. /**
  45263. * Gets the hosting scene
  45264. */
  45265. scene: Scene;
  45266. /**
  45267. * Gets or sets a number used to scale line length
  45268. */
  45269. scaleLines: number;
  45270. /** Gets the node hierarchy used to render x-axis */
  45271. readonly xAxis: TransformNode;
  45272. /** Gets the node hierarchy used to render y-axis */
  45273. readonly yAxis: TransformNode;
  45274. /** Gets the node hierarchy used to render z-axis */
  45275. readonly zAxis: TransformNode;
  45276. /**
  45277. * Creates a new AxesViewer
  45278. * @param scene defines the hosting scene
  45279. * @param scaleLines defines a number used to scale line length (1 by default)
  45280. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45281. * @param xAxis defines the node hierarchy used to render the x-axis
  45282. * @param yAxis defines the node hierarchy used to render the y-axis
  45283. * @param zAxis defines the node hierarchy used to render the z-axis
  45284. */
  45285. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45286. /**
  45287. * Force the viewer to update
  45288. * @param position defines the position of the viewer
  45289. * @param xaxis defines the x axis of the viewer
  45290. * @param yaxis defines the y axis of the viewer
  45291. * @param zaxis defines the z axis of the viewer
  45292. */
  45293. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45294. /**
  45295. * Creates an instance of this axes viewer.
  45296. * @returns a new axes viewer with instanced meshes
  45297. */
  45298. createInstance(): AxesViewer;
  45299. /** Releases resources */
  45300. dispose(): void;
  45301. private static _SetRenderingGroupId;
  45302. }
  45303. }
  45304. declare module "babylonjs/Debug/boneAxesViewer" {
  45305. import { Nullable } from "babylonjs/types";
  45306. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45307. import { Vector3 } from "babylonjs/Maths/math.vector";
  45308. import { Mesh } from "babylonjs/Meshes/mesh";
  45309. import { Bone } from "babylonjs/Bones/bone";
  45310. import { Scene } from "babylonjs/scene";
  45311. /**
  45312. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45313. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45314. */
  45315. export class BoneAxesViewer extends AxesViewer {
  45316. /**
  45317. * Gets or sets the target mesh where to display the axes viewer
  45318. */
  45319. mesh: Nullable<Mesh>;
  45320. /**
  45321. * Gets or sets the target bone where to display the axes viewer
  45322. */
  45323. bone: Nullable<Bone>;
  45324. /** Gets current position */
  45325. pos: Vector3;
  45326. /** Gets direction of X axis */
  45327. xaxis: Vector3;
  45328. /** Gets direction of Y axis */
  45329. yaxis: Vector3;
  45330. /** Gets direction of Z axis */
  45331. zaxis: Vector3;
  45332. /**
  45333. * Creates a new BoneAxesViewer
  45334. * @param scene defines the hosting scene
  45335. * @param bone defines the target bone
  45336. * @param mesh defines the target mesh
  45337. * @param scaleLines defines a scaling factor for line length (1 by default)
  45338. */
  45339. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45340. /**
  45341. * Force the viewer to update
  45342. */
  45343. update(): void;
  45344. /** Releases resources */
  45345. dispose(): void;
  45346. }
  45347. }
  45348. declare module "babylonjs/Debug/debugLayer" {
  45349. import { Scene } from "babylonjs/scene";
  45350. /**
  45351. * Interface used to define scene explorer extensibility option
  45352. */
  45353. export interface IExplorerExtensibilityOption {
  45354. /**
  45355. * Define the option label
  45356. */
  45357. label: string;
  45358. /**
  45359. * Defines the action to execute on click
  45360. */
  45361. action: (entity: any) => void;
  45362. }
  45363. /**
  45364. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45365. */
  45366. export interface IExplorerExtensibilityGroup {
  45367. /**
  45368. * Defines a predicate to test if a given type mut be extended
  45369. */
  45370. predicate: (entity: any) => boolean;
  45371. /**
  45372. * Gets the list of options added to a type
  45373. */
  45374. entries: IExplorerExtensibilityOption[];
  45375. }
  45376. /**
  45377. * Interface used to define the options to use to create the Inspector
  45378. */
  45379. export interface IInspectorOptions {
  45380. /**
  45381. * Display in overlay mode (default: false)
  45382. */
  45383. overlay?: boolean;
  45384. /**
  45385. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45386. */
  45387. globalRoot?: HTMLElement;
  45388. /**
  45389. * Display the Scene explorer
  45390. */
  45391. showExplorer?: boolean;
  45392. /**
  45393. * Display the property inspector
  45394. */
  45395. showInspector?: boolean;
  45396. /**
  45397. * Display in embed mode (both panes on the right)
  45398. */
  45399. embedMode?: boolean;
  45400. /**
  45401. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45402. */
  45403. handleResize?: boolean;
  45404. /**
  45405. * Allow the panes to popup (default: true)
  45406. */
  45407. enablePopup?: boolean;
  45408. /**
  45409. * Allow the panes to be closed by users (default: true)
  45410. */
  45411. enableClose?: boolean;
  45412. /**
  45413. * Optional list of extensibility entries
  45414. */
  45415. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45416. /**
  45417. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45418. */
  45419. inspectorURL?: string;
  45420. }
  45421. module "babylonjs/scene" {
  45422. interface Scene {
  45423. /**
  45424. * @hidden
  45425. * Backing field
  45426. */
  45427. _debugLayer: DebugLayer;
  45428. /**
  45429. * Gets the debug layer (aka Inspector) associated with the scene
  45430. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45431. */
  45432. debugLayer: DebugLayer;
  45433. }
  45434. }
  45435. /**
  45436. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45437. * what is happening in your scene
  45438. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45439. */
  45440. export class DebugLayer {
  45441. /**
  45442. * Define the url to get the inspector script from.
  45443. * By default it uses the babylonjs CDN.
  45444. * @ignoreNaming
  45445. */
  45446. static InspectorURL: string;
  45447. private _scene;
  45448. private BJSINSPECTOR;
  45449. private _onPropertyChangedObservable?;
  45450. /**
  45451. * Observable triggered when a property is changed through the inspector.
  45452. */
  45453. readonly onPropertyChangedObservable: any;
  45454. /**
  45455. * Instantiates a new debug layer.
  45456. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45457. * what is happening in your scene
  45458. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45459. * @param scene Defines the scene to inspect
  45460. */
  45461. constructor(scene: Scene);
  45462. /** Creates the inspector window. */
  45463. private _createInspector;
  45464. /**
  45465. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45466. * @param entity defines the entity to select
  45467. * @param lineContainerTitle defines the specific block to highlight
  45468. */
  45469. select(entity: any, lineContainerTitle?: string): void;
  45470. /** Get the inspector from bundle or global */
  45471. private _getGlobalInspector;
  45472. /**
  45473. * Get if the inspector is visible or not.
  45474. * @returns true if visible otherwise, false
  45475. */
  45476. isVisible(): boolean;
  45477. /**
  45478. * Hide the inspector and close its window.
  45479. */
  45480. hide(): void;
  45481. /**
  45482. * Launch the debugLayer.
  45483. * @param config Define the configuration of the inspector
  45484. * @return a promise fulfilled when the debug layer is visible
  45485. */
  45486. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45487. }
  45488. }
  45489. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45490. import { Nullable } from "babylonjs/types";
  45491. import { Scene } from "babylonjs/scene";
  45492. import { Vector4 } from "babylonjs/Maths/math.vector";
  45493. import { Color4 } from "babylonjs/Maths/math.color";
  45494. import { Mesh } from "babylonjs/Meshes/mesh";
  45495. /**
  45496. * Class containing static functions to help procedurally build meshes
  45497. */
  45498. export class BoxBuilder {
  45499. /**
  45500. * Creates a box mesh
  45501. * * The parameter `size` sets the size (float) of each box side (default 1)
  45502. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45503. * * 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)
  45504. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45508. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45509. * @param name defines the name of the mesh
  45510. * @param options defines the options used to create the mesh
  45511. * @param scene defines the hosting scene
  45512. * @returns the box mesh
  45513. */
  45514. static CreateBox(name: string, options: {
  45515. size?: number;
  45516. width?: number;
  45517. height?: number;
  45518. depth?: number;
  45519. faceUV?: Vector4[];
  45520. faceColors?: Color4[];
  45521. sideOrientation?: number;
  45522. frontUVs?: Vector4;
  45523. backUVs?: Vector4;
  45524. wrap?: boolean;
  45525. topBaseAt?: number;
  45526. bottomBaseAt?: number;
  45527. updatable?: boolean;
  45528. }, scene?: Nullable<Scene>): Mesh;
  45529. }
  45530. }
  45531. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45532. import { Vector4 } from "babylonjs/Maths/math.vector";
  45533. import { Mesh } from "babylonjs/Meshes/mesh";
  45534. import { Scene } from "babylonjs/scene";
  45535. import { Nullable } from "babylonjs/types";
  45536. /**
  45537. * Class containing static functions to help procedurally build meshes
  45538. */
  45539. export class SphereBuilder {
  45540. /**
  45541. * Creates a sphere mesh
  45542. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45543. * * 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`)
  45544. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45545. * * 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
  45546. * * 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)
  45547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45550. * @param name defines the name of the mesh
  45551. * @param options defines the options used to create the mesh
  45552. * @param scene defines the hosting scene
  45553. * @returns the sphere mesh
  45554. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45555. */
  45556. static CreateSphere(name: string, options: {
  45557. segments?: number;
  45558. diameter?: number;
  45559. diameterX?: number;
  45560. diameterY?: number;
  45561. diameterZ?: number;
  45562. arc?: number;
  45563. slice?: number;
  45564. sideOrientation?: number;
  45565. frontUVs?: Vector4;
  45566. backUVs?: Vector4;
  45567. updatable?: boolean;
  45568. }, scene?: Nullable<Scene>): Mesh;
  45569. }
  45570. }
  45571. declare module "babylonjs/Debug/physicsViewer" {
  45572. import { Nullable } from "babylonjs/types";
  45573. import { Scene } from "babylonjs/scene";
  45574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45575. import { Mesh } from "babylonjs/Meshes/mesh";
  45576. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45577. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45578. /**
  45579. * Used to show the physics impostor around the specific mesh
  45580. */
  45581. export class PhysicsViewer {
  45582. /** @hidden */
  45583. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45584. /** @hidden */
  45585. protected _meshes: Array<Nullable<AbstractMesh>>;
  45586. /** @hidden */
  45587. protected _scene: Nullable<Scene>;
  45588. /** @hidden */
  45589. protected _numMeshes: number;
  45590. /** @hidden */
  45591. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45592. private _renderFunction;
  45593. private _utilityLayer;
  45594. private _debugBoxMesh;
  45595. private _debugSphereMesh;
  45596. private _debugCylinderMesh;
  45597. private _debugMaterial;
  45598. private _debugMeshMeshes;
  45599. /**
  45600. * Creates a new PhysicsViewer
  45601. * @param scene defines the hosting scene
  45602. */
  45603. constructor(scene: Scene);
  45604. /** @hidden */
  45605. protected _updateDebugMeshes(): void;
  45606. /**
  45607. * Renders a specified physic impostor
  45608. * @param impostor defines the impostor to render
  45609. * @param targetMesh defines the mesh represented by the impostor
  45610. * @returns the new debug mesh used to render the impostor
  45611. */
  45612. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45613. /**
  45614. * Hides a specified physic impostor
  45615. * @param impostor defines the impostor to hide
  45616. */
  45617. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45618. private _getDebugMaterial;
  45619. private _getDebugBoxMesh;
  45620. private _getDebugSphereMesh;
  45621. private _getDebugCylinderMesh;
  45622. private _getDebugMeshMesh;
  45623. private _getDebugMesh;
  45624. /** Releases all resources */
  45625. dispose(): void;
  45626. }
  45627. }
  45628. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45629. import { Vector3 } from "babylonjs/Maths/math.vector";
  45630. import { Color4 } from "babylonjs/Maths/math.color";
  45631. import { Nullable } from "babylonjs/types";
  45632. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45633. import { Scene } from "babylonjs/scene";
  45634. /**
  45635. * Class containing static functions to help procedurally build meshes
  45636. */
  45637. export class LinesBuilder {
  45638. /**
  45639. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45640. * * 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
  45641. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45642. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45643. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45644. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45645. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45646. * * 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
  45647. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45650. * @param name defines the name of the new line system
  45651. * @param options defines the options used to create the line system
  45652. * @param scene defines the hosting scene
  45653. * @returns a new line system mesh
  45654. */
  45655. static CreateLineSystem(name: string, options: {
  45656. lines: Vector3[][];
  45657. updatable?: boolean;
  45658. instance?: Nullable<LinesMesh>;
  45659. colors?: Nullable<Color4[][]>;
  45660. useVertexAlpha?: boolean;
  45661. }, scene: Nullable<Scene>): LinesMesh;
  45662. /**
  45663. * Creates a line mesh
  45664. * 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
  45665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45666. * * The parameter `points` is an array successive Vector3
  45667. * * 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
  45668. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45669. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45670. * * When updating an instance, remember that only point positions can change, not the number of points
  45671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45673. * @param name defines the name of the new line system
  45674. * @param options defines the options used to create the line system
  45675. * @param scene defines the hosting scene
  45676. * @returns a new line mesh
  45677. */
  45678. static CreateLines(name: string, options: {
  45679. points: Vector3[];
  45680. updatable?: boolean;
  45681. instance?: Nullable<LinesMesh>;
  45682. colors?: Color4[];
  45683. useVertexAlpha?: boolean;
  45684. }, scene?: Nullable<Scene>): LinesMesh;
  45685. /**
  45686. * Creates a dashed line mesh
  45687. * * 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
  45688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45689. * * The parameter `points` is an array successive Vector3
  45690. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45691. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45692. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45693. * * 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
  45694. * * When updating an instance, remember that only point positions can change, not the number of points
  45695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45696. * @param name defines the name of the mesh
  45697. * @param options defines the options used to create the mesh
  45698. * @param scene defines the hosting scene
  45699. * @returns the dashed line mesh
  45700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45701. */
  45702. static CreateDashedLines(name: string, options: {
  45703. points: Vector3[];
  45704. dashSize?: number;
  45705. gapSize?: number;
  45706. dashNb?: number;
  45707. updatable?: boolean;
  45708. instance?: LinesMesh;
  45709. }, scene?: Nullable<Scene>): LinesMesh;
  45710. }
  45711. }
  45712. declare module "babylonjs/Debug/rayHelper" {
  45713. import { Nullable } from "babylonjs/types";
  45714. import { Ray } from "babylonjs/Culling/ray";
  45715. import { Vector3 } from "babylonjs/Maths/math.vector";
  45716. import { Color3 } from "babylonjs/Maths/math.color";
  45717. import { Scene } from "babylonjs/scene";
  45718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45719. import "babylonjs/Meshes/Builders/linesBuilder";
  45720. /**
  45721. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45722. * in order to better appreciate the issue one might have.
  45723. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45724. */
  45725. export class RayHelper {
  45726. /**
  45727. * Defines the ray we are currently tryin to visualize.
  45728. */
  45729. ray: Nullable<Ray>;
  45730. private _renderPoints;
  45731. private _renderLine;
  45732. private _renderFunction;
  45733. private _scene;
  45734. private _updateToMeshFunction;
  45735. private _attachedToMesh;
  45736. private _meshSpaceDirection;
  45737. private _meshSpaceOrigin;
  45738. /**
  45739. * Helper function to create a colored helper in a scene in one line.
  45740. * @param ray Defines the ray we are currently tryin to visualize
  45741. * @param scene Defines the scene the ray is used in
  45742. * @param color Defines the color we want to see the ray in
  45743. * @returns The newly created ray helper.
  45744. */
  45745. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45746. /**
  45747. * Instantiate a new ray helper.
  45748. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45749. * in order to better appreciate the issue one might have.
  45750. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45751. * @param ray Defines the ray we are currently tryin to visualize
  45752. */
  45753. constructor(ray: Ray);
  45754. /**
  45755. * Shows the ray we are willing to debug.
  45756. * @param scene Defines the scene the ray needs to be rendered in
  45757. * @param color Defines the color the ray needs to be rendered in
  45758. */
  45759. show(scene: Scene, color?: Color3): void;
  45760. /**
  45761. * Hides the ray we are debugging.
  45762. */
  45763. hide(): void;
  45764. private _render;
  45765. /**
  45766. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45767. * @param mesh Defines the mesh we want the helper attached to
  45768. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45769. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45770. * @param length Defines the length of the ray
  45771. */
  45772. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45773. /**
  45774. * Detach the ray helper from the mesh it has previously been attached to.
  45775. */
  45776. detachFromMesh(): void;
  45777. private _updateToMesh;
  45778. /**
  45779. * Dispose the helper and release its associated resources.
  45780. */
  45781. dispose(): void;
  45782. }
  45783. }
  45784. declare module "babylonjs/Debug/skeletonViewer" {
  45785. import { Color3 } from "babylonjs/Maths/math.color";
  45786. import { Scene } from "babylonjs/scene";
  45787. import { Nullable } from "babylonjs/types";
  45788. import { Skeleton } from "babylonjs/Bones/skeleton";
  45789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45790. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45791. /**
  45792. * Class used to render a debug view of a given skeleton
  45793. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45794. */
  45795. export class SkeletonViewer {
  45796. /** defines the skeleton to render */
  45797. skeleton: Skeleton;
  45798. /** defines the mesh attached to the skeleton */
  45799. mesh: AbstractMesh;
  45800. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45801. autoUpdateBonesMatrices: boolean;
  45802. /** defines the rendering group id to use with the viewer */
  45803. renderingGroupId: number;
  45804. /** Gets or sets the color used to render the skeleton */
  45805. color: Color3;
  45806. private _scene;
  45807. private _debugLines;
  45808. private _debugMesh;
  45809. private _isEnabled;
  45810. private _renderFunction;
  45811. private _utilityLayer;
  45812. /**
  45813. * Returns the mesh used to render the bones
  45814. */
  45815. readonly debugMesh: Nullable<LinesMesh>;
  45816. /**
  45817. * Creates a new SkeletonViewer
  45818. * @param skeleton defines the skeleton to render
  45819. * @param mesh defines the mesh attached to the skeleton
  45820. * @param scene defines the hosting scene
  45821. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45822. * @param renderingGroupId defines the rendering group id to use with the viewer
  45823. */
  45824. constructor(
  45825. /** defines the skeleton to render */
  45826. skeleton: Skeleton,
  45827. /** defines the mesh attached to the skeleton */
  45828. mesh: AbstractMesh, scene: Scene,
  45829. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45830. autoUpdateBonesMatrices?: boolean,
  45831. /** defines the rendering group id to use with the viewer */
  45832. renderingGroupId?: number);
  45833. /** Gets or sets a boolean indicating if the viewer is enabled */
  45834. isEnabled: boolean;
  45835. private _getBonePosition;
  45836. private _getLinesForBonesWithLength;
  45837. private _getLinesForBonesNoLength;
  45838. /** Update the viewer to sync with current skeleton state */
  45839. update(): void;
  45840. /** Release associated resources */
  45841. dispose(): void;
  45842. }
  45843. }
  45844. declare module "babylonjs/Debug/index" {
  45845. export * from "babylonjs/Debug/axesViewer";
  45846. export * from "babylonjs/Debug/boneAxesViewer";
  45847. export * from "babylonjs/Debug/debugLayer";
  45848. export * from "babylonjs/Debug/physicsViewer";
  45849. export * from "babylonjs/Debug/rayHelper";
  45850. export * from "babylonjs/Debug/skeletonViewer";
  45851. }
  45852. declare module "babylonjs/Engines/nullEngine" {
  45853. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45854. import { Scene } from "babylonjs/scene";
  45855. import { Engine } from "babylonjs/Engines/engine";
  45856. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45857. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45858. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45859. import { Effect } from "babylonjs/Materials/effect";
  45860. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45861. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45862. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45863. /**
  45864. * Options to create the null engine
  45865. */
  45866. export class NullEngineOptions {
  45867. /**
  45868. * Render width (Default: 512)
  45869. */
  45870. renderWidth: number;
  45871. /**
  45872. * Render height (Default: 256)
  45873. */
  45874. renderHeight: number;
  45875. /**
  45876. * Texture size (Default: 512)
  45877. */
  45878. textureSize: number;
  45879. /**
  45880. * If delta time between frames should be constant
  45881. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45882. */
  45883. deterministicLockstep: boolean;
  45884. /**
  45885. * Maximum about of steps between frames (Default: 4)
  45886. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45887. */
  45888. lockstepMaxSteps: number;
  45889. }
  45890. /**
  45891. * The null engine class provides support for headless version of babylon.js.
  45892. * This can be used in server side scenario or for testing purposes
  45893. */
  45894. export class NullEngine extends Engine {
  45895. private _options;
  45896. /**
  45897. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45898. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45899. * @returns true if engine is in deterministic lock step mode
  45900. */
  45901. isDeterministicLockStep(): boolean;
  45902. /**
  45903. * Gets the max steps when engine is running in deterministic lock step
  45904. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45905. * @returns the max steps
  45906. */
  45907. getLockstepMaxSteps(): number;
  45908. /**
  45909. * Gets the current hardware scaling level.
  45910. * By default the hardware scaling level is computed from the window device ratio.
  45911. * 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.
  45912. * @returns a number indicating the current hardware scaling level
  45913. */
  45914. getHardwareScalingLevel(): number;
  45915. constructor(options?: NullEngineOptions);
  45916. /**
  45917. * Creates a vertex buffer
  45918. * @param vertices the data for the vertex buffer
  45919. * @returns the new WebGL static buffer
  45920. */
  45921. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45922. /**
  45923. * Creates a new index buffer
  45924. * @param indices defines the content of the index buffer
  45925. * @param updatable defines if the index buffer must be updatable
  45926. * @returns a new webGL buffer
  45927. */
  45928. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45929. /**
  45930. * Clear the current render buffer or the current render target (if any is set up)
  45931. * @param color defines the color to use
  45932. * @param backBuffer defines if the back buffer must be cleared
  45933. * @param depth defines if the depth buffer must be cleared
  45934. * @param stencil defines if the stencil buffer must be cleared
  45935. */
  45936. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45937. /**
  45938. * Gets the current render width
  45939. * @param useScreen defines if screen size must be used (or the current render target if any)
  45940. * @returns a number defining the current render width
  45941. */
  45942. getRenderWidth(useScreen?: boolean): number;
  45943. /**
  45944. * Gets the current render height
  45945. * @param useScreen defines if screen size must be used (or the current render target if any)
  45946. * @returns a number defining the current render height
  45947. */
  45948. getRenderHeight(useScreen?: boolean): number;
  45949. /**
  45950. * Set the WebGL's viewport
  45951. * @param viewport defines the viewport element to be used
  45952. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45953. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45954. */
  45955. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45956. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45957. /**
  45958. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45959. * @param pipelineContext defines the pipeline context to use
  45960. * @param uniformsNames defines the list of uniform names
  45961. * @returns an array of webGL uniform locations
  45962. */
  45963. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45964. /**
  45965. * Gets the lsit of active attributes for a given webGL program
  45966. * @param pipelineContext defines the pipeline context to use
  45967. * @param attributesNames defines the list of attribute names to get
  45968. * @returns an array of indices indicating the offset of each attribute
  45969. */
  45970. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45971. /**
  45972. * Binds an effect to the webGL context
  45973. * @param effect defines the effect to bind
  45974. */
  45975. bindSamplers(effect: Effect): void;
  45976. /**
  45977. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45978. * @param effect defines the effect to activate
  45979. */
  45980. enableEffect(effect: Effect): void;
  45981. /**
  45982. * Set various states to the webGL context
  45983. * @param culling defines backface culling state
  45984. * @param zOffset defines the value to apply to zOffset (0 by default)
  45985. * @param force defines if states must be applied even if cache is up to date
  45986. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45987. */
  45988. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45989. /**
  45990. * Set the value of an uniform to an array of int32
  45991. * @param uniform defines the webGL uniform location where to store the value
  45992. * @param array defines the array of int32 to store
  45993. */
  45994. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45995. /**
  45996. * Set the value of an uniform to an array of int32 (stored as vec2)
  45997. * @param uniform defines the webGL uniform location where to store the value
  45998. * @param array defines the array of int32 to store
  45999. */
  46000. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46001. /**
  46002. * Set the value of an uniform to an array of int32 (stored as vec3)
  46003. * @param uniform defines the webGL uniform location where to store the value
  46004. * @param array defines the array of int32 to store
  46005. */
  46006. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46007. /**
  46008. * Set the value of an uniform to an array of int32 (stored as vec4)
  46009. * @param uniform defines the webGL uniform location where to store the value
  46010. * @param array defines the array of int32 to store
  46011. */
  46012. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46013. /**
  46014. * Set the value of an uniform to an array of float32
  46015. * @param uniform defines the webGL uniform location where to store the value
  46016. * @param array defines the array of float32 to store
  46017. */
  46018. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46019. /**
  46020. * Set the value of an uniform to an array of float32 (stored as vec2)
  46021. * @param uniform defines the webGL uniform location where to store the value
  46022. * @param array defines the array of float32 to store
  46023. */
  46024. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46025. /**
  46026. * Set the value of an uniform to an array of float32 (stored as vec3)
  46027. * @param uniform defines the webGL uniform location where to store the value
  46028. * @param array defines the array of float32 to store
  46029. */
  46030. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46031. /**
  46032. * Set the value of an uniform to an array of float32 (stored as vec4)
  46033. * @param uniform defines the webGL uniform location where to store the value
  46034. * @param array defines the array of float32 to store
  46035. */
  46036. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46037. /**
  46038. * Set the value of an uniform to an array of number
  46039. * @param uniform defines the webGL uniform location where to store the value
  46040. * @param array defines the array of number to store
  46041. */
  46042. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46043. /**
  46044. * Set the value of an uniform to an array of number (stored as vec2)
  46045. * @param uniform defines the webGL uniform location where to store the value
  46046. * @param array defines the array of number to store
  46047. */
  46048. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46049. /**
  46050. * Set the value of an uniform to an array of number (stored as vec3)
  46051. * @param uniform defines the webGL uniform location where to store the value
  46052. * @param array defines the array of number to store
  46053. */
  46054. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46055. /**
  46056. * Set the value of an uniform to an array of number (stored as vec4)
  46057. * @param uniform defines the webGL uniform location where to store the value
  46058. * @param array defines the array of number to store
  46059. */
  46060. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46061. /**
  46062. * Set the value of an uniform to an array of float32 (stored as matrices)
  46063. * @param uniform defines the webGL uniform location where to store the value
  46064. * @param matrices defines the array of float32 to store
  46065. */
  46066. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46067. /**
  46068. * Set the value of an uniform to a matrix (3x3)
  46069. * @param uniform defines the webGL uniform location where to store the value
  46070. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46071. */
  46072. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46073. /**
  46074. * Set the value of an uniform to a matrix (2x2)
  46075. * @param uniform defines the webGL uniform location where to store the value
  46076. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46077. */
  46078. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46079. /**
  46080. * Set the value of an uniform to a number (float)
  46081. * @param uniform defines the webGL uniform location where to store the value
  46082. * @param value defines the float number to store
  46083. */
  46084. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46085. /**
  46086. * Set the value of an uniform to a vec2
  46087. * @param uniform defines the webGL uniform location where to store the value
  46088. * @param x defines the 1st component of the value
  46089. * @param y defines the 2nd component of the value
  46090. */
  46091. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46092. /**
  46093. * Set the value of an uniform to a vec3
  46094. * @param uniform defines the webGL uniform location where to store the value
  46095. * @param x defines the 1st component of the value
  46096. * @param y defines the 2nd component of the value
  46097. * @param z defines the 3rd component of the value
  46098. */
  46099. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46100. /**
  46101. * Set the value of an uniform to a boolean
  46102. * @param uniform defines the webGL uniform location where to store the value
  46103. * @param bool defines the boolean to store
  46104. */
  46105. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46106. /**
  46107. * Set the value of an uniform to a vec4
  46108. * @param uniform defines the webGL uniform location where to store the value
  46109. * @param x defines the 1st component of the value
  46110. * @param y defines the 2nd component of the value
  46111. * @param z defines the 3rd component of the value
  46112. * @param w defines the 4th component of the value
  46113. */
  46114. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46115. /**
  46116. * Sets the current alpha mode
  46117. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46118. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46119. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46120. */
  46121. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46122. /**
  46123. * Bind webGl buffers directly to the webGL context
  46124. * @param vertexBuffers defines the vertex buffer to bind
  46125. * @param indexBuffer defines the index buffer to bind
  46126. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46127. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46128. * @param effect defines the effect associated with the vertex buffer
  46129. */
  46130. bindBuffers(vertexBuffers: {
  46131. [key: string]: VertexBuffer;
  46132. }, indexBuffer: DataBuffer, effect: Effect): void;
  46133. /**
  46134. * Force the entire cache to be cleared
  46135. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46136. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46137. */
  46138. wipeCaches(bruteForce?: boolean): void;
  46139. /**
  46140. * Send a draw order
  46141. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46142. * @param indexStart defines the starting index
  46143. * @param indexCount defines the number of index to draw
  46144. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46145. */
  46146. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46147. /**
  46148. * Draw a list of indexed primitives
  46149. * @param fillMode defines the primitive to use
  46150. * @param indexStart defines the starting index
  46151. * @param indexCount defines the number of index to draw
  46152. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46153. */
  46154. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46155. /**
  46156. * Draw a list of unindexed primitives
  46157. * @param fillMode defines the primitive to use
  46158. * @param verticesStart defines the index of first vertex to draw
  46159. * @param verticesCount defines the count of vertices to draw
  46160. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46161. */
  46162. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46163. /** @hidden */
  46164. _createTexture(): WebGLTexture;
  46165. /** @hidden */
  46166. _releaseTexture(texture: InternalTexture): void;
  46167. /**
  46168. * Usually called from Texture.ts.
  46169. * Passed information to create a WebGLTexture
  46170. * @param urlArg defines a value which contains one of the following:
  46171. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46172. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46173. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46174. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46175. * @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)
  46176. * @param scene needed for loading to the correct scene
  46177. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46178. * @param onLoad optional callback to be called upon successful completion
  46179. * @param onError optional callback to be called upon failure
  46180. * @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
  46181. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46182. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46183. * @param forcedExtension defines the extension to use to pick the right loader
  46184. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46185. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46186. */
  46187. 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;
  46188. /**
  46189. * Creates a new render target texture
  46190. * @param size defines the size of the texture
  46191. * @param options defines the options used to create the texture
  46192. * @returns a new render target texture stored in an InternalTexture
  46193. */
  46194. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46195. /**
  46196. * Update the sampling mode of a given texture
  46197. * @param samplingMode defines the required sampling mode
  46198. * @param texture defines the texture to update
  46199. */
  46200. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46201. /**
  46202. * Binds the frame buffer to the specified texture.
  46203. * @param texture The texture to render to or null for the default canvas
  46204. * @param faceIndex The face of the texture to render to in case of cube texture
  46205. * @param requiredWidth The width of the target to render to
  46206. * @param requiredHeight The height of the target to render to
  46207. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46208. * @param depthStencilTexture The depth stencil texture to use to render
  46209. * @param lodLevel defines le lod level to bind to the frame buffer
  46210. */
  46211. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46212. /**
  46213. * Unbind the current render target texture from the webGL context
  46214. * @param texture defines the render target texture to unbind
  46215. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46216. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46217. */
  46218. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46219. /**
  46220. * Creates a dynamic vertex buffer
  46221. * @param vertices the data for the dynamic vertex buffer
  46222. * @returns the new WebGL dynamic buffer
  46223. */
  46224. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46225. /**
  46226. * Update the content of a dynamic texture
  46227. * @param texture defines the texture to update
  46228. * @param canvas defines the canvas containing the source
  46229. * @param invertY defines if data must be stored with Y axis inverted
  46230. * @param premulAlpha defines if alpha is stored as premultiplied
  46231. * @param format defines the format of the data
  46232. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46233. */
  46234. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46235. /**
  46236. * Gets a boolean indicating if all created effects are ready
  46237. * @returns true if all effects are ready
  46238. */
  46239. areAllEffectsReady(): boolean;
  46240. /**
  46241. * @hidden
  46242. * Get the current error code of the webGL context
  46243. * @returns the error code
  46244. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46245. */
  46246. getError(): number;
  46247. /** @hidden */
  46248. _getUnpackAlignement(): number;
  46249. /** @hidden */
  46250. _unpackFlipY(value: boolean): void;
  46251. /**
  46252. * Update a dynamic index buffer
  46253. * @param indexBuffer defines the target index buffer
  46254. * @param indices defines the data to update
  46255. * @param offset defines the offset in the target index buffer where update should start
  46256. */
  46257. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46258. /**
  46259. * Updates a dynamic vertex buffer.
  46260. * @param vertexBuffer the vertex buffer to update
  46261. * @param vertices the data used to update the vertex buffer
  46262. * @param byteOffset the byte offset of the data (optional)
  46263. * @param byteLength the byte length of the data (optional)
  46264. */
  46265. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46266. /** @hidden */
  46267. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46268. /** @hidden */
  46269. _bindTexture(channel: number, texture: InternalTexture): void;
  46270. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46271. /**
  46272. * 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
  46273. */
  46274. releaseEffects(): void;
  46275. displayLoadingUI(): void;
  46276. hideLoadingUI(): void;
  46277. /** @hidden */
  46278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46279. /** @hidden */
  46280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46281. /** @hidden */
  46282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46283. /** @hidden */
  46284. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46285. }
  46286. }
  46287. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46288. import { Nullable, int } from "babylonjs/types";
  46289. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46290. /** @hidden */
  46291. export class _OcclusionDataStorage {
  46292. /** @hidden */
  46293. occlusionInternalRetryCounter: number;
  46294. /** @hidden */
  46295. isOcclusionQueryInProgress: boolean;
  46296. /** @hidden */
  46297. isOccluded: boolean;
  46298. /** @hidden */
  46299. occlusionRetryCount: number;
  46300. /** @hidden */
  46301. occlusionType: number;
  46302. /** @hidden */
  46303. occlusionQueryAlgorithmType: number;
  46304. }
  46305. module "babylonjs/Engines/engine" {
  46306. interface Engine {
  46307. /**
  46308. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46309. * @return the new query
  46310. */
  46311. createQuery(): WebGLQuery;
  46312. /**
  46313. * Delete and release a webGL query
  46314. * @param query defines the query to delete
  46315. * @return the current engine
  46316. */
  46317. deleteQuery(query: WebGLQuery): Engine;
  46318. /**
  46319. * Check if a given query has resolved and got its value
  46320. * @param query defines the query to check
  46321. * @returns true if the query got its value
  46322. */
  46323. isQueryResultAvailable(query: WebGLQuery): boolean;
  46324. /**
  46325. * Gets the value of a given query
  46326. * @param query defines the query to check
  46327. * @returns the value of the query
  46328. */
  46329. getQueryResult(query: WebGLQuery): number;
  46330. /**
  46331. * Initiates an occlusion query
  46332. * @param algorithmType defines the algorithm to use
  46333. * @param query defines the query to use
  46334. * @returns the current engine
  46335. * @see http://doc.babylonjs.com/features/occlusionquery
  46336. */
  46337. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46338. /**
  46339. * Ends an occlusion query
  46340. * @see http://doc.babylonjs.com/features/occlusionquery
  46341. * @param algorithmType defines the algorithm to use
  46342. * @returns the current engine
  46343. */
  46344. endOcclusionQuery(algorithmType: number): Engine;
  46345. /**
  46346. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46347. * Please note that only one query can be issued at a time
  46348. * @returns a time token used to track the time span
  46349. */
  46350. startTimeQuery(): Nullable<_TimeToken>;
  46351. /**
  46352. * Ends a time query
  46353. * @param token defines the token used to measure the time span
  46354. * @returns the time spent (in ns)
  46355. */
  46356. endTimeQuery(token: _TimeToken): int;
  46357. /** @hidden */
  46358. _currentNonTimestampToken: Nullable<_TimeToken>;
  46359. /** @hidden */
  46360. _createTimeQuery(): WebGLQuery;
  46361. /** @hidden */
  46362. _deleteTimeQuery(query: WebGLQuery): void;
  46363. /** @hidden */
  46364. _getGlAlgorithmType(algorithmType: number): number;
  46365. /** @hidden */
  46366. _getTimeQueryResult(query: WebGLQuery): any;
  46367. /** @hidden */
  46368. _getTimeQueryAvailability(query: WebGLQuery): any;
  46369. }
  46370. }
  46371. module "babylonjs/Meshes/abstractMesh" {
  46372. interface AbstractMesh {
  46373. /**
  46374. * Backing filed
  46375. * @hidden
  46376. */
  46377. __occlusionDataStorage: _OcclusionDataStorage;
  46378. /**
  46379. * Access property
  46380. * @hidden
  46381. */
  46382. _occlusionDataStorage: _OcclusionDataStorage;
  46383. /**
  46384. * 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.
  46385. * The default value is -1 which means don't break the query and wait till the result
  46386. * @see http://doc.babylonjs.com/features/occlusionquery
  46387. */
  46388. occlusionRetryCount: number;
  46389. /**
  46390. * 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:
  46391. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46392. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46393. * * 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.
  46394. * @see http://doc.babylonjs.com/features/occlusionquery
  46395. */
  46396. occlusionType: number;
  46397. /**
  46398. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46399. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46400. * * 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.
  46401. * @see http://doc.babylonjs.com/features/occlusionquery
  46402. */
  46403. occlusionQueryAlgorithmType: number;
  46404. /**
  46405. * 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
  46406. * @see http://doc.babylonjs.com/features/occlusionquery
  46407. */
  46408. isOccluded: boolean;
  46409. /**
  46410. * Flag to check the progress status of the query
  46411. * @see http://doc.babylonjs.com/features/occlusionquery
  46412. */
  46413. isOcclusionQueryInProgress: boolean;
  46414. }
  46415. }
  46416. }
  46417. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46418. import { Nullable } from "babylonjs/types";
  46419. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46420. /** @hidden */
  46421. export var _forceTransformFeedbackToBundle: boolean;
  46422. module "babylonjs/Engines/engine" {
  46423. interface Engine {
  46424. /**
  46425. * Creates a webGL transform feedback object
  46426. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46427. * @returns the webGL transform feedback object
  46428. */
  46429. createTransformFeedback(): WebGLTransformFeedback;
  46430. /**
  46431. * Delete a webGL transform feedback object
  46432. * @param value defines the webGL transform feedback object to delete
  46433. */
  46434. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46435. /**
  46436. * Bind a webGL transform feedback object to the webgl context
  46437. * @param value defines the webGL transform feedback object to bind
  46438. */
  46439. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46440. /**
  46441. * Begins a transform feedback operation
  46442. * @param usePoints defines if points or triangles must be used
  46443. */
  46444. beginTransformFeedback(usePoints: boolean): void;
  46445. /**
  46446. * Ends a transform feedback operation
  46447. */
  46448. endTransformFeedback(): void;
  46449. /**
  46450. * Specify the varyings to use with transform feedback
  46451. * @param program defines the associated webGL program
  46452. * @param value defines the list of strings representing the varying names
  46453. */
  46454. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46455. /**
  46456. * Bind a webGL buffer for a transform feedback operation
  46457. * @param value defines the webGL buffer to bind
  46458. */
  46459. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46460. }
  46461. }
  46462. }
  46463. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46464. import { Scene } from "babylonjs/scene";
  46465. import { Engine } from "babylonjs/Engines/engine";
  46466. import { Texture } from "babylonjs/Materials/Textures/texture";
  46467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46468. import "babylonjs/Engines/Extensions/engine.multiRender";
  46469. /**
  46470. * Creation options of the multi render target texture.
  46471. */
  46472. export interface IMultiRenderTargetOptions {
  46473. /**
  46474. * Define if the texture needs to create mip maps after render.
  46475. */
  46476. generateMipMaps?: boolean;
  46477. /**
  46478. * Define the types of all the draw buffers we want to create
  46479. */
  46480. types?: number[];
  46481. /**
  46482. * Define the sampling modes of all the draw buffers we want to create
  46483. */
  46484. samplingModes?: number[];
  46485. /**
  46486. * Define if a depth buffer is required
  46487. */
  46488. generateDepthBuffer?: boolean;
  46489. /**
  46490. * Define if a stencil buffer is required
  46491. */
  46492. generateStencilBuffer?: boolean;
  46493. /**
  46494. * Define if a depth texture is required instead of a depth buffer
  46495. */
  46496. generateDepthTexture?: boolean;
  46497. /**
  46498. * Define the number of desired draw buffers
  46499. */
  46500. textureCount?: number;
  46501. /**
  46502. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46503. */
  46504. doNotChangeAspectRatio?: boolean;
  46505. /**
  46506. * Define the default type of the buffers we are creating
  46507. */
  46508. defaultType?: number;
  46509. }
  46510. /**
  46511. * A multi render target, like a render target provides the ability to render to a texture.
  46512. * Unlike the render target, it can render to several draw buffers in one draw.
  46513. * This is specially interesting in deferred rendering or for any effects requiring more than
  46514. * just one color from a single pass.
  46515. */
  46516. export class MultiRenderTarget extends RenderTargetTexture {
  46517. private _internalTextures;
  46518. private _textures;
  46519. private _multiRenderTargetOptions;
  46520. /**
  46521. * Get if draw buffers are currently supported by the used hardware and browser.
  46522. */
  46523. readonly isSupported: boolean;
  46524. /**
  46525. * Get the list of textures generated by the multi render target.
  46526. */
  46527. readonly textures: Texture[];
  46528. /**
  46529. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46530. */
  46531. readonly depthTexture: Texture;
  46532. /**
  46533. * Set the wrapping mode on U of all the textures we are rendering to.
  46534. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46535. */
  46536. wrapU: number;
  46537. /**
  46538. * Set the wrapping mode on V of all the textures we are rendering to.
  46539. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46540. */
  46541. wrapV: number;
  46542. /**
  46543. * Instantiate a new multi render target texture.
  46544. * A multi render target, like a render target provides the ability to render to a texture.
  46545. * Unlike the render target, it can render to several draw buffers in one draw.
  46546. * This is specially interesting in deferred rendering or for any effects requiring more than
  46547. * just one color from a single pass.
  46548. * @param name Define the name of the texture
  46549. * @param size Define the size of the buffers to render to
  46550. * @param count Define the number of target we are rendering into
  46551. * @param scene Define the scene the texture belongs to
  46552. * @param options Define the options used to create the multi render target
  46553. */
  46554. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46555. /** @hidden */
  46556. _rebuild(): void;
  46557. private _createInternalTextures;
  46558. private _createTextures;
  46559. /**
  46560. * Define the number of samples used if MSAA is enabled.
  46561. */
  46562. samples: number;
  46563. /**
  46564. * Resize all the textures in the multi render target.
  46565. * Be carrefull as it will recreate all the data in the new texture.
  46566. * @param size Define the new size
  46567. */
  46568. resize(size: any): void;
  46569. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46570. /**
  46571. * Dispose the render targets and their associated resources
  46572. */
  46573. dispose(): void;
  46574. /**
  46575. * Release all the underlying texture used as draw buffers.
  46576. */
  46577. releaseInternalTextures(): void;
  46578. }
  46579. }
  46580. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46582. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46583. import { Nullable } from "babylonjs/types";
  46584. module "babylonjs/Engines/thinEngine" {
  46585. interface ThinEngine {
  46586. /**
  46587. * Unbind a list of render target textures from the webGL context
  46588. * This is used only when drawBuffer extension or webGL2 are active
  46589. * @param textures defines the render target textures to unbind
  46590. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46591. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46592. */
  46593. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46594. /**
  46595. * Create a multi render target texture
  46596. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46597. * @param size defines the size of the texture
  46598. * @param options defines the creation options
  46599. * @returns the cube texture as an InternalTexture
  46600. */
  46601. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46602. /**
  46603. * Update the sample count for a given multiple render target texture
  46604. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46605. * @param textures defines the textures to update
  46606. * @param samples defines the sample count to set
  46607. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46608. */
  46609. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46610. }
  46611. }
  46612. }
  46613. declare module "babylonjs/Engines/Extensions/engine.views" {
  46614. import { Camera } from "babylonjs/Cameras/camera";
  46615. import { Nullable } from "babylonjs/types";
  46616. /**
  46617. * Class used to define an additional view for the engine
  46618. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46619. */
  46620. export class EngineView {
  46621. /** Defines the canvas where to render the view */
  46622. target: HTMLCanvasElement;
  46623. /** Defines an optional camera used to render the view (will use active camera else) */
  46624. camera?: Camera;
  46625. }
  46626. module "babylonjs/Engines/engine" {
  46627. interface Engine {
  46628. /**
  46629. * Gets or sets the HTML element to use for attaching events
  46630. */
  46631. inputElement: Nullable<HTMLElement>;
  46632. /**
  46633. * Gets the current engine view
  46634. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46635. */
  46636. activeView: Nullable<EngineView>;
  46637. /** Gets or sets the list of views */
  46638. views: EngineView[];
  46639. /**
  46640. * Register a new child canvas
  46641. * @param canvas defines the canvas to register
  46642. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46643. * @returns the associated view
  46644. */
  46645. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46646. /**
  46647. * Remove a registered child canvas
  46648. * @param canvas defines the canvas to remove
  46649. * @returns the current engine
  46650. */
  46651. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46652. }
  46653. }
  46654. }
  46655. declare module "babylonjs/Engines/Extensions/index" {
  46656. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46657. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46658. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46659. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46660. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46661. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46662. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46663. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46664. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46665. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46666. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46667. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46668. export * from "babylonjs/Engines/Extensions/engine.views";
  46669. }
  46670. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46671. import { Nullable } from "babylonjs/types";
  46672. /**
  46673. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46674. */
  46675. export interface CubeMapInfo {
  46676. /**
  46677. * The pixel array for the front face.
  46678. * This is stored in format, left to right, up to down format.
  46679. */
  46680. front: Nullable<ArrayBufferView>;
  46681. /**
  46682. * The pixel array for the back face.
  46683. * This is stored in format, left to right, up to down format.
  46684. */
  46685. back: Nullable<ArrayBufferView>;
  46686. /**
  46687. * The pixel array for the left face.
  46688. * This is stored in format, left to right, up to down format.
  46689. */
  46690. left: Nullable<ArrayBufferView>;
  46691. /**
  46692. * The pixel array for the right face.
  46693. * This is stored in format, left to right, up to down format.
  46694. */
  46695. right: Nullable<ArrayBufferView>;
  46696. /**
  46697. * The pixel array for the up face.
  46698. * This is stored in format, left to right, up to down format.
  46699. */
  46700. up: Nullable<ArrayBufferView>;
  46701. /**
  46702. * The pixel array for the down face.
  46703. * This is stored in format, left to right, up to down format.
  46704. */
  46705. down: Nullable<ArrayBufferView>;
  46706. /**
  46707. * The size of the cubemap stored.
  46708. *
  46709. * Each faces will be size * size pixels.
  46710. */
  46711. size: number;
  46712. /**
  46713. * The format of the texture.
  46714. *
  46715. * RGBA, RGB.
  46716. */
  46717. format: number;
  46718. /**
  46719. * The type of the texture data.
  46720. *
  46721. * UNSIGNED_INT, FLOAT.
  46722. */
  46723. type: number;
  46724. /**
  46725. * Specifies whether the texture is in gamma space.
  46726. */
  46727. gammaSpace: boolean;
  46728. }
  46729. /**
  46730. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46731. */
  46732. export class PanoramaToCubeMapTools {
  46733. private static FACE_FRONT;
  46734. private static FACE_BACK;
  46735. private static FACE_RIGHT;
  46736. private static FACE_LEFT;
  46737. private static FACE_DOWN;
  46738. private static FACE_UP;
  46739. /**
  46740. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46741. *
  46742. * @param float32Array The source data.
  46743. * @param inputWidth The width of the input panorama.
  46744. * @param inputHeight The height of the input panorama.
  46745. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46746. * @return The cubemap data
  46747. */
  46748. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46749. private static CreateCubemapTexture;
  46750. private static CalcProjectionSpherical;
  46751. }
  46752. }
  46753. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46754. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46756. import { Nullable } from "babylonjs/types";
  46757. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46758. /**
  46759. * Helper class dealing with the extraction of spherical polynomial dataArray
  46760. * from a cube map.
  46761. */
  46762. export class CubeMapToSphericalPolynomialTools {
  46763. private static FileFaces;
  46764. /**
  46765. * Converts a texture to the according Spherical Polynomial data.
  46766. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46767. *
  46768. * @param texture The texture to extract the information from.
  46769. * @return The Spherical Polynomial data.
  46770. */
  46771. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46772. /**
  46773. * Converts a cubemap to the according Spherical Polynomial data.
  46774. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46775. *
  46776. * @param cubeInfo The Cube map to extract the information from.
  46777. * @return The Spherical Polynomial data.
  46778. */
  46779. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46780. }
  46781. }
  46782. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46783. import { Nullable } from "babylonjs/types";
  46784. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46785. module "babylonjs/Materials/Textures/baseTexture" {
  46786. interface BaseTexture {
  46787. /**
  46788. * Get the polynomial representation of the texture data.
  46789. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46790. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46791. */
  46792. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46793. }
  46794. }
  46795. }
  46796. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46797. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46798. /** @hidden */
  46799. export var rgbdEncodePixelShader: {
  46800. name: string;
  46801. shader: string;
  46802. };
  46803. }
  46804. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46806. /** @hidden */
  46807. export var rgbdDecodePixelShader: {
  46808. name: string;
  46809. shader: string;
  46810. };
  46811. }
  46812. declare module "babylonjs/Misc/environmentTextureTools" {
  46813. import { Nullable } from "babylonjs/types";
  46814. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46816. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46817. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46818. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46819. import "babylonjs/Shaders/rgbdEncode.fragment";
  46820. import "babylonjs/Shaders/rgbdDecode.fragment";
  46821. /**
  46822. * Raw texture data and descriptor sufficient for WebGL texture upload
  46823. */
  46824. export interface EnvironmentTextureInfo {
  46825. /**
  46826. * Version of the environment map
  46827. */
  46828. version: number;
  46829. /**
  46830. * Width of image
  46831. */
  46832. width: number;
  46833. /**
  46834. * Irradiance information stored in the file.
  46835. */
  46836. irradiance: any;
  46837. /**
  46838. * Specular information stored in the file.
  46839. */
  46840. specular: any;
  46841. }
  46842. /**
  46843. * Defines One Image in the file. It requires only the position in the file
  46844. * as well as the length.
  46845. */
  46846. interface BufferImageData {
  46847. /**
  46848. * Length of the image data.
  46849. */
  46850. length: number;
  46851. /**
  46852. * Position of the data from the null terminator delimiting the end of the JSON.
  46853. */
  46854. position: number;
  46855. }
  46856. /**
  46857. * Defines the specular data enclosed in the file.
  46858. * This corresponds to the version 1 of the data.
  46859. */
  46860. export interface EnvironmentTextureSpecularInfoV1 {
  46861. /**
  46862. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46863. */
  46864. specularDataPosition?: number;
  46865. /**
  46866. * This contains all the images data needed to reconstruct the cubemap.
  46867. */
  46868. mipmaps: Array<BufferImageData>;
  46869. /**
  46870. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46871. */
  46872. lodGenerationScale: number;
  46873. }
  46874. /**
  46875. * Sets of helpers addressing the serialization and deserialization of environment texture
  46876. * stored in a BabylonJS env file.
  46877. * Those files are usually stored as .env files.
  46878. */
  46879. export class EnvironmentTextureTools {
  46880. /**
  46881. * Magic number identifying the env file.
  46882. */
  46883. private static _MagicBytes;
  46884. /**
  46885. * Gets the environment info from an env file.
  46886. * @param data The array buffer containing the .env bytes.
  46887. * @returns the environment file info (the json header) if successfully parsed.
  46888. */
  46889. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46890. /**
  46891. * Creates an environment texture from a loaded cube texture.
  46892. * @param texture defines the cube texture to convert in env file
  46893. * @return a promise containing the environment data if succesfull.
  46894. */
  46895. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46896. /**
  46897. * Creates a JSON representation of the spherical data.
  46898. * @param texture defines the texture containing the polynomials
  46899. * @return the JSON representation of the spherical info
  46900. */
  46901. private static _CreateEnvTextureIrradiance;
  46902. /**
  46903. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46904. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46905. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46906. * @return the views described by info providing access to the underlying buffer
  46907. */
  46908. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46909. /**
  46910. * Uploads the texture info contained in the env file to the GPU.
  46911. * @param texture defines the internal texture to upload to
  46912. * @param arrayBuffer defines the buffer cotaining the data to load
  46913. * @param info defines the texture info retrieved through the GetEnvInfo method
  46914. * @returns a promise
  46915. */
  46916. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46917. private static _OnImageReadyAsync;
  46918. /**
  46919. * Uploads the levels of image data to the GPU.
  46920. * @param texture defines the internal texture to upload to
  46921. * @param imageData defines the array buffer views of image data [mipmap][face]
  46922. * @returns a promise
  46923. */
  46924. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46925. /**
  46926. * Uploads spherical polynomials information to the texture.
  46927. * @param texture defines the texture we are trying to upload the information to
  46928. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46929. */
  46930. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46931. /** @hidden */
  46932. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46933. }
  46934. }
  46935. declare module "babylonjs/Maths/math.vertexFormat" {
  46936. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46937. /**
  46938. * Contains position and normal vectors for a vertex
  46939. */
  46940. export class PositionNormalVertex {
  46941. /** the position of the vertex (defaut: 0,0,0) */
  46942. position: Vector3;
  46943. /** the normal of the vertex (defaut: 0,1,0) */
  46944. normal: Vector3;
  46945. /**
  46946. * Creates a PositionNormalVertex
  46947. * @param position the position of the vertex (defaut: 0,0,0)
  46948. * @param normal the normal of the vertex (defaut: 0,1,0)
  46949. */
  46950. constructor(
  46951. /** the position of the vertex (defaut: 0,0,0) */
  46952. position?: Vector3,
  46953. /** the normal of the vertex (defaut: 0,1,0) */
  46954. normal?: Vector3);
  46955. /**
  46956. * Clones the PositionNormalVertex
  46957. * @returns the cloned PositionNormalVertex
  46958. */
  46959. clone(): PositionNormalVertex;
  46960. }
  46961. /**
  46962. * Contains position, normal and uv vectors for a vertex
  46963. */
  46964. export class PositionNormalTextureVertex {
  46965. /** the position of the vertex (defaut: 0,0,0) */
  46966. position: Vector3;
  46967. /** the normal of the vertex (defaut: 0,1,0) */
  46968. normal: Vector3;
  46969. /** the uv of the vertex (default: 0,0) */
  46970. uv: Vector2;
  46971. /**
  46972. * Creates a PositionNormalTextureVertex
  46973. * @param position the position of the vertex (defaut: 0,0,0)
  46974. * @param normal the normal of the vertex (defaut: 0,1,0)
  46975. * @param uv the uv of the vertex (default: 0,0)
  46976. */
  46977. constructor(
  46978. /** the position of the vertex (defaut: 0,0,0) */
  46979. position?: Vector3,
  46980. /** the normal of the vertex (defaut: 0,1,0) */
  46981. normal?: Vector3,
  46982. /** the uv of the vertex (default: 0,0) */
  46983. uv?: Vector2);
  46984. /**
  46985. * Clones the PositionNormalTextureVertex
  46986. * @returns the cloned PositionNormalTextureVertex
  46987. */
  46988. clone(): PositionNormalTextureVertex;
  46989. }
  46990. }
  46991. declare module "babylonjs/Maths/math" {
  46992. export * from "babylonjs/Maths/math.axis";
  46993. export * from "babylonjs/Maths/math.color";
  46994. export * from "babylonjs/Maths/math.constants";
  46995. export * from "babylonjs/Maths/math.frustum";
  46996. export * from "babylonjs/Maths/math.path";
  46997. export * from "babylonjs/Maths/math.plane";
  46998. export * from "babylonjs/Maths/math.size";
  46999. export * from "babylonjs/Maths/math.vector";
  47000. export * from "babylonjs/Maths/math.vertexFormat";
  47001. export * from "babylonjs/Maths/math.viewport";
  47002. }
  47003. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47004. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47005. /** @hidden */
  47006. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47007. private _genericAttributeLocation;
  47008. private _varyingLocationCount;
  47009. private _varyingLocationMap;
  47010. private _replacements;
  47011. private _textureCount;
  47012. private _uniforms;
  47013. lineProcessor(line: string): string;
  47014. attributeProcessor(attribute: string): string;
  47015. varyingProcessor(varying: string, isFragment: boolean): string;
  47016. uniformProcessor(uniform: string): string;
  47017. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47018. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47019. }
  47020. }
  47021. declare module "babylonjs/Engines/nativeEngine" {
  47022. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47023. import { Engine } from "babylonjs/Engines/engine";
  47024. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47027. import { Effect } from "babylonjs/Materials/effect";
  47028. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47029. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47030. import { IColor4Like } from "babylonjs/Maths/math.like";
  47031. import { Scene } from "babylonjs/scene";
  47032. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47033. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47034. /**
  47035. * Container for accessors for natively-stored mesh data buffers.
  47036. */
  47037. class NativeDataBuffer extends DataBuffer {
  47038. /**
  47039. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47040. */
  47041. nativeIndexBuffer?: any;
  47042. /**
  47043. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47044. */
  47045. nativeVertexBuffer?: any;
  47046. }
  47047. /** @hidden */
  47048. class NativeTexture extends InternalTexture {
  47049. getInternalTexture(): InternalTexture;
  47050. getViewCount(): number;
  47051. }
  47052. /** @hidden */
  47053. export class NativeEngine extends Engine {
  47054. private readonly _native;
  47055. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47056. private readonly INVALID_HANDLE;
  47057. getHardwareScalingLevel(): number;
  47058. constructor();
  47059. /**
  47060. * Can be used to override the current requestAnimationFrame requester.
  47061. * @hidden
  47062. */
  47063. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47064. /**
  47065. * Override default engine behavior.
  47066. * @param color
  47067. * @param backBuffer
  47068. * @param depth
  47069. * @param stencil
  47070. */
  47071. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47072. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47073. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47074. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47075. recordVertexArrayObject(vertexBuffers: {
  47076. [key: string]: VertexBuffer;
  47077. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47078. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47079. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47080. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47081. /**
  47082. * Draw a list of indexed primitives
  47083. * @param fillMode defines the primitive to use
  47084. * @param indexStart defines the starting index
  47085. * @param indexCount defines the number of index to draw
  47086. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47087. */
  47088. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47089. /**
  47090. * Draw a list of unindexed primitives
  47091. * @param fillMode defines the primitive to use
  47092. * @param verticesStart defines the index of first vertex to draw
  47093. * @param verticesCount defines the count of vertices to draw
  47094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47095. */
  47096. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47097. createPipelineContext(): IPipelineContext;
  47098. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47099. /** @hidden */
  47100. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47101. /** @hidden */
  47102. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47103. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47104. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47105. protected _setProgram(program: WebGLProgram): void;
  47106. _releaseEffect(effect: Effect): void;
  47107. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47108. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47109. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47110. bindSamplers(effect: Effect): void;
  47111. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47112. getRenderWidth(useScreen?: boolean): number;
  47113. getRenderHeight(useScreen?: boolean): number;
  47114. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47115. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47116. /**
  47117. * Set the z offset to apply to current rendering
  47118. * @param value defines the offset to apply
  47119. */
  47120. setZOffset(value: number): void;
  47121. /**
  47122. * Gets the current value of the zOffset
  47123. * @returns the current zOffset state
  47124. */
  47125. getZOffset(): number;
  47126. /**
  47127. * Enable or disable depth buffering
  47128. * @param enable defines the state to set
  47129. */
  47130. setDepthBuffer(enable: boolean): void;
  47131. /**
  47132. * Gets a boolean indicating if depth writing is enabled
  47133. * @returns the current depth writing state
  47134. */
  47135. getDepthWrite(): boolean;
  47136. /**
  47137. * Enable or disable depth writing
  47138. * @param enable defines the state to set
  47139. */
  47140. setDepthWrite(enable: boolean): void;
  47141. /**
  47142. * Enable or disable color writing
  47143. * @param enable defines the state to set
  47144. */
  47145. setColorWrite(enable: boolean): void;
  47146. /**
  47147. * Gets a boolean indicating if color writing is enabled
  47148. * @returns the current color writing state
  47149. */
  47150. getColorWrite(): boolean;
  47151. /**
  47152. * Sets alpha constants used by some alpha blending modes
  47153. * @param r defines the red component
  47154. * @param g defines the green component
  47155. * @param b defines the blue component
  47156. * @param a defines the alpha component
  47157. */
  47158. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47159. /**
  47160. * Sets the current alpha mode
  47161. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47162. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47164. */
  47165. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47166. /**
  47167. * Gets the current alpha mode
  47168. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47169. * @returns the current alpha mode
  47170. */
  47171. getAlphaMode(): number;
  47172. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47173. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47174. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47175. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47176. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47177. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47178. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47179. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47180. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47181. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47182. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47183. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47184. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47185. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47186. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47187. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47188. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47189. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47190. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47191. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47192. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47193. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47194. wipeCaches(bruteForce?: boolean): void;
  47195. _createTexture(): WebGLTexture;
  47196. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47197. /**
  47198. * Usually called from BABYLON.Texture.ts.
  47199. * Passed information to create a WebGLTexture
  47200. * @param urlArg defines a value which contains one of the following:
  47201. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47202. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47203. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47204. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47205. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47206. * @param scene needed for loading to the correct scene
  47207. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47208. * @param onLoad optional callback to be called upon successful completion
  47209. * @param onError optional callback to be called upon failure
  47210. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47211. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47212. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47213. * @param forcedExtension defines the extension to use to pick the right loader
  47214. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47215. */
  47216. 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;
  47217. /**
  47218. * Creates a cube texture
  47219. * @param rootUrl defines the url where the files to load is located
  47220. * @param scene defines the current scene
  47221. * @param files defines the list of files to load (1 per face)
  47222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47223. * @param onLoad defines an optional callback raised when the texture is loaded
  47224. * @param onError defines an optional callback raised if there is an issue to load the texture
  47225. * @param format defines the format of the data
  47226. * @param forcedExtension defines the extension to use to pick the right loader
  47227. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47228. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47229. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47230. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47231. * @returns the cube texture as an InternalTexture
  47232. */
  47233. 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;
  47234. private _getSamplingFilter;
  47235. private static _GetNativeTextureFormat;
  47236. createRenderTargetTexture(size: number | {
  47237. width: number;
  47238. height: number;
  47239. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47240. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47241. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47242. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47243. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47244. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47245. /**
  47246. * Updates a dynamic vertex buffer.
  47247. * @param vertexBuffer the vertex buffer to update
  47248. * @param data the data used to update the vertex buffer
  47249. * @param byteOffset the byte offset of the data (optional)
  47250. * @param byteLength the byte length of the data (optional)
  47251. */
  47252. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47253. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47254. private _updateAnisotropicLevel;
  47255. private _getAddressMode;
  47256. /** @hidden */
  47257. _bindTexture(channel: number, texture: InternalTexture): void;
  47258. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47259. releaseEffects(): void;
  47260. /** @hidden */
  47261. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47262. /** @hidden */
  47263. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47264. /** @hidden */
  47265. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47266. /** @hidden */
  47267. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47268. }
  47269. }
  47270. declare module "babylonjs/Engines/index" {
  47271. export * from "babylonjs/Engines/constants";
  47272. export * from "babylonjs/Engines/engineCapabilities";
  47273. export * from "babylonjs/Engines/instancingAttributeInfo";
  47274. export * from "babylonjs/Engines/thinEngine";
  47275. export * from "babylonjs/Engines/engine";
  47276. export * from "babylonjs/Engines/engineStore";
  47277. export * from "babylonjs/Engines/nullEngine";
  47278. export * from "babylonjs/Engines/Extensions/index";
  47279. export * from "babylonjs/Engines/IPipelineContext";
  47280. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47281. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47282. export * from "babylonjs/Engines/nativeEngine";
  47283. }
  47284. declare module "babylonjs/Events/clipboardEvents" {
  47285. /**
  47286. * Gather the list of clipboard event types as constants.
  47287. */
  47288. export class ClipboardEventTypes {
  47289. /**
  47290. * The clipboard event is fired when a copy command is active (pressed).
  47291. */
  47292. static readonly COPY: number;
  47293. /**
  47294. * The clipboard event is fired when a cut command is active (pressed).
  47295. */
  47296. static readonly CUT: number;
  47297. /**
  47298. * The clipboard event is fired when a paste command is active (pressed).
  47299. */
  47300. static readonly PASTE: number;
  47301. }
  47302. /**
  47303. * This class is used to store clipboard related info for the onClipboardObservable event.
  47304. */
  47305. export class ClipboardInfo {
  47306. /**
  47307. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47308. */
  47309. type: number;
  47310. /**
  47311. * Defines the related dom event
  47312. */
  47313. event: ClipboardEvent;
  47314. /**
  47315. *Creates an instance of ClipboardInfo.
  47316. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47317. * @param event Defines the related dom event
  47318. */
  47319. constructor(
  47320. /**
  47321. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47322. */
  47323. type: number,
  47324. /**
  47325. * Defines the related dom event
  47326. */
  47327. event: ClipboardEvent);
  47328. /**
  47329. * Get the clipboard event's type from the keycode.
  47330. * @param keyCode Defines the keyCode for the current keyboard event.
  47331. * @return {number}
  47332. */
  47333. static GetTypeFromCharacter(keyCode: number): number;
  47334. }
  47335. }
  47336. declare module "babylonjs/Events/index" {
  47337. export * from "babylonjs/Events/keyboardEvents";
  47338. export * from "babylonjs/Events/pointerEvents";
  47339. export * from "babylonjs/Events/clipboardEvents";
  47340. }
  47341. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47342. import { Scene } from "babylonjs/scene";
  47343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47344. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47345. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47346. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47347. /**
  47348. * Google Daydream controller
  47349. */
  47350. export class DaydreamController extends WebVRController {
  47351. /**
  47352. * Base Url for the controller model.
  47353. */
  47354. static MODEL_BASE_URL: string;
  47355. /**
  47356. * File name for the controller model.
  47357. */
  47358. static MODEL_FILENAME: string;
  47359. /**
  47360. * Gamepad Id prefix used to identify Daydream Controller.
  47361. */
  47362. static readonly GAMEPAD_ID_PREFIX: string;
  47363. /**
  47364. * Creates a new DaydreamController from a gamepad
  47365. * @param vrGamepad the gamepad that the controller should be created from
  47366. */
  47367. constructor(vrGamepad: any);
  47368. /**
  47369. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47370. * @param scene scene in which to add meshes
  47371. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47372. */
  47373. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47374. /**
  47375. * Called once for each button that changed state since the last frame
  47376. * @param buttonIdx Which button index changed
  47377. * @param state New state of the button
  47378. * @param changes Which properties on the state changed since last frame
  47379. */
  47380. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47381. }
  47382. }
  47383. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47384. import { Scene } from "babylonjs/scene";
  47385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47386. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47387. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47388. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47389. /**
  47390. * Gear VR Controller
  47391. */
  47392. export class GearVRController extends WebVRController {
  47393. /**
  47394. * Base Url for the controller model.
  47395. */
  47396. static MODEL_BASE_URL: string;
  47397. /**
  47398. * File name for the controller model.
  47399. */
  47400. static MODEL_FILENAME: string;
  47401. /**
  47402. * Gamepad Id prefix used to identify this controller.
  47403. */
  47404. static readonly GAMEPAD_ID_PREFIX: string;
  47405. private readonly _buttonIndexToObservableNameMap;
  47406. /**
  47407. * Creates a new GearVRController from a gamepad
  47408. * @param vrGamepad the gamepad that the controller should be created from
  47409. */
  47410. constructor(vrGamepad: any);
  47411. /**
  47412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47413. * @param scene scene in which to add meshes
  47414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47415. */
  47416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47417. /**
  47418. * Called once for each button that changed state since the last frame
  47419. * @param buttonIdx Which button index changed
  47420. * @param state New state of the button
  47421. * @param changes Which properties on the state changed since last frame
  47422. */
  47423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47424. }
  47425. }
  47426. declare module "babylonjs/Gamepads/Controllers/index" {
  47427. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47428. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47429. export * from "babylonjs/Gamepads/Controllers/genericController";
  47430. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47431. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47432. export * from "babylonjs/Gamepads/Controllers/viveController";
  47433. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47434. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47435. }
  47436. declare module "babylonjs/Gamepads/index" {
  47437. export * from "babylonjs/Gamepads/Controllers/index";
  47438. export * from "babylonjs/Gamepads/gamepad";
  47439. export * from "babylonjs/Gamepads/gamepadManager";
  47440. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47441. export * from "babylonjs/Gamepads/xboxGamepad";
  47442. export * from "babylonjs/Gamepads/dualShockGamepad";
  47443. }
  47444. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47445. import { Scene } from "babylonjs/scene";
  47446. import { Vector4 } from "babylonjs/Maths/math.vector";
  47447. import { Color4 } from "babylonjs/Maths/math.color";
  47448. import { Mesh } from "babylonjs/Meshes/mesh";
  47449. import { Nullable } from "babylonjs/types";
  47450. /**
  47451. * Class containing static functions to help procedurally build meshes
  47452. */
  47453. export class PolyhedronBuilder {
  47454. /**
  47455. * Creates a polyhedron mesh
  47456. * * 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
  47457. * * The parameter `size` (positive float, default 1) sets the polygon size
  47458. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47459. * * 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`
  47460. * * 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
  47461. * * 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)`)
  47462. * * 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
  47463. * * 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
  47464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47467. * @param name defines the name of the mesh
  47468. * @param options defines the options used to create the mesh
  47469. * @param scene defines the hosting scene
  47470. * @returns the polyhedron mesh
  47471. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47472. */
  47473. static CreatePolyhedron(name: string, options: {
  47474. type?: number;
  47475. size?: number;
  47476. sizeX?: number;
  47477. sizeY?: number;
  47478. sizeZ?: number;
  47479. custom?: any;
  47480. faceUV?: Vector4[];
  47481. faceColors?: Color4[];
  47482. flat?: boolean;
  47483. updatable?: boolean;
  47484. sideOrientation?: number;
  47485. frontUVs?: Vector4;
  47486. backUVs?: Vector4;
  47487. }, scene?: Nullable<Scene>): Mesh;
  47488. }
  47489. }
  47490. declare module "babylonjs/Gizmos/scaleGizmo" {
  47491. import { Observable } from "babylonjs/Misc/observable";
  47492. import { Nullable } from "babylonjs/types";
  47493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47494. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47495. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47497. /**
  47498. * Gizmo that enables scaling a mesh along 3 axis
  47499. */
  47500. export class ScaleGizmo extends Gizmo {
  47501. /**
  47502. * Internal gizmo used for interactions on the x axis
  47503. */
  47504. xGizmo: AxisScaleGizmo;
  47505. /**
  47506. * Internal gizmo used for interactions on the y axis
  47507. */
  47508. yGizmo: AxisScaleGizmo;
  47509. /**
  47510. * Internal gizmo used for interactions on the z axis
  47511. */
  47512. zGizmo: AxisScaleGizmo;
  47513. /**
  47514. * Internal gizmo used to scale all axis equally
  47515. */
  47516. uniformScaleGizmo: AxisScaleGizmo;
  47517. private _meshAttached;
  47518. private _updateGizmoRotationToMatchAttachedMesh;
  47519. private _snapDistance;
  47520. private _scaleRatio;
  47521. private _uniformScalingMesh;
  47522. private _octahedron;
  47523. /** Fires an event when any of it's sub gizmos are dragged */
  47524. onDragStartObservable: Observable<unknown>;
  47525. /** Fires an event when any of it's sub gizmos are released from dragging */
  47526. onDragEndObservable: Observable<unknown>;
  47527. attachedMesh: Nullable<AbstractMesh>;
  47528. /**
  47529. * Creates a ScaleGizmo
  47530. * @param gizmoLayer The utility layer the gizmo will be added to
  47531. */
  47532. constructor(gizmoLayer?: UtilityLayerRenderer);
  47533. updateGizmoRotationToMatchAttachedMesh: boolean;
  47534. /**
  47535. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47536. */
  47537. snapDistance: number;
  47538. /**
  47539. * Ratio for the scale of the gizmo (Default: 1)
  47540. */
  47541. scaleRatio: number;
  47542. /**
  47543. * Disposes of the gizmo
  47544. */
  47545. dispose(): void;
  47546. }
  47547. }
  47548. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47549. import { Observable } from "babylonjs/Misc/observable";
  47550. import { Nullable } from "babylonjs/types";
  47551. import { Vector3 } from "babylonjs/Maths/math.vector";
  47552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47553. import { Mesh } from "babylonjs/Meshes/mesh";
  47554. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47555. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47556. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47557. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47558. import { Color3 } from "babylonjs/Maths/math.color";
  47559. /**
  47560. * Single axis scale gizmo
  47561. */
  47562. export class AxisScaleGizmo extends Gizmo {
  47563. /**
  47564. * Drag behavior responsible for the gizmos dragging interactions
  47565. */
  47566. dragBehavior: PointerDragBehavior;
  47567. private _pointerObserver;
  47568. /**
  47569. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47570. */
  47571. snapDistance: number;
  47572. /**
  47573. * Event that fires each time the gizmo snaps to a new location.
  47574. * * snapDistance is the the change in distance
  47575. */
  47576. onSnapObservable: Observable<{
  47577. snapDistance: number;
  47578. }>;
  47579. /**
  47580. * If the scaling operation should be done on all axis (default: false)
  47581. */
  47582. uniformScaling: boolean;
  47583. private _isEnabled;
  47584. private _parent;
  47585. private _arrow;
  47586. private _coloredMaterial;
  47587. private _hoverMaterial;
  47588. /**
  47589. * Creates an AxisScaleGizmo
  47590. * @param gizmoLayer The utility layer the gizmo will be added to
  47591. * @param dragAxis The axis which the gizmo will be able to scale on
  47592. * @param color The color of the gizmo
  47593. */
  47594. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47595. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47596. /**
  47597. * If the gizmo is enabled
  47598. */
  47599. isEnabled: boolean;
  47600. /**
  47601. * Disposes of the gizmo
  47602. */
  47603. dispose(): void;
  47604. /**
  47605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47606. * @param mesh The mesh to replace the default mesh of the gizmo
  47607. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47608. */
  47609. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47610. }
  47611. }
  47612. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47613. import { Observable } from "babylonjs/Misc/observable";
  47614. import { Nullable } from "babylonjs/types";
  47615. import { Vector3 } from "babylonjs/Maths/math.vector";
  47616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47617. import { Mesh } from "babylonjs/Meshes/mesh";
  47618. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47619. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47620. import { Color3 } from "babylonjs/Maths/math.color";
  47621. import "babylonjs/Meshes/Builders/boxBuilder";
  47622. /**
  47623. * Bounding box gizmo
  47624. */
  47625. export class BoundingBoxGizmo extends Gizmo {
  47626. private _lineBoundingBox;
  47627. private _rotateSpheresParent;
  47628. private _scaleBoxesParent;
  47629. private _boundingDimensions;
  47630. private _renderObserver;
  47631. private _pointerObserver;
  47632. private _scaleDragSpeed;
  47633. private _tmpQuaternion;
  47634. private _tmpVector;
  47635. private _tmpRotationMatrix;
  47636. /**
  47637. * 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)
  47638. */
  47639. ignoreChildren: boolean;
  47640. /**
  47641. * 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)
  47642. */
  47643. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47644. /**
  47645. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47646. */
  47647. rotationSphereSize: number;
  47648. /**
  47649. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47650. */
  47651. scaleBoxSize: number;
  47652. /**
  47653. * 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)
  47654. */
  47655. fixedDragMeshScreenSize: boolean;
  47656. /**
  47657. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47658. */
  47659. fixedDragMeshScreenSizeDistanceFactor: number;
  47660. /**
  47661. * Fired when a rotation sphere or scale box is dragged
  47662. */
  47663. onDragStartObservable: Observable<{}>;
  47664. /**
  47665. * Fired when a scale box is dragged
  47666. */
  47667. onScaleBoxDragObservable: Observable<{}>;
  47668. /**
  47669. * Fired when a scale box drag is ended
  47670. */
  47671. onScaleBoxDragEndObservable: Observable<{}>;
  47672. /**
  47673. * Fired when a rotation sphere is dragged
  47674. */
  47675. onRotationSphereDragObservable: Observable<{}>;
  47676. /**
  47677. * Fired when a rotation sphere drag is ended
  47678. */
  47679. onRotationSphereDragEndObservable: Observable<{}>;
  47680. /**
  47681. * 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)
  47682. */
  47683. scalePivot: Nullable<Vector3>;
  47684. /**
  47685. * Mesh used as a pivot to rotate the attached mesh
  47686. */
  47687. private _anchorMesh;
  47688. private _existingMeshScale;
  47689. private _dragMesh;
  47690. private pointerDragBehavior;
  47691. private coloredMaterial;
  47692. private hoverColoredMaterial;
  47693. /**
  47694. * Sets the color of the bounding box gizmo
  47695. * @param color the color to set
  47696. */
  47697. setColor(color: Color3): void;
  47698. /**
  47699. * Creates an BoundingBoxGizmo
  47700. * @param gizmoLayer The utility layer the gizmo will be added to
  47701. * @param color The color of the gizmo
  47702. */
  47703. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47704. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47705. private _selectNode;
  47706. /**
  47707. * Updates the bounding box information for the Gizmo
  47708. */
  47709. updateBoundingBox(): void;
  47710. private _updateRotationSpheres;
  47711. private _updateScaleBoxes;
  47712. /**
  47713. * Enables rotation on the specified axis and disables rotation on the others
  47714. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47715. */
  47716. setEnabledRotationAxis(axis: string): void;
  47717. /**
  47718. * Enables/disables scaling
  47719. * @param enable if scaling should be enabled
  47720. */
  47721. setEnabledScaling(enable: boolean): void;
  47722. private _updateDummy;
  47723. /**
  47724. * Enables a pointer drag behavior on the bounding box of the gizmo
  47725. */
  47726. enableDragBehavior(): void;
  47727. /**
  47728. * Disposes of the gizmo
  47729. */
  47730. dispose(): void;
  47731. /**
  47732. * 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)
  47733. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47734. * @returns the bounding box mesh with the passed in mesh as a child
  47735. */
  47736. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47737. /**
  47738. * CustomMeshes are not supported by this gizmo
  47739. * @param mesh The mesh to replace the default mesh of the gizmo
  47740. */
  47741. setCustomMesh(mesh: Mesh): void;
  47742. }
  47743. }
  47744. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47745. import { Observable } from "babylonjs/Misc/observable";
  47746. import { Nullable } from "babylonjs/types";
  47747. import { Vector3 } from "babylonjs/Maths/math.vector";
  47748. import { Color3 } from "babylonjs/Maths/math.color";
  47749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47750. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47751. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47752. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47753. import "babylonjs/Meshes/Builders/linesBuilder";
  47754. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47755. /**
  47756. * Single plane rotation gizmo
  47757. */
  47758. export class PlaneRotationGizmo extends Gizmo {
  47759. /**
  47760. * Drag behavior responsible for the gizmos dragging interactions
  47761. */
  47762. dragBehavior: PointerDragBehavior;
  47763. private _pointerObserver;
  47764. /**
  47765. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47766. */
  47767. snapDistance: number;
  47768. /**
  47769. * Event that fires each time the gizmo snaps to a new location.
  47770. * * snapDistance is the the change in distance
  47771. */
  47772. onSnapObservable: Observable<{
  47773. snapDistance: number;
  47774. }>;
  47775. private _isEnabled;
  47776. private _parent;
  47777. /**
  47778. * Creates a PlaneRotationGizmo
  47779. * @param gizmoLayer The utility layer the gizmo will be added to
  47780. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47781. * @param color The color of the gizmo
  47782. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47783. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47784. */
  47785. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47786. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47787. /**
  47788. * If the gizmo is enabled
  47789. */
  47790. isEnabled: boolean;
  47791. /**
  47792. * Disposes of the gizmo
  47793. */
  47794. dispose(): void;
  47795. }
  47796. }
  47797. declare module "babylonjs/Gizmos/rotationGizmo" {
  47798. import { Observable } from "babylonjs/Misc/observable";
  47799. import { Nullable } from "babylonjs/types";
  47800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47801. import { Mesh } from "babylonjs/Meshes/mesh";
  47802. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47803. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47804. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47805. /**
  47806. * Gizmo that enables rotating a mesh along 3 axis
  47807. */
  47808. export class RotationGizmo extends Gizmo {
  47809. /**
  47810. * Internal gizmo used for interactions on the x axis
  47811. */
  47812. xGizmo: PlaneRotationGizmo;
  47813. /**
  47814. * Internal gizmo used for interactions on the y axis
  47815. */
  47816. yGizmo: PlaneRotationGizmo;
  47817. /**
  47818. * Internal gizmo used for interactions on the z axis
  47819. */
  47820. zGizmo: PlaneRotationGizmo;
  47821. /** Fires an event when any of it's sub gizmos are dragged */
  47822. onDragStartObservable: Observable<unknown>;
  47823. /** Fires an event when any of it's sub gizmos are released from dragging */
  47824. onDragEndObservable: Observable<unknown>;
  47825. private _meshAttached;
  47826. attachedMesh: Nullable<AbstractMesh>;
  47827. /**
  47828. * Creates a RotationGizmo
  47829. * @param gizmoLayer The utility layer the gizmo will be added to
  47830. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47831. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47832. */
  47833. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47834. updateGizmoRotationToMatchAttachedMesh: boolean;
  47835. /**
  47836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47837. */
  47838. snapDistance: number;
  47839. /**
  47840. * Ratio for the scale of the gizmo (Default: 1)
  47841. */
  47842. scaleRatio: number;
  47843. /**
  47844. * Disposes of the gizmo
  47845. */
  47846. dispose(): void;
  47847. /**
  47848. * CustomMeshes are not supported by this gizmo
  47849. * @param mesh The mesh to replace the default mesh of the gizmo
  47850. */
  47851. setCustomMesh(mesh: Mesh): void;
  47852. }
  47853. }
  47854. declare module "babylonjs/Gizmos/gizmoManager" {
  47855. import { Observable } from "babylonjs/Misc/observable";
  47856. import { Nullable } from "babylonjs/types";
  47857. import { Scene, IDisposable } from "babylonjs/scene";
  47858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47859. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47860. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47861. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47862. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47863. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47864. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47865. /**
  47866. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47867. */
  47868. export class GizmoManager implements IDisposable {
  47869. private scene;
  47870. /**
  47871. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47872. */
  47873. gizmos: {
  47874. positionGizmo: Nullable<PositionGizmo>;
  47875. rotationGizmo: Nullable<RotationGizmo>;
  47876. scaleGizmo: Nullable<ScaleGizmo>;
  47877. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47878. };
  47879. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47880. clearGizmoOnEmptyPointerEvent: boolean;
  47881. /** Fires an event when the manager is attached to a mesh */
  47882. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47883. private _gizmosEnabled;
  47884. private _pointerObserver;
  47885. private _attachedMesh;
  47886. private _boundingBoxColor;
  47887. private _defaultUtilityLayer;
  47888. private _defaultKeepDepthUtilityLayer;
  47889. /**
  47890. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47891. */
  47892. boundingBoxDragBehavior: SixDofDragBehavior;
  47893. /**
  47894. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47895. */
  47896. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47897. /**
  47898. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47899. */
  47900. usePointerToAttachGizmos: boolean;
  47901. /**
  47902. * Utility layer that the bounding box gizmo belongs to
  47903. */
  47904. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47905. /**
  47906. * Utility layer that all gizmos besides bounding box belong to
  47907. */
  47908. readonly utilityLayer: UtilityLayerRenderer;
  47909. /**
  47910. * Instatiates a gizmo manager
  47911. * @param scene the scene to overlay the gizmos on top of
  47912. */
  47913. constructor(scene: Scene);
  47914. /**
  47915. * Attaches a set of gizmos to the specified mesh
  47916. * @param mesh The mesh the gizmo's should be attached to
  47917. */
  47918. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47919. /**
  47920. * If the position gizmo is enabled
  47921. */
  47922. positionGizmoEnabled: boolean;
  47923. /**
  47924. * If the rotation gizmo is enabled
  47925. */
  47926. rotationGizmoEnabled: boolean;
  47927. /**
  47928. * If the scale gizmo is enabled
  47929. */
  47930. scaleGizmoEnabled: boolean;
  47931. /**
  47932. * If the boundingBox gizmo is enabled
  47933. */
  47934. boundingBoxGizmoEnabled: boolean;
  47935. /**
  47936. * Disposes of the gizmo manager
  47937. */
  47938. dispose(): void;
  47939. }
  47940. }
  47941. declare module "babylonjs/Lights/directionalLight" {
  47942. import { Camera } from "babylonjs/Cameras/camera";
  47943. import { Scene } from "babylonjs/scene";
  47944. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47946. import { Light } from "babylonjs/Lights/light";
  47947. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47948. import { Effect } from "babylonjs/Materials/effect";
  47949. /**
  47950. * A directional light is defined by a direction (what a surprise!).
  47951. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47952. * 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.
  47953. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47954. */
  47955. export class DirectionalLight extends ShadowLight {
  47956. private _shadowFrustumSize;
  47957. /**
  47958. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47959. */
  47960. /**
  47961. * Specifies a fix frustum size for the shadow generation.
  47962. */
  47963. shadowFrustumSize: number;
  47964. private _shadowOrthoScale;
  47965. /**
  47966. * Gets the shadow projection scale against the optimal computed one.
  47967. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47968. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47969. */
  47970. /**
  47971. * Sets the shadow projection scale against the optimal computed one.
  47972. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47973. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47974. */
  47975. shadowOrthoScale: number;
  47976. /**
  47977. * Automatically compute the projection matrix to best fit (including all the casters)
  47978. * on each frame.
  47979. */
  47980. autoUpdateExtends: boolean;
  47981. private _orthoLeft;
  47982. private _orthoRight;
  47983. private _orthoTop;
  47984. private _orthoBottom;
  47985. /**
  47986. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47987. * The directional light is emitted from everywhere in the given direction.
  47988. * It can cast shadows.
  47989. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47990. * @param name The friendly name of the light
  47991. * @param direction The direction of the light
  47992. * @param scene The scene the light belongs to
  47993. */
  47994. constructor(name: string, direction: Vector3, scene: Scene);
  47995. /**
  47996. * Returns the string "DirectionalLight".
  47997. * @return The class name
  47998. */
  47999. getClassName(): string;
  48000. /**
  48001. * Returns the integer 1.
  48002. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48003. */
  48004. getTypeID(): number;
  48005. /**
  48006. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48007. * Returns the DirectionalLight Shadow projection matrix.
  48008. */
  48009. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48010. /**
  48011. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48012. * Returns the DirectionalLight Shadow projection matrix.
  48013. */
  48014. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48015. /**
  48016. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48017. * Returns the DirectionalLight Shadow projection matrix.
  48018. */
  48019. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48020. protected _buildUniformLayout(): void;
  48021. /**
  48022. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48023. * @param effect The effect to update
  48024. * @param lightIndex The index of the light in the effect to update
  48025. * @returns The directional light
  48026. */
  48027. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48028. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48029. /**
  48030. * Gets the minZ used for shadow according to both the scene and the light.
  48031. *
  48032. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48033. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48034. * @param activeCamera The camera we are returning the min for
  48035. * @returns the depth min z
  48036. */
  48037. getDepthMinZ(activeCamera: Camera): number;
  48038. /**
  48039. * Gets the maxZ used for shadow according to both the scene and the light.
  48040. *
  48041. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48042. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48043. * @param activeCamera The camera we are returning the max for
  48044. * @returns the depth max z
  48045. */
  48046. getDepthMaxZ(activeCamera: Camera): number;
  48047. /**
  48048. * Prepares the list of defines specific to the light type.
  48049. * @param defines the list of defines
  48050. * @param lightIndex defines the index of the light for the effect
  48051. */
  48052. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48053. }
  48054. }
  48055. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48056. import { Mesh } from "babylonjs/Meshes/mesh";
  48057. /**
  48058. * Class containing static functions to help procedurally build meshes
  48059. */
  48060. export class HemisphereBuilder {
  48061. /**
  48062. * Creates a hemisphere mesh
  48063. * @param name defines the name of the mesh
  48064. * @param options defines the options used to create the mesh
  48065. * @param scene defines the hosting scene
  48066. * @returns the hemisphere mesh
  48067. */
  48068. static CreateHemisphere(name: string, options: {
  48069. segments?: number;
  48070. diameter?: number;
  48071. sideOrientation?: number;
  48072. }, scene: any): Mesh;
  48073. }
  48074. }
  48075. declare module "babylonjs/Lights/spotLight" {
  48076. import { Nullable } from "babylonjs/types";
  48077. import { Scene } from "babylonjs/scene";
  48078. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48080. import { Effect } from "babylonjs/Materials/effect";
  48081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48082. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48083. /**
  48084. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48085. * These values define a cone of light starting from the position, emitting toward the direction.
  48086. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48087. * and the exponent defines the speed of the decay of the light with distance (reach).
  48088. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48089. */
  48090. export class SpotLight extends ShadowLight {
  48091. private _angle;
  48092. private _innerAngle;
  48093. private _cosHalfAngle;
  48094. private _lightAngleScale;
  48095. private _lightAngleOffset;
  48096. /**
  48097. * Gets the cone angle of the spot light in Radians.
  48098. */
  48099. /**
  48100. * Sets the cone angle of the spot light in Radians.
  48101. */
  48102. angle: number;
  48103. /**
  48104. * Only used in gltf falloff mode, this defines the angle where
  48105. * the directional falloff will start before cutting at angle which could be seen
  48106. * as outer angle.
  48107. */
  48108. /**
  48109. * Only used in gltf falloff mode, this defines the angle where
  48110. * the directional falloff will start before cutting at angle which could be seen
  48111. * as outer angle.
  48112. */
  48113. innerAngle: number;
  48114. private _shadowAngleScale;
  48115. /**
  48116. * Allows scaling the angle of the light for shadow generation only.
  48117. */
  48118. /**
  48119. * Allows scaling the angle of the light for shadow generation only.
  48120. */
  48121. shadowAngleScale: number;
  48122. /**
  48123. * The light decay speed with the distance from the emission spot.
  48124. */
  48125. exponent: number;
  48126. private _projectionTextureMatrix;
  48127. /**
  48128. * Allows reading the projecton texture
  48129. */
  48130. readonly projectionTextureMatrix: Matrix;
  48131. protected _projectionTextureLightNear: number;
  48132. /**
  48133. * Gets the near clip of the Spotlight for texture projection.
  48134. */
  48135. /**
  48136. * Sets the near clip of the Spotlight for texture projection.
  48137. */
  48138. projectionTextureLightNear: number;
  48139. protected _projectionTextureLightFar: number;
  48140. /**
  48141. * Gets the far clip of the Spotlight for texture projection.
  48142. */
  48143. /**
  48144. * Sets the far clip of the Spotlight for texture projection.
  48145. */
  48146. projectionTextureLightFar: number;
  48147. protected _projectionTextureUpDirection: Vector3;
  48148. /**
  48149. * Gets the Up vector of the Spotlight for texture projection.
  48150. */
  48151. /**
  48152. * Sets the Up vector of the Spotlight for texture projection.
  48153. */
  48154. projectionTextureUpDirection: Vector3;
  48155. private _projectionTexture;
  48156. /**
  48157. * Gets the projection texture of the light.
  48158. */
  48159. /**
  48160. * Sets the projection texture of the light.
  48161. */
  48162. projectionTexture: Nullable<BaseTexture>;
  48163. private _projectionTextureViewLightDirty;
  48164. private _projectionTextureProjectionLightDirty;
  48165. private _projectionTextureDirty;
  48166. private _projectionTextureViewTargetVector;
  48167. private _projectionTextureViewLightMatrix;
  48168. private _projectionTextureProjectionLightMatrix;
  48169. private _projectionTextureScalingMatrix;
  48170. /**
  48171. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48172. * It can cast shadows.
  48173. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48174. * @param name The light friendly name
  48175. * @param position The position of the spot light in the scene
  48176. * @param direction The direction of the light in the scene
  48177. * @param angle The cone angle of the light in Radians
  48178. * @param exponent The light decay speed with the distance from the emission spot
  48179. * @param scene The scene the lights belongs to
  48180. */
  48181. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48182. /**
  48183. * Returns the string "SpotLight".
  48184. * @returns the class name
  48185. */
  48186. getClassName(): string;
  48187. /**
  48188. * Returns the integer 2.
  48189. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48190. */
  48191. getTypeID(): number;
  48192. /**
  48193. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48194. */
  48195. protected _setDirection(value: Vector3): void;
  48196. /**
  48197. * Overrides the position setter to recompute the projection texture view light Matrix.
  48198. */
  48199. protected _setPosition(value: Vector3): void;
  48200. /**
  48201. * 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.
  48202. * Returns the SpotLight.
  48203. */
  48204. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48205. protected _computeProjectionTextureViewLightMatrix(): void;
  48206. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48207. /**
  48208. * Main function for light texture projection matrix computing.
  48209. */
  48210. protected _computeProjectionTextureMatrix(): void;
  48211. protected _buildUniformLayout(): void;
  48212. private _computeAngleValues;
  48213. /**
  48214. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48215. * @param effect The effect to update
  48216. * @param lightIndex The index of the light in the effect to update
  48217. * @returns The spot light
  48218. */
  48219. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48220. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48221. /**
  48222. * Disposes the light and the associated resources.
  48223. */
  48224. dispose(): void;
  48225. /**
  48226. * Prepares the list of defines specific to the light type.
  48227. * @param defines the list of defines
  48228. * @param lightIndex defines the index of the light for the effect
  48229. */
  48230. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48231. }
  48232. }
  48233. declare module "babylonjs/Gizmos/lightGizmo" {
  48234. import { Nullable } from "babylonjs/types";
  48235. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48236. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48237. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48238. import { Light } from "babylonjs/Lights/light";
  48239. /**
  48240. * Gizmo that enables viewing a light
  48241. */
  48242. export class LightGizmo extends Gizmo {
  48243. private _lightMesh;
  48244. private _material;
  48245. private cachedPosition;
  48246. private cachedForward;
  48247. /**
  48248. * Creates a LightGizmo
  48249. * @param gizmoLayer The utility layer the gizmo will be added to
  48250. */
  48251. constructor(gizmoLayer?: UtilityLayerRenderer);
  48252. private _light;
  48253. /**
  48254. * The light that the gizmo is attached to
  48255. */
  48256. light: Nullable<Light>;
  48257. /**
  48258. * Gets the material used to render the light gizmo
  48259. */
  48260. readonly material: StandardMaterial;
  48261. /**
  48262. * @hidden
  48263. * Updates the gizmo to match the attached mesh's position/rotation
  48264. */
  48265. protected _update(): void;
  48266. private static _Scale;
  48267. /**
  48268. * Creates the lines for a light mesh
  48269. */
  48270. private static _createLightLines;
  48271. /**
  48272. * Disposes of the light gizmo
  48273. */
  48274. dispose(): void;
  48275. private static _CreateHemisphericLightMesh;
  48276. private static _CreatePointLightMesh;
  48277. private static _CreateSpotLightMesh;
  48278. private static _CreateDirectionalLightMesh;
  48279. }
  48280. }
  48281. declare module "babylonjs/Gizmos/index" {
  48282. export * from "babylonjs/Gizmos/axisDragGizmo";
  48283. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48284. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48285. export * from "babylonjs/Gizmos/gizmo";
  48286. export * from "babylonjs/Gizmos/gizmoManager";
  48287. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48288. export * from "babylonjs/Gizmos/positionGizmo";
  48289. export * from "babylonjs/Gizmos/rotationGizmo";
  48290. export * from "babylonjs/Gizmos/scaleGizmo";
  48291. export * from "babylonjs/Gizmos/lightGizmo";
  48292. export * from "babylonjs/Gizmos/planeDragGizmo";
  48293. }
  48294. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48295. /** @hidden */
  48296. export var backgroundFragmentDeclaration: {
  48297. name: string;
  48298. shader: string;
  48299. };
  48300. }
  48301. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48302. /** @hidden */
  48303. export var backgroundUboDeclaration: {
  48304. name: string;
  48305. shader: string;
  48306. };
  48307. }
  48308. declare module "babylonjs/Shaders/background.fragment" {
  48309. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48310. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48311. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48312. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48313. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48314. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48315. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48316. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48317. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48318. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48319. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48320. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48322. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48323. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48324. /** @hidden */
  48325. export var backgroundPixelShader: {
  48326. name: string;
  48327. shader: string;
  48328. };
  48329. }
  48330. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48331. /** @hidden */
  48332. export var backgroundVertexDeclaration: {
  48333. name: string;
  48334. shader: string;
  48335. };
  48336. }
  48337. declare module "babylonjs/Shaders/background.vertex" {
  48338. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48339. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48340. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48341. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48342. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48343. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48344. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48345. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48346. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48347. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48348. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48349. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48350. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48351. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48352. /** @hidden */
  48353. export var backgroundVertexShader: {
  48354. name: string;
  48355. shader: string;
  48356. };
  48357. }
  48358. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48359. import { Nullable, int, float } from "babylonjs/types";
  48360. import { Scene } from "babylonjs/scene";
  48361. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48362. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48364. import { Mesh } from "babylonjs/Meshes/mesh";
  48365. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48366. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48367. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48369. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48370. import { Color3 } from "babylonjs/Maths/math.color";
  48371. import "babylonjs/Shaders/background.fragment";
  48372. import "babylonjs/Shaders/background.vertex";
  48373. /**
  48374. * Background material used to create an efficient environement around your scene.
  48375. */
  48376. export class BackgroundMaterial extends PushMaterial {
  48377. /**
  48378. * Standard reflectance value at parallel view angle.
  48379. */
  48380. static StandardReflectance0: number;
  48381. /**
  48382. * Standard reflectance value at grazing angle.
  48383. */
  48384. static StandardReflectance90: number;
  48385. protected _primaryColor: Color3;
  48386. /**
  48387. * Key light Color (multiply against the environement texture)
  48388. */
  48389. primaryColor: Color3;
  48390. protected __perceptualColor: Nullable<Color3>;
  48391. /**
  48392. * Experimental Internal Use Only.
  48393. *
  48394. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48395. * This acts as a helper to set the primary color to a more "human friendly" value.
  48396. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48397. * output color as close as possible from the chosen value.
  48398. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48399. * part of lighting setup.)
  48400. */
  48401. _perceptualColor: Nullable<Color3>;
  48402. protected _primaryColorShadowLevel: float;
  48403. /**
  48404. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48405. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48406. */
  48407. primaryColorShadowLevel: float;
  48408. protected _primaryColorHighlightLevel: float;
  48409. /**
  48410. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48411. * The primary color is used at the level chosen to define what the white area would look.
  48412. */
  48413. primaryColorHighlightLevel: float;
  48414. protected _reflectionTexture: Nullable<BaseTexture>;
  48415. /**
  48416. * Reflection Texture used in the material.
  48417. * Should be author in a specific way for the best result (refer to the documentation).
  48418. */
  48419. reflectionTexture: Nullable<BaseTexture>;
  48420. protected _reflectionBlur: float;
  48421. /**
  48422. * Reflection Texture level of blur.
  48423. *
  48424. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48425. * texture twice.
  48426. */
  48427. reflectionBlur: float;
  48428. protected _diffuseTexture: Nullable<BaseTexture>;
  48429. /**
  48430. * Diffuse Texture used in the material.
  48431. * Should be author in a specific way for the best result (refer to the documentation).
  48432. */
  48433. diffuseTexture: Nullable<BaseTexture>;
  48434. protected _shadowLights: Nullable<IShadowLight[]>;
  48435. /**
  48436. * Specify the list of lights casting shadow on the material.
  48437. * All scene shadow lights will be included if null.
  48438. */
  48439. shadowLights: Nullable<IShadowLight[]>;
  48440. protected _shadowLevel: float;
  48441. /**
  48442. * Helps adjusting the shadow to a softer level if required.
  48443. * 0 means black shadows and 1 means no shadows.
  48444. */
  48445. shadowLevel: float;
  48446. protected _sceneCenter: Vector3;
  48447. /**
  48448. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48449. * It is usually zero but might be interesting to modify according to your setup.
  48450. */
  48451. sceneCenter: Vector3;
  48452. protected _opacityFresnel: boolean;
  48453. /**
  48454. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48455. * This helps ensuring a nice transition when the camera goes under the ground.
  48456. */
  48457. opacityFresnel: boolean;
  48458. protected _reflectionFresnel: boolean;
  48459. /**
  48460. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48461. * This helps adding a mirror texture on the ground.
  48462. */
  48463. reflectionFresnel: boolean;
  48464. protected _reflectionFalloffDistance: number;
  48465. /**
  48466. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48467. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48468. */
  48469. reflectionFalloffDistance: number;
  48470. protected _reflectionAmount: number;
  48471. /**
  48472. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48473. */
  48474. reflectionAmount: number;
  48475. protected _reflectionReflectance0: number;
  48476. /**
  48477. * This specifies the weight of the reflection at grazing angle.
  48478. */
  48479. reflectionReflectance0: number;
  48480. protected _reflectionReflectance90: number;
  48481. /**
  48482. * This specifies the weight of the reflection at a perpendicular point of view.
  48483. */
  48484. reflectionReflectance90: number;
  48485. /**
  48486. * Sets the reflection reflectance fresnel values according to the default standard
  48487. * empirically know to work well :-)
  48488. */
  48489. reflectionStandardFresnelWeight: number;
  48490. protected _useRGBColor: boolean;
  48491. /**
  48492. * Helps to directly use the maps channels instead of their level.
  48493. */
  48494. useRGBColor: boolean;
  48495. protected _enableNoise: boolean;
  48496. /**
  48497. * This helps reducing the banding effect that could occur on the background.
  48498. */
  48499. enableNoise: boolean;
  48500. /**
  48501. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48502. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48503. * Recommended to be keep at 1.0 except for special cases.
  48504. */
  48505. fovMultiplier: number;
  48506. private _fovMultiplier;
  48507. /**
  48508. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48509. */
  48510. useEquirectangularFOV: boolean;
  48511. private _maxSimultaneousLights;
  48512. /**
  48513. * Number of Simultaneous lights allowed on the material.
  48514. */
  48515. maxSimultaneousLights: int;
  48516. /**
  48517. * Default configuration related to image processing available in the Background Material.
  48518. */
  48519. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48520. /**
  48521. * Keep track of the image processing observer to allow dispose and replace.
  48522. */
  48523. private _imageProcessingObserver;
  48524. /**
  48525. * Attaches a new image processing configuration to the PBR Material.
  48526. * @param configuration (if null the scene configuration will be use)
  48527. */
  48528. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48529. /**
  48530. * Gets the image processing configuration used either in this material.
  48531. */
  48532. /**
  48533. * Sets the Default image processing configuration used either in the this material.
  48534. *
  48535. * If sets to null, the scene one is in use.
  48536. */
  48537. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48538. /**
  48539. * Gets wether the color curves effect is enabled.
  48540. */
  48541. /**
  48542. * Sets wether the color curves effect is enabled.
  48543. */
  48544. cameraColorCurvesEnabled: boolean;
  48545. /**
  48546. * Gets wether the color grading effect is enabled.
  48547. */
  48548. /**
  48549. * Gets wether the color grading effect is enabled.
  48550. */
  48551. cameraColorGradingEnabled: boolean;
  48552. /**
  48553. * Gets wether tonemapping is enabled or not.
  48554. */
  48555. /**
  48556. * Sets wether tonemapping is enabled or not
  48557. */
  48558. cameraToneMappingEnabled: boolean;
  48559. /**
  48560. * The camera exposure used on this material.
  48561. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48562. * This corresponds to a photographic exposure.
  48563. */
  48564. /**
  48565. * The camera exposure used on this material.
  48566. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48567. * This corresponds to a photographic exposure.
  48568. */
  48569. cameraExposure: float;
  48570. /**
  48571. * Gets The camera contrast used on this material.
  48572. */
  48573. /**
  48574. * Sets The camera contrast used on this material.
  48575. */
  48576. cameraContrast: float;
  48577. /**
  48578. * Gets the Color Grading 2D Lookup Texture.
  48579. */
  48580. /**
  48581. * Sets the Color Grading 2D Lookup Texture.
  48582. */
  48583. cameraColorGradingTexture: Nullable<BaseTexture>;
  48584. /**
  48585. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48586. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48587. * 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;
  48588. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48589. */
  48590. /**
  48591. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48592. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48593. * 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;
  48594. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48595. */
  48596. cameraColorCurves: Nullable<ColorCurves>;
  48597. /**
  48598. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48599. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48600. */
  48601. switchToBGR: boolean;
  48602. private _renderTargets;
  48603. private _reflectionControls;
  48604. private _white;
  48605. private _primaryShadowColor;
  48606. private _primaryHighlightColor;
  48607. /**
  48608. * Instantiates a Background Material in the given scene
  48609. * @param name The friendly name of the material
  48610. * @param scene The scene to add the material to
  48611. */
  48612. constructor(name: string, scene: Scene);
  48613. /**
  48614. * Gets a boolean indicating that current material needs to register RTT
  48615. */
  48616. readonly hasRenderTargetTextures: boolean;
  48617. /**
  48618. * The entire material has been created in order to prevent overdraw.
  48619. * @returns false
  48620. */
  48621. needAlphaTesting(): boolean;
  48622. /**
  48623. * The entire material has been created in order to prevent overdraw.
  48624. * @returns true if blending is enable
  48625. */
  48626. needAlphaBlending(): boolean;
  48627. /**
  48628. * Checks wether the material is ready to be rendered for a given mesh.
  48629. * @param mesh The mesh to render
  48630. * @param subMesh The submesh to check against
  48631. * @param useInstances Specify wether or not the material is used with instances
  48632. * @returns true if all the dependencies are ready (Textures, Effects...)
  48633. */
  48634. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48635. /**
  48636. * Compute the primary color according to the chosen perceptual color.
  48637. */
  48638. private _computePrimaryColorFromPerceptualColor;
  48639. /**
  48640. * Compute the highlights and shadow colors according to their chosen levels.
  48641. */
  48642. private _computePrimaryColors;
  48643. /**
  48644. * Build the uniform buffer used in the material.
  48645. */
  48646. buildUniformLayout(): void;
  48647. /**
  48648. * Unbind the material.
  48649. */
  48650. unbind(): void;
  48651. /**
  48652. * Bind only the world matrix to the material.
  48653. * @param world The world matrix to bind.
  48654. */
  48655. bindOnlyWorldMatrix(world: Matrix): void;
  48656. /**
  48657. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48658. * @param world The world matrix to bind.
  48659. * @param subMesh The submesh to bind for.
  48660. */
  48661. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48662. /**
  48663. * Checks to see if a texture is used in the material.
  48664. * @param texture - Base texture to use.
  48665. * @returns - Boolean specifying if a texture is used in the material.
  48666. */
  48667. hasTexture(texture: BaseTexture): boolean;
  48668. /**
  48669. * Dispose the material.
  48670. * @param forceDisposeEffect Force disposal of the associated effect.
  48671. * @param forceDisposeTextures Force disposal of the associated textures.
  48672. */
  48673. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48674. /**
  48675. * Clones the material.
  48676. * @param name The cloned name.
  48677. * @returns The cloned material.
  48678. */
  48679. clone(name: string): BackgroundMaterial;
  48680. /**
  48681. * Serializes the current material to its JSON representation.
  48682. * @returns The JSON representation.
  48683. */
  48684. serialize(): any;
  48685. /**
  48686. * Gets the class name of the material
  48687. * @returns "BackgroundMaterial"
  48688. */
  48689. getClassName(): string;
  48690. /**
  48691. * Parse a JSON input to create back a background material.
  48692. * @param source The JSON data to parse
  48693. * @param scene The scene to create the parsed material in
  48694. * @param rootUrl The root url of the assets the material depends upon
  48695. * @returns the instantiated BackgroundMaterial.
  48696. */
  48697. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48698. }
  48699. }
  48700. declare module "babylonjs/Helpers/environmentHelper" {
  48701. import { Observable } from "babylonjs/Misc/observable";
  48702. import { Nullable } from "babylonjs/types";
  48703. import { Scene } from "babylonjs/scene";
  48704. import { Vector3 } from "babylonjs/Maths/math.vector";
  48705. import { Color3 } from "babylonjs/Maths/math.color";
  48706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48707. import { Mesh } from "babylonjs/Meshes/mesh";
  48708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48709. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48710. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48711. import "babylonjs/Meshes/Builders/planeBuilder";
  48712. import "babylonjs/Meshes/Builders/boxBuilder";
  48713. /**
  48714. * Represents the different options available during the creation of
  48715. * a Environment helper.
  48716. *
  48717. * This can control the default ground, skybox and image processing setup of your scene.
  48718. */
  48719. export interface IEnvironmentHelperOptions {
  48720. /**
  48721. * Specifies wether or not to create a ground.
  48722. * True by default.
  48723. */
  48724. createGround: boolean;
  48725. /**
  48726. * Specifies the ground size.
  48727. * 15 by default.
  48728. */
  48729. groundSize: number;
  48730. /**
  48731. * The texture used on the ground for the main color.
  48732. * Comes from the BabylonJS CDN by default.
  48733. *
  48734. * Remarks: Can be either a texture or a url.
  48735. */
  48736. groundTexture: string | BaseTexture;
  48737. /**
  48738. * The color mixed in the ground texture by default.
  48739. * BabylonJS clearColor by default.
  48740. */
  48741. groundColor: Color3;
  48742. /**
  48743. * Specifies the ground opacity.
  48744. * 1 by default.
  48745. */
  48746. groundOpacity: number;
  48747. /**
  48748. * Enables the ground to receive shadows.
  48749. * True by default.
  48750. */
  48751. enableGroundShadow: boolean;
  48752. /**
  48753. * Helps preventing the shadow to be fully black on the ground.
  48754. * 0.5 by default.
  48755. */
  48756. groundShadowLevel: number;
  48757. /**
  48758. * Creates a mirror texture attach to the ground.
  48759. * false by default.
  48760. */
  48761. enableGroundMirror: boolean;
  48762. /**
  48763. * Specifies the ground mirror size ratio.
  48764. * 0.3 by default as the default kernel is 64.
  48765. */
  48766. groundMirrorSizeRatio: number;
  48767. /**
  48768. * Specifies the ground mirror blur kernel size.
  48769. * 64 by default.
  48770. */
  48771. groundMirrorBlurKernel: number;
  48772. /**
  48773. * Specifies the ground mirror visibility amount.
  48774. * 1 by default
  48775. */
  48776. groundMirrorAmount: number;
  48777. /**
  48778. * Specifies the ground mirror reflectance weight.
  48779. * This uses the standard weight of the background material to setup the fresnel effect
  48780. * of the mirror.
  48781. * 1 by default.
  48782. */
  48783. groundMirrorFresnelWeight: number;
  48784. /**
  48785. * Specifies the ground mirror Falloff distance.
  48786. * This can helps reducing the size of the reflection.
  48787. * 0 by Default.
  48788. */
  48789. groundMirrorFallOffDistance: number;
  48790. /**
  48791. * Specifies the ground mirror texture type.
  48792. * Unsigned Int by Default.
  48793. */
  48794. groundMirrorTextureType: number;
  48795. /**
  48796. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48797. * the shown objects.
  48798. */
  48799. groundYBias: number;
  48800. /**
  48801. * Specifies wether or not to create a skybox.
  48802. * True by default.
  48803. */
  48804. createSkybox: boolean;
  48805. /**
  48806. * Specifies the skybox size.
  48807. * 20 by default.
  48808. */
  48809. skyboxSize: number;
  48810. /**
  48811. * The texture used on the skybox for the main color.
  48812. * Comes from the BabylonJS CDN by default.
  48813. *
  48814. * Remarks: Can be either a texture or a url.
  48815. */
  48816. skyboxTexture: string | BaseTexture;
  48817. /**
  48818. * The color mixed in the skybox texture by default.
  48819. * BabylonJS clearColor by default.
  48820. */
  48821. skyboxColor: Color3;
  48822. /**
  48823. * The background rotation around the Y axis of the scene.
  48824. * This helps aligning the key lights of your scene with the background.
  48825. * 0 by default.
  48826. */
  48827. backgroundYRotation: number;
  48828. /**
  48829. * Compute automatically the size of the elements to best fit with the scene.
  48830. */
  48831. sizeAuto: boolean;
  48832. /**
  48833. * Default position of the rootMesh if autoSize is not true.
  48834. */
  48835. rootPosition: Vector3;
  48836. /**
  48837. * Sets up the image processing in the scene.
  48838. * true by default.
  48839. */
  48840. setupImageProcessing: boolean;
  48841. /**
  48842. * The texture used as your environment texture in the scene.
  48843. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48844. *
  48845. * Remarks: Can be either a texture or a url.
  48846. */
  48847. environmentTexture: string | BaseTexture;
  48848. /**
  48849. * The value of the exposure to apply to the scene.
  48850. * 0.6 by default if setupImageProcessing is true.
  48851. */
  48852. cameraExposure: number;
  48853. /**
  48854. * The value of the contrast to apply to the scene.
  48855. * 1.6 by default if setupImageProcessing is true.
  48856. */
  48857. cameraContrast: number;
  48858. /**
  48859. * Specifies wether or not tonemapping should be enabled in the scene.
  48860. * true by default if setupImageProcessing is true.
  48861. */
  48862. toneMappingEnabled: boolean;
  48863. }
  48864. /**
  48865. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48866. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48867. * It also helps with the default setup of your imageProcessing configuration.
  48868. */
  48869. export class EnvironmentHelper {
  48870. /**
  48871. * Default ground texture URL.
  48872. */
  48873. private static _groundTextureCDNUrl;
  48874. /**
  48875. * Default skybox texture URL.
  48876. */
  48877. private static _skyboxTextureCDNUrl;
  48878. /**
  48879. * Default environment texture URL.
  48880. */
  48881. private static _environmentTextureCDNUrl;
  48882. /**
  48883. * Creates the default options for the helper.
  48884. */
  48885. private static _getDefaultOptions;
  48886. private _rootMesh;
  48887. /**
  48888. * Gets the root mesh created by the helper.
  48889. */
  48890. readonly rootMesh: Mesh;
  48891. private _skybox;
  48892. /**
  48893. * Gets the skybox created by the helper.
  48894. */
  48895. readonly skybox: Nullable<Mesh>;
  48896. private _skyboxTexture;
  48897. /**
  48898. * Gets the skybox texture created by the helper.
  48899. */
  48900. readonly skyboxTexture: Nullable<BaseTexture>;
  48901. private _skyboxMaterial;
  48902. /**
  48903. * Gets the skybox material created by the helper.
  48904. */
  48905. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48906. private _ground;
  48907. /**
  48908. * Gets the ground mesh created by the helper.
  48909. */
  48910. readonly ground: Nullable<Mesh>;
  48911. private _groundTexture;
  48912. /**
  48913. * Gets the ground texture created by the helper.
  48914. */
  48915. readonly groundTexture: Nullable<BaseTexture>;
  48916. private _groundMirror;
  48917. /**
  48918. * Gets the ground mirror created by the helper.
  48919. */
  48920. readonly groundMirror: Nullable<MirrorTexture>;
  48921. /**
  48922. * Gets the ground mirror render list to helps pushing the meshes
  48923. * you wish in the ground reflection.
  48924. */
  48925. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48926. private _groundMaterial;
  48927. /**
  48928. * Gets the ground material created by the helper.
  48929. */
  48930. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48931. /**
  48932. * Stores the creation options.
  48933. */
  48934. private readonly _scene;
  48935. private _options;
  48936. /**
  48937. * This observable will be notified with any error during the creation of the environment,
  48938. * mainly texture creation errors.
  48939. */
  48940. onErrorObservable: Observable<{
  48941. message?: string;
  48942. exception?: any;
  48943. }>;
  48944. /**
  48945. * constructor
  48946. * @param options Defines the options we want to customize the helper
  48947. * @param scene The scene to add the material to
  48948. */
  48949. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48950. /**
  48951. * Updates the background according to the new options
  48952. * @param options
  48953. */
  48954. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48955. /**
  48956. * Sets the primary color of all the available elements.
  48957. * @param color the main color to affect to the ground and the background
  48958. */
  48959. setMainColor(color: Color3): void;
  48960. /**
  48961. * Setup the image processing according to the specified options.
  48962. */
  48963. private _setupImageProcessing;
  48964. /**
  48965. * Setup the environment texture according to the specified options.
  48966. */
  48967. private _setupEnvironmentTexture;
  48968. /**
  48969. * Setup the background according to the specified options.
  48970. */
  48971. private _setupBackground;
  48972. /**
  48973. * Get the scene sizes according to the setup.
  48974. */
  48975. private _getSceneSize;
  48976. /**
  48977. * Setup the ground according to the specified options.
  48978. */
  48979. private _setupGround;
  48980. /**
  48981. * Setup the ground material according to the specified options.
  48982. */
  48983. private _setupGroundMaterial;
  48984. /**
  48985. * Setup the ground diffuse texture according to the specified options.
  48986. */
  48987. private _setupGroundDiffuseTexture;
  48988. /**
  48989. * Setup the ground mirror texture according to the specified options.
  48990. */
  48991. private _setupGroundMirrorTexture;
  48992. /**
  48993. * Setup the ground to receive the mirror texture.
  48994. */
  48995. private _setupMirrorInGroundMaterial;
  48996. /**
  48997. * Setup the skybox according to the specified options.
  48998. */
  48999. private _setupSkybox;
  49000. /**
  49001. * Setup the skybox material according to the specified options.
  49002. */
  49003. private _setupSkyboxMaterial;
  49004. /**
  49005. * Setup the skybox reflection texture according to the specified options.
  49006. */
  49007. private _setupSkyboxReflectionTexture;
  49008. private _errorHandler;
  49009. /**
  49010. * Dispose all the elements created by the Helper.
  49011. */
  49012. dispose(): void;
  49013. }
  49014. }
  49015. declare module "babylonjs/Helpers/photoDome" {
  49016. import { Observable } from "babylonjs/Misc/observable";
  49017. import { Nullable } from "babylonjs/types";
  49018. import { Scene } from "babylonjs/scene";
  49019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49020. import { Mesh } from "babylonjs/Meshes/mesh";
  49021. import { Texture } from "babylonjs/Materials/Textures/texture";
  49022. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49023. import "babylonjs/Meshes/Builders/sphereBuilder";
  49024. /**
  49025. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49026. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49027. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49028. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49029. */
  49030. export class PhotoDome extends TransformNode {
  49031. /**
  49032. * Define the image as a Monoscopic panoramic 360 image.
  49033. */
  49034. static readonly MODE_MONOSCOPIC: number;
  49035. /**
  49036. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49037. */
  49038. static readonly MODE_TOPBOTTOM: number;
  49039. /**
  49040. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49041. */
  49042. static readonly MODE_SIDEBYSIDE: number;
  49043. private _useDirectMapping;
  49044. /**
  49045. * The texture being displayed on the sphere
  49046. */
  49047. protected _photoTexture: Texture;
  49048. /**
  49049. * Gets or sets the texture being displayed on the sphere
  49050. */
  49051. photoTexture: Texture;
  49052. /**
  49053. * Observable raised when an error occured while loading the 360 image
  49054. */
  49055. onLoadErrorObservable: Observable<string>;
  49056. /**
  49057. * The skybox material
  49058. */
  49059. protected _material: BackgroundMaterial;
  49060. /**
  49061. * The surface used for the skybox
  49062. */
  49063. protected _mesh: Mesh;
  49064. /**
  49065. * Gets the mesh used for the skybox.
  49066. */
  49067. readonly mesh: Mesh;
  49068. /**
  49069. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49070. * Also see the options.resolution property.
  49071. */
  49072. fovMultiplier: number;
  49073. private _imageMode;
  49074. /**
  49075. * Gets or set the current video mode for the video. It can be:
  49076. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49077. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49078. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49079. */
  49080. imageMode: number;
  49081. /**
  49082. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49083. * @param name Element's name, child elements will append suffixes for their own names.
  49084. * @param urlsOfPhoto defines the url of the photo to display
  49085. * @param options defines an object containing optional or exposed sub element properties
  49086. * @param onError defines a callback called when an error occured while loading the texture
  49087. */
  49088. constructor(name: string, urlOfPhoto: string, options: {
  49089. resolution?: number;
  49090. size?: number;
  49091. useDirectMapping?: boolean;
  49092. faceForward?: boolean;
  49093. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49094. private _onBeforeCameraRenderObserver;
  49095. private _changeImageMode;
  49096. /**
  49097. * Releases resources associated with this node.
  49098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49100. */
  49101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49102. }
  49103. }
  49104. declare module "babylonjs/Misc/rgbdTextureTools" {
  49105. import "babylonjs/Shaders/rgbdDecode.fragment";
  49106. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49107. import { Texture } from "babylonjs/Materials/Textures/texture";
  49108. /**
  49109. * Class used to host RGBD texture specific utilities
  49110. */
  49111. export class RGBDTextureTools {
  49112. /**
  49113. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49114. * @param texture the texture to expand.
  49115. */
  49116. static ExpandRGBDTexture(texture: Texture): void;
  49117. }
  49118. }
  49119. declare module "babylonjs/Misc/brdfTextureTools" {
  49120. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49121. import { Scene } from "babylonjs/scene";
  49122. /**
  49123. * Class used to host texture specific utilities
  49124. */
  49125. export class BRDFTextureTools {
  49126. /**
  49127. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49128. * @param scene defines the hosting scene
  49129. * @returns the environment BRDF texture
  49130. */
  49131. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49132. private static _environmentBRDFBase64Texture;
  49133. }
  49134. }
  49135. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49136. import { Nullable } from "babylonjs/types";
  49137. import { Color3 } from "babylonjs/Maths/math.color";
  49138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49139. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49140. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49141. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49142. import { Engine } from "babylonjs/Engines/engine";
  49143. import { Scene } from "babylonjs/scene";
  49144. /**
  49145. * @hidden
  49146. */
  49147. export interface IMaterialClearCoatDefines {
  49148. CLEARCOAT: boolean;
  49149. CLEARCOAT_DEFAULTIOR: boolean;
  49150. CLEARCOAT_TEXTURE: boolean;
  49151. CLEARCOAT_TEXTUREDIRECTUV: number;
  49152. CLEARCOAT_BUMP: boolean;
  49153. CLEARCOAT_BUMPDIRECTUV: number;
  49154. CLEARCOAT_TINT: boolean;
  49155. CLEARCOAT_TINT_TEXTURE: boolean;
  49156. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49157. /** @hidden */
  49158. _areTexturesDirty: boolean;
  49159. }
  49160. /**
  49161. * Define the code related to the clear coat parameters of the pbr material.
  49162. */
  49163. export class PBRClearCoatConfiguration {
  49164. /**
  49165. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49166. * The default fits with a polyurethane material.
  49167. */
  49168. private static readonly _DefaultIndexOfRefraction;
  49169. private _isEnabled;
  49170. /**
  49171. * Defines if the clear coat is enabled in the material.
  49172. */
  49173. isEnabled: boolean;
  49174. /**
  49175. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49176. */
  49177. intensity: number;
  49178. /**
  49179. * Defines the clear coat layer roughness.
  49180. */
  49181. roughness: number;
  49182. private _indexOfRefraction;
  49183. /**
  49184. * Defines the index of refraction of the clear coat.
  49185. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49186. * The default fits with a polyurethane material.
  49187. * Changing the default value is more performance intensive.
  49188. */
  49189. indexOfRefraction: number;
  49190. private _texture;
  49191. /**
  49192. * Stores the clear coat values in a texture.
  49193. */
  49194. texture: Nullable<BaseTexture>;
  49195. private _bumpTexture;
  49196. /**
  49197. * Define the clear coat specific bump texture.
  49198. */
  49199. bumpTexture: Nullable<BaseTexture>;
  49200. private _isTintEnabled;
  49201. /**
  49202. * Defines if the clear coat tint is enabled in the material.
  49203. */
  49204. isTintEnabled: boolean;
  49205. /**
  49206. * Defines the clear coat tint of the material.
  49207. * This is only use if tint is enabled
  49208. */
  49209. tintColor: Color3;
  49210. /**
  49211. * Defines the distance at which the tint color should be found in the
  49212. * clear coat media.
  49213. * This is only use if tint is enabled
  49214. */
  49215. tintColorAtDistance: number;
  49216. /**
  49217. * Defines the clear coat layer thickness.
  49218. * This is only use if tint is enabled
  49219. */
  49220. tintThickness: number;
  49221. private _tintTexture;
  49222. /**
  49223. * Stores the clear tint values in a texture.
  49224. * rgb is tint
  49225. * a is a thickness factor
  49226. */
  49227. tintTexture: Nullable<BaseTexture>;
  49228. /** @hidden */
  49229. private _internalMarkAllSubMeshesAsTexturesDirty;
  49230. /** @hidden */
  49231. _markAllSubMeshesAsTexturesDirty(): void;
  49232. /**
  49233. * Instantiate a new istance of clear coat configuration.
  49234. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49235. */
  49236. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49237. /**
  49238. * Gets wehter the submesh is ready to be used or not.
  49239. * @param defines the list of "defines" to update.
  49240. * @param scene defines the scene the material belongs to.
  49241. * @param engine defines the engine the material belongs to.
  49242. * @param disableBumpMap defines wether the material disables bump or not.
  49243. * @returns - boolean indicating that the submesh is ready or not.
  49244. */
  49245. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49246. /**
  49247. * Checks to see if a texture is used in the material.
  49248. * @param defines the list of "defines" to update.
  49249. * @param scene defines the scene to the material belongs to.
  49250. */
  49251. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49252. /**
  49253. * Binds the material data.
  49254. * @param uniformBuffer defines the Uniform buffer to fill in.
  49255. * @param scene defines the scene the material belongs to.
  49256. * @param engine defines the engine the material belongs to.
  49257. * @param disableBumpMap defines wether the material disables bump or not.
  49258. * @param isFrozen defines wether the material is frozen or not.
  49259. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49260. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49261. */
  49262. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49263. /**
  49264. * Checks to see if a texture is used in the material.
  49265. * @param texture - Base texture to use.
  49266. * @returns - Boolean specifying if a texture is used in the material.
  49267. */
  49268. hasTexture(texture: BaseTexture): boolean;
  49269. /**
  49270. * Returns an array of the actively used textures.
  49271. * @param activeTextures Array of BaseTextures
  49272. */
  49273. getActiveTextures(activeTextures: BaseTexture[]): void;
  49274. /**
  49275. * Returns the animatable textures.
  49276. * @param animatables Array of animatable textures.
  49277. */
  49278. getAnimatables(animatables: IAnimatable[]): void;
  49279. /**
  49280. * Disposes the resources of the material.
  49281. * @param forceDisposeTextures - Forces the disposal of all textures.
  49282. */
  49283. dispose(forceDisposeTextures?: boolean): void;
  49284. /**
  49285. * Get the current class name of the texture useful for serialization or dynamic coding.
  49286. * @returns "PBRClearCoatConfiguration"
  49287. */
  49288. getClassName(): string;
  49289. /**
  49290. * Add fallbacks to the effect fallbacks list.
  49291. * @param defines defines the Base texture to use.
  49292. * @param fallbacks defines the current fallback list.
  49293. * @param currentRank defines the current fallback rank.
  49294. * @returns the new fallback rank.
  49295. */
  49296. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49297. /**
  49298. * Add the required uniforms to the current list.
  49299. * @param uniforms defines the current uniform list.
  49300. */
  49301. static AddUniforms(uniforms: string[]): void;
  49302. /**
  49303. * Add the required samplers to the current list.
  49304. * @param samplers defines the current sampler list.
  49305. */
  49306. static AddSamplers(samplers: string[]): void;
  49307. /**
  49308. * Add the required uniforms to the current buffer.
  49309. * @param uniformBuffer defines the current uniform buffer.
  49310. */
  49311. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49312. /**
  49313. * Makes a duplicate of the current configuration into another one.
  49314. * @param clearCoatConfiguration define the config where to copy the info
  49315. */
  49316. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49317. /**
  49318. * Serializes this clear coat configuration.
  49319. * @returns - An object with the serialized config.
  49320. */
  49321. serialize(): any;
  49322. /**
  49323. * Parses a anisotropy Configuration from a serialized object.
  49324. * @param source - Serialized object.
  49325. * @param scene Defines the scene we are parsing for
  49326. * @param rootUrl Defines the rootUrl to load from
  49327. */
  49328. parse(source: any, scene: Scene, rootUrl: string): void;
  49329. }
  49330. }
  49331. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49332. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49334. import { Vector2 } from "babylonjs/Maths/math.vector";
  49335. import { Scene } from "babylonjs/scene";
  49336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49337. import { Nullable } from "babylonjs/types";
  49338. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49339. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49340. /**
  49341. * @hidden
  49342. */
  49343. export interface IMaterialAnisotropicDefines {
  49344. ANISOTROPIC: boolean;
  49345. ANISOTROPIC_TEXTURE: boolean;
  49346. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49347. MAINUV1: boolean;
  49348. _areTexturesDirty: boolean;
  49349. _needUVs: boolean;
  49350. }
  49351. /**
  49352. * Define the code related to the anisotropic parameters of the pbr material.
  49353. */
  49354. export class PBRAnisotropicConfiguration {
  49355. private _isEnabled;
  49356. /**
  49357. * Defines if the anisotropy is enabled in the material.
  49358. */
  49359. isEnabled: boolean;
  49360. /**
  49361. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49362. */
  49363. intensity: number;
  49364. /**
  49365. * Defines if the effect is along the tangents, bitangents or in between.
  49366. * By default, the effect is "strectching" the highlights along the tangents.
  49367. */
  49368. direction: Vector2;
  49369. private _texture;
  49370. /**
  49371. * Stores the anisotropy values in a texture.
  49372. * rg is direction (like normal from -1 to 1)
  49373. * b is a intensity
  49374. */
  49375. texture: Nullable<BaseTexture>;
  49376. /** @hidden */
  49377. private _internalMarkAllSubMeshesAsTexturesDirty;
  49378. /** @hidden */
  49379. _markAllSubMeshesAsTexturesDirty(): void;
  49380. /**
  49381. * Instantiate a new istance of anisotropy configuration.
  49382. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49383. */
  49384. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49385. /**
  49386. * Specifies that the submesh is ready to be used.
  49387. * @param defines the list of "defines" to update.
  49388. * @param scene defines the scene the material belongs to.
  49389. * @returns - boolean indicating that the submesh is ready or not.
  49390. */
  49391. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49392. /**
  49393. * Checks to see if a texture is used in the material.
  49394. * @param defines the list of "defines" to update.
  49395. * @param mesh the mesh we are preparing the defines for.
  49396. * @param scene defines the scene the material belongs to.
  49397. */
  49398. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49399. /**
  49400. * Binds the material data.
  49401. * @param uniformBuffer defines the Uniform buffer to fill in.
  49402. * @param scene defines the scene the material belongs to.
  49403. * @param isFrozen defines wether the material is frozen or not.
  49404. */
  49405. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49406. /**
  49407. * Checks to see if a texture is used in the material.
  49408. * @param texture - Base texture to use.
  49409. * @returns - Boolean specifying if a texture is used in the material.
  49410. */
  49411. hasTexture(texture: BaseTexture): boolean;
  49412. /**
  49413. * Returns an array of the actively used textures.
  49414. * @param activeTextures Array of BaseTextures
  49415. */
  49416. getActiveTextures(activeTextures: BaseTexture[]): void;
  49417. /**
  49418. * Returns the animatable textures.
  49419. * @param animatables Array of animatable textures.
  49420. */
  49421. getAnimatables(animatables: IAnimatable[]): void;
  49422. /**
  49423. * Disposes the resources of the material.
  49424. * @param forceDisposeTextures - Forces the disposal of all textures.
  49425. */
  49426. dispose(forceDisposeTextures?: boolean): void;
  49427. /**
  49428. * Get the current class name of the texture useful for serialization or dynamic coding.
  49429. * @returns "PBRAnisotropicConfiguration"
  49430. */
  49431. getClassName(): string;
  49432. /**
  49433. * Add fallbacks to the effect fallbacks list.
  49434. * @param defines defines the Base texture to use.
  49435. * @param fallbacks defines the current fallback list.
  49436. * @param currentRank defines the current fallback rank.
  49437. * @returns the new fallback rank.
  49438. */
  49439. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49440. /**
  49441. * Add the required uniforms to the current list.
  49442. * @param uniforms defines the current uniform list.
  49443. */
  49444. static AddUniforms(uniforms: string[]): void;
  49445. /**
  49446. * Add the required uniforms to the current buffer.
  49447. * @param uniformBuffer defines the current uniform buffer.
  49448. */
  49449. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49450. /**
  49451. * Add the required samplers to the current list.
  49452. * @param samplers defines the current sampler list.
  49453. */
  49454. static AddSamplers(samplers: string[]): void;
  49455. /**
  49456. * Makes a duplicate of the current configuration into another one.
  49457. * @param anisotropicConfiguration define the config where to copy the info
  49458. */
  49459. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49460. /**
  49461. * Serializes this anisotropy configuration.
  49462. * @returns - An object with the serialized config.
  49463. */
  49464. serialize(): any;
  49465. /**
  49466. * Parses a anisotropy Configuration from a serialized object.
  49467. * @param source - Serialized object.
  49468. * @param scene Defines the scene we are parsing for
  49469. * @param rootUrl Defines the rootUrl to load from
  49470. */
  49471. parse(source: any, scene: Scene, rootUrl: string): void;
  49472. }
  49473. }
  49474. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49475. import { Scene } from "babylonjs/scene";
  49476. /**
  49477. * @hidden
  49478. */
  49479. export interface IMaterialBRDFDefines {
  49480. BRDF_V_HEIGHT_CORRELATED: boolean;
  49481. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49482. SPHERICAL_HARMONICS: boolean;
  49483. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49484. /** @hidden */
  49485. _areMiscDirty: boolean;
  49486. }
  49487. /**
  49488. * Define the code related to the BRDF parameters of the pbr material.
  49489. */
  49490. export class PBRBRDFConfiguration {
  49491. /**
  49492. * Default value used for the energy conservation.
  49493. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49494. */
  49495. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49496. /**
  49497. * Default value used for the Smith Visibility Height Correlated mode.
  49498. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49499. */
  49500. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49501. /**
  49502. * Default value used for the IBL diffuse part.
  49503. * This can help switching back to the polynomials mode globally which is a tiny bit
  49504. * less GPU intensive at the drawback of a lower quality.
  49505. */
  49506. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49507. /**
  49508. * Default value used for activating energy conservation for the specular workflow.
  49509. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49510. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49511. */
  49512. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49513. private _useEnergyConservation;
  49514. /**
  49515. * Defines if the material uses energy conservation.
  49516. */
  49517. useEnergyConservation: boolean;
  49518. private _useSmithVisibilityHeightCorrelated;
  49519. /**
  49520. * LEGACY Mode set to false
  49521. * Defines if the material uses height smith correlated visibility term.
  49522. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49523. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49524. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49525. * Not relying on height correlated will also disable energy conservation.
  49526. */
  49527. useSmithVisibilityHeightCorrelated: boolean;
  49528. private _useSphericalHarmonics;
  49529. /**
  49530. * LEGACY Mode set to false
  49531. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49532. * diffuse part of the IBL.
  49533. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49534. * to the ground truth.
  49535. */
  49536. useSphericalHarmonics: boolean;
  49537. private _useSpecularGlossinessInputEnergyConservation;
  49538. /**
  49539. * Defines if the material uses energy conservation, when the specular workflow is active.
  49540. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49541. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49542. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49543. */
  49544. useSpecularGlossinessInputEnergyConservation: boolean;
  49545. /** @hidden */
  49546. private _internalMarkAllSubMeshesAsMiscDirty;
  49547. /** @hidden */
  49548. _markAllSubMeshesAsMiscDirty(): void;
  49549. /**
  49550. * Instantiate a new istance of clear coat configuration.
  49551. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49552. */
  49553. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49554. /**
  49555. * Checks to see if a texture is used in the material.
  49556. * @param defines the list of "defines" to update.
  49557. */
  49558. prepareDefines(defines: IMaterialBRDFDefines): void;
  49559. /**
  49560. * Get the current class name of the texture useful for serialization or dynamic coding.
  49561. * @returns "PBRClearCoatConfiguration"
  49562. */
  49563. getClassName(): string;
  49564. /**
  49565. * Makes a duplicate of the current configuration into another one.
  49566. * @param brdfConfiguration define the config where to copy the info
  49567. */
  49568. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49569. /**
  49570. * Serializes this BRDF 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/pbrSheenConfiguration" {
  49584. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49585. import { Color3 } from "babylonjs/Maths/math.color";
  49586. import { Scene } from "babylonjs/scene";
  49587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49588. import { Nullable } from "babylonjs/types";
  49589. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49590. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49591. /**
  49592. * @hidden
  49593. */
  49594. export interface IMaterialSheenDefines {
  49595. SHEEN: boolean;
  49596. SHEEN_TEXTURE: boolean;
  49597. SHEEN_TEXTUREDIRECTUV: number;
  49598. SHEEN_LINKWITHALBEDO: boolean;
  49599. /** @hidden */
  49600. _areTexturesDirty: boolean;
  49601. }
  49602. /**
  49603. * Define the code related to the Sheen parameters of the pbr material.
  49604. */
  49605. export class PBRSheenConfiguration {
  49606. private _isEnabled;
  49607. /**
  49608. * Defines if the material uses sheen.
  49609. */
  49610. isEnabled: boolean;
  49611. private _linkSheenWithAlbedo;
  49612. /**
  49613. * Defines if the sheen is linked to the sheen color.
  49614. */
  49615. linkSheenWithAlbedo: boolean;
  49616. /**
  49617. * Defines the sheen intensity.
  49618. */
  49619. intensity: number;
  49620. /**
  49621. * Defines the sheen color.
  49622. */
  49623. color: Color3;
  49624. private _texture;
  49625. /**
  49626. * Stores the sheen tint values in a texture.
  49627. * rgb is tint
  49628. * a is a intensity
  49629. */
  49630. texture: Nullable<BaseTexture>;
  49631. /** @hidden */
  49632. private _internalMarkAllSubMeshesAsTexturesDirty;
  49633. /** @hidden */
  49634. _markAllSubMeshesAsTexturesDirty(): void;
  49635. /**
  49636. * Instantiate a new istance of clear coat configuration.
  49637. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49638. */
  49639. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49640. /**
  49641. * Specifies that the submesh is ready to be used.
  49642. * @param defines the list of "defines" to update.
  49643. * @param scene defines the scene the material belongs to.
  49644. * @returns - boolean indicating that the submesh is ready or not.
  49645. */
  49646. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49647. /**
  49648. * Checks to see if a texture is used in the material.
  49649. * @param defines the list of "defines" to update.
  49650. * @param scene defines the scene the material belongs to.
  49651. */
  49652. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49653. /**
  49654. * Binds the material data.
  49655. * @param uniformBuffer defines the Uniform buffer to fill in.
  49656. * @param scene defines the scene the material belongs to.
  49657. * @param isFrozen defines wether the material is frozen or not.
  49658. */
  49659. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49660. /**
  49661. * Checks to see if a texture is used in the material.
  49662. * @param texture - Base texture to use.
  49663. * @returns - Boolean specifying if a texture is used in the material.
  49664. */
  49665. hasTexture(texture: BaseTexture): boolean;
  49666. /**
  49667. * Returns an array of the actively used textures.
  49668. * @param activeTextures Array of BaseTextures
  49669. */
  49670. getActiveTextures(activeTextures: BaseTexture[]): void;
  49671. /**
  49672. * Returns the animatable textures.
  49673. * @param animatables Array of animatable textures.
  49674. */
  49675. getAnimatables(animatables: IAnimatable[]): void;
  49676. /**
  49677. * Disposes the resources of the material.
  49678. * @param forceDisposeTextures - Forces the disposal of all textures.
  49679. */
  49680. dispose(forceDisposeTextures?: boolean): void;
  49681. /**
  49682. * Get the current class name of the texture useful for serialization or dynamic coding.
  49683. * @returns "PBRSheenConfiguration"
  49684. */
  49685. getClassName(): string;
  49686. /**
  49687. * Add fallbacks to the effect fallbacks list.
  49688. * @param defines defines the Base texture to use.
  49689. * @param fallbacks defines the current fallback list.
  49690. * @param currentRank defines the current fallback rank.
  49691. * @returns the new fallback rank.
  49692. */
  49693. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49694. /**
  49695. * Add the required uniforms to the current list.
  49696. * @param uniforms defines the current uniform list.
  49697. */
  49698. static AddUniforms(uniforms: string[]): void;
  49699. /**
  49700. * Add the required uniforms to the current buffer.
  49701. * @param uniformBuffer defines the current uniform buffer.
  49702. */
  49703. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49704. /**
  49705. * Add the required samplers to the current list.
  49706. * @param samplers defines the current sampler list.
  49707. */
  49708. static AddSamplers(samplers: string[]): void;
  49709. /**
  49710. * Makes a duplicate of the current configuration into another one.
  49711. * @param sheenConfiguration define the config where to copy the info
  49712. */
  49713. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49714. /**
  49715. * Serializes this BRDF configuration.
  49716. * @returns - An object with the serialized config.
  49717. */
  49718. serialize(): any;
  49719. /**
  49720. * Parses a anisotropy Configuration from a serialized object.
  49721. * @param source - Serialized object.
  49722. * @param scene Defines the scene we are parsing for
  49723. * @param rootUrl Defines the rootUrl to load from
  49724. */
  49725. parse(source: any, scene: Scene, rootUrl: string): void;
  49726. }
  49727. }
  49728. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49729. import { Nullable } from "babylonjs/types";
  49730. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49731. import { Color3 } from "babylonjs/Maths/math.color";
  49732. import { SmartArray } from "babylonjs/Misc/smartArray";
  49733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49734. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49735. import { Effect } from "babylonjs/Materials/effect";
  49736. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49737. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49738. import { Engine } from "babylonjs/Engines/engine";
  49739. import { Scene } from "babylonjs/scene";
  49740. /**
  49741. * @hidden
  49742. */
  49743. export interface IMaterialSubSurfaceDefines {
  49744. SUBSURFACE: boolean;
  49745. SS_REFRACTION: boolean;
  49746. SS_TRANSLUCENCY: boolean;
  49747. SS_SCATERRING: boolean;
  49748. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49749. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49750. SS_REFRACTIONMAP_3D: boolean;
  49751. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49752. SS_LODINREFRACTIONALPHA: boolean;
  49753. SS_GAMMAREFRACTION: boolean;
  49754. SS_RGBDREFRACTION: boolean;
  49755. SS_LINEARSPECULARREFRACTION: boolean;
  49756. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49757. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49758. /** @hidden */
  49759. _areTexturesDirty: boolean;
  49760. }
  49761. /**
  49762. * Define the code related to the sub surface parameters of the pbr material.
  49763. */
  49764. export class PBRSubSurfaceConfiguration {
  49765. private _isRefractionEnabled;
  49766. /**
  49767. * Defines if the refraction is enabled in the material.
  49768. */
  49769. isRefractionEnabled: boolean;
  49770. private _isTranslucencyEnabled;
  49771. /**
  49772. * Defines if the translucency is enabled in the material.
  49773. */
  49774. isTranslucencyEnabled: boolean;
  49775. private _isScatteringEnabled;
  49776. /**
  49777. * Defines the refraction intensity of the material.
  49778. * The refraction when enabled replaces the Diffuse part of the material.
  49779. * The intensity helps transitionning between diffuse and refraction.
  49780. */
  49781. refractionIntensity: number;
  49782. /**
  49783. * Defines the translucency intensity of the material.
  49784. * When translucency has been enabled, this defines how much of the "translucency"
  49785. * is addded to the diffuse part of the material.
  49786. */
  49787. translucencyIntensity: number;
  49788. /**
  49789. * Defines the scattering intensity of the material.
  49790. * When scattering has been enabled, this defines how much of the "scattered light"
  49791. * is addded to the diffuse part of the material.
  49792. */
  49793. scatteringIntensity: number;
  49794. private _thicknessTexture;
  49795. /**
  49796. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49797. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49798. * 0 would mean minimumThickness
  49799. * 1 would mean maximumThickness
  49800. * The other channels might be use as a mask to vary the different effects intensity.
  49801. */
  49802. thicknessTexture: Nullable<BaseTexture>;
  49803. private _refractionTexture;
  49804. /**
  49805. * Defines the texture to use for refraction.
  49806. */
  49807. refractionTexture: Nullable<BaseTexture>;
  49808. private _indexOfRefraction;
  49809. /**
  49810. * Defines the index of refraction used in the material.
  49811. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49812. */
  49813. indexOfRefraction: number;
  49814. private _invertRefractionY;
  49815. /**
  49816. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49817. */
  49818. invertRefractionY: boolean;
  49819. private _linkRefractionWithTransparency;
  49820. /**
  49821. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49822. * Materials half opaque for instance using refraction could benefit from this control.
  49823. */
  49824. linkRefractionWithTransparency: boolean;
  49825. /**
  49826. * Defines the minimum thickness stored in the thickness map.
  49827. * If no thickness map is defined, this value will be used to simulate thickness.
  49828. */
  49829. minimumThickness: number;
  49830. /**
  49831. * Defines the maximum thickness stored in the thickness map.
  49832. */
  49833. maximumThickness: number;
  49834. /**
  49835. * Defines the volume tint of the material.
  49836. * This is used for both translucency and scattering.
  49837. */
  49838. tintColor: Color3;
  49839. /**
  49840. * Defines the distance at which the tint color should be found in the media.
  49841. * This is used for refraction only.
  49842. */
  49843. tintColorAtDistance: number;
  49844. /**
  49845. * Defines how far each channel transmit through the media.
  49846. * It is defined as a color to simplify it selection.
  49847. */
  49848. diffusionDistance: Color3;
  49849. private _useMaskFromThicknessTexture;
  49850. /**
  49851. * Stores the intensity of the different subsurface effects in the thickness texture.
  49852. * * the green channel is the translucency intensity.
  49853. * * the blue channel is the scattering intensity.
  49854. * * the alpha channel is the refraction intensity.
  49855. */
  49856. useMaskFromThicknessTexture: boolean;
  49857. /** @hidden */
  49858. private _internalMarkAllSubMeshesAsTexturesDirty;
  49859. /** @hidden */
  49860. _markAllSubMeshesAsTexturesDirty(): void;
  49861. /**
  49862. * Instantiate a new istance of sub surface configuration.
  49863. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49864. */
  49865. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49866. /**
  49867. * Gets wehter the submesh is ready to be used or not.
  49868. * @param defines the list of "defines" to update.
  49869. * @param scene defines the scene the material belongs to.
  49870. * @returns - boolean indicating that the submesh is ready or not.
  49871. */
  49872. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49873. /**
  49874. * Checks to see if a texture is used in the material.
  49875. * @param defines the list of "defines" to update.
  49876. * @param scene defines the scene to the material belongs to.
  49877. */
  49878. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49879. /**
  49880. * Binds the material data.
  49881. * @param uniformBuffer defines the Uniform buffer to fill in.
  49882. * @param scene defines the scene the material belongs to.
  49883. * @param engine defines the engine the material belongs to.
  49884. * @param isFrozen defines wether the material is frozen or not.
  49885. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49886. */
  49887. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49888. /**
  49889. * Unbinds the material from the mesh.
  49890. * @param activeEffect defines the effect that should be unbound from.
  49891. * @returns true if unbound, otherwise false
  49892. */
  49893. unbind(activeEffect: Effect): boolean;
  49894. /**
  49895. * Returns the texture used for refraction or null if none is used.
  49896. * @param scene defines the scene the material belongs to.
  49897. * @returns - Refraction texture if present. If no refraction texture and refraction
  49898. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49899. */
  49900. private _getRefractionTexture;
  49901. /**
  49902. * Returns true if alpha blending should be disabled.
  49903. */
  49904. readonly disableAlphaBlending: boolean;
  49905. /**
  49906. * Fills the list of render target textures.
  49907. * @param renderTargets the list of render targets to update
  49908. */
  49909. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49910. /**
  49911. * Checks to see if a texture is used in the material.
  49912. * @param texture - Base texture to use.
  49913. * @returns - Boolean specifying if a texture is used in the material.
  49914. */
  49915. hasTexture(texture: BaseTexture): boolean;
  49916. /**
  49917. * Gets a boolean indicating that current material needs to register RTT
  49918. * @returns true if this uses a render target otherwise false.
  49919. */
  49920. hasRenderTargetTextures(): boolean;
  49921. /**
  49922. * Returns an array of the actively used textures.
  49923. * @param activeTextures Array of BaseTextures
  49924. */
  49925. getActiveTextures(activeTextures: BaseTexture[]): void;
  49926. /**
  49927. * Returns the animatable textures.
  49928. * @param animatables Array of animatable textures.
  49929. */
  49930. getAnimatables(animatables: IAnimatable[]): void;
  49931. /**
  49932. * Disposes the resources of the material.
  49933. * @param forceDisposeTextures - Forces the disposal of all textures.
  49934. */
  49935. dispose(forceDisposeTextures?: boolean): void;
  49936. /**
  49937. * Get the current class name of the texture useful for serialization or dynamic coding.
  49938. * @returns "PBRSubSurfaceConfiguration"
  49939. */
  49940. getClassName(): string;
  49941. /**
  49942. * Add fallbacks to the effect fallbacks list.
  49943. * @param defines defines the Base texture to use.
  49944. * @param fallbacks defines the current fallback list.
  49945. * @param currentRank defines the current fallback rank.
  49946. * @returns the new fallback rank.
  49947. */
  49948. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49949. /**
  49950. * Add the required uniforms to the current list.
  49951. * @param uniforms defines the current uniform list.
  49952. */
  49953. static AddUniforms(uniforms: string[]): void;
  49954. /**
  49955. * Add the required samplers to the current list.
  49956. * @param samplers defines the current sampler list.
  49957. */
  49958. static AddSamplers(samplers: string[]): void;
  49959. /**
  49960. * Add the required uniforms to the current buffer.
  49961. * @param uniformBuffer defines the current uniform buffer.
  49962. */
  49963. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49964. /**
  49965. * Makes a duplicate of the current configuration into another one.
  49966. * @param configuration define the config where to copy the info
  49967. */
  49968. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49969. /**
  49970. * Serializes this Sub Surface configuration.
  49971. * @returns - An object with the serialized config.
  49972. */
  49973. serialize(): any;
  49974. /**
  49975. * Parses a anisotropy Configuration from a serialized object.
  49976. * @param source - Serialized object.
  49977. * @param scene Defines the scene we are parsing for
  49978. * @param rootUrl Defines the rootUrl to load from
  49979. */
  49980. parse(source: any, scene: Scene, rootUrl: string): void;
  49981. }
  49982. }
  49983. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49984. /** @hidden */
  49985. export var pbrFragmentDeclaration: {
  49986. name: string;
  49987. shader: string;
  49988. };
  49989. }
  49990. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49991. /** @hidden */
  49992. export var pbrUboDeclaration: {
  49993. name: string;
  49994. shader: string;
  49995. };
  49996. }
  49997. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49998. /** @hidden */
  49999. export var pbrFragmentExtraDeclaration: {
  50000. name: string;
  50001. shader: string;
  50002. };
  50003. }
  50004. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50005. /** @hidden */
  50006. export var pbrFragmentSamplersDeclaration: {
  50007. name: string;
  50008. shader: string;
  50009. };
  50010. }
  50011. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50012. /** @hidden */
  50013. export var pbrHelperFunctions: {
  50014. name: string;
  50015. shader: string;
  50016. };
  50017. }
  50018. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50019. /** @hidden */
  50020. export var harmonicsFunctions: {
  50021. name: string;
  50022. shader: string;
  50023. };
  50024. }
  50025. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50026. /** @hidden */
  50027. export var pbrDirectLightingSetupFunctions: {
  50028. name: string;
  50029. shader: string;
  50030. };
  50031. }
  50032. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50033. /** @hidden */
  50034. export var pbrDirectLightingFalloffFunctions: {
  50035. name: string;
  50036. shader: string;
  50037. };
  50038. }
  50039. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50040. /** @hidden */
  50041. export var pbrBRDFFunctions: {
  50042. name: string;
  50043. shader: string;
  50044. };
  50045. }
  50046. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50047. /** @hidden */
  50048. export var pbrDirectLightingFunctions: {
  50049. name: string;
  50050. shader: string;
  50051. };
  50052. }
  50053. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50054. /** @hidden */
  50055. export var pbrIBLFunctions: {
  50056. name: string;
  50057. shader: string;
  50058. };
  50059. }
  50060. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50061. /** @hidden */
  50062. export var pbrDebug: {
  50063. name: string;
  50064. shader: string;
  50065. };
  50066. }
  50067. declare module "babylonjs/Shaders/pbr.fragment" {
  50068. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50069. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50070. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50071. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50072. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50073. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50074. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50075. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50076. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50077. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50078. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50079. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50080. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50081. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50082. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50083. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50084. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50085. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50086. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50087. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50088. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50089. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50091. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50092. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50093. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50094. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50095. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50096. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50097. /** @hidden */
  50098. export var pbrPixelShader: {
  50099. name: string;
  50100. shader: string;
  50101. };
  50102. }
  50103. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50104. /** @hidden */
  50105. export var pbrVertexDeclaration: {
  50106. name: string;
  50107. shader: string;
  50108. };
  50109. }
  50110. declare module "babylonjs/Shaders/pbr.vertex" {
  50111. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50112. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50113. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50114. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50115. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50116. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50117. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50118. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50119. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50120. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50121. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50122. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50124. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50125. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50126. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50127. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50128. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50129. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50130. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50131. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50132. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50133. /** @hidden */
  50134. export var pbrVertexShader: {
  50135. name: string;
  50136. shader: string;
  50137. };
  50138. }
  50139. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50140. import { Nullable } from "babylonjs/types";
  50141. import { Scene } from "babylonjs/scene";
  50142. import { Matrix } from "babylonjs/Maths/math.vector";
  50143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50145. import { Mesh } from "babylonjs/Meshes/mesh";
  50146. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50147. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50148. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50149. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50150. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50151. import { Color3 } from "babylonjs/Maths/math.color";
  50152. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50153. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50154. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50155. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50156. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50157. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50158. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50159. import "babylonjs/Shaders/pbr.fragment";
  50160. import "babylonjs/Shaders/pbr.vertex";
  50161. /**
  50162. * Manages the defines for the PBR Material.
  50163. * @hidden
  50164. */
  50165. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50166. PBR: boolean;
  50167. MAINUV1: boolean;
  50168. MAINUV2: boolean;
  50169. UV1: boolean;
  50170. UV2: boolean;
  50171. ALBEDO: boolean;
  50172. ALBEDODIRECTUV: number;
  50173. VERTEXCOLOR: boolean;
  50174. AMBIENT: boolean;
  50175. AMBIENTDIRECTUV: number;
  50176. AMBIENTINGRAYSCALE: boolean;
  50177. OPACITY: boolean;
  50178. VERTEXALPHA: boolean;
  50179. OPACITYDIRECTUV: number;
  50180. OPACITYRGB: boolean;
  50181. ALPHATEST: boolean;
  50182. DEPTHPREPASS: boolean;
  50183. ALPHABLEND: boolean;
  50184. ALPHAFROMALBEDO: boolean;
  50185. ALPHATESTVALUE: string;
  50186. SPECULAROVERALPHA: boolean;
  50187. RADIANCEOVERALPHA: boolean;
  50188. ALPHAFRESNEL: boolean;
  50189. LINEARALPHAFRESNEL: boolean;
  50190. PREMULTIPLYALPHA: boolean;
  50191. EMISSIVE: boolean;
  50192. EMISSIVEDIRECTUV: number;
  50193. REFLECTIVITY: boolean;
  50194. REFLECTIVITYDIRECTUV: number;
  50195. SPECULARTERM: boolean;
  50196. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50197. MICROSURFACEAUTOMATIC: boolean;
  50198. LODBASEDMICROSFURACE: boolean;
  50199. MICROSURFACEMAP: boolean;
  50200. MICROSURFACEMAPDIRECTUV: number;
  50201. METALLICWORKFLOW: boolean;
  50202. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50203. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50204. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50205. AOSTOREINMETALMAPRED: boolean;
  50206. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50207. ENVIRONMENTBRDF: boolean;
  50208. ENVIRONMENTBRDF_RGBD: boolean;
  50209. NORMAL: boolean;
  50210. TANGENT: boolean;
  50211. BUMP: boolean;
  50212. BUMPDIRECTUV: number;
  50213. OBJECTSPACE_NORMALMAP: boolean;
  50214. PARALLAX: boolean;
  50215. PARALLAXOCCLUSION: boolean;
  50216. NORMALXYSCALE: boolean;
  50217. LIGHTMAP: boolean;
  50218. LIGHTMAPDIRECTUV: number;
  50219. USELIGHTMAPASSHADOWMAP: boolean;
  50220. GAMMALIGHTMAP: boolean;
  50221. RGBDLIGHTMAP: boolean;
  50222. REFLECTION: boolean;
  50223. REFLECTIONMAP_3D: boolean;
  50224. REFLECTIONMAP_SPHERICAL: boolean;
  50225. REFLECTIONMAP_PLANAR: boolean;
  50226. REFLECTIONMAP_CUBIC: boolean;
  50227. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50228. REFLECTIONMAP_PROJECTION: boolean;
  50229. REFLECTIONMAP_SKYBOX: boolean;
  50230. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50231. REFLECTIONMAP_EXPLICIT: boolean;
  50232. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50233. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50234. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50235. INVERTCUBICMAP: boolean;
  50236. USESPHERICALFROMREFLECTIONMAP: boolean;
  50237. USEIRRADIANCEMAP: boolean;
  50238. SPHERICAL_HARMONICS: boolean;
  50239. USESPHERICALINVERTEX: boolean;
  50240. REFLECTIONMAP_OPPOSITEZ: boolean;
  50241. LODINREFLECTIONALPHA: boolean;
  50242. GAMMAREFLECTION: boolean;
  50243. RGBDREFLECTION: boolean;
  50244. LINEARSPECULARREFLECTION: boolean;
  50245. RADIANCEOCCLUSION: boolean;
  50246. HORIZONOCCLUSION: boolean;
  50247. INSTANCES: boolean;
  50248. NUM_BONE_INFLUENCERS: number;
  50249. BonesPerMesh: number;
  50250. BONETEXTURE: boolean;
  50251. NONUNIFORMSCALING: boolean;
  50252. MORPHTARGETS: boolean;
  50253. MORPHTARGETS_NORMAL: boolean;
  50254. MORPHTARGETS_TANGENT: boolean;
  50255. MORPHTARGETS_UV: boolean;
  50256. NUM_MORPH_INFLUENCERS: number;
  50257. IMAGEPROCESSING: boolean;
  50258. VIGNETTE: boolean;
  50259. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50260. VIGNETTEBLENDMODEOPAQUE: boolean;
  50261. TONEMAPPING: boolean;
  50262. TONEMAPPING_ACES: boolean;
  50263. CONTRAST: boolean;
  50264. COLORCURVES: boolean;
  50265. COLORGRADING: boolean;
  50266. COLORGRADING3D: boolean;
  50267. SAMPLER3DGREENDEPTH: boolean;
  50268. SAMPLER3DBGRMAP: boolean;
  50269. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50270. EXPOSURE: boolean;
  50271. MULTIVIEW: boolean;
  50272. USEPHYSICALLIGHTFALLOFF: boolean;
  50273. USEGLTFLIGHTFALLOFF: boolean;
  50274. TWOSIDEDLIGHTING: boolean;
  50275. SHADOWFLOAT: boolean;
  50276. CLIPPLANE: boolean;
  50277. CLIPPLANE2: boolean;
  50278. CLIPPLANE3: boolean;
  50279. CLIPPLANE4: boolean;
  50280. POINTSIZE: boolean;
  50281. FOG: boolean;
  50282. LOGARITHMICDEPTH: boolean;
  50283. FORCENORMALFORWARD: boolean;
  50284. SPECULARAA: boolean;
  50285. CLEARCOAT: boolean;
  50286. CLEARCOAT_DEFAULTIOR: boolean;
  50287. CLEARCOAT_TEXTURE: boolean;
  50288. CLEARCOAT_TEXTUREDIRECTUV: number;
  50289. CLEARCOAT_BUMP: boolean;
  50290. CLEARCOAT_BUMPDIRECTUV: number;
  50291. CLEARCOAT_TINT: boolean;
  50292. CLEARCOAT_TINT_TEXTURE: boolean;
  50293. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50294. ANISOTROPIC: boolean;
  50295. ANISOTROPIC_TEXTURE: boolean;
  50296. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50297. BRDF_V_HEIGHT_CORRELATED: boolean;
  50298. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50299. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50300. SHEEN: boolean;
  50301. SHEEN_TEXTURE: boolean;
  50302. SHEEN_TEXTUREDIRECTUV: number;
  50303. SHEEN_LINKWITHALBEDO: boolean;
  50304. SUBSURFACE: boolean;
  50305. SS_REFRACTION: boolean;
  50306. SS_TRANSLUCENCY: boolean;
  50307. SS_SCATERRING: boolean;
  50308. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50309. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50310. SS_REFRACTIONMAP_3D: boolean;
  50311. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50312. SS_LODINREFRACTIONALPHA: boolean;
  50313. SS_GAMMAREFRACTION: boolean;
  50314. SS_RGBDREFRACTION: boolean;
  50315. SS_LINEARSPECULARREFRACTION: boolean;
  50316. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50317. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50318. UNLIT: boolean;
  50319. DEBUGMODE: number;
  50320. /**
  50321. * Initializes the PBR Material defines.
  50322. */
  50323. constructor();
  50324. /**
  50325. * Resets the PBR Material defines.
  50326. */
  50327. reset(): void;
  50328. }
  50329. /**
  50330. * The Physically based material base class of BJS.
  50331. *
  50332. * This offers the main features of a standard PBR material.
  50333. * For more information, please refer to the documentation :
  50334. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50335. */
  50336. export abstract class PBRBaseMaterial extends PushMaterial {
  50337. /**
  50338. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50339. */
  50340. static readonly PBRMATERIAL_OPAQUE: number;
  50341. /**
  50342. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50343. */
  50344. static readonly PBRMATERIAL_ALPHATEST: number;
  50345. /**
  50346. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50347. */
  50348. static readonly PBRMATERIAL_ALPHABLEND: number;
  50349. /**
  50350. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50351. * They are also discarded below the alpha cutoff threshold to improve performances.
  50352. */
  50353. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50354. /**
  50355. * Defines the default value of how much AO map is occluding the analytical lights
  50356. * (point spot...).
  50357. */
  50358. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50359. /**
  50360. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50361. */
  50362. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50363. /**
  50364. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50365. * to enhance interoperability with other engines.
  50366. */
  50367. static readonly LIGHTFALLOFF_GLTF: number;
  50368. /**
  50369. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50370. * to enhance interoperability with other materials.
  50371. */
  50372. static readonly LIGHTFALLOFF_STANDARD: number;
  50373. /**
  50374. * Intensity of the direct lights e.g. the four lights available in your scene.
  50375. * This impacts both the direct diffuse and specular highlights.
  50376. */
  50377. protected _directIntensity: number;
  50378. /**
  50379. * Intensity of the emissive part of the material.
  50380. * This helps controlling the emissive effect without modifying the emissive color.
  50381. */
  50382. protected _emissiveIntensity: number;
  50383. /**
  50384. * Intensity of the environment e.g. how much the environment will light the object
  50385. * either through harmonics for rough material or through the refelction for shiny ones.
  50386. */
  50387. protected _environmentIntensity: number;
  50388. /**
  50389. * This is a special control allowing the reduction of the specular highlights coming from the
  50390. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50391. */
  50392. protected _specularIntensity: number;
  50393. /**
  50394. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50395. */
  50396. private _lightingInfos;
  50397. /**
  50398. * Debug Control allowing disabling the bump map on this material.
  50399. */
  50400. protected _disableBumpMap: boolean;
  50401. /**
  50402. * AKA Diffuse Texture in standard nomenclature.
  50403. */
  50404. protected _albedoTexture: Nullable<BaseTexture>;
  50405. /**
  50406. * AKA Occlusion Texture in other nomenclature.
  50407. */
  50408. protected _ambientTexture: Nullable<BaseTexture>;
  50409. /**
  50410. * AKA Occlusion Texture Intensity in other nomenclature.
  50411. */
  50412. protected _ambientTextureStrength: number;
  50413. /**
  50414. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50415. * 1 means it completely occludes it
  50416. * 0 mean it has no impact
  50417. */
  50418. protected _ambientTextureImpactOnAnalyticalLights: number;
  50419. /**
  50420. * Stores the alpha values in a texture.
  50421. */
  50422. protected _opacityTexture: Nullable<BaseTexture>;
  50423. /**
  50424. * Stores the reflection values in a texture.
  50425. */
  50426. protected _reflectionTexture: Nullable<BaseTexture>;
  50427. /**
  50428. * Stores the emissive values in a texture.
  50429. */
  50430. protected _emissiveTexture: Nullable<BaseTexture>;
  50431. /**
  50432. * AKA Specular texture in other nomenclature.
  50433. */
  50434. protected _reflectivityTexture: Nullable<BaseTexture>;
  50435. /**
  50436. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50437. */
  50438. protected _metallicTexture: Nullable<BaseTexture>;
  50439. /**
  50440. * Specifies the metallic scalar of the metallic/roughness workflow.
  50441. * Can also be used to scale the metalness values of the metallic texture.
  50442. */
  50443. protected _metallic: Nullable<number>;
  50444. /**
  50445. * Specifies the roughness scalar of the metallic/roughness workflow.
  50446. * Can also be used to scale the roughness values of the metallic texture.
  50447. */
  50448. protected _roughness: Nullable<number>;
  50449. /**
  50450. * Specifies the an F0 factor to help configuring the material F0.
  50451. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50452. * to 0.5 the previously hard coded value stays the same.
  50453. * Can also be used to scale the F0 values of the metallic texture.
  50454. */
  50455. protected _metallicF0Factor: number;
  50456. /**
  50457. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50458. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50459. * your expectation as it multiplies with the texture data.
  50460. */
  50461. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50462. /**
  50463. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50464. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50465. */
  50466. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50467. /**
  50468. * Stores surface normal data used to displace a mesh in a texture.
  50469. */
  50470. protected _bumpTexture: Nullable<BaseTexture>;
  50471. /**
  50472. * Stores the pre-calculated light information of a mesh in a texture.
  50473. */
  50474. protected _lightmapTexture: Nullable<BaseTexture>;
  50475. /**
  50476. * The color of a material in ambient lighting.
  50477. */
  50478. protected _ambientColor: Color3;
  50479. /**
  50480. * AKA Diffuse Color in other nomenclature.
  50481. */
  50482. protected _albedoColor: Color3;
  50483. /**
  50484. * AKA Specular Color in other nomenclature.
  50485. */
  50486. protected _reflectivityColor: Color3;
  50487. /**
  50488. * The color applied when light is reflected from a material.
  50489. */
  50490. protected _reflectionColor: Color3;
  50491. /**
  50492. * The color applied when light is emitted from a material.
  50493. */
  50494. protected _emissiveColor: Color3;
  50495. /**
  50496. * AKA Glossiness in other nomenclature.
  50497. */
  50498. protected _microSurface: number;
  50499. /**
  50500. * Specifies that the material will use the light map as a show map.
  50501. */
  50502. protected _useLightmapAsShadowmap: boolean;
  50503. /**
  50504. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50505. * makes the reflect vector face the model (under horizon).
  50506. */
  50507. protected _useHorizonOcclusion: boolean;
  50508. /**
  50509. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50510. * too much the area relying on ambient texture to define their ambient occlusion.
  50511. */
  50512. protected _useRadianceOcclusion: boolean;
  50513. /**
  50514. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50515. */
  50516. protected _useAlphaFromAlbedoTexture: boolean;
  50517. /**
  50518. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50519. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50520. */
  50521. protected _useSpecularOverAlpha: boolean;
  50522. /**
  50523. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50524. */
  50525. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50526. /**
  50527. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50528. */
  50529. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50530. /**
  50531. * Specifies if the metallic texture contains the roughness information in its green channel.
  50532. */
  50533. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50534. /**
  50535. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50536. */
  50537. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50538. /**
  50539. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50540. */
  50541. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50542. /**
  50543. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50544. */
  50545. protected _useAmbientInGrayScale: boolean;
  50546. /**
  50547. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50548. * The material will try to infer what glossiness each pixel should be.
  50549. */
  50550. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50551. /**
  50552. * Defines the falloff type used in this material.
  50553. * It by default is Physical.
  50554. */
  50555. protected _lightFalloff: number;
  50556. /**
  50557. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50558. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50559. */
  50560. protected _useRadianceOverAlpha: boolean;
  50561. /**
  50562. * Allows using an object space normal map (instead of tangent space).
  50563. */
  50564. protected _useObjectSpaceNormalMap: boolean;
  50565. /**
  50566. * Allows using the bump map in parallax mode.
  50567. */
  50568. protected _useParallax: boolean;
  50569. /**
  50570. * Allows using the bump map in parallax occlusion mode.
  50571. */
  50572. protected _useParallaxOcclusion: boolean;
  50573. /**
  50574. * Controls the scale bias of the parallax mode.
  50575. */
  50576. protected _parallaxScaleBias: number;
  50577. /**
  50578. * If sets to true, disables all the lights affecting the material.
  50579. */
  50580. protected _disableLighting: boolean;
  50581. /**
  50582. * Number of Simultaneous lights allowed on the material.
  50583. */
  50584. protected _maxSimultaneousLights: number;
  50585. /**
  50586. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50587. */
  50588. protected _invertNormalMapX: boolean;
  50589. /**
  50590. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50591. */
  50592. protected _invertNormalMapY: boolean;
  50593. /**
  50594. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50595. */
  50596. protected _twoSidedLighting: boolean;
  50597. /**
  50598. * Defines the alpha limits in alpha test mode.
  50599. */
  50600. protected _alphaCutOff: number;
  50601. /**
  50602. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50603. */
  50604. protected _forceAlphaTest: boolean;
  50605. /**
  50606. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50607. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50608. */
  50609. protected _useAlphaFresnel: boolean;
  50610. /**
  50611. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50612. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50613. */
  50614. protected _useLinearAlphaFresnel: boolean;
  50615. /**
  50616. * The transparency mode of the material.
  50617. */
  50618. protected _transparencyMode: Nullable<number>;
  50619. /**
  50620. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50621. * from cos thetav and roughness:
  50622. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50623. */
  50624. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50625. /**
  50626. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50627. */
  50628. protected _forceIrradianceInFragment: boolean;
  50629. /**
  50630. * Force normal to face away from face.
  50631. */
  50632. protected _forceNormalForward: boolean;
  50633. /**
  50634. * Enables specular anti aliasing in the PBR shader.
  50635. * It will both interacts on the Geometry for analytical and IBL lighting.
  50636. * It also prefilter the roughness map based on the bump values.
  50637. */
  50638. protected _enableSpecularAntiAliasing: boolean;
  50639. /**
  50640. * Default configuration related to image processing available in the PBR Material.
  50641. */
  50642. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50643. /**
  50644. * Keep track of the image processing observer to allow dispose and replace.
  50645. */
  50646. private _imageProcessingObserver;
  50647. /**
  50648. * Attaches a new image processing configuration to the PBR Material.
  50649. * @param configuration
  50650. */
  50651. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50652. /**
  50653. * Stores the available render targets.
  50654. */
  50655. private _renderTargets;
  50656. /**
  50657. * Sets the global ambient color for the material used in lighting calculations.
  50658. */
  50659. private _globalAmbientColor;
  50660. /**
  50661. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50662. */
  50663. private _useLogarithmicDepth;
  50664. /**
  50665. * If set to true, no lighting calculations will be applied.
  50666. */
  50667. private _unlit;
  50668. private _debugMode;
  50669. /**
  50670. * @hidden
  50671. * This is reserved for the inspector.
  50672. * Defines the material debug mode.
  50673. * It helps seeing only some components of the material while troubleshooting.
  50674. */
  50675. debugMode: number;
  50676. /**
  50677. * @hidden
  50678. * This is reserved for the inspector.
  50679. * Specify from where on screen the debug mode should start.
  50680. * The value goes from -1 (full screen) to 1 (not visible)
  50681. * It helps with side by side comparison against the final render
  50682. * This defaults to -1
  50683. */
  50684. private debugLimit;
  50685. /**
  50686. * @hidden
  50687. * This is reserved for the inspector.
  50688. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50689. * You can use the factor to better multiply the final value.
  50690. */
  50691. private debugFactor;
  50692. /**
  50693. * Defines the clear coat layer parameters for the material.
  50694. */
  50695. readonly clearCoat: PBRClearCoatConfiguration;
  50696. /**
  50697. * Defines the anisotropic parameters for the material.
  50698. */
  50699. readonly anisotropy: PBRAnisotropicConfiguration;
  50700. /**
  50701. * Defines the BRDF parameters for the material.
  50702. */
  50703. readonly brdf: PBRBRDFConfiguration;
  50704. /**
  50705. * Defines the Sheen parameters for the material.
  50706. */
  50707. readonly sheen: PBRSheenConfiguration;
  50708. /**
  50709. * Defines the SubSurface parameters for the material.
  50710. */
  50711. readonly subSurface: PBRSubSurfaceConfiguration;
  50712. /**
  50713. * Custom callback helping to override the default shader used in the material.
  50714. */
  50715. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50716. protected _rebuildInParallel: boolean;
  50717. /**
  50718. * Instantiates a new PBRMaterial instance.
  50719. *
  50720. * @param name The material name
  50721. * @param scene The scene the material will be use in.
  50722. */
  50723. constructor(name: string, scene: Scene);
  50724. /**
  50725. * Gets a boolean indicating that current material needs to register RTT
  50726. */
  50727. readonly hasRenderTargetTextures: boolean;
  50728. /**
  50729. * Gets the name of the material class.
  50730. */
  50731. getClassName(): string;
  50732. /**
  50733. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50734. */
  50735. /**
  50736. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50737. */
  50738. useLogarithmicDepth: boolean;
  50739. /**
  50740. * Gets the current transparency mode.
  50741. */
  50742. /**
  50743. * Sets the transparency mode of the material.
  50744. *
  50745. * | Value | Type | Description |
  50746. * | ----- | ----------------------------------- | ----------- |
  50747. * | 0 | OPAQUE | |
  50748. * | 1 | ALPHATEST | |
  50749. * | 2 | ALPHABLEND | |
  50750. * | 3 | ALPHATESTANDBLEND | |
  50751. *
  50752. */
  50753. transparencyMode: Nullable<number>;
  50754. /**
  50755. * Returns true if alpha blending should be disabled.
  50756. */
  50757. private readonly _disableAlphaBlending;
  50758. /**
  50759. * Specifies whether or not this material should be rendered in alpha blend mode.
  50760. */
  50761. needAlphaBlending(): boolean;
  50762. /**
  50763. * Specifies if the mesh will require alpha blending.
  50764. * @param mesh - BJS mesh.
  50765. */
  50766. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50767. /**
  50768. * Specifies whether or not this material should be rendered in alpha test mode.
  50769. */
  50770. needAlphaTesting(): boolean;
  50771. /**
  50772. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50773. */
  50774. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50775. /**
  50776. * Gets the texture used for the alpha test.
  50777. */
  50778. getAlphaTestTexture(): Nullable<BaseTexture>;
  50779. /**
  50780. * Specifies that the submesh is ready to be used.
  50781. * @param mesh - BJS mesh.
  50782. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50783. * @param useInstances - Specifies that instances should be used.
  50784. * @returns - boolean indicating that the submesh is ready or not.
  50785. */
  50786. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50787. /**
  50788. * Specifies if the material uses metallic roughness workflow.
  50789. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50790. */
  50791. isMetallicWorkflow(): boolean;
  50792. private _prepareEffect;
  50793. private _prepareDefines;
  50794. /**
  50795. * Force shader compilation
  50796. */
  50797. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50798. /**
  50799. * Initializes the uniform buffer layout for the shader.
  50800. */
  50801. buildUniformLayout(): void;
  50802. /**
  50803. * Unbinds the material from the mesh
  50804. */
  50805. unbind(): void;
  50806. /**
  50807. * Binds the submesh data.
  50808. * @param world - The world matrix.
  50809. * @param mesh - The BJS mesh.
  50810. * @param subMesh - A submesh of the BJS mesh.
  50811. */
  50812. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50813. /**
  50814. * Returns the animatable textures.
  50815. * @returns - Array of animatable textures.
  50816. */
  50817. getAnimatables(): IAnimatable[];
  50818. /**
  50819. * Returns the texture used for reflections.
  50820. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50821. */
  50822. private _getReflectionTexture;
  50823. /**
  50824. * Returns an array of the actively used textures.
  50825. * @returns - Array of BaseTextures
  50826. */
  50827. getActiveTextures(): BaseTexture[];
  50828. /**
  50829. * Checks to see if a texture is used in the material.
  50830. * @param texture - Base texture to use.
  50831. * @returns - Boolean specifying if a texture is used in the material.
  50832. */
  50833. hasTexture(texture: BaseTexture): boolean;
  50834. /**
  50835. * Disposes the resources of the material.
  50836. * @param forceDisposeEffect - Forces the disposal of effects.
  50837. * @param forceDisposeTextures - Forces the disposal of all textures.
  50838. */
  50839. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50840. }
  50841. }
  50842. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50843. import { Nullable } from "babylonjs/types";
  50844. import { Scene } from "babylonjs/scene";
  50845. import { Color3 } from "babylonjs/Maths/math.color";
  50846. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50847. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50849. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50850. /**
  50851. * The Physically based material of BJS.
  50852. *
  50853. * This offers the main features of a standard PBR material.
  50854. * For more information, please refer to the documentation :
  50855. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50856. */
  50857. export class PBRMaterial extends PBRBaseMaterial {
  50858. /**
  50859. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50860. */
  50861. static readonly PBRMATERIAL_OPAQUE: number;
  50862. /**
  50863. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50864. */
  50865. static readonly PBRMATERIAL_ALPHATEST: number;
  50866. /**
  50867. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50868. */
  50869. static readonly PBRMATERIAL_ALPHABLEND: number;
  50870. /**
  50871. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50872. * They are also discarded below the alpha cutoff threshold to improve performances.
  50873. */
  50874. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50875. /**
  50876. * Defines the default value of how much AO map is occluding the analytical lights
  50877. * (point spot...).
  50878. */
  50879. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50880. /**
  50881. * Intensity of the direct lights e.g. the four lights available in your scene.
  50882. * This impacts both the direct diffuse and specular highlights.
  50883. */
  50884. directIntensity: number;
  50885. /**
  50886. * Intensity of the emissive part of the material.
  50887. * This helps controlling the emissive effect without modifying the emissive color.
  50888. */
  50889. emissiveIntensity: number;
  50890. /**
  50891. * Intensity of the environment e.g. how much the environment will light the object
  50892. * either through harmonics for rough material or through the refelction for shiny ones.
  50893. */
  50894. environmentIntensity: number;
  50895. /**
  50896. * This is a special control allowing the reduction of the specular highlights coming from the
  50897. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50898. */
  50899. specularIntensity: number;
  50900. /**
  50901. * Debug Control allowing disabling the bump map on this material.
  50902. */
  50903. disableBumpMap: boolean;
  50904. /**
  50905. * AKA Diffuse Texture in standard nomenclature.
  50906. */
  50907. albedoTexture: BaseTexture;
  50908. /**
  50909. * AKA Occlusion Texture in other nomenclature.
  50910. */
  50911. ambientTexture: BaseTexture;
  50912. /**
  50913. * AKA Occlusion Texture Intensity in other nomenclature.
  50914. */
  50915. ambientTextureStrength: number;
  50916. /**
  50917. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50918. * 1 means it completely occludes it
  50919. * 0 mean it has no impact
  50920. */
  50921. ambientTextureImpactOnAnalyticalLights: number;
  50922. /**
  50923. * Stores the alpha values in a texture.
  50924. */
  50925. opacityTexture: BaseTexture;
  50926. /**
  50927. * Stores the reflection values in a texture.
  50928. */
  50929. reflectionTexture: Nullable<BaseTexture>;
  50930. /**
  50931. * Stores the emissive values in a texture.
  50932. */
  50933. emissiveTexture: BaseTexture;
  50934. /**
  50935. * AKA Specular texture in other nomenclature.
  50936. */
  50937. reflectivityTexture: BaseTexture;
  50938. /**
  50939. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50940. */
  50941. metallicTexture: BaseTexture;
  50942. /**
  50943. * Specifies the metallic scalar of the metallic/roughness workflow.
  50944. * Can also be used to scale the metalness values of the metallic texture.
  50945. */
  50946. metallic: Nullable<number>;
  50947. /**
  50948. * Specifies the roughness scalar of the metallic/roughness workflow.
  50949. * Can also be used to scale the roughness values of the metallic texture.
  50950. */
  50951. roughness: Nullable<number>;
  50952. /**
  50953. * Specifies the an F0 factor to help configuring the material F0.
  50954. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50955. * to 0.5 the previously hard coded value stays the same.
  50956. * Can also be used to scale the F0 values of the metallic texture.
  50957. */
  50958. metallicF0Factor: number;
  50959. /**
  50960. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50961. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50962. * your expectation as it multiplies with the texture data.
  50963. */
  50964. useMetallicF0FactorFromMetallicTexture: boolean;
  50965. /**
  50966. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50967. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50968. */
  50969. microSurfaceTexture: BaseTexture;
  50970. /**
  50971. * Stores surface normal data used to displace a mesh in a texture.
  50972. */
  50973. bumpTexture: BaseTexture;
  50974. /**
  50975. * Stores the pre-calculated light information of a mesh in a texture.
  50976. */
  50977. lightmapTexture: BaseTexture;
  50978. /**
  50979. * Stores the refracted light information in a texture.
  50980. */
  50981. refractionTexture: Nullable<BaseTexture>;
  50982. /**
  50983. * The color of a material in ambient lighting.
  50984. */
  50985. ambientColor: Color3;
  50986. /**
  50987. * AKA Diffuse Color in other nomenclature.
  50988. */
  50989. albedoColor: Color3;
  50990. /**
  50991. * AKA Specular Color in other nomenclature.
  50992. */
  50993. reflectivityColor: Color3;
  50994. /**
  50995. * The color reflected from the material.
  50996. */
  50997. reflectionColor: Color3;
  50998. /**
  50999. * The color emitted from the material.
  51000. */
  51001. emissiveColor: Color3;
  51002. /**
  51003. * AKA Glossiness in other nomenclature.
  51004. */
  51005. microSurface: number;
  51006. /**
  51007. * source material index of refraction (IOR)' / 'destination material IOR.
  51008. */
  51009. indexOfRefraction: number;
  51010. /**
  51011. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51012. */
  51013. invertRefractionY: boolean;
  51014. /**
  51015. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51016. * Materials half opaque for instance using refraction could benefit from this control.
  51017. */
  51018. linkRefractionWithTransparency: boolean;
  51019. /**
  51020. * If true, the light map contains occlusion information instead of lighting info.
  51021. */
  51022. useLightmapAsShadowmap: boolean;
  51023. /**
  51024. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51025. */
  51026. useAlphaFromAlbedoTexture: boolean;
  51027. /**
  51028. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51029. */
  51030. forceAlphaTest: boolean;
  51031. /**
  51032. * Defines the alpha limits in alpha test mode.
  51033. */
  51034. alphaCutOff: number;
  51035. /**
  51036. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51037. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51038. */
  51039. useSpecularOverAlpha: boolean;
  51040. /**
  51041. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51042. */
  51043. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51044. /**
  51045. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51046. */
  51047. useRoughnessFromMetallicTextureAlpha: boolean;
  51048. /**
  51049. * Specifies if the metallic texture contains the roughness information in its green channel.
  51050. */
  51051. useRoughnessFromMetallicTextureGreen: boolean;
  51052. /**
  51053. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51054. */
  51055. useMetallnessFromMetallicTextureBlue: boolean;
  51056. /**
  51057. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51058. */
  51059. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51060. /**
  51061. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51062. */
  51063. useAmbientInGrayScale: boolean;
  51064. /**
  51065. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51066. * The material will try to infer what glossiness each pixel should be.
  51067. */
  51068. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51069. /**
  51070. * BJS is using an harcoded light falloff based on a manually sets up range.
  51071. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51072. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51073. */
  51074. /**
  51075. * BJS is using an harcoded light falloff based on a manually sets up range.
  51076. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51077. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51078. */
  51079. usePhysicalLightFalloff: boolean;
  51080. /**
  51081. * In order to support the falloff compatibility with gltf, a special mode has been added
  51082. * to reproduce the gltf light falloff.
  51083. */
  51084. /**
  51085. * In order to support the falloff compatibility with gltf, a special mode has been added
  51086. * to reproduce the gltf light falloff.
  51087. */
  51088. useGLTFLightFalloff: boolean;
  51089. /**
  51090. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51091. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51092. */
  51093. useRadianceOverAlpha: boolean;
  51094. /**
  51095. * Allows using an object space normal map (instead of tangent space).
  51096. */
  51097. useObjectSpaceNormalMap: boolean;
  51098. /**
  51099. * Allows using the bump map in parallax mode.
  51100. */
  51101. useParallax: boolean;
  51102. /**
  51103. * Allows using the bump map in parallax occlusion mode.
  51104. */
  51105. useParallaxOcclusion: boolean;
  51106. /**
  51107. * Controls the scale bias of the parallax mode.
  51108. */
  51109. parallaxScaleBias: number;
  51110. /**
  51111. * If sets to true, disables all the lights affecting the material.
  51112. */
  51113. disableLighting: boolean;
  51114. /**
  51115. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51116. */
  51117. forceIrradianceInFragment: boolean;
  51118. /**
  51119. * Number of Simultaneous lights allowed on the material.
  51120. */
  51121. maxSimultaneousLights: number;
  51122. /**
  51123. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51124. */
  51125. invertNormalMapX: boolean;
  51126. /**
  51127. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51128. */
  51129. invertNormalMapY: boolean;
  51130. /**
  51131. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51132. */
  51133. twoSidedLighting: boolean;
  51134. /**
  51135. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51136. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51137. */
  51138. useAlphaFresnel: boolean;
  51139. /**
  51140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51141. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51142. */
  51143. useLinearAlphaFresnel: boolean;
  51144. /**
  51145. * Let user defines the brdf lookup texture used for IBL.
  51146. * A default 8bit version is embedded but you could point at :
  51147. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51148. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51149. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51150. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51151. */
  51152. environmentBRDFTexture: Nullable<BaseTexture>;
  51153. /**
  51154. * Force normal to face away from face.
  51155. */
  51156. forceNormalForward: boolean;
  51157. /**
  51158. * Enables specular anti aliasing in the PBR shader.
  51159. * It will both interacts on the Geometry for analytical and IBL lighting.
  51160. * It also prefilter the roughness map based on the bump values.
  51161. */
  51162. enableSpecularAntiAliasing: boolean;
  51163. /**
  51164. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51165. * makes the reflect vector face the model (under horizon).
  51166. */
  51167. useHorizonOcclusion: boolean;
  51168. /**
  51169. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51170. * too much the area relying on ambient texture to define their ambient occlusion.
  51171. */
  51172. useRadianceOcclusion: boolean;
  51173. /**
  51174. * If set to true, no lighting calculations will be applied.
  51175. */
  51176. unlit: boolean;
  51177. /**
  51178. * Gets the image processing configuration used either in this material.
  51179. */
  51180. /**
  51181. * Sets the Default image processing configuration used either in the this material.
  51182. *
  51183. * If sets to null, the scene one is in use.
  51184. */
  51185. imageProcessingConfiguration: ImageProcessingConfiguration;
  51186. /**
  51187. * Gets wether the color curves effect is enabled.
  51188. */
  51189. /**
  51190. * Sets wether the color curves effect is enabled.
  51191. */
  51192. cameraColorCurvesEnabled: boolean;
  51193. /**
  51194. * Gets wether the color grading effect is enabled.
  51195. */
  51196. /**
  51197. * Gets wether the color grading effect is enabled.
  51198. */
  51199. cameraColorGradingEnabled: boolean;
  51200. /**
  51201. * Gets wether tonemapping is enabled or not.
  51202. */
  51203. /**
  51204. * Sets wether tonemapping is enabled or not
  51205. */
  51206. cameraToneMappingEnabled: boolean;
  51207. /**
  51208. * The camera exposure used on this material.
  51209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51210. * This corresponds to a photographic exposure.
  51211. */
  51212. /**
  51213. * The camera exposure used on this material.
  51214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51215. * This corresponds to a photographic exposure.
  51216. */
  51217. cameraExposure: number;
  51218. /**
  51219. * Gets The camera contrast used on this material.
  51220. */
  51221. /**
  51222. * Sets The camera contrast used on this material.
  51223. */
  51224. cameraContrast: number;
  51225. /**
  51226. * Gets the Color Grading 2D Lookup Texture.
  51227. */
  51228. /**
  51229. * Sets the Color Grading 2D Lookup Texture.
  51230. */
  51231. cameraColorGradingTexture: Nullable<BaseTexture>;
  51232. /**
  51233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51235. * 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;
  51236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51237. */
  51238. /**
  51239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51241. * 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;
  51242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51243. */
  51244. cameraColorCurves: Nullable<ColorCurves>;
  51245. /**
  51246. * Instantiates a new PBRMaterial instance.
  51247. *
  51248. * @param name The material name
  51249. * @param scene The scene the material will be use in.
  51250. */
  51251. constructor(name: string, scene: Scene);
  51252. /**
  51253. * Returns the name of this material class.
  51254. */
  51255. getClassName(): string;
  51256. /**
  51257. * Makes a duplicate of the current material.
  51258. * @param name - name to use for the new material.
  51259. */
  51260. clone(name: string): PBRMaterial;
  51261. /**
  51262. * Serializes this PBR Material.
  51263. * @returns - An object with the serialized material.
  51264. */
  51265. serialize(): any;
  51266. /**
  51267. * Parses a PBR Material from a serialized object.
  51268. * @param source - Serialized object.
  51269. * @param scene - BJS scene instance.
  51270. * @param rootUrl - url for the scene object
  51271. * @returns - PBRMaterial
  51272. */
  51273. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51274. }
  51275. }
  51276. declare module "babylonjs/Misc/dds" {
  51277. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51278. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51279. import { Nullable } from "babylonjs/types";
  51280. import { Scene } from "babylonjs/scene";
  51281. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51282. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51283. /**
  51284. * Direct draw surface info
  51285. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51286. */
  51287. export interface DDSInfo {
  51288. /**
  51289. * Width of the texture
  51290. */
  51291. width: number;
  51292. /**
  51293. * Width of the texture
  51294. */
  51295. height: number;
  51296. /**
  51297. * Number of Mipmaps for the texture
  51298. * @see https://en.wikipedia.org/wiki/Mipmap
  51299. */
  51300. mipmapCount: number;
  51301. /**
  51302. * If the textures format is a known fourCC format
  51303. * @see https://www.fourcc.org/
  51304. */
  51305. isFourCC: boolean;
  51306. /**
  51307. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51308. */
  51309. isRGB: boolean;
  51310. /**
  51311. * If the texture is a lumincance format
  51312. */
  51313. isLuminance: boolean;
  51314. /**
  51315. * If this is a cube texture
  51316. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51317. */
  51318. isCube: boolean;
  51319. /**
  51320. * If the texture is a compressed format eg. FOURCC_DXT1
  51321. */
  51322. isCompressed: boolean;
  51323. /**
  51324. * The dxgiFormat of the texture
  51325. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51326. */
  51327. dxgiFormat: number;
  51328. /**
  51329. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51330. */
  51331. textureType: number;
  51332. /**
  51333. * Sphericle polynomial created for the dds texture
  51334. */
  51335. sphericalPolynomial?: SphericalPolynomial;
  51336. }
  51337. /**
  51338. * Class used to provide DDS decompression tools
  51339. */
  51340. export class DDSTools {
  51341. /**
  51342. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51343. */
  51344. static StoreLODInAlphaChannel: boolean;
  51345. /**
  51346. * Gets DDS information from an array buffer
  51347. * @param arrayBuffer defines the array buffer to read data from
  51348. * @returns the DDS information
  51349. */
  51350. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51351. private static _FloatView;
  51352. private static _Int32View;
  51353. private static _ToHalfFloat;
  51354. private static _FromHalfFloat;
  51355. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51356. private static _GetHalfFloatRGBAArrayBuffer;
  51357. private static _GetFloatRGBAArrayBuffer;
  51358. private static _GetFloatAsUIntRGBAArrayBuffer;
  51359. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51360. private static _GetRGBAArrayBuffer;
  51361. private static _ExtractLongWordOrder;
  51362. private static _GetRGBArrayBuffer;
  51363. private static _GetLuminanceArrayBuffer;
  51364. /**
  51365. * Uploads DDS Levels to a Babylon Texture
  51366. * @hidden
  51367. */
  51368. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51369. }
  51370. module "babylonjs/Engines/thinEngine" {
  51371. interface ThinEngine {
  51372. /**
  51373. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51374. * @param rootUrl defines the url where the file to load is located
  51375. * @param scene defines the current scene
  51376. * @param lodScale defines scale to apply to the mip map selection
  51377. * @param lodOffset defines offset to apply to the mip map selection
  51378. * @param onLoad defines an optional callback raised when the texture is loaded
  51379. * @param onError defines an optional callback raised if there is an issue to load the texture
  51380. * @param format defines the format of the data
  51381. * @param forcedExtension defines the extension to use to pick the right loader
  51382. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51383. * @returns the cube texture as an InternalTexture
  51384. */
  51385. 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;
  51386. }
  51387. }
  51388. }
  51389. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51390. import { Nullable } from "babylonjs/types";
  51391. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51392. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51393. /**
  51394. * Implementation of the DDS Texture Loader.
  51395. * @hidden
  51396. */
  51397. export class _DDSTextureLoader implements IInternalTextureLoader {
  51398. /**
  51399. * Defines wether the loader supports cascade loading the different faces.
  51400. */
  51401. readonly supportCascades: boolean;
  51402. /**
  51403. * This returns if the loader support the current file information.
  51404. * @param extension defines the file extension of the file being loaded
  51405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51406. * @param fallback defines the fallback internal texture if any
  51407. * @param isBase64 defines whether the texture is encoded as a base64
  51408. * @param isBuffer defines whether the texture data are stored as a buffer
  51409. * @returns true if the loader can load the specified file
  51410. */
  51411. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51412. /**
  51413. * Transform the url before loading if required.
  51414. * @param rootUrl the url of the texture
  51415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51416. * @returns the transformed texture
  51417. */
  51418. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51419. /**
  51420. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51421. * @param rootUrl the url of the texture
  51422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51423. * @returns the fallback texture
  51424. */
  51425. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51426. /**
  51427. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51428. * @param data contains the texture data
  51429. * @param texture defines the BabylonJS internal texture
  51430. * @param createPolynomials will be true if polynomials have been requested
  51431. * @param onLoad defines the callback to trigger once the texture is ready
  51432. * @param onError defines the callback to trigger in case of error
  51433. */
  51434. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51435. /**
  51436. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51437. * @param data contains the texture data
  51438. * @param texture defines the BabylonJS internal texture
  51439. * @param callback defines the method to call once ready to upload
  51440. */
  51441. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51442. }
  51443. }
  51444. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51445. import { Nullable } from "babylonjs/types";
  51446. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51447. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51448. /**
  51449. * Implementation of the ENV Texture Loader.
  51450. * @hidden
  51451. */
  51452. export class _ENVTextureLoader implements IInternalTextureLoader {
  51453. /**
  51454. * Defines wether the loader supports cascade loading the different faces.
  51455. */
  51456. readonly supportCascades: boolean;
  51457. /**
  51458. * This returns if the loader support the current file information.
  51459. * @param extension defines the file extension of the file being loaded
  51460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51461. * @param fallback defines the fallback internal texture if any
  51462. * @param isBase64 defines whether the texture is encoded as a base64
  51463. * @param isBuffer defines whether the texture data are stored as a buffer
  51464. * @returns true if the loader can load the specified file
  51465. */
  51466. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51467. /**
  51468. * Transform the url before loading if required.
  51469. * @param rootUrl the url of the texture
  51470. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51471. * @returns the transformed texture
  51472. */
  51473. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51474. /**
  51475. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51476. * @param rootUrl the url of the texture
  51477. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51478. * @returns the fallback texture
  51479. */
  51480. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51481. /**
  51482. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51483. * @param data contains the texture data
  51484. * @param texture defines the BabylonJS internal texture
  51485. * @param createPolynomials will be true if polynomials have been requested
  51486. * @param onLoad defines the callback to trigger once the texture is ready
  51487. * @param onError defines the callback to trigger in case of error
  51488. */
  51489. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51490. /**
  51491. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51492. * @param data contains the texture data
  51493. * @param texture defines the BabylonJS internal texture
  51494. * @param callback defines the method to call once ready to upload
  51495. */
  51496. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51497. }
  51498. }
  51499. declare module "babylonjs/Misc/khronosTextureContainer" {
  51500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51501. /**
  51502. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51503. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51504. */
  51505. export class KhronosTextureContainer {
  51506. /** contents of the KTX container file */
  51507. arrayBuffer: any;
  51508. private static HEADER_LEN;
  51509. private static COMPRESSED_2D;
  51510. private static COMPRESSED_3D;
  51511. private static TEX_2D;
  51512. private static TEX_3D;
  51513. /**
  51514. * Gets the openGL type
  51515. */
  51516. glType: number;
  51517. /**
  51518. * Gets the openGL type size
  51519. */
  51520. glTypeSize: number;
  51521. /**
  51522. * Gets the openGL format
  51523. */
  51524. glFormat: number;
  51525. /**
  51526. * Gets the openGL internal format
  51527. */
  51528. glInternalFormat: number;
  51529. /**
  51530. * Gets the base internal format
  51531. */
  51532. glBaseInternalFormat: number;
  51533. /**
  51534. * Gets image width in pixel
  51535. */
  51536. pixelWidth: number;
  51537. /**
  51538. * Gets image height in pixel
  51539. */
  51540. pixelHeight: number;
  51541. /**
  51542. * Gets image depth in pixels
  51543. */
  51544. pixelDepth: number;
  51545. /**
  51546. * Gets the number of array elements
  51547. */
  51548. numberOfArrayElements: number;
  51549. /**
  51550. * Gets the number of faces
  51551. */
  51552. numberOfFaces: number;
  51553. /**
  51554. * Gets the number of mipmap levels
  51555. */
  51556. numberOfMipmapLevels: number;
  51557. /**
  51558. * Gets the bytes of key value data
  51559. */
  51560. bytesOfKeyValueData: number;
  51561. /**
  51562. * Gets the load type
  51563. */
  51564. loadType: number;
  51565. /**
  51566. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51567. */
  51568. isInvalid: boolean;
  51569. /**
  51570. * Creates a new KhronosTextureContainer
  51571. * @param arrayBuffer contents of the KTX container file
  51572. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51573. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51574. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51575. */
  51576. constructor(
  51577. /** contents of the KTX container file */
  51578. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51579. /**
  51580. * Uploads KTX content to a Babylon Texture.
  51581. * It is assumed that the texture has already been created & is currently bound
  51582. * @hidden
  51583. */
  51584. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51585. private _upload2DCompressedLevels;
  51586. }
  51587. }
  51588. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51589. import { Nullable } from "babylonjs/types";
  51590. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51591. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51592. /**
  51593. * Implementation of the KTX Texture Loader.
  51594. * @hidden
  51595. */
  51596. export class _KTXTextureLoader implements IInternalTextureLoader {
  51597. /**
  51598. * Defines wether the loader supports cascade loading the different faces.
  51599. */
  51600. readonly supportCascades: boolean;
  51601. /**
  51602. * This returns if the loader support the current file information.
  51603. * @param extension defines the file extension of the file being loaded
  51604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51605. * @param fallback defines the fallback internal texture if any
  51606. * @param isBase64 defines whether the texture is encoded as a base64
  51607. * @param isBuffer defines whether the texture data are stored as a buffer
  51608. * @returns true if the loader can load the specified file
  51609. */
  51610. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51611. /**
  51612. * Transform the url before loading if required.
  51613. * @param rootUrl the url of the texture
  51614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51615. * @returns the transformed texture
  51616. */
  51617. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51618. /**
  51619. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51620. * @param rootUrl the url of the texture
  51621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51622. * @returns the fallback texture
  51623. */
  51624. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51625. /**
  51626. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51627. * @param data contains the texture data
  51628. * @param texture defines the BabylonJS internal texture
  51629. * @param createPolynomials will be true if polynomials have been requested
  51630. * @param onLoad defines the callback to trigger once the texture is ready
  51631. * @param onError defines the callback to trigger in case of error
  51632. */
  51633. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51634. /**
  51635. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51636. * @param data contains the texture data
  51637. * @param texture defines the BabylonJS internal texture
  51638. * @param callback defines the method to call once ready to upload
  51639. */
  51640. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51641. }
  51642. }
  51643. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51644. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51645. import { Scene } from "babylonjs/scene";
  51646. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51647. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51648. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51649. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51650. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51651. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51653. /**
  51654. * Options for the default xr helper
  51655. */
  51656. export class WebXRDefaultExperienceOptions {
  51657. /**
  51658. * Floor meshes that should be used for teleporting
  51659. */
  51660. floorMeshes: Array<AbstractMesh>;
  51661. /**
  51662. * Enable or disable default UI to enter XR
  51663. */
  51664. disableDefaultUI: boolean;
  51665. }
  51666. /**
  51667. * Default experience which provides a similar setup to the previous webVRExperience
  51668. */
  51669. export class WebXRDefaultExperience {
  51670. /**
  51671. * Base experience
  51672. */
  51673. baseExperience: WebXRExperienceHelper;
  51674. /**
  51675. * Input experience extension
  51676. */
  51677. input: WebXRInput;
  51678. /**
  51679. * Loads the controller models
  51680. */
  51681. controllerModelLoader: WebXRControllerModelLoader;
  51682. /**
  51683. * Enables laser pointer and selection
  51684. */
  51685. pointerSelection: WebXRControllerPointerSelection;
  51686. /**
  51687. * Enables teleportation
  51688. */
  51689. teleportation: WebXRControllerTeleportation;
  51690. /**
  51691. * Enables ui for enetering/exiting xr
  51692. */
  51693. enterExitUI: WebXREnterExitUI;
  51694. /**
  51695. * Default target xr should render to
  51696. */
  51697. renderTarget: WebXRRenderTarget;
  51698. /**
  51699. * Creates the default xr experience
  51700. * @param scene scene
  51701. * @param options options for basic configuration
  51702. * @returns resulting WebXRDefaultExperience
  51703. */
  51704. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51705. private constructor();
  51706. /**
  51707. * DIsposes of the experience helper
  51708. */
  51709. dispose(): void;
  51710. }
  51711. }
  51712. declare module "babylonjs/Helpers/sceneHelpers" {
  51713. import { Nullable } from "babylonjs/types";
  51714. import { Mesh } from "babylonjs/Meshes/mesh";
  51715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51716. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51717. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51718. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51719. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51720. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51721. import "babylonjs/Meshes/Builders/boxBuilder";
  51722. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51723. /** @hidden */
  51724. export var _forceSceneHelpersToBundle: boolean;
  51725. module "babylonjs/scene" {
  51726. interface Scene {
  51727. /**
  51728. * Creates a default light for the scene.
  51729. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51730. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51731. */
  51732. createDefaultLight(replace?: boolean): void;
  51733. /**
  51734. * Creates a default camera for the scene.
  51735. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51736. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51737. * @param replace has default false, when true replaces the active camera in the scene
  51738. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51739. */
  51740. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51741. /**
  51742. * Creates a default camera and a default light.
  51743. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51744. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51745. * @param replace has the default false, when true replaces the active camera/light in the scene
  51746. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51747. */
  51748. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51749. /**
  51750. * Creates a new sky box
  51751. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51752. * @param environmentTexture defines the texture to use as environment texture
  51753. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51754. * @param scale defines the overall scale of the skybox
  51755. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51756. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51757. * @returns a new mesh holding the sky box
  51758. */
  51759. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51760. /**
  51761. * Creates a new environment
  51762. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51763. * @param options defines the options you can use to configure the environment
  51764. * @returns the new EnvironmentHelper
  51765. */
  51766. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51767. /**
  51768. * Creates a new VREXperienceHelper
  51769. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51770. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51771. * @returns a new VREXperienceHelper
  51772. */
  51773. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51774. /**
  51775. * Creates a new WebXRDefaultExperience
  51776. * @see http://doc.babylonjs.com/how_to/webxr
  51777. * @param options experience options
  51778. * @returns a promise for a new WebXRDefaultExperience
  51779. */
  51780. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51781. }
  51782. }
  51783. }
  51784. declare module "babylonjs/Helpers/videoDome" {
  51785. import { Scene } from "babylonjs/scene";
  51786. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51787. import { Mesh } from "babylonjs/Meshes/mesh";
  51788. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51789. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51790. import "babylonjs/Meshes/Builders/sphereBuilder";
  51791. /**
  51792. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51793. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51794. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51795. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51796. */
  51797. export class VideoDome extends TransformNode {
  51798. /**
  51799. * Define the video source as a Monoscopic panoramic 360 video.
  51800. */
  51801. static readonly MODE_MONOSCOPIC: number;
  51802. /**
  51803. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51804. */
  51805. static readonly MODE_TOPBOTTOM: number;
  51806. /**
  51807. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51808. */
  51809. static readonly MODE_SIDEBYSIDE: number;
  51810. private _halfDome;
  51811. private _useDirectMapping;
  51812. /**
  51813. * The video texture being displayed on the sphere
  51814. */
  51815. protected _videoTexture: VideoTexture;
  51816. /**
  51817. * Gets the video texture being displayed on the sphere
  51818. */
  51819. readonly videoTexture: VideoTexture;
  51820. /**
  51821. * The skybox material
  51822. */
  51823. protected _material: BackgroundMaterial;
  51824. /**
  51825. * The surface used for the skybox
  51826. */
  51827. protected _mesh: Mesh;
  51828. /**
  51829. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51830. */
  51831. private _halfDomeMask;
  51832. /**
  51833. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51834. * Also see the options.resolution property.
  51835. */
  51836. fovMultiplier: number;
  51837. private _videoMode;
  51838. /**
  51839. * Gets or set the current video mode for the video. It can be:
  51840. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51841. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51842. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51843. */
  51844. videoMode: number;
  51845. /**
  51846. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51847. *
  51848. */
  51849. /**
  51850. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51851. */
  51852. halfDome: boolean;
  51853. /**
  51854. * Oberserver used in Stereoscopic VR Mode.
  51855. */
  51856. private _onBeforeCameraRenderObserver;
  51857. /**
  51858. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51859. * @param name Element's name, child elements will append suffixes for their own names.
  51860. * @param urlsOrVideo defines the url(s) or the video element to use
  51861. * @param options An object containing optional or exposed sub element properties
  51862. */
  51863. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51864. resolution?: number;
  51865. clickToPlay?: boolean;
  51866. autoPlay?: boolean;
  51867. loop?: boolean;
  51868. size?: number;
  51869. poster?: string;
  51870. faceForward?: boolean;
  51871. useDirectMapping?: boolean;
  51872. halfDomeMode?: boolean;
  51873. }, scene: Scene);
  51874. private _changeVideoMode;
  51875. /**
  51876. * Releases resources associated with this node.
  51877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51879. */
  51880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51881. }
  51882. }
  51883. declare module "babylonjs/Helpers/index" {
  51884. export * from "babylonjs/Helpers/environmentHelper";
  51885. export * from "babylonjs/Helpers/photoDome";
  51886. export * from "babylonjs/Helpers/sceneHelpers";
  51887. export * from "babylonjs/Helpers/videoDome";
  51888. }
  51889. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51890. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51891. import { IDisposable } from "babylonjs/scene";
  51892. import { Engine } from "babylonjs/Engines/engine";
  51893. /**
  51894. * This class can be used to get instrumentation data from a Babylon engine
  51895. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51896. */
  51897. export class EngineInstrumentation implements IDisposable {
  51898. /**
  51899. * Define the instrumented engine.
  51900. */
  51901. engine: Engine;
  51902. private _captureGPUFrameTime;
  51903. private _gpuFrameTimeToken;
  51904. private _gpuFrameTime;
  51905. private _captureShaderCompilationTime;
  51906. private _shaderCompilationTime;
  51907. private _onBeginFrameObserver;
  51908. private _onEndFrameObserver;
  51909. private _onBeforeShaderCompilationObserver;
  51910. private _onAfterShaderCompilationObserver;
  51911. /**
  51912. * Gets the perf counter used for GPU frame time
  51913. */
  51914. readonly gpuFrameTimeCounter: PerfCounter;
  51915. /**
  51916. * Gets the GPU frame time capture status
  51917. */
  51918. /**
  51919. * Enable or disable the GPU frame time capture
  51920. */
  51921. captureGPUFrameTime: boolean;
  51922. /**
  51923. * Gets the perf counter used for shader compilation time
  51924. */
  51925. readonly shaderCompilationTimeCounter: PerfCounter;
  51926. /**
  51927. * Gets the shader compilation time capture status
  51928. */
  51929. /**
  51930. * Enable or disable the shader compilation time capture
  51931. */
  51932. captureShaderCompilationTime: boolean;
  51933. /**
  51934. * Instantiates a new engine instrumentation.
  51935. * This class can be used to get instrumentation data from a Babylon engine
  51936. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51937. * @param engine Defines the engine to instrument
  51938. */
  51939. constructor(
  51940. /**
  51941. * Define the instrumented engine.
  51942. */
  51943. engine: Engine);
  51944. /**
  51945. * Dispose and release associated resources.
  51946. */
  51947. dispose(): void;
  51948. }
  51949. }
  51950. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51951. import { Scene, IDisposable } from "babylonjs/scene";
  51952. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51953. /**
  51954. * This class can be used to get instrumentation data from a Babylon engine
  51955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51956. */
  51957. export class SceneInstrumentation implements IDisposable {
  51958. /**
  51959. * Defines the scene to instrument
  51960. */
  51961. scene: Scene;
  51962. private _captureActiveMeshesEvaluationTime;
  51963. private _activeMeshesEvaluationTime;
  51964. private _captureRenderTargetsRenderTime;
  51965. private _renderTargetsRenderTime;
  51966. private _captureFrameTime;
  51967. private _frameTime;
  51968. private _captureRenderTime;
  51969. private _renderTime;
  51970. private _captureInterFrameTime;
  51971. private _interFrameTime;
  51972. private _captureParticlesRenderTime;
  51973. private _particlesRenderTime;
  51974. private _captureSpritesRenderTime;
  51975. private _spritesRenderTime;
  51976. private _capturePhysicsTime;
  51977. private _physicsTime;
  51978. private _captureAnimationsTime;
  51979. private _animationsTime;
  51980. private _captureCameraRenderTime;
  51981. private _cameraRenderTime;
  51982. private _onBeforeActiveMeshesEvaluationObserver;
  51983. private _onAfterActiveMeshesEvaluationObserver;
  51984. private _onBeforeRenderTargetsRenderObserver;
  51985. private _onAfterRenderTargetsRenderObserver;
  51986. private _onAfterRenderObserver;
  51987. private _onBeforeDrawPhaseObserver;
  51988. private _onAfterDrawPhaseObserver;
  51989. private _onBeforeAnimationsObserver;
  51990. private _onBeforeParticlesRenderingObserver;
  51991. private _onAfterParticlesRenderingObserver;
  51992. private _onBeforeSpritesRenderingObserver;
  51993. private _onAfterSpritesRenderingObserver;
  51994. private _onBeforePhysicsObserver;
  51995. private _onAfterPhysicsObserver;
  51996. private _onAfterAnimationsObserver;
  51997. private _onBeforeCameraRenderObserver;
  51998. private _onAfterCameraRenderObserver;
  51999. /**
  52000. * Gets the perf counter used for active meshes evaluation time
  52001. */
  52002. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52003. /**
  52004. * Gets the active meshes evaluation time capture status
  52005. */
  52006. /**
  52007. * Enable or disable the active meshes evaluation time capture
  52008. */
  52009. captureActiveMeshesEvaluationTime: boolean;
  52010. /**
  52011. * Gets the perf counter used for render targets render time
  52012. */
  52013. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52014. /**
  52015. * Gets the render targets render time capture status
  52016. */
  52017. /**
  52018. * Enable or disable the render targets render time capture
  52019. */
  52020. captureRenderTargetsRenderTime: boolean;
  52021. /**
  52022. * Gets the perf counter used for particles render time
  52023. */
  52024. readonly particlesRenderTimeCounter: PerfCounter;
  52025. /**
  52026. * Gets the particles render time capture status
  52027. */
  52028. /**
  52029. * Enable or disable the particles render time capture
  52030. */
  52031. captureParticlesRenderTime: boolean;
  52032. /**
  52033. * Gets the perf counter used for sprites render time
  52034. */
  52035. readonly spritesRenderTimeCounter: PerfCounter;
  52036. /**
  52037. * Gets the sprites render time capture status
  52038. */
  52039. /**
  52040. * Enable or disable the sprites render time capture
  52041. */
  52042. captureSpritesRenderTime: boolean;
  52043. /**
  52044. * Gets the perf counter used for physics time
  52045. */
  52046. readonly physicsTimeCounter: PerfCounter;
  52047. /**
  52048. * Gets the physics time capture status
  52049. */
  52050. /**
  52051. * Enable or disable the physics time capture
  52052. */
  52053. capturePhysicsTime: boolean;
  52054. /**
  52055. * Gets the perf counter used for animations time
  52056. */
  52057. readonly animationsTimeCounter: PerfCounter;
  52058. /**
  52059. * Gets the animations time capture status
  52060. */
  52061. /**
  52062. * Enable or disable the animations time capture
  52063. */
  52064. captureAnimationsTime: boolean;
  52065. /**
  52066. * Gets the perf counter used for frame time capture
  52067. */
  52068. readonly frameTimeCounter: PerfCounter;
  52069. /**
  52070. * Gets the frame time capture status
  52071. */
  52072. /**
  52073. * Enable or disable the frame time capture
  52074. */
  52075. captureFrameTime: boolean;
  52076. /**
  52077. * Gets the perf counter used for inter-frames time capture
  52078. */
  52079. readonly interFrameTimeCounter: PerfCounter;
  52080. /**
  52081. * Gets the inter-frames time capture status
  52082. */
  52083. /**
  52084. * Enable or disable the inter-frames time capture
  52085. */
  52086. captureInterFrameTime: boolean;
  52087. /**
  52088. * Gets the perf counter used for render time capture
  52089. */
  52090. readonly renderTimeCounter: PerfCounter;
  52091. /**
  52092. * Gets the render time capture status
  52093. */
  52094. /**
  52095. * Enable or disable the render time capture
  52096. */
  52097. captureRenderTime: boolean;
  52098. /**
  52099. * Gets the perf counter used for camera render time capture
  52100. */
  52101. readonly cameraRenderTimeCounter: PerfCounter;
  52102. /**
  52103. * Gets the camera render time capture status
  52104. */
  52105. /**
  52106. * Enable or disable the camera render time capture
  52107. */
  52108. captureCameraRenderTime: boolean;
  52109. /**
  52110. * Gets the perf counter used for draw calls
  52111. */
  52112. readonly drawCallsCounter: PerfCounter;
  52113. /**
  52114. * Instantiates a new scene instrumentation.
  52115. * This class can be used to get instrumentation data from a Babylon engine
  52116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52117. * @param scene Defines the scene to instrument
  52118. */
  52119. constructor(
  52120. /**
  52121. * Defines the scene to instrument
  52122. */
  52123. scene: Scene);
  52124. /**
  52125. * Dispose and release associated resources.
  52126. */
  52127. dispose(): void;
  52128. }
  52129. }
  52130. declare module "babylonjs/Instrumentation/index" {
  52131. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52132. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52133. export * from "babylonjs/Instrumentation/timeToken";
  52134. }
  52135. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52136. /** @hidden */
  52137. export var glowMapGenerationPixelShader: {
  52138. name: string;
  52139. shader: string;
  52140. };
  52141. }
  52142. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52143. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52144. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52145. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52146. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52147. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52148. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52149. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52150. /** @hidden */
  52151. export var glowMapGenerationVertexShader: {
  52152. name: string;
  52153. shader: string;
  52154. };
  52155. }
  52156. declare module "babylonjs/Layers/effectLayer" {
  52157. import { Observable } from "babylonjs/Misc/observable";
  52158. import { Nullable } from "babylonjs/types";
  52159. import { Camera } from "babylonjs/Cameras/camera";
  52160. import { Scene } from "babylonjs/scene";
  52161. import { ISize } from "babylonjs/Maths/math.size";
  52162. import { Color4 } from "babylonjs/Maths/math.color";
  52163. import { Engine } from "babylonjs/Engines/engine";
  52164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52166. import { Mesh } from "babylonjs/Meshes/mesh";
  52167. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52169. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52170. import { Effect } from "babylonjs/Materials/effect";
  52171. import { Material } from "babylonjs/Materials/material";
  52172. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52173. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52174. /**
  52175. * Effect layer options. This helps customizing the behaviour
  52176. * of the effect layer.
  52177. */
  52178. export interface IEffectLayerOptions {
  52179. /**
  52180. * Multiplication factor apply to the canvas size to compute the render target size
  52181. * used to generated the objects (the smaller the faster).
  52182. */
  52183. mainTextureRatio: number;
  52184. /**
  52185. * Enforces a fixed size texture to ensure effect stability across devices.
  52186. */
  52187. mainTextureFixedSize?: number;
  52188. /**
  52189. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52190. */
  52191. alphaBlendingMode: number;
  52192. /**
  52193. * The camera attached to the layer.
  52194. */
  52195. camera: Nullable<Camera>;
  52196. /**
  52197. * The rendering group to draw the layer in.
  52198. */
  52199. renderingGroupId: number;
  52200. }
  52201. /**
  52202. * The effect layer Helps adding post process effect blended with the main pass.
  52203. *
  52204. * This can be for instance use to generate glow or higlight effects on the scene.
  52205. *
  52206. * The effect layer class can not be used directly and is intented to inherited from to be
  52207. * customized per effects.
  52208. */
  52209. export abstract class EffectLayer {
  52210. private _vertexBuffers;
  52211. private _indexBuffer;
  52212. private _cachedDefines;
  52213. private _effectLayerMapGenerationEffect;
  52214. private _effectLayerOptions;
  52215. private _mergeEffect;
  52216. protected _scene: Scene;
  52217. protected _engine: Engine;
  52218. protected _maxSize: number;
  52219. protected _mainTextureDesiredSize: ISize;
  52220. protected _mainTexture: RenderTargetTexture;
  52221. protected _shouldRender: boolean;
  52222. protected _postProcesses: PostProcess[];
  52223. protected _textures: BaseTexture[];
  52224. protected _emissiveTextureAndColor: {
  52225. texture: Nullable<BaseTexture>;
  52226. color: Color4;
  52227. };
  52228. /**
  52229. * The name of the layer
  52230. */
  52231. name: string;
  52232. /**
  52233. * The clear color of the texture used to generate the glow map.
  52234. */
  52235. neutralColor: Color4;
  52236. /**
  52237. * Specifies wether the highlight layer is enabled or not.
  52238. */
  52239. isEnabled: boolean;
  52240. /**
  52241. * Gets the camera attached to the layer.
  52242. */
  52243. readonly camera: Nullable<Camera>;
  52244. /**
  52245. * Gets the rendering group id the layer should render in.
  52246. */
  52247. renderingGroupId: number;
  52248. /**
  52249. * An event triggered when the effect layer has been disposed.
  52250. */
  52251. onDisposeObservable: Observable<EffectLayer>;
  52252. /**
  52253. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52254. */
  52255. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52256. /**
  52257. * An event triggered when the generated texture is being merged in the scene.
  52258. */
  52259. onBeforeComposeObservable: Observable<EffectLayer>;
  52260. /**
  52261. * An event triggered when the mesh is rendered into the effect render target.
  52262. */
  52263. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52264. /**
  52265. * An event triggered after the mesh has been rendered into the effect render target.
  52266. */
  52267. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52268. /**
  52269. * An event triggered when the generated texture has been merged in the scene.
  52270. */
  52271. onAfterComposeObservable: Observable<EffectLayer>;
  52272. /**
  52273. * An event triggered when the efffect layer changes its size.
  52274. */
  52275. onSizeChangedObservable: Observable<EffectLayer>;
  52276. /** @hidden */
  52277. static _SceneComponentInitialization: (scene: Scene) => void;
  52278. /**
  52279. * Instantiates a new effect Layer and references it in the scene.
  52280. * @param name The name of the layer
  52281. * @param scene The scene to use the layer in
  52282. */
  52283. constructor(
  52284. /** The Friendly of the effect in the scene */
  52285. name: string, scene: Scene);
  52286. /**
  52287. * Get the effect name of the layer.
  52288. * @return The effect name
  52289. */
  52290. abstract getEffectName(): string;
  52291. /**
  52292. * Checks for the readiness of the element composing the layer.
  52293. * @param subMesh the mesh to check for
  52294. * @param useInstances specify wether or not to use instances to render the mesh
  52295. * @return true if ready otherwise, false
  52296. */
  52297. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52298. /**
  52299. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52300. * @returns true if the effect requires stencil during the main canvas render pass.
  52301. */
  52302. abstract needStencil(): boolean;
  52303. /**
  52304. * Create the merge effect. This is the shader use to blit the information back
  52305. * to the main canvas at the end of the scene rendering.
  52306. * @returns The effect containing the shader used to merge the effect on the main canvas
  52307. */
  52308. protected abstract _createMergeEffect(): Effect;
  52309. /**
  52310. * Creates the render target textures and post processes used in the effect layer.
  52311. */
  52312. protected abstract _createTextureAndPostProcesses(): void;
  52313. /**
  52314. * Implementation specific of rendering the generating effect on the main canvas.
  52315. * @param effect The effect used to render through
  52316. */
  52317. protected abstract _internalRender(effect: Effect): void;
  52318. /**
  52319. * Sets the required values for both the emissive texture and and the main color.
  52320. */
  52321. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52322. /**
  52323. * Free any resources and references associated to a mesh.
  52324. * Internal use
  52325. * @param mesh The mesh to free.
  52326. */
  52327. abstract _disposeMesh(mesh: Mesh): void;
  52328. /**
  52329. * Serializes this layer (Glow or Highlight for example)
  52330. * @returns a serialized layer object
  52331. */
  52332. abstract serialize?(): any;
  52333. /**
  52334. * Initializes the effect layer with the required options.
  52335. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52336. */
  52337. protected _init(options: Partial<IEffectLayerOptions>): void;
  52338. /**
  52339. * Generates the index buffer of the full screen quad blending to the main canvas.
  52340. */
  52341. private _generateIndexBuffer;
  52342. /**
  52343. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52344. */
  52345. private _generateVertexBuffer;
  52346. /**
  52347. * Sets the main texture desired size which is the closest power of two
  52348. * of the engine canvas size.
  52349. */
  52350. private _setMainTextureSize;
  52351. /**
  52352. * Creates the main texture for the effect layer.
  52353. */
  52354. protected _createMainTexture(): void;
  52355. /**
  52356. * Adds specific effects defines.
  52357. * @param defines The defines to add specifics to.
  52358. */
  52359. protected _addCustomEffectDefines(defines: string[]): void;
  52360. /**
  52361. * Checks for the readiness of the element composing the layer.
  52362. * @param subMesh the mesh to check for
  52363. * @param useInstances specify wether or not to use instances to render the mesh
  52364. * @param emissiveTexture the associated emissive texture used to generate the glow
  52365. * @return true if ready otherwise, false
  52366. */
  52367. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52368. /**
  52369. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52370. */
  52371. render(): void;
  52372. /**
  52373. * Determine if a given mesh will be used in the current effect.
  52374. * @param mesh mesh to test
  52375. * @returns true if the mesh will be used
  52376. */
  52377. hasMesh(mesh: AbstractMesh): boolean;
  52378. /**
  52379. * Returns true if the layer contains information to display, otherwise false.
  52380. * @returns true if the glow layer should be rendered
  52381. */
  52382. shouldRender(): boolean;
  52383. /**
  52384. * Returns true if the mesh should render, otherwise false.
  52385. * @param mesh The mesh to render
  52386. * @returns true if it should render otherwise false
  52387. */
  52388. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52389. /**
  52390. * Returns true if the mesh can be rendered, otherwise false.
  52391. * @param mesh The mesh to render
  52392. * @param material The material used on the mesh
  52393. * @returns true if it can be rendered otherwise false
  52394. */
  52395. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52396. /**
  52397. * Returns true if the mesh should render, otherwise false.
  52398. * @param mesh The mesh to render
  52399. * @returns true if it should render otherwise false
  52400. */
  52401. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52402. /**
  52403. * Renders the submesh passed in parameter to the generation map.
  52404. */
  52405. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52406. /**
  52407. * Defines wether the current material of the mesh should be use to render the effect.
  52408. * @param mesh defines the current mesh to render
  52409. */
  52410. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52411. /**
  52412. * Rebuild the required buffers.
  52413. * @hidden Internal use only.
  52414. */
  52415. _rebuild(): void;
  52416. /**
  52417. * Dispose only the render target textures and post process.
  52418. */
  52419. private _disposeTextureAndPostProcesses;
  52420. /**
  52421. * Dispose the highlight layer and free resources.
  52422. */
  52423. dispose(): void;
  52424. /**
  52425. * Gets the class name of the effect layer
  52426. * @returns the string with the class name of the effect layer
  52427. */
  52428. getClassName(): string;
  52429. /**
  52430. * Creates an effect layer from parsed effect layer data
  52431. * @param parsedEffectLayer defines effect layer data
  52432. * @param scene defines the current scene
  52433. * @param rootUrl defines the root URL containing the effect layer information
  52434. * @returns a parsed effect Layer
  52435. */
  52436. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52437. }
  52438. }
  52439. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52440. import { Scene } from "babylonjs/scene";
  52441. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52442. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52443. import { AbstractScene } from "babylonjs/abstractScene";
  52444. module "babylonjs/abstractScene" {
  52445. interface AbstractScene {
  52446. /**
  52447. * The list of effect layers (highlights/glow) added to the scene
  52448. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52449. * @see http://doc.babylonjs.com/how_to/glow_layer
  52450. */
  52451. effectLayers: Array<EffectLayer>;
  52452. /**
  52453. * Removes the given effect layer from this scene.
  52454. * @param toRemove defines the effect layer to remove
  52455. * @returns the index of the removed effect layer
  52456. */
  52457. removeEffectLayer(toRemove: EffectLayer): number;
  52458. /**
  52459. * Adds the given effect layer to this scene
  52460. * @param newEffectLayer defines the effect layer to add
  52461. */
  52462. addEffectLayer(newEffectLayer: EffectLayer): void;
  52463. }
  52464. }
  52465. /**
  52466. * Defines the layer scene component responsible to manage any effect layers
  52467. * in a given scene.
  52468. */
  52469. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52470. /**
  52471. * The component name helpfull to identify the component in the list of scene components.
  52472. */
  52473. readonly name: string;
  52474. /**
  52475. * The scene the component belongs to.
  52476. */
  52477. scene: Scene;
  52478. private _engine;
  52479. private _renderEffects;
  52480. private _needStencil;
  52481. private _previousStencilState;
  52482. /**
  52483. * Creates a new instance of the component for the given scene
  52484. * @param scene Defines the scene to register the component in
  52485. */
  52486. constructor(scene: Scene);
  52487. /**
  52488. * Registers the component in a given scene
  52489. */
  52490. register(): void;
  52491. /**
  52492. * Rebuilds the elements related to this component in case of
  52493. * context lost for instance.
  52494. */
  52495. rebuild(): void;
  52496. /**
  52497. * Serializes the component data to the specified json object
  52498. * @param serializationObject The object to serialize to
  52499. */
  52500. serialize(serializationObject: any): void;
  52501. /**
  52502. * Adds all the elements from the container to the scene
  52503. * @param container the container holding the elements
  52504. */
  52505. addFromContainer(container: AbstractScene): void;
  52506. /**
  52507. * Removes all the elements in the container from the scene
  52508. * @param container contains the elements to remove
  52509. * @param dispose if the removed element should be disposed (default: false)
  52510. */
  52511. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52512. /**
  52513. * Disposes the component and the associated ressources.
  52514. */
  52515. dispose(): void;
  52516. private _isReadyForMesh;
  52517. private _renderMainTexture;
  52518. private _setStencil;
  52519. private _setStencilBack;
  52520. private _draw;
  52521. private _drawCamera;
  52522. private _drawRenderingGroup;
  52523. }
  52524. }
  52525. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52526. /** @hidden */
  52527. export var glowMapMergePixelShader: {
  52528. name: string;
  52529. shader: string;
  52530. };
  52531. }
  52532. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52533. /** @hidden */
  52534. export var glowMapMergeVertexShader: {
  52535. name: string;
  52536. shader: string;
  52537. };
  52538. }
  52539. declare module "babylonjs/Layers/glowLayer" {
  52540. import { Nullable } from "babylonjs/types";
  52541. import { Camera } from "babylonjs/Cameras/camera";
  52542. import { Scene } from "babylonjs/scene";
  52543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52545. import { Mesh } from "babylonjs/Meshes/mesh";
  52546. import { Texture } from "babylonjs/Materials/Textures/texture";
  52547. import { Effect } from "babylonjs/Materials/effect";
  52548. import { Material } from "babylonjs/Materials/material";
  52549. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52550. import { Color4 } from "babylonjs/Maths/math.color";
  52551. import "babylonjs/Shaders/glowMapMerge.fragment";
  52552. import "babylonjs/Shaders/glowMapMerge.vertex";
  52553. import "babylonjs/Layers/effectLayerSceneComponent";
  52554. module "babylonjs/abstractScene" {
  52555. interface AbstractScene {
  52556. /**
  52557. * Return a the first highlight layer of the scene with a given name.
  52558. * @param name The name of the highlight layer to look for.
  52559. * @return The highlight layer if found otherwise null.
  52560. */
  52561. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52562. }
  52563. }
  52564. /**
  52565. * Glow layer options. This helps customizing the behaviour
  52566. * of the glow layer.
  52567. */
  52568. export interface IGlowLayerOptions {
  52569. /**
  52570. * Multiplication factor apply to the canvas size to compute the render target size
  52571. * used to generated the glowing objects (the smaller the faster).
  52572. */
  52573. mainTextureRatio: number;
  52574. /**
  52575. * Enforces a fixed size texture to ensure resize independant blur.
  52576. */
  52577. mainTextureFixedSize?: number;
  52578. /**
  52579. * How big is the kernel of the blur texture.
  52580. */
  52581. blurKernelSize: number;
  52582. /**
  52583. * The camera attached to the layer.
  52584. */
  52585. camera: Nullable<Camera>;
  52586. /**
  52587. * Enable MSAA by chosing the number of samples.
  52588. */
  52589. mainTextureSamples?: number;
  52590. /**
  52591. * The rendering group to draw the layer in.
  52592. */
  52593. renderingGroupId: number;
  52594. }
  52595. /**
  52596. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52597. *
  52598. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52599. *
  52600. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52601. */
  52602. export class GlowLayer extends EffectLayer {
  52603. /**
  52604. * Effect Name of the layer.
  52605. */
  52606. static readonly EffectName: string;
  52607. /**
  52608. * The default blur kernel size used for the glow.
  52609. */
  52610. static DefaultBlurKernelSize: number;
  52611. /**
  52612. * The default texture size ratio used for the glow.
  52613. */
  52614. static DefaultTextureRatio: number;
  52615. /**
  52616. * Sets the kernel size of the blur.
  52617. */
  52618. /**
  52619. * Gets the kernel size of the blur.
  52620. */
  52621. blurKernelSize: number;
  52622. /**
  52623. * Sets the glow intensity.
  52624. */
  52625. /**
  52626. * Gets the glow intensity.
  52627. */
  52628. intensity: number;
  52629. private _options;
  52630. private _intensity;
  52631. private _horizontalBlurPostprocess1;
  52632. private _verticalBlurPostprocess1;
  52633. private _horizontalBlurPostprocess2;
  52634. private _verticalBlurPostprocess2;
  52635. private _blurTexture1;
  52636. private _blurTexture2;
  52637. private _postProcesses1;
  52638. private _postProcesses2;
  52639. private _includedOnlyMeshes;
  52640. private _excludedMeshes;
  52641. private _meshesUsingTheirOwnMaterials;
  52642. /**
  52643. * Callback used to let the user override the color selection on a per mesh basis
  52644. */
  52645. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52646. /**
  52647. * Callback used to let the user override the texture selection on a per mesh basis
  52648. */
  52649. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52650. /**
  52651. * Instantiates a new glow Layer and references it to the scene.
  52652. * @param name The name of the layer
  52653. * @param scene The scene to use the layer in
  52654. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52655. */
  52656. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52657. /**
  52658. * Get the effect name of the layer.
  52659. * @return The effect name
  52660. */
  52661. getEffectName(): string;
  52662. /**
  52663. * Create the merge effect. This is the shader use to blit the information back
  52664. * to the main canvas at the end of the scene rendering.
  52665. */
  52666. protected _createMergeEffect(): Effect;
  52667. /**
  52668. * Creates the render target textures and post processes used in the glow layer.
  52669. */
  52670. protected _createTextureAndPostProcesses(): void;
  52671. /**
  52672. * Checks for the readiness of the element composing the layer.
  52673. * @param subMesh the mesh to check for
  52674. * @param useInstances specify wether or not to use instances to render the mesh
  52675. * @param emissiveTexture the associated emissive texture used to generate the glow
  52676. * @return true if ready otherwise, false
  52677. */
  52678. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52679. /**
  52680. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52681. */
  52682. needStencil(): boolean;
  52683. /**
  52684. * Returns true if the mesh can be rendered, otherwise false.
  52685. * @param mesh The mesh to render
  52686. * @param material The material used on the mesh
  52687. * @returns true if it can be rendered otherwise false
  52688. */
  52689. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52690. /**
  52691. * Implementation specific of rendering the generating effect on the main canvas.
  52692. * @param effect The effect used to render through
  52693. */
  52694. protected _internalRender(effect: Effect): void;
  52695. /**
  52696. * Sets the required values for both the emissive texture and and the main color.
  52697. */
  52698. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52699. /**
  52700. * Returns true if the mesh should render, otherwise false.
  52701. * @param mesh The mesh to render
  52702. * @returns true if it should render otherwise false
  52703. */
  52704. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52705. /**
  52706. * Adds specific effects defines.
  52707. * @param defines The defines to add specifics to.
  52708. */
  52709. protected _addCustomEffectDefines(defines: string[]): void;
  52710. /**
  52711. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52712. * @param mesh The mesh to exclude from the glow layer
  52713. */
  52714. addExcludedMesh(mesh: Mesh): void;
  52715. /**
  52716. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52717. * @param mesh The mesh to remove
  52718. */
  52719. removeExcludedMesh(mesh: Mesh): void;
  52720. /**
  52721. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52722. * @param mesh The mesh to include in the glow layer
  52723. */
  52724. addIncludedOnlyMesh(mesh: Mesh): void;
  52725. /**
  52726. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52727. * @param mesh The mesh to remove
  52728. */
  52729. removeIncludedOnlyMesh(mesh: Mesh): void;
  52730. /**
  52731. * Determine if a given mesh will be used in the glow layer
  52732. * @param mesh The mesh to test
  52733. * @returns true if the mesh will be highlighted by the current glow layer
  52734. */
  52735. hasMesh(mesh: AbstractMesh): boolean;
  52736. /**
  52737. * Defines wether the current material of the mesh should be use to render the effect.
  52738. * @param mesh defines the current mesh to render
  52739. */
  52740. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52741. /**
  52742. * Add a mesh to be rendered through its own material and not with emissive only.
  52743. * @param mesh The mesh for which we need to use its material
  52744. */
  52745. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52746. /**
  52747. * Remove a mesh from being rendered through its own material and not with emissive only.
  52748. * @param mesh The mesh for which we need to not use its material
  52749. */
  52750. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52751. /**
  52752. * Free any resources and references associated to a mesh.
  52753. * Internal use
  52754. * @param mesh The mesh to free.
  52755. * @hidden
  52756. */
  52757. _disposeMesh(mesh: Mesh): void;
  52758. /**
  52759. * Gets the class name of the effect layer
  52760. * @returns the string with the class name of the effect layer
  52761. */
  52762. getClassName(): string;
  52763. /**
  52764. * Serializes this glow layer
  52765. * @returns a serialized glow layer object
  52766. */
  52767. serialize(): any;
  52768. /**
  52769. * Creates a Glow Layer from parsed glow layer data
  52770. * @param parsedGlowLayer defines glow layer data
  52771. * @param scene defines the current scene
  52772. * @param rootUrl defines the root URL containing the glow layer information
  52773. * @returns a parsed Glow Layer
  52774. */
  52775. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52776. }
  52777. }
  52778. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52779. /** @hidden */
  52780. export var glowBlurPostProcessPixelShader: {
  52781. name: string;
  52782. shader: string;
  52783. };
  52784. }
  52785. declare module "babylonjs/Layers/highlightLayer" {
  52786. import { Observable } from "babylonjs/Misc/observable";
  52787. import { Nullable } from "babylonjs/types";
  52788. import { Camera } from "babylonjs/Cameras/camera";
  52789. import { Scene } from "babylonjs/scene";
  52790. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52792. import { Mesh } from "babylonjs/Meshes/mesh";
  52793. import { Effect } from "babylonjs/Materials/effect";
  52794. import { Material } from "babylonjs/Materials/material";
  52795. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52796. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52797. import "babylonjs/Shaders/glowMapMerge.fragment";
  52798. import "babylonjs/Shaders/glowMapMerge.vertex";
  52799. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52800. module "babylonjs/abstractScene" {
  52801. interface AbstractScene {
  52802. /**
  52803. * Return a the first highlight layer of the scene with a given name.
  52804. * @param name The name of the highlight layer to look for.
  52805. * @return The highlight layer if found otherwise null.
  52806. */
  52807. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52808. }
  52809. }
  52810. /**
  52811. * Highlight layer options. This helps customizing the behaviour
  52812. * of the highlight layer.
  52813. */
  52814. export interface IHighlightLayerOptions {
  52815. /**
  52816. * Multiplication factor apply to the canvas size to compute the render target size
  52817. * used to generated the glowing objects (the smaller the faster).
  52818. */
  52819. mainTextureRatio: number;
  52820. /**
  52821. * Enforces a fixed size texture to ensure resize independant blur.
  52822. */
  52823. mainTextureFixedSize?: number;
  52824. /**
  52825. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52826. * of the picture to blur (the smaller the faster).
  52827. */
  52828. blurTextureSizeRatio: number;
  52829. /**
  52830. * How big in texel of the blur texture is the vertical blur.
  52831. */
  52832. blurVerticalSize: number;
  52833. /**
  52834. * How big in texel of the blur texture is the horizontal blur.
  52835. */
  52836. blurHorizontalSize: number;
  52837. /**
  52838. * Alpha blending mode used to apply the blur. Default is combine.
  52839. */
  52840. alphaBlendingMode: number;
  52841. /**
  52842. * The camera attached to the layer.
  52843. */
  52844. camera: Nullable<Camera>;
  52845. /**
  52846. * Should we display highlight as a solid stroke?
  52847. */
  52848. isStroke?: boolean;
  52849. /**
  52850. * The rendering group to draw the layer in.
  52851. */
  52852. renderingGroupId: number;
  52853. }
  52854. /**
  52855. * The highlight layer Helps adding a glow effect around a mesh.
  52856. *
  52857. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52858. * glowy meshes to your scene.
  52859. *
  52860. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52861. */
  52862. export class HighlightLayer extends EffectLayer {
  52863. name: string;
  52864. /**
  52865. * Effect Name of the highlight layer.
  52866. */
  52867. static readonly EffectName: string;
  52868. /**
  52869. * The neutral color used during the preparation of the glow effect.
  52870. * This is black by default as the blend operation is a blend operation.
  52871. */
  52872. static NeutralColor: Color4;
  52873. /**
  52874. * Stencil value used for glowing meshes.
  52875. */
  52876. static GlowingMeshStencilReference: number;
  52877. /**
  52878. * Stencil value used for the other meshes in the scene.
  52879. */
  52880. static NormalMeshStencilReference: number;
  52881. /**
  52882. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52883. */
  52884. innerGlow: boolean;
  52885. /**
  52886. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52887. */
  52888. outerGlow: boolean;
  52889. /**
  52890. * Specifies the horizontal size of the blur.
  52891. */
  52892. /**
  52893. * Gets the horizontal size of the blur.
  52894. */
  52895. blurHorizontalSize: number;
  52896. /**
  52897. * Specifies the vertical size of the blur.
  52898. */
  52899. /**
  52900. * Gets the vertical size of the blur.
  52901. */
  52902. blurVerticalSize: number;
  52903. /**
  52904. * An event triggered when the highlight layer is being blurred.
  52905. */
  52906. onBeforeBlurObservable: Observable<HighlightLayer>;
  52907. /**
  52908. * An event triggered when the highlight layer has been blurred.
  52909. */
  52910. onAfterBlurObservable: Observable<HighlightLayer>;
  52911. private _instanceGlowingMeshStencilReference;
  52912. private _options;
  52913. private _downSamplePostprocess;
  52914. private _horizontalBlurPostprocess;
  52915. private _verticalBlurPostprocess;
  52916. private _blurTexture;
  52917. private _meshes;
  52918. private _excludedMeshes;
  52919. /**
  52920. * Instantiates a new highlight Layer and references it to the scene..
  52921. * @param name The name of the layer
  52922. * @param scene The scene to use the layer in
  52923. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52924. */
  52925. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52926. /**
  52927. * Get the effect name of the layer.
  52928. * @return The effect name
  52929. */
  52930. getEffectName(): string;
  52931. /**
  52932. * Create the merge effect. This is the shader use to blit the information back
  52933. * to the main canvas at the end of the scene rendering.
  52934. */
  52935. protected _createMergeEffect(): Effect;
  52936. /**
  52937. * Creates the render target textures and post processes used in the highlight layer.
  52938. */
  52939. protected _createTextureAndPostProcesses(): void;
  52940. /**
  52941. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52942. */
  52943. needStencil(): boolean;
  52944. /**
  52945. * Checks for the readiness of the element composing the layer.
  52946. * @param subMesh the mesh to check for
  52947. * @param useInstances specify wether or not to use instances to render the mesh
  52948. * @param emissiveTexture the associated emissive texture used to generate the glow
  52949. * @return true if ready otherwise, false
  52950. */
  52951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52952. /**
  52953. * Implementation specific of rendering the generating effect on the main canvas.
  52954. * @param effect The effect used to render through
  52955. */
  52956. protected _internalRender(effect: Effect): void;
  52957. /**
  52958. * Returns true if the layer contains information to display, otherwise false.
  52959. */
  52960. shouldRender(): boolean;
  52961. /**
  52962. * Returns true if the mesh should render, otherwise false.
  52963. * @param mesh The mesh to render
  52964. * @returns true if it should render otherwise false
  52965. */
  52966. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52967. /**
  52968. * Sets the required values for both the emissive texture and and the main color.
  52969. */
  52970. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52971. /**
  52972. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52973. * @param mesh The mesh to exclude from the highlight layer
  52974. */
  52975. addExcludedMesh(mesh: Mesh): void;
  52976. /**
  52977. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52978. * @param mesh The mesh to highlight
  52979. */
  52980. removeExcludedMesh(mesh: Mesh): void;
  52981. /**
  52982. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52983. * @param mesh mesh to test
  52984. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52985. */
  52986. hasMesh(mesh: AbstractMesh): boolean;
  52987. /**
  52988. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52989. * @param mesh The mesh to highlight
  52990. * @param color The color of the highlight
  52991. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52992. */
  52993. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52994. /**
  52995. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52996. * @param mesh The mesh to highlight
  52997. */
  52998. removeMesh(mesh: Mesh): void;
  52999. /**
  53000. * Force the stencil to the normal expected value for none glowing parts
  53001. */
  53002. private _defaultStencilReference;
  53003. /**
  53004. * Free any resources and references associated to a mesh.
  53005. * Internal use
  53006. * @param mesh The mesh to free.
  53007. * @hidden
  53008. */
  53009. _disposeMesh(mesh: Mesh): void;
  53010. /**
  53011. * Dispose the highlight layer and free resources.
  53012. */
  53013. dispose(): void;
  53014. /**
  53015. * Gets the class name of the effect layer
  53016. * @returns the string with the class name of the effect layer
  53017. */
  53018. getClassName(): string;
  53019. /**
  53020. * Serializes this Highlight layer
  53021. * @returns a serialized Highlight layer object
  53022. */
  53023. serialize(): any;
  53024. /**
  53025. * Creates a Highlight layer from parsed Highlight layer data
  53026. * @param parsedHightlightLayer defines the Highlight layer data
  53027. * @param scene defines the current scene
  53028. * @param rootUrl defines the root URL containing the Highlight layer information
  53029. * @returns a parsed Highlight layer
  53030. */
  53031. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53032. }
  53033. }
  53034. declare module "babylonjs/Layers/layerSceneComponent" {
  53035. import { Scene } from "babylonjs/scene";
  53036. import { ISceneComponent } from "babylonjs/sceneComponent";
  53037. import { Layer } from "babylonjs/Layers/layer";
  53038. import { AbstractScene } from "babylonjs/abstractScene";
  53039. module "babylonjs/abstractScene" {
  53040. interface AbstractScene {
  53041. /**
  53042. * The list of layers (background and foreground) of the scene
  53043. */
  53044. layers: Array<Layer>;
  53045. }
  53046. }
  53047. /**
  53048. * Defines the layer scene component responsible to manage any layers
  53049. * in a given scene.
  53050. */
  53051. export class LayerSceneComponent implements ISceneComponent {
  53052. /**
  53053. * The component name helpfull to identify the component in the list of scene components.
  53054. */
  53055. readonly name: string;
  53056. /**
  53057. * The scene the component belongs to.
  53058. */
  53059. scene: Scene;
  53060. private _engine;
  53061. /**
  53062. * Creates a new instance of the component for the given scene
  53063. * @param scene Defines the scene to register the component in
  53064. */
  53065. constructor(scene: Scene);
  53066. /**
  53067. * Registers the component in a given scene
  53068. */
  53069. register(): void;
  53070. /**
  53071. * Rebuilds the elements related to this component in case of
  53072. * context lost for instance.
  53073. */
  53074. rebuild(): void;
  53075. /**
  53076. * Disposes the component and the associated ressources.
  53077. */
  53078. dispose(): void;
  53079. private _draw;
  53080. private _drawCameraPredicate;
  53081. private _drawCameraBackground;
  53082. private _drawCameraForeground;
  53083. private _drawRenderTargetPredicate;
  53084. private _drawRenderTargetBackground;
  53085. private _drawRenderTargetForeground;
  53086. /**
  53087. * Adds all the elements from the container to the scene
  53088. * @param container the container holding the elements
  53089. */
  53090. addFromContainer(container: AbstractScene): void;
  53091. /**
  53092. * Removes all the elements in the container from the scene
  53093. * @param container contains the elements to remove
  53094. * @param dispose if the removed element should be disposed (default: false)
  53095. */
  53096. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53097. }
  53098. }
  53099. declare module "babylonjs/Shaders/layer.fragment" {
  53100. /** @hidden */
  53101. export var layerPixelShader: {
  53102. name: string;
  53103. shader: string;
  53104. };
  53105. }
  53106. declare module "babylonjs/Shaders/layer.vertex" {
  53107. /** @hidden */
  53108. export var layerVertexShader: {
  53109. name: string;
  53110. shader: string;
  53111. };
  53112. }
  53113. declare module "babylonjs/Layers/layer" {
  53114. import { Observable } from "babylonjs/Misc/observable";
  53115. import { Nullable } from "babylonjs/types";
  53116. import { Scene } from "babylonjs/scene";
  53117. import { Vector2 } from "babylonjs/Maths/math.vector";
  53118. import { Color4 } from "babylonjs/Maths/math.color";
  53119. import { Texture } from "babylonjs/Materials/Textures/texture";
  53120. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53121. import "babylonjs/Shaders/layer.fragment";
  53122. import "babylonjs/Shaders/layer.vertex";
  53123. /**
  53124. * This represents a full screen 2d layer.
  53125. * This can be useful to display a picture in the background of your scene for instance.
  53126. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53127. */
  53128. export class Layer {
  53129. /**
  53130. * Define the name of the layer.
  53131. */
  53132. name: string;
  53133. /**
  53134. * Define the texture the layer should display.
  53135. */
  53136. texture: Nullable<Texture>;
  53137. /**
  53138. * Is the layer in background or foreground.
  53139. */
  53140. isBackground: boolean;
  53141. /**
  53142. * Define the color of the layer (instead of texture).
  53143. */
  53144. color: Color4;
  53145. /**
  53146. * Define the scale of the layer in order to zoom in out of the texture.
  53147. */
  53148. scale: Vector2;
  53149. /**
  53150. * Define an offset for the layer in order to shift the texture.
  53151. */
  53152. offset: Vector2;
  53153. /**
  53154. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53155. */
  53156. alphaBlendingMode: number;
  53157. /**
  53158. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53159. * Alpha test will not mix with the background color in case of transparency.
  53160. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53161. */
  53162. alphaTest: boolean;
  53163. /**
  53164. * Define a mask to restrict the layer to only some of the scene cameras.
  53165. */
  53166. layerMask: number;
  53167. /**
  53168. * Define the list of render target the layer is visible into.
  53169. */
  53170. renderTargetTextures: RenderTargetTexture[];
  53171. /**
  53172. * Define if the layer is only used in renderTarget or if it also
  53173. * renders in the main frame buffer of the canvas.
  53174. */
  53175. renderOnlyInRenderTargetTextures: boolean;
  53176. private _scene;
  53177. private _vertexBuffers;
  53178. private _indexBuffer;
  53179. private _effect;
  53180. private _alphaTestEffect;
  53181. /**
  53182. * An event triggered when the layer is disposed.
  53183. */
  53184. onDisposeObservable: Observable<Layer>;
  53185. private _onDisposeObserver;
  53186. /**
  53187. * Back compatibility with callback before the onDisposeObservable existed.
  53188. * The set callback will be triggered when the layer has been disposed.
  53189. */
  53190. onDispose: () => void;
  53191. /**
  53192. * An event triggered before rendering the scene
  53193. */
  53194. onBeforeRenderObservable: Observable<Layer>;
  53195. private _onBeforeRenderObserver;
  53196. /**
  53197. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53198. * The set callback will be triggered just before rendering the layer.
  53199. */
  53200. onBeforeRender: () => void;
  53201. /**
  53202. * An event triggered after rendering the scene
  53203. */
  53204. onAfterRenderObservable: Observable<Layer>;
  53205. private _onAfterRenderObserver;
  53206. /**
  53207. * Back compatibility with callback before the onAfterRenderObservable existed.
  53208. * The set callback will be triggered just after rendering the layer.
  53209. */
  53210. onAfterRender: () => void;
  53211. /**
  53212. * Instantiates a new layer.
  53213. * This represents a full screen 2d layer.
  53214. * This can be useful to display a picture in the background of your scene for instance.
  53215. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53216. * @param name Define the name of the layer in the scene
  53217. * @param imgUrl Define the url of the texture to display in the layer
  53218. * @param scene Define the scene the layer belongs to
  53219. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53220. * @param color Defines a color for the layer
  53221. */
  53222. constructor(
  53223. /**
  53224. * Define the name of the layer.
  53225. */
  53226. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53227. private _createIndexBuffer;
  53228. /** @hidden */
  53229. _rebuild(): void;
  53230. /**
  53231. * Renders the layer in the scene.
  53232. */
  53233. render(): void;
  53234. /**
  53235. * Disposes and releases the associated ressources.
  53236. */
  53237. dispose(): void;
  53238. }
  53239. }
  53240. declare module "babylonjs/Layers/index" {
  53241. export * from "babylonjs/Layers/effectLayer";
  53242. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53243. export * from "babylonjs/Layers/glowLayer";
  53244. export * from "babylonjs/Layers/highlightLayer";
  53245. export * from "babylonjs/Layers/layer";
  53246. export * from "babylonjs/Layers/layerSceneComponent";
  53247. }
  53248. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53249. /** @hidden */
  53250. export var lensFlarePixelShader: {
  53251. name: string;
  53252. shader: string;
  53253. };
  53254. }
  53255. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53256. /** @hidden */
  53257. export var lensFlareVertexShader: {
  53258. name: string;
  53259. shader: string;
  53260. };
  53261. }
  53262. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53263. import { Scene } from "babylonjs/scene";
  53264. import { Vector3 } from "babylonjs/Maths/math.vector";
  53265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53266. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53267. import "babylonjs/Shaders/lensFlare.fragment";
  53268. import "babylonjs/Shaders/lensFlare.vertex";
  53269. import { Viewport } from "babylonjs/Maths/math.viewport";
  53270. /**
  53271. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53272. * It is usually composed of several `lensFlare`.
  53273. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53274. */
  53275. export class LensFlareSystem {
  53276. /**
  53277. * Define the name of the lens flare system
  53278. */
  53279. name: string;
  53280. /**
  53281. * List of lens flares used in this system.
  53282. */
  53283. lensFlares: LensFlare[];
  53284. /**
  53285. * Define a limit from the border the lens flare can be visible.
  53286. */
  53287. borderLimit: number;
  53288. /**
  53289. * Define a viewport border we do not want to see the lens flare in.
  53290. */
  53291. viewportBorder: number;
  53292. /**
  53293. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53294. */
  53295. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53296. /**
  53297. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53298. */
  53299. layerMask: number;
  53300. /**
  53301. * Define the id of the lens flare system in the scene.
  53302. * (equal to name by default)
  53303. */
  53304. id: string;
  53305. private _scene;
  53306. private _emitter;
  53307. private _vertexBuffers;
  53308. private _indexBuffer;
  53309. private _effect;
  53310. private _positionX;
  53311. private _positionY;
  53312. private _isEnabled;
  53313. /** @hidden */
  53314. static _SceneComponentInitialization: (scene: Scene) => void;
  53315. /**
  53316. * Instantiates a lens flare system.
  53317. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53318. * It is usually composed of several `lensFlare`.
  53319. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53320. * @param name Define the name of the lens flare system in the scene
  53321. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53322. * @param scene Define the scene the lens flare system belongs to
  53323. */
  53324. constructor(
  53325. /**
  53326. * Define the name of the lens flare system
  53327. */
  53328. name: string, emitter: any, scene: Scene);
  53329. /**
  53330. * Define if the lens flare system is enabled.
  53331. */
  53332. isEnabled: boolean;
  53333. /**
  53334. * Get the scene the effects belongs to.
  53335. * @returns the scene holding the lens flare system
  53336. */
  53337. getScene(): Scene;
  53338. /**
  53339. * Get the emitter of the lens flare system.
  53340. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53341. * @returns the emitter of the lens flare system
  53342. */
  53343. getEmitter(): any;
  53344. /**
  53345. * Set the emitter of the lens flare system.
  53346. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53347. * @param newEmitter Define the new emitter of the system
  53348. */
  53349. setEmitter(newEmitter: any): void;
  53350. /**
  53351. * Get the lens flare system emitter position.
  53352. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53353. * @returns the position
  53354. */
  53355. getEmitterPosition(): Vector3;
  53356. /**
  53357. * @hidden
  53358. */
  53359. computeEffectivePosition(globalViewport: Viewport): boolean;
  53360. /** @hidden */
  53361. _isVisible(): boolean;
  53362. /**
  53363. * @hidden
  53364. */
  53365. render(): boolean;
  53366. /**
  53367. * Dispose and release the lens flare with its associated resources.
  53368. */
  53369. dispose(): void;
  53370. /**
  53371. * Parse a lens flare system from a JSON repressentation
  53372. * @param parsedLensFlareSystem Define the JSON to parse
  53373. * @param scene Define the scene the parsed system should be instantiated in
  53374. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53375. * @returns the parsed system
  53376. */
  53377. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53378. /**
  53379. * Serialize the current Lens Flare System into a JSON representation.
  53380. * @returns the serialized JSON
  53381. */
  53382. serialize(): any;
  53383. }
  53384. }
  53385. declare module "babylonjs/LensFlares/lensFlare" {
  53386. import { Nullable } from "babylonjs/types";
  53387. import { Color3 } from "babylonjs/Maths/math.color";
  53388. import { Texture } from "babylonjs/Materials/Textures/texture";
  53389. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53390. /**
  53391. * This represents one of the lens effect in a `lensFlareSystem`.
  53392. * It controls one of the indiviual texture used in the effect.
  53393. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53394. */
  53395. export class LensFlare {
  53396. /**
  53397. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53398. */
  53399. size: number;
  53400. /**
  53401. * 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.
  53402. */
  53403. position: number;
  53404. /**
  53405. * Define the lens color.
  53406. */
  53407. color: Color3;
  53408. /**
  53409. * Define the lens texture.
  53410. */
  53411. texture: Nullable<Texture>;
  53412. /**
  53413. * Define the alpha mode to render this particular lens.
  53414. */
  53415. alphaMode: number;
  53416. private _system;
  53417. /**
  53418. * Creates a new Lens Flare.
  53419. * This represents one of the lens effect in a `lensFlareSystem`.
  53420. * It controls one of the indiviual texture used in the effect.
  53421. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53422. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53423. * @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.
  53424. * @param color Define the lens color
  53425. * @param imgUrl Define the lens texture url
  53426. * @param system Define the `lensFlareSystem` this flare is part of
  53427. * @returns The newly created Lens Flare
  53428. */
  53429. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53430. /**
  53431. * Instantiates a new Lens Flare.
  53432. * This represents one of the lens effect in a `lensFlareSystem`.
  53433. * It controls one of the indiviual texture used in the effect.
  53434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53435. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53436. * @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.
  53437. * @param color Define the lens color
  53438. * @param imgUrl Define the lens texture url
  53439. * @param system Define the `lensFlareSystem` this flare is part of
  53440. */
  53441. constructor(
  53442. /**
  53443. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53444. */
  53445. size: number,
  53446. /**
  53447. * 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.
  53448. */
  53449. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53450. /**
  53451. * Dispose and release the lens flare with its associated resources.
  53452. */
  53453. dispose(): void;
  53454. }
  53455. }
  53456. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53457. import { Nullable } from "babylonjs/types";
  53458. import { Scene } from "babylonjs/scene";
  53459. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53460. import { AbstractScene } from "babylonjs/abstractScene";
  53461. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53462. module "babylonjs/abstractScene" {
  53463. interface AbstractScene {
  53464. /**
  53465. * The list of lens flare system added to the scene
  53466. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53467. */
  53468. lensFlareSystems: Array<LensFlareSystem>;
  53469. /**
  53470. * Removes the given lens flare system from this scene.
  53471. * @param toRemove The lens flare system to remove
  53472. * @returns The index of the removed lens flare system
  53473. */
  53474. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53475. /**
  53476. * Adds the given lens flare system to this scene
  53477. * @param newLensFlareSystem The lens flare system to add
  53478. */
  53479. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53480. /**
  53481. * Gets a lens flare system using its name
  53482. * @param name defines the name to look for
  53483. * @returns the lens flare system or null if not found
  53484. */
  53485. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53486. /**
  53487. * Gets a lens flare system using its id
  53488. * @param id defines the id to look for
  53489. * @returns the lens flare system or null if not found
  53490. */
  53491. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53492. }
  53493. }
  53494. /**
  53495. * Defines the lens flare scene component responsible to manage any lens flares
  53496. * in a given scene.
  53497. */
  53498. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53499. /**
  53500. * The component name helpfull to identify the component in the list of scene components.
  53501. */
  53502. readonly name: string;
  53503. /**
  53504. * The scene the component belongs to.
  53505. */
  53506. scene: Scene;
  53507. /**
  53508. * Creates a new instance of the component for the given scene
  53509. * @param scene Defines the scene to register the component in
  53510. */
  53511. constructor(scene: Scene);
  53512. /**
  53513. * Registers the component in a given scene
  53514. */
  53515. register(): void;
  53516. /**
  53517. * Rebuilds the elements related to this component in case of
  53518. * context lost for instance.
  53519. */
  53520. rebuild(): void;
  53521. /**
  53522. * Adds all the elements from the container to the scene
  53523. * @param container the container holding the elements
  53524. */
  53525. addFromContainer(container: AbstractScene): void;
  53526. /**
  53527. * Removes all the elements in the container from the scene
  53528. * @param container contains the elements to remove
  53529. * @param dispose if the removed element should be disposed (default: false)
  53530. */
  53531. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53532. /**
  53533. * Serializes the component data to the specified json object
  53534. * @param serializationObject The object to serialize to
  53535. */
  53536. serialize(serializationObject: any): void;
  53537. /**
  53538. * Disposes the component and the associated ressources.
  53539. */
  53540. dispose(): void;
  53541. private _draw;
  53542. }
  53543. }
  53544. declare module "babylonjs/LensFlares/index" {
  53545. export * from "babylonjs/LensFlares/lensFlare";
  53546. export * from "babylonjs/LensFlares/lensFlareSystem";
  53547. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53548. }
  53549. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53550. import { Scene } from "babylonjs/scene";
  53551. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53552. import { AbstractScene } from "babylonjs/abstractScene";
  53553. /**
  53554. * Defines the shadow generator component responsible to manage any shadow generators
  53555. * in a given scene.
  53556. */
  53557. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53558. /**
  53559. * The component name helpfull to identify the component in the list of scene components.
  53560. */
  53561. readonly name: string;
  53562. /**
  53563. * The scene the component belongs to.
  53564. */
  53565. scene: Scene;
  53566. /**
  53567. * Creates a new instance of the component for the given scene
  53568. * @param scene Defines the scene to register the component in
  53569. */
  53570. constructor(scene: Scene);
  53571. /**
  53572. * Registers the component in a given scene
  53573. */
  53574. register(): void;
  53575. /**
  53576. * Rebuilds the elements related to this component in case of
  53577. * context lost for instance.
  53578. */
  53579. rebuild(): void;
  53580. /**
  53581. * Serializes the component data to the specified json object
  53582. * @param serializationObject The object to serialize to
  53583. */
  53584. serialize(serializationObject: any): void;
  53585. /**
  53586. * Adds all the elements from the container to the scene
  53587. * @param container the container holding the elements
  53588. */
  53589. addFromContainer(container: AbstractScene): void;
  53590. /**
  53591. * Removes all the elements in the container from the scene
  53592. * @param container contains the elements to remove
  53593. * @param dispose if the removed element should be disposed (default: false)
  53594. */
  53595. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53596. /**
  53597. * Rebuilds the elements related to this component in case of
  53598. * context lost for instance.
  53599. */
  53600. dispose(): void;
  53601. private _gatherRenderTargets;
  53602. }
  53603. }
  53604. declare module "babylonjs/Lights/Shadows/index" {
  53605. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53606. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53607. }
  53608. declare module "babylonjs/Lights/pointLight" {
  53609. import { Scene } from "babylonjs/scene";
  53610. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53612. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53613. import { Effect } from "babylonjs/Materials/effect";
  53614. /**
  53615. * A point light is a light defined by an unique point in world space.
  53616. * The light is emitted in every direction from this point.
  53617. * A good example of a point light is a standard light bulb.
  53618. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53619. */
  53620. export class PointLight extends ShadowLight {
  53621. private _shadowAngle;
  53622. /**
  53623. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53624. * This specifies what angle the shadow will use to be created.
  53625. *
  53626. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53627. */
  53628. /**
  53629. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53630. * This specifies what angle the shadow will use to be created.
  53631. *
  53632. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53633. */
  53634. shadowAngle: number;
  53635. /**
  53636. * Gets the direction if it has been set.
  53637. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53638. */
  53639. /**
  53640. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53641. */
  53642. direction: Vector3;
  53643. /**
  53644. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53645. * A PointLight emits the light in every direction.
  53646. * It can cast shadows.
  53647. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53648. * ```javascript
  53649. * var pointLight = new PointLight("pl", camera.position, scene);
  53650. * ```
  53651. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53652. * @param name The light friendly name
  53653. * @param position The position of the point light in the scene
  53654. * @param scene The scene the lights belongs to
  53655. */
  53656. constructor(name: string, position: Vector3, scene: Scene);
  53657. /**
  53658. * Returns the string "PointLight"
  53659. * @returns the class name
  53660. */
  53661. getClassName(): string;
  53662. /**
  53663. * Returns the integer 0.
  53664. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53665. */
  53666. getTypeID(): number;
  53667. /**
  53668. * Specifies wether or not the shadowmap should be a cube texture.
  53669. * @returns true if the shadowmap needs to be a cube texture.
  53670. */
  53671. needCube(): boolean;
  53672. /**
  53673. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53674. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53675. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53676. */
  53677. getShadowDirection(faceIndex?: number): Vector3;
  53678. /**
  53679. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53680. * - fov = PI / 2
  53681. * - aspect ratio : 1.0
  53682. * - z-near and far equal to the active camera minZ and maxZ.
  53683. * Returns the PointLight.
  53684. */
  53685. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53686. protected _buildUniformLayout(): void;
  53687. /**
  53688. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53689. * @param effect The effect to update
  53690. * @param lightIndex The index of the light in the effect to update
  53691. * @returns The point light
  53692. */
  53693. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53694. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53695. /**
  53696. * Prepares the list of defines specific to the light type.
  53697. * @param defines the list of defines
  53698. * @param lightIndex defines the index of the light for the effect
  53699. */
  53700. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53701. }
  53702. }
  53703. declare module "babylonjs/Lights/index" {
  53704. export * from "babylonjs/Lights/light";
  53705. export * from "babylonjs/Lights/shadowLight";
  53706. export * from "babylonjs/Lights/Shadows/index";
  53707. export * from "babylonjs/Lights/directionalLight";
  53708. export * from "babylonjs/Lights/hemisphericLight";
  53709. export * from "babylonjs/Lights/pointLight";
  53710. export * from "babylonjs/Lights/spotLight";
  53711. }
  53712. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53713. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53714. /**
  53715. * Header information of HDR texture files.
  53716. */
  53717. export interface HDRInfo {
  53718. /**
  53719. * The height of the texture in pixels.
  53720. */
  53721. height: number;
  53722. /**
  53723. * The width of the texture in pixels.
  53724. */
  53725. width: number;
  53726. /**
  53727. * The index of the beginning of the data in the binary file.
  53728. */
  53729. dataPosition: number;
  53730. }
  53731. /**
  53732. * This groups tools to convert HDR texture to native colors array.
  53733. */
  53734. export class HDRTools {
  53735. private static Ldexp;
  53736. private static Rgbe2float;
  53737. private static readStringLine;
  53738. /**
  53739. * Reads header information from an RGBE texture stored in a native array.
  53740. * More information on this format are available here:
  53741. * https://en.wikipedia.org/wiki/RGBE_image_format
  53742. *
  53743. * @param uint8array The binary file stored in native array.
  53744. * @return The header information.
  53745. */
  53746. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53747. /**
  53748. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53749. * This RGBE texture needs to store the information as a panorama.
  53750. *
  53751. * More information on this format are available here:
  53752. * https://en.wikipedia.org/wiki/RGBE_image_format
  53753. *
  53754. * @param buffer The binary file stored in an array buffer.
  53755. * @param size The expected size of the extracted cubemap.
  53756. * @return The Cube Map information.
  53757. */
  53758. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53759. /**
  53760. * Returns the pixels data extracted from an RGBE texture.
  53761. * This pixels will be stored left to right up to down in the R G B order in one array.
  53762. *
  53763. * More information on this format are available here:
  53764. * https://en.wikipedia.org/wiki/RGBE_image_format
  53765. *
  53766. * @param uint8array The binary file stored in an array buffer.
  53767. * @param hdrInfo The header information of the file.
  53768. * @return The pixels data in RGB right to left up to down order.
  53769. */
  53770. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53771. private static RGBE_ReadPixels_RLE;
  53772. }
  53773. }
  53774. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53775. import { Nullable } from "babylonjs/types";
  53776. import { Scene } from "babylonjs/scene";
  53777. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53779. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53780. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53781. /**
  53782. * This represents a texture coming from an HDR input.
  53783. *
  53784. * The only supported format is currently panorama picture stored in RGBE format.
  53785. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53786. */
  53787. export class HDRCubeTexture extends BaseTexture {
  53788. private static _facesMapping;
  53789. private _generateHarmonics;
  53790. private _noMipmap;
  53791. private _textureMatrix;
  53792. private _size;
  53793. private _onLoad;
  53794. private _onError;
  53795. /**
  53796. * The texture URL.
  53797. */
  53798. url: string;
  53799. /**
  53800. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53801. */
  53802. coordinatesMode: number;
  53803. protected _isBlocking: boolean;
  53804. /**
  53805. * Sets wether or not the texture is blocking during loading.
  53806. */
  53807. /**
  53808. * Gets wether or not the texture is blocking during loading.
  53809. */
  53810. isBlocking: boolean;
  53811. protected _rotationY: number;
  53812. /**
  53813. * Sets texture matrix rotation angle around Y axis in radians.
  53814. */
  53815. /**
  53816. * Gets texture matrix rotation angle around Y axis radians.
  53817. */
  53818. rotationY: number;
  53819. /**
  53820. * Gets or sets the center of the bounding box associated with the cube texture
  53821. * It must define where the camera used to render the texture was set
  53822. */
  53823. boundingBoxPosition: Vector3;
  53824. private _boundingBoxSize;
  53825. /**
  53826. * Gets or sets the size of the bounding box associated with the cube texture
  53827. * When defined, the cubemap will switch to local mode
  53828. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53829. * @example https://www.babylonjs-playground.com/#RNASML
  53830. */
  53831. boundingBoxSize: Vector3;
  53832. /**
  53833. * Instantiates an HDRTexture from the following parameters.
  53834. *
  53835. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53836. * @param scene The scene the texture will be used in
  53837. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53838. * @param noMipmap Forces to not generate the mipmap if true
  53839. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53840. * @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)
  53841. * @param reserved Reserved flag for internal use.
  53842. */
  53843. 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>);
  53844. /**
  53845. * Get the current class name of the texture useful for serialization or dynamic coding.
  53846. * @returns "HDRCubeTexture"
  53847. */
  53848. getClassName(): string;
  53849. /**
  53850. * Occurs when the file is raw .hdr file.
  53851. */
  53852. private loadTexture;
  53853. clone(): HDRCubeTexture;
  53854. delayLoad(): void;
  53855. /**
  53856. * Get the texture reflection matrix used to rotate/transform the reflection.
  53857. * @returns the reflection matrix
  53858. */
  53859. getReflectionTextureMatrix(): Matrix;
  53860. /**
  53861. * Set the texture reflection matrix used to rotate/transform the reflection.
  53862. * @param value Define the reflection matrix to set
  53863. */
  53864. setReflectionTextureMatrix(value: Matrix): void;
  53865. /**
  53866. * Parses a JSON representation of an HDR Texture in order to create the texture
  53867. * @param parsedTexture Define the JSON representation
  53868. * @param scene Define the scene the texture should be created in
  53869. * @param rootUrl Define the root url in case we need to load relative dependencies
  53870. * @returns the newly created texture after parsing
  53871. */
  53872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53873. serialize(): any;
  53874. }
  53875. }
  53876. declare module "babylonjs/Physics/physicsEngine" {
  53877. import { Nullable } from "babylonjs/types";
  53878. import { Vector3 } from "babylonjs/Maths/math.vector";
  53879. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53880. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53881. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53882. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53883. /**
  53884. * Class used to control physics engine
  53885. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53886. */
  53887. export class PhysicsEngine implements IPhysicsEngine {
  53888. private _physicsPlugin;
  53889. /**
  53890. * Global value used to control the smallest number supported by the simulation
  53891. */
  53892. static Epsilon: number;
  53893. private _impostors;
  53894. private _joints;
  53895. /**
  53896. * Gets the gravity vector used by the simulation
  53897. */
  53898. gravity: Vector3;
  53899. /**
  53900. * Factory used to create the default physics plugin.
  53901. * @returns The default physics plugin
  53902. */
  53903. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53904. /**
  53905. * Creates a new Physics Engine
  53906. * @param gravity defines the gravity vector used by the simulation
  53907. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53908. */
  53909. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53910. /**
  53911. * Sets the gravity vector used by the simulation
  53912. * @param gravity defines the gravity vector to use
  53913. */
  53914. setGravity(gravity: Vector3): void;
  53915. /**
  53916. * Set the time step of the physics engine.
  53917. * Default is 1/60.
  53918. * To slow it down, enter 1/600 for example.
  53919. * To speed it up, 1/30
  53920. * @param newTimeStep defines the new timestep to apply to this world.
  53921. */
  53922. setTimeStep(newTimeStep?: number): void;
  53923. /**
  53924. * Get the time step of the physics engine.
  53925. * @returns the current time step
  53926. */
  53927. getTimeStep(): number;
  53928. /**
  53929. * Release all resources
  53930. */
  53931. dispose(): void;
  53932. /**
  53933. * Gets the name of the current physics plugin
  53934. * @returns the name of the plugin
  53935. */
  53936. getPhysicsPluginName(): string;
  53937. /**
  53938. * Adding a new impostor for the impostor tracking.
  53939. * This will be done by the impostor itself.
  53940. * @param impostor the impostor to add
  53941. */
  53942. addImpostor(impostor: PhysicsImpostor): void;
  53943. /**
  53944. * Remove an impostor from the engine.
  53945. * This impostor and its mesh will not longer be updated by the physics engine.
  53946. * @param impostor the impostor to remove
  53947. */
  53948. removeImpostor(impostor: PhysicsImpostor): void;
  53949. /**
  53950. * Add a joint to the physics engine
  53951. * @param mainImpostor defines the main impostor to which the joint is added.
  53952. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53953. * @param joint defines the joint that will connect both impostors.
  53954. */
  53955. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53956. /**
  53957. * Removes a joint from the simulation
  53958. * @param mainImpostor defines the impostor used with the joint
  53959. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53960. * @param joint defines the joint to remove
  53961. */
  53962. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53963. /**
  53964. * Called by the scene. No need to call it.
  53965. * @param delta defines the timespam between frames
  53966. */
  53967. _step(delta: number): void;
  53968. /**
  53969. * Gets the current plugin used to run the simulation
  53970. * @returns current plugin
  53971. */
  53972. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53973. /**
  53974. * Gets the list of physic impostors
  53975. * @returns an array of PhysicsImpostor
  53976. */
  53977. getImpostors(): Array<PhysicsImpostor>;
  53978. /**
  53979. * Gets the impostor for a physics enabled object
  53980. * @param object defines the object impersonated by the impostor
  53981. * @returns the PhysicsImpostor or null if not found
  53982. */
  53983. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53984. /**
  53985. * Gets the impostor for a physics body object
  53986. * @param body defines physics body used by the impostor
  53987. * @returns the PhysicsImpostor or null if not found
  53988. */
  53989. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53990. /**
  53991. * Does a raycast in the physics world
  53992. * @param from when should the ray start?
  53993. * @param to when should the ray end?
  53994. * @returns PhysicsRaycastResult
  53995. */
  53996. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53997. }
  53998. }
  53999. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54000. import { Nullable } from "babylonjs/types";
  54001. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54003. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54004. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54005. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54006. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54007. /** @hidden */
  54008. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54009. private _useDeltaForWorldStep;
  54010. world: any;
  54011. name: string;
  54012. private _physicsMaterials;
  54013. private _fixedTimeStep;
  54014. private _cannonRaycastResult;
  54015. private _raycastResult;
  54016. private _physicsBodysToRemoveAfterStep;
  54017. BJSCANNON: any;
  54018. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54019. setGravity(gravity: Vector3): void;
  54020. setTimeStep(timeStep: number): void;
  54021. getTimeStep(): number;
  54022. executeStep(delta: number): void;
  54023. private _removeMarkedPhysicsBodiesFromWorld;
  54024. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54026. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54027. private _processChildMeshes;
  54028. removePhysicsBody(impostor: PhysicsImpostor): void;
  54029. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54030. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54031. private _addMaterial;
  54032. private _checkWithEpsilon;
  54033. private _createShape;
  54034. private _createHeightmap;
  54035. private _minus90X;
  54036. private _plus90X;
  54037. private _tmpPosition;
  54038. private _tmpDeltaPosition;
  54039. private _tmpUnityRotation;
  54040. private _updatePhysicsBodyTransformation;
  54041. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54042. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54043. isSupported(): boolean;
  54044. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54045. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54046. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54047. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54048. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54049. getBodyMass(impostor: PhysicsImpostor): number;
  54050. getBodyFriction(impostor: PhysicsImpostor): number;
  54051. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54052. getBodyRestitution(impostor: PhysicsImpostor): number;
  54053. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54054. sleepBody(impostor: PhysicsImpostor): void;
  54055. wakeUpBody(impostor: PhysicsImpostor): void;
  54056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54057. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54058. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54059. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54060. getRadius(impostor: PhysicsImpostor): number;
  54061. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54062. dispose(): void;
  54063. private _extendNamespace;
  54064. /**
  54065. * Does a raycast in the physics world
  54066. * @param from when should the ray start?
  54067. * @param to when should the ray end?
  54068. * @returns PhysicsRaycastResult
  54069. */
  54070. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54071. }
  54072. }
  54073. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54074. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54075. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54076. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54078. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54079. import { Nullable } from "babylonjs/types";
  54080. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54081. /** @hidden */
  54082. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54083. world: any;
  54084. name: string;
  54085. BJSOIMO: any;
  54086. private _raycastResult;
  54087. constructor(iterations?: number, oimoInjection?: any);
  54088. setGravity(gravity: Vector3): void;
  54089. setTimeStep(timeStep: number): void;
  54090. getTimeStep(): number;
  54091. private _tmpImpostorsArray;
  54092. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54093. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54094. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54095. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54096. private _tmpPositionVector;
  54097. removePhysicsBody(impostor: PhysicsImpostor): void;
  54098. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54099. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54100. isSupported(): boolean;
  54101. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54102. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54103. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54104. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54105. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54106. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54107. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54108. getBodyMass(impostor: PhysicsImpostor): number;
  54109. getBodyFriction(impostor: PhysicsImpostor): number;
  54110. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54111. getBodyRestitution(impostor: PhysicsImpostor): number;
  54112. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54113. sleepBody(impostor: PhysicsImpostor): void;
  54114. wakeUpBody(impostor: PhysicsImpostor): void;
  54115. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54116. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54117. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54118. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54119. getRadius(impostor: PhysicsImpostor): number;
  54120. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54121. dispose(): void;
  54122. /**
  54123. * Does a raycast in the physics world
  54124. * @param from when should the ray start?
  54125. * @param to when should the ray end?
  54126. * @returns PhysicsRaycastResult
  54127. */
  54128. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54129. }
  54130. }
  54131. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54132. import { Nullable } from "babylonjs/types";
  54133. import { Scene } from "babylonjs/scene";
  54134. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54135. import { Color4 } from "babylonjs/Maths/math.color";
  54136. import { Mesh } from "babylonjs/Meshes/mesh";
  54137. /**
  54138. * Class containing static functions to help procedurally build meshes
  54139. */
  54140. export class RibbonBuilder {
  54141. /**
  54142. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54143. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54144. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54145. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54146. * * 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
  54147. * * 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
  54148. * * 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
  54149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54152. * * 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
  54153. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54154. * * 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
  54155. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54157. * @param name defines the name of the mesh
  54158. * @param options defines the options used to create the mesh
  54159. * @param scene defines the hosting scene
  54160. * @returns the ribbon mesh
  54161. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54162. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54163. */
  54164. static CreateRibbon(name: string, options: {
  54165. pathArray: Vector3[][];
  54166. closeArray?: boolean;
  54167. closePath?: boolean;
  54168. offset?: number;
  54169. updatable?: boolean;
  54170. sideOrientation?: number;
  54171. frontUVs?: Vector4;
  54172. backUVs?: Vector4;
  54173. instance?: Mesh;
  54174. invertUV?: boolean;
  54175. uvs?: Vector2[];
  54176. colors?: Color4[];
  54177. }, scene?: Nullable<Scene>): Mesh;
  54178. }
  54179. }
  54180. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54181. import { Nullable } from "babylonjs/types";
  54182. import { Scene } from "babylonjs/scene";
  54183. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54184. import { Mesh } from "babylonjs/Meshes/mesh";
  54185. /**
  54186. * Class containing static functions to help procedurally build meshes
  54187. */
  54188. export class ShapeBuilder {
  54189. /**
  54190. * 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.
  54191. * * 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.
  54192. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54193. * * 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.
  54194. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54195. * * 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
  54196. * * 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
  54197. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54202. * @param name defines the name of the mesh
  54203. * @param options defines the options used to create the mesh
  54204. * @param scene defines the hosting scene
  54205. * @returns the extruded shape mesh
  54206. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54208. */
  54209. static ExtrudeShape(name: string, options: {
  54210. shape: Vector3[];
  54211. path: Vector3[];
  54212. scale?: number;
  54213. rotation?: number;
  54214. cap?: number;
  54215. updatable?: boolean;
  54216. sideOrientation?: number;
  54217. frontUVs?: Vector4;
  54218. backUVs?: Vector4;
  54219. instance?: Mesh;
  54220. invertUV?: boolean;
  54221. }, scene?: Nullable<Scene>): Mesh;
  54222. /**
  54223. * Creates an custom extruded shape mesh.
  54224. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54225. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  54226. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54227. * * The parameter `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
  54228. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54229. * * 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
  54230. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54231. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54232. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54233. * * 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
  54234. * * 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
  54235. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54240. * @param name defines the name of the mesh
  54241. * @param options defines the options used to create the mesh
  54242. * @param scene defines the hosting scene
  54243. * @returns the custom extruded shape mesh
  54244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54247. */
  54248. static ExtrudeShapeCustom(name: string, options: {
  54249. shape: Vector3[];
  54250. path: Vector3[];
  54251. scaleFunction?: any;
  54252. rotationFunction?: any;
  54253. ribbonCloseArray?: boolean;
  54254. ribbonClosePath?: boolean;
  54255. cap?: number;
  54256. updatable?: boolean;
  54257. sideOrientation?: number;
  54258. frontUVs?: Vector4;
  54259. backUVs?: Vector4;
  54260. instance?: Mesh;
  54261. invertUV?: boolean;
  54262. }, scene?: Nullable<Scene>): Mesh;
  54263. private static _ExtrudeShapeGeneric;
  54264. }
  54265. }
  54266. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54267. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54268. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54269. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54270. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54271. import { Nullable } from "babylonjs/types";
  54272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54273. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54274. /**
  54275. * AmmoJS Physics plugin
  54276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54277. * @see https://github.com/kripken/ammo.js/
  54278. */
  54279. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54280. private _useDeltaForWorldStep;
  54281. /**
  54282. * Reference to the Ammo library
  54283. */
  54284. bjsAMMO: any;
  54285. /**
  54286. * Created ammoJS world which physics bodies are added to
  54287. */
  54288. world: any;
  54289. /**
  54290. * Name of the plugin
  54291. */
  54292. name: string;
  54293. private _timeStep;
  54294. private _fixedTimeStep;
  54295. private _maxSteps;
  54296. private _tmpQuaternion;
  54297. private _tmpAmmoTransform;
  54298. private _tmpAmmoQuaternion;
  54299. private _tmpAmmoConcreteContactResultCallback;
  54300. private _collisionConfiguration;
  54301. private _dispatcher;
  54302. private _overlappingPairCache;
  54303. private _solver;
  54304. private _softBodySolver;
  54305. private _tmpAmmoVectorA;
  54306. private _tmpAmmoVectorB;
  54307. private _tmpAmmoVectorC;
  54308. private _tmpAmmoVectorD;
  54309. private _tmpContactCallbackResult;
  54310. private _tmpAmmoVectorRCA;
  54311. private _tmpAmmoVectorRCB;
  54312. private _raycastResult;
  54313. private static readonly DISABLE_COLLISION_FLAG;
  54314. private static readonly KINEMATIC_FLAG;
  54315. private static readonly DISABLE_DEACTIVATION_FLAG;
  54316. /**
  54317. * Initializes the ammoJS plugin
  54318. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54319. * @param ammoInjection can be used to inject your own ammo reference
  54320. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54321. */
  54322. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54323. /**
  54324. * Sets the gravity of the physics world (m/(s^2))
  54325. * @param gravity Gravity to set
  54326. */
  54327. setGravity(gravity: Vector3): void;
  54328. /**
  54329. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54330. * @param timeStep timestep to use in seconds
  54331. */
  54332. setTimeStep(timeStep: number): void;
  54333. /**
  54334. * 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)
  54335. * @param fixedTimeStep fixedTimeStep to use in seconds
  54336. */
  54337. setFixedTimeStep(fixedTimeStep: number): void;
  54338. /**
  54339. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54340. * @param maxSteps the maximum number of steps by the physics engine per frame
  54341. */
  54342. setMaxSteps(maxSteps: number): void;
  54343. /**
  54344. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54345. * @returns the current timestep in seconds
  54346. */
  54347. getTimeStep(): number;
  54348. private _isImpostorInContact;
  54349. private _isImpostorPairInContact;
  54350. private _stepSimulation;
  54351. /**
  54352. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54353. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54354. * After the step the babylon meshes are set to the position of the physics imposters
  54355. * @param delta amount of time to step forward
  54356. * @param impostors array of imposters to update before/after the step
  54357. */
  54358. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54359. /**
  54360. * Update babylon mesh to match physics world object
  54361. * @param impostor imposter to match
  54362. */
  54363. private _afterSoftStep;
  54364. /**
  54365. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54366. * @param impostor imposter to match
  54367. */
  54368. private _ropeStep;
  54369. /**
  54370. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54371. * @param impostor imposter to match
  54372. */
  54373. private _softbodyOrClothStep;
  54374. private _tmpVector;
  54375. private _tmpMatrix;
  54376. /**
  54377. * Applies an impulse on the imposter
  54378. * @param impostor imposter to apply impulse to
  54379. * @param force amount of force to be applied to the imposter
  54380. * @param contactPoint the location to apply the impulse on the imposter
  54381. */
  54382. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54383. /**
  54384. * Applies a force on the imposter
  54385. * @param impostor imposter to apply force
  54386. * @param force amount of force to be applied to the imposter
  54387. * @param contactPoint the location to apply the force on the imposter
  54388. */
  54389. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54390. /**
  54391. * Creates a physics body using the plugin
  54392. * @param impostor the imposter to create the physics body on
  54393. */
  54394. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54395. /**
  54396. * Removes the physics body from the imposter and disposes of the body's memory
  54397. * @param impostor imposter to remove the physics body from
  54398. */
  54399. removePhysicsBody(impostor: PhysicsImpostor): void;
  54400. /**
  54401. * Generates a joint
  54402. * @param impostorJoint the imposter joint to create the joint with
  54403. */
  54404. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54405. /**
  54406. * Removes a joint
  54407. * @param impostorJoint the imposter joint to remove the joint from
  54408. */
  54409. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54410. private _addMeshVerts;
  54411. /**
  54412. * Initialise the soft body vertices to match its object's (mesh) vertices
  54413. * Softbody vertices (nodes) are in world space and to match this
  54414. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54415. * @param impostor to create the softbody for
  54416. */
  54417. private _softVertexData;
  54418. /**
  54419. * Create an impostor's soft body
  54420. * @param impostor to create the softbody for
  54421. */
  54422. private _createSoftbody;
  54423. /**
  54424. * Create cloth for an impostor
  54425. * @param impostor to create the softbody for
  54426. */
  54427. private _createCloth;
  54428. /**
  54429. * Create rope for an impostor
  54430. * @param impostor to create the softbody for
  54431. */
  54432. private _createRope;
  54433. private _addHullVerts;
  54434. private _createShape;
  54435. /**
  54436. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54437. * @param impostor imposter containing the physics body and babylon object
  54438. */
  54439. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54440. /**
  54441. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54442. * @param impostor imposter containing the physics body and babylon object
  54443. * @param newPosition new position
  54444. * @param newRotation new rotation
  54445. */
  54446. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54447. /**
  54448. * If this plugin is supported
  54449. * @returns true if its supported
  54450. */
  54451. isSupported(): boolean;
  54452. /**
  54453. * Sets the linear velocity of the physics body
  54454. * @param impostor imposter to set the velocity on
  54455. * @param velocity velocity to set
  54456. */
  54457. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54458. /**
  54459. * Sets the angular velocity of the physics body
  54460. * @param impostor imposter to set the velocity on
  54461. * @param velocity velocity to set
  54462. */
  54463. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54464. /**
  54465. * gets the linear velocity
  54466. * @param impostor imposter to get linear velocity from
  54467. * @returns linear velocity
  54468. */
  54469. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54470. /**
  54471. * gets the angular velocity
  54472. * @param impostor imposter to get angular velocity from
  54473. * @returns angular velocity
  54474. */
  54475. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54476. /**
  54477. * Sets the mass of physics body
  54478. * @param impostor imposter to set the mass on
  54479. * @param mass mass to set
  54480. */
  54481. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54482. /**
  54483. * Gets the mass of the physics body
  54484. * @param impostor imposter to get the mass from
  54485. * @returns mass
  54486. */
  54487. getBodyMass(impostor: PhysicsImpostor): number;
  54488. /**
  54489. * Gets friction of the impostor
  54490. * @param impostor impostor to get friction from
  54491. * @returns friction value
  54492. */
  54493. getBodyFriction(impostor: PhysicsImpostor): number;
  54494. /**
  54495. * Sets friction of the impostor
  54496. * @param impostor impostor to set friction on
  54497. * @param friction friction value
  54498. */
  54499. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54500. /**
  54501. * Gets restitution of the impostor
  54502. * @param impostor impostor to get restitution from
  54503. * @returns restitution value
  54504. */
  54505. getBodyRestitution(impostor: PhysicsImpostor): number;
  54506. /**
  54507. * Sets resitution of the impostor
  54508. * @param impostor impostor to set resitution on
  54509. * @param restitution resitution value
  54510. */
  54511. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54512. /**
  54513. * Gets pressure inside the impostor
  54514. * @param impostor impostor to get pressure from
  54515. * @returns pressure value
  54516. */
  54517. getBodyPressure(impostor: PhysicsImpostor): number;
  54518. /**
  54519. * Sets pressure inside a soft body impostor
  54520. * Cloth and rope must remain 0 pressure
  54521. * @param impostor impostor to set pressure on
  54522. * @param pressure pressure value
  54523. */
  54524. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54525. /**
  54526. * Gets stiffness of the impostor
  54527. * @param impostor impostor to get stiffness from
  54528. * @returns pressure value
  54529. */
  54530. getBodyStiffness(impostor: PhysicsImpostor): number;
  54531. /**
  54532. * Sets stiffness of the impostor
  54533. * @param impostor impostor to set stiffness on
  54534. * @param stiffness stiffness value from 0 to 1
  54535. */
  54536. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54537. /**
  54538. * Gets velocityIterations of the impostor
  54539. * @param impostor impostor to get velocity iterations from
  54540. * @returns velocityIterations value
  54541. */
  54542. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54543. /**
  54544. * Sets velocityIterations of the impostor
  54545. * @param impostor impostor to set velocity iterations on
  54546. * @param velocityIterations velocityIterations value
  54547. */
  54548. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54549. /**
  54550. * Gets positionIterations of the impostor
  54551. * @param impostor impostor to get position iterations from
  54552. * @returns positionIterations value
  54553. */
  54554. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54555. /**
  54556. * Sets positionIterations of the impostor
  54557. * @param impostor impostor to set position on
  54558. * @param positionIterations positionIterations value
  54559. */
  54560. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54561. /**
  54562. * Append an anchor to a cloth object
  54563. * @param impostor is the cloth impostor to add anchor to
  54564. * @param otherImpostor is the rigid impostor to anchor to
  54565. * @param width ratio across width from 0 to 1
  54566. * @param height ratio up height from 0 to 1
  54567. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54568. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54569. */
  54570. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54571. /**
  54572. * Append an hook to a rope object
  54573. * @param impostor is the rope impostor to add hook to
  54574. * @param otherImpostor is the rigid impostor to hook to
  54575. * @param length ratio along the rope from 0 to 1
  54576. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54577. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54578. */
  54579. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54580. /**
  54581. * Sleeps the physics body and stops it from being active
  54582. * @param impostor impostor to sleep
  54583. */
  54584. sleepBody(impostor: PhysicsImpostor): void;
  54585. /**
  54586. * Activates the physics body
  54587. * @param impostor impostor to activate
  54588. */
  54589. wakeUpBody(impostor: PhysicsImpostor): void;
  54590. /**
  54591. * Updates the distance parameters of the joint
  54592. * @param joint joint to update
  54593. * @param maxDistance maximum distance of the joint
  54594. * @param minDistance minimum distance of the joint
  54595. */
  54596. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54597. /**
  54598. * Sets a motor on the joint
  54599. * @param joint joint to set motor on
  54600. * @param speed speed of the motor
  54601. * @param maxForce maximum force of the motor
  54602. * @param motorIndex index of the motor
  54603. */
  54604. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54605. /**
  54606. * Sets the motors limit
  54607. * @param joint joint to set limit on
  54608. * @param upperLimit upper limit
  54609. * @param lowerLimit lower limit
  54610. */
  54611. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54612. /**
  54613. * Syncs the position and rotation of a mesh with the impostor
  54614. * @param mesh mesh to sync
  54615. * @param impostor impostor to update the mesh with
  54616. */
  54617. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54618. /**
  54619. * Gets the radius of the impostor
  54620. * @param impostor impostor to get radius from
  54621. * @returns the radius
  54622. */
  54623. getRadius(impostor: PhysicsImpostor): number;
  54624. /**
  54625. * Gets the box size of the impostor
  54626. * @param impostor impostor to get box size from
  54627. * @param result the resulting box size
  54628. */
  54629. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54630. /**
  54631. * Disposes of the impostor
  54632. */
  54633. dispose(): void;
  54634. /**
  54635. * Does a raycast in the physics world
  54636. * @param from when should the ray start?
  54637. * @param to when should the ray end?
  54638. * @returns PhysicsRaycastResult
  54639. */
  54640. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54641. }
  54642. }
  54643. declare module "babylonjs/Probes/reflectionProbe" {
  54644. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54645. import { Vector3 } from "babylonjs/Maths/math.vector";
  54646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54647. import { Nullable } from "babylonjs/types";
  54648. import { Scene } from "babylonjs/scene";
  54649. module "babylonjs/abstractScene" {
  54650. interface AbstractScene {
  54651. /**
  54652. * The list of reflection probes added to the scene
  54653. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54654. */
  54655. reflectionProbes: Array<ReflectionProbe>;
  54656. /**
  54657. * Removes the given reflection probe from this scene.
  54658. * @param toRemove The reflection probe to remove
  54659. * @returns The index of the removed reflection probe
  54660. */
  54661. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54662. /**
  54663. * Adds the given reflection probe to this scene.
  54664. * @param newReflectionProbe The reflection probe to add
  54665. */
  54666. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54667. }
  54668. }
  54669. /**
  54670. * Class used to generate realtime reflection / refraction cube textures
  54671. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54672. */
  54673. export class ReflectionProbe {
  54674. /** defines the name of the probe */
  54675. name: string;
  54676. private _scene;
  54677. private _renderTargetTexture;
  54678. private _projectionMatrix;
  54679. private _viewMatrix;
  54680. private _target;
  54681. private _add;
  54682. private _attachedMesh;
  54683. private _invertYAxis;
  54684. /** Gets or sets probe position (center of the cube map) */
  54685. position: Vector3;
  54686. /**
  54687. * Creates a new reflection probe
  54688. * @param name defines the name of the probe
  54689. * @param size defines the texture resolution (for each face)
  54690. * @param scene defines the hosting scene
  54691. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54692. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54693. */
  54694. constructor(
  54695. /** defines the name of the probe */
  54696. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54697. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54698. samples: number;
  54699. /** Gets or sets the refresh rate to use (on every frame by default) */
  54700. refreshRate: number;
  54701. /**
  54702. * Gets the hosting scene
  54703. * @returns a Scene
  54704. */
  54705. getScene(): Scene;
  54706. /** Gets the internal CubeTexture used to render to */
  54707. readonly cubeTexture: RenderTargetTexture;
  54708. /** Gets the list of meshes to render */
  54709. readonly renderList: Nullable<AbstractMesh[]>;
  54710. /**
  54711. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54712. * @param mesh defines the mesh to attach to
  54713. */
  54714. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54715. /**
  54716. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54717. * @param renderingGroupId The rendering group id corresponding to its index
  54718. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54719. */
  54720. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54721. /**
  54722. * Clean all associated resources
  54723. */
  54724. dispose(): void;
  54725. /**
  54726. * Converts the reflection probe information to a readable string for debug purpose.
  54727. * @param fullDetails Supports for multiple levels of logging within scene loading
  54728. * @returns the human readable reflection probe info
  54729. */
  54730. toString(fullDetails?: boolean): string;
  54731. /**
  54732. * Get the class name of the relfection probe.
  54733. * @returns "ReflectionProbe"
  54734. */
  54735. getClassName(): string;
  54736. /**
  54737. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54738. * @returns The JSON representation of the texture
  54739. */
  54740. serialize(): any;
  54741. /**
  54742. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54743. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54744. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54745. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54746. * @returns The parsed reflection probe if successful
  54747. */
  54748. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54749. }
  54750. }
  54751. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54752. /** @hidden */
  54753. export var _BabylonLoaderRegistered: boolean;
  54754. /**
  54755. * Helps setting up some configuration for the babylon file loader.
  54756. */
  54757. export class BabylonFileLoaderConfiguration {
  54758. /**
  54759. * The loader does not allow injecting custom physix engine into the plugins.
  54760. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54761. * So you could set this variable to your engine import to make it work.
  54762. */
  54763. static LoaderInjectedPhysicsEngine: any;
  54764. }
  54765. }
  54766. declare module "babylonjs/Loading/Plugins/index" {
  54767. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54768. }
  54769. declare module "babylonjs/Loading/index" {
  54770. export * from "babylonjs/Loading/loadingScreen";
  54771. export * from "babylonjs/Loading/Plugins/index";
  54772. export * from "babylonjs/Loading/sceneLoader";
  54773. export * from "babylonjs/Loading/sceneLoaderFlags";
  54774. }
  54775. declare module "babylonjs/Materials/Background/index" {
  54776. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54777. }
  54778. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54779. import { Scene } from "babylonjs/scene";
  54780. import { Color3 } from "babylonjs/Maths/math.color";
  54781. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54782. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54783. /**
  54784. * The Physically based simple base material of BJS.
  54785. *
  54786. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54787. * It is used as the base class for both the specGloss and metalRough conventions.
  54788. */
  54789. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54790. /**
  54791. * Number of Simultaneous lights allowed on the material.
  54792. */
  54793. maxSimultaneousLights: number;
  54794. /**
  54795. * If sets to true, disables all the lights affecting the material.
  54796. */
  54797. disableLighting: boolean;
  54798. /**
  54799. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54800. */
  54801. environmentTexture: BaseTexture;
  54802. /**
  54803. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54804. */
  54805. invertNormalMapX: boolean;
  54806. /**
  54807. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54808. */
  54809. invertNormalMapY: boolean;
  54810. /**
  54811. * Normal map used in the model.
  54812. */
  54813. normalTexture: BaseTexture;
  54814. /**
  54815. * Emissivie color used to self-illuminate the model.
  54816. */
  54817. emissiveColor: Color3;
  54818. /**
  54819. * Emissivie texture used to self-illuminate the model.
  54820. */
  54821. emissiveTexture: BaseTexture;
  54822. /**
  54823. * Occlusion Channel Strenght.
  54824. */
  54825. occlusionStrength: number;
  54826. /**
  54827. * Occlusion Texture of the material (adding extra occlusion effects).
  54828. */
  54829. occlusionTexture: BaseTexture;
  54830. /**
  54831. * Defines the alpha limits in alpha test mode.
  54832. */
  54833. alphaCutOff: number;
  54834. /**
  54835. * Gets the current double sided mode.
  54836. */
  54837. /**
  54838. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54839. */
  54840. doubleSided: boolean;
  54841. /**
  54842. * Stores the pre-calculated light information of a mesh in a texture.
  54843. */
  54844. lightmapTexture: BaseTexture;
  54845. /**
  54846. * If true, the light map contains occlusion information instead of lighting info.
  54847. */
  54848. useLightmapAsShadowmap: boolean;
  54849. /**
  54850. * Instantiates a new PBRMaterial instance.
  54851. *
  54852. * @param name The material name
  54853. * @param scene The scene the material will be use in.
  54854. */
  54855. constructor(name: string, scene: Scene);
  54856. getClassName(): string;
  54857. }
  54858. }
  54859. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54860. import { Scene } from "babylonjs/scene";
  54861. import { Color3 } from "babylonjs/Maths/math.color";
  54862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54863. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54864. /**
  54865. * The PBR material of BJS following the metal roughness convention.
  54866. *
  54867. * This fits to the PBR convention in the GLTF definition:
  54868. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54869. */
  54870. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54871. /**
  54872. * The base color has two different interpretations depending on the value of metalness.
  54873. * When the material is a metal, the base color is the specific measured reflectance value
  54874. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54875. * of the material.
  54876. */
  54877. baseColor: Color3;
  54878. /**
  54879. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54880. * well as opacity information in the alpha channel.
  54881. */
  54882. baseTexture: BaseTexture;
  54883. /**
  54884. * Specifies the metallic scalar value of the material.
  54885. * Can also be used to scale the metalness values of the metallic texture.
  54886. */
  54887. metallic: number;
  54888. /**
  54889. * Specifies the roughness scalar value of the material.
  54890. * Can also be used to scale the roughness values of the metallic texture.
  54891. */
  54892. roughness: number;
  54893. /**
  54894. * Texture containing both the metallic value in the B channel and the
  54895. * roughness value in the G channel to keep better precision.
  54896. */
  54897. metallicRoughnessTexture: BaseTexture;
  54898. /**
  54899. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54900. *
  54901. * @param name The material name
  54902. * @param scene The scene the material will be use in.
  54903. */
  54904. constructor(name: string, scene: Scene);
  54905. /**
  54906. * Return the currrent class name of the material.
  54907. */
  54908. getClassName(): string;
  54909. /**
  54910. * Makes a duplicate of the current material.
  54911. * @param name - name to use for the new material.
  54912. */
  54913. clone(name: string): PBRMetallicRoughnessMaterial;
  54914. /**
  54915. * Serialize the material to a parsable JSON object.
  54916. */
  54917. serialize(): any;
  54918. /**
  54919. * Parses a JSON object correponding to the serialize function.
  54920. */
  54921. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54922. }
  54923. }
  54924. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54925. import { Scene } from "babylonjs/scene";
  54926. import { Color3 } from "babylonjs/Maths/math.color";
  54927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54928. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54929. /**
  54930. * The PBR material of BJS following the specular glossiness convention.
  54931. *
  54932. * This fits to the PBR convention in the GLTF definition:
  54933. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54934. */
  54935. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54936. /**
  54937. * Specifies the diffuse color of the material.
  54938. */
  54939. diffuseColor: Color3;
  54940. /**
  54941. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54942. * channel.
  54943. */
  54944. diffuseTexture: BaseTexture;
  54945. /**
  54946. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54947. */
  54948. specularColor: Color3;
  54949. /**
  54950. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54951. */
  54952. glossiness: number;
  54953. /**
  54954. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54955. */
  54956. specularGlossinessTexture: BaseTexture;
  54957. /**
  54958. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54959. *
  54960. * @param name The material name
  54961. * @param scene The scene the material will be use in.
  54962. */
  54963. constructor(name: string, scene: Scene);
  54964. /**
  54965. * Return the currrent class name of the material.
  54966. */
  54967. getClassName(): string;
  54968. /**
  54969. * Makes a duplicate of the current material.
  54970. * @param name - name to use for the new material.
  54971. */
  54972. clone(name: string): PBRSpecularGlossinessMaterial;
  54973. /**
  54974. * Serialize the material to a parsable JSON object.
  54975. */
  54976. serialize(): any;
  54977. /**
  54978. * Parses a JSON object correponding to the serialize function.
  54979. */
  54980. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54981. }
  54982. }
  54983. declare module "babylonjs/Materials/PBR/index" {
  54984. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54985. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54986. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54987. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54988. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54989. }
  54990. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54991. import { Nullable } from "babylonjs/types";
  54992. import { Scene } from "babylonjs/scene";
  54993. import { Matrix } from "babylonjs/Maths/math.vector";
  54994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54995. /**
  54996. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54997. * It can help converting any input color in a desired output one. This can then be used to create effects
  54998. * from sepia, black and white to sixties or futuristic rendering...
  54999. *
  55000. * The only supported format is currently 3dl.
  55001. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55002. */
  55003. export class ColorGradingTexture extends BaseTexture {
  55004. /**
  55005. * The current texture matrix. (will always be identity in color grading texture)
  55006. */
  55007. private _textureMatrix;
  55008. /**
  55009. * The texture URL.
  55010. */
  55011. url: string;
  55012. /**
  55013. * Empty line regex stored for GC.
  55014. */
  55015. private static _noneEmptyLineRegex;
  55016. private _engine;
  55017. /**
  55018. * Instantiates a ColorGradingTexture from the following parameters.
  55019. *
  55020. * @param url The location of the color gradind data (currently only supporting 3dl)
  55021. * @param scene The scene the texture will be used in
  55022. */
  55023. constructor(url: string, scene: Scene);
  55024. /**
  55025. * Returns the texture matrix used in most of the material.
  55026. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55027. */
  55028. getTextureMatrix(): Matrix;
  55029. /**
  55030. * Occurs when the file being loaded is a .3dl LUT file.
  55031. */
  55032. private load3dlTexture;
  55033. /**
  55034. * Starts the loading process of the texture.
  55035. */
  55036. private loadTexture;
  55037. /**
  55038. * Clones the color gradind texture.
  55039. */
  55040. clone(): ColorGradingTexture;
  55041. /**
  55042. * Called during delayed load for textures.
  55043. */
  55044. delayLoad(): void;
  55045. /**
  55046. * Parses a color grading texture serialized by Babylon.
  55047. * @param parsedTexture The texture information being parsedTexture
  55048. * @param scene The scene to load the texture in
  55049. * @param rootUrl The root url of the data assets to load
  55050. * @return A color gradind texture
  55051. */
  55052. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55053. /**
  55054. * Serializes the LUT texture to json format.
  55055. */
  55056. serialize(): any;
  55057. }
  55058. }
  55059. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55061. import { Scene } from "babylonjs/scene";
  55062. import { Nullable } from "babylonjs/types";
  55063. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55064. /**
  55065. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55066. */
  55067. export class EquiRectangularCubeTexture extends BaseTexture {
  55068. /** The six faces of the cube. */
  55069. private static _FacesMapping;
  55070. private _noMipmap;
  55071. private _onLoad;
  55072. private _onError;
  55073. /** The size of the cubemap. */
  55074. private _size;
  55075. /** The buffer of the image. */
  55076. private _buffer;
  55077. /** The width of the input image. */
  55078. private _width;
  55079. /** The height of the input image. */
  55080. private _height;
  55081. /** The URL to the image. */
  55082. url: string;
  55083. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55084. coordinatesMode: number;
  55085. /**
  55086. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55087. * @param url The location of the image
  55088. * @param scene The scene the texture will be used in
  55089. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55090. * @param noMipmap Forces to not generate the mipmap if true
  55091. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55092. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55093. * @param onLoad — defines a callback called when texture is loaded
  55094. * @param onError — defines a callback called if there is an error
  55095. */
  55096. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55097. /**
  55098. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55099. */
  55100. private loadImage;
  55101. /**
  55102. * Convert the image buffer into a cubemap and create a CubeTexture.
  55103. */
  55104. private loadTexture;
  55105. /**
  55106. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55107. * @param buffer The ArrayBuffer that should be converted.
  55108. * @returns The buffer as Float32Array.
  55109. */
  55110. private getFloat32ArrayFromArrayBuffer;
  55111. /**
  55112. * Get the current class name of the texture useful for serialization or dynamic coding.
  55113. * @returns "EquiRectangularCubeTexture"
  55114. */
  55115. getClassName(): string;
  55116. /**
  55117. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55118. * @returns A clone of the current EquiRectangularCubeTexture.
  55119. */
  55120. clone(): EquiRectangularCubeTexture;
  55121. }
  55122. }
  55123. declare module "babylonjs/Misc/tga" {
  55124. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55125. /**
  55126. * Based on jsTGALoader - Javascript loader for TGA file
  55127. * By Vincent Thibault
  55128. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55129. */
  55130. export class TGATools {
  55131. private static _TYPE_INDEXED;
  55132. private static _TYPE_RGB;
  55133. private static _TYPE_GREY;
  55134. private static _TYPE_RLE_INDEXED;
  55135. private static _TYPE_RLE_RGB;
  55136. private static _TYPE_RLE_GREY;
  55137. private static _ORIGIN_MASK;
  55138. private static _ORIGIN_SHIFT;
  55139. private static _ORIGIN_BL;
  55140. private static _ORIGIN_BR;
  55141. private static _ORIGIN_UL;
  55142. private static _ORIGIN_UR;
  55143. /**
  55144. * Gets the header of a TGA file
  55145. * @param data defines the TGA data
  55146. * @returns the header
  55147. */
  55148. static GetTGAHeader(data: Uint8Array): any;
  55149. /**
  55150. * Uploads TGA content to a Babylon Texture
  55151. * @hidden
  55152. */
  55153. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55154. /** @hidden */
  55155. 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;
  55156. /** @hidden */
  55157. 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;
  55158. /** @hidden */
  55159. 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;
  55160. /** @hidden */
  55161. 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;
  55162. /** @hidden */
  55163. 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;
  55164. /** @hidden */
  55165. 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;
  55166. }
  55167. }
  55168. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55169. import { Nullable } from "babylonjs/types";
  55170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55171. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55172. /**
  55173. * Implementation of the TGA Texture Loader.
  55174. * @hidden
  55175. */
  55176. export class _TGATextureLoader implements IInternalTextureLoader {
  55177. /**
  55178. * Defines wether the loader supports cascade loading the different faces.
  55179. */
  55180. readonly supportCascades: boolean;
  55181. /**
  55182. * This returns if the loader support the current file information.
  55183. * @param extension defines the file extension of the file being loaded
  55184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55185. * @param fallback defines the fallback internal texture if any
  55186. * @param isBase64 defines whether the texture is encoded as a base64
  55187. * @param isBuffer defines whether the texture data are stored as a buffer
  55188. * @returns true if the loader can load the specified file
  55189. */
  55190. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55191. /**
  55192. * Transform the url before loading if required.
  55193. * @param rootUrl the url of the texture
  55194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55195. * @returns the transformed texture
  55196. */
  55197. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55198. /**
  55199. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55200. * @param rootUrl the url of the texture
  55201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55202. * @returns the fallback texture
  55203. */
  55204. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55205. /**
  55206. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55207. * @param data contains the texture data
  55208. * @param texture defines the BabylonJS internal texture
  55209. * @param createPolynomials will be true if polynomials have been requested
  55210. * @param onLoad defines the callback to trigger once the texture is ready
  55211. * @param onError defines the callback to trigger in case of error
  55212. */
  55213. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55214. /**
  55215. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55216. * @param data contains the texture data
  55217. * @param texture defines the BabylonJS internal texture
  55218. * @param callback defines the method to call once ready to upload
  55219. */
  55220. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55221. }
  55222. }
  55223. declare module "babylonjs/Misc/basis" {
  55224. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55225. /**
  55226. * Info about the .basis files
  55227. */
  55228. class BasisFileInfo {
  55229. /**
  55230. * If the file has alpha
  55231. */
  55232. hasAlpha: boolean;
  55233. /**
  55234. * Info about each image of the basis file
  55235. */
  55236. images: Array<{
  55237. levels: Array<{
  55238. width: number;
  55239. height: number;
  55240. transcodedPixels: ArrayBufferView;
  55241. }>;
  55242. }>;
  55243. }
  55244. /**
  55245. * Result of transcoding a basis file
  55246. */
  55247. class TranscodeResult {
  55248. /**
  55249. * Info about the .basis file
  55250. */
  55251. fileInfo: BasisFileInfo;
  55252. /**
  55253. * Format to use when loading the file
  55254. */
  55255. format: number;
  55256. }
  55257. /**
  55258. * Configuration options for the Basis transcoder
  55259. */
  55260. export class BasisTranscodeConfiguration {
  55261. /**
  55262. * Supported compression formats used to determine the supported output format of the transcoder
  55263. */
  55264. supportedCompressionFormats?: {
  55265. /**
  55266. * etc1 compression format
  55267. */
  55268. etc1?: boolean;
  55269. /**
  55270. * s3tc compression format
  55271. */
  55272. s3tc?: boolean;
  55273. /**
  55274. * pvrtc compression format
  55275. */
  55276. pvrtc?: boolean;
  55277. /**
  55278. * etc2 compression format
  55279. */
  55280. etc2?: boolean;
  55281. };
  55282. /**
  55283. * If mipmap levels should be loaded for transcoded images (Default: true)
  55284. */
  55285. loadMipmapLevels?: boolean;
  55286. /**
  55287. * Index of a single image to load (Default: all images)
  55288. */
  55289. loadSingleImage?: number;
  55290. }
  55291. /**
  55292. * Used to load .Basis files
  55293. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55294. */
  55295. export class BasisTools {
  55296. private static _IgnoreSupportedFormats;
  55297. /**
  55298. * URL to use when loading the basis transcoder
  55299. */
  55300. static JSModuleURL: string;
  55301. /**
  55302. * URL to use when loading the wasm module for the transcoder
  55303. */
  55304. static WasmModuleURL: string;
  55305. /**
  55306. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55307. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55308. * @returns internal format corresponding to the Basis format
  55309. */
  55310. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55311. private static _WorkerPromise;
  55312. private static _Worker;
  55313. private static _actionId;
  55314. private static _CreateWorkerAsync;
  55315. /**
  55316. * Transcodes a loaded image file to compressed pixel data
  55317. * @param imageData image data to transcode
  55318. * @param config configuration options for the transcoding
  55319. * @returns a promise resulting in the transcoded image
  55320. */
  55321. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55322. /**
  55323. * Loads a texture from the transcode result
  55324. * @param texture texture load to
  55325. * @param transcodeResult the result of transcoding the basis file to load from
  55326. */
  55327. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55328. }
  55329. }
  55330. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55331. import { Nullable } from "babylonjs/types";
  55332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55333. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55334. /**
  55335. * Loader for .basis file format
  55336. */
  55337. export class _BasisTextureLoader implements IInternalTextureLoader {
  55338. /**
  55339. * Defines whether the loader supports cascade loading the different faces.
  55340. */
  55341. readonly supportCascades: boolean;
  55342. /**
  55343. * This returns if the loader support the current file information.
  55344. * @param extension defines the file extension of the file being loaded
  55345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55346. * @param fallback defines the fallback internal texture if any
  55347. * @param isBase64 defines whether the texture is encoded as a base64
  55348. * @param isBuffer defines whether the texture data are stored as a buffer
  55349. * @returns true if the loader can load the specified file
  55350. */
  55351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55352. /**
  55353. * Transform the url before loading if required.
  55354. * @param rootUrl the url of the texture
  55355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55356. * @returns the transformed texture
  55357. */
  55358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55359. /**
  55360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55361. * @param rootUrl the url of the texture
  55362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55363. * @returns the fallback texture
  55364. */
  55365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55366. /**
  55367. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55368. * @param data contains the texture data
  55369. * @param texture defines the BabylonJS internal texture
  55370. * @param createPolynomials will be true if polynomials have been requested
  55371. * @param onLoad defines the callback to trigger once the texture is ready
  55372. * @param onError defines the callback to trigger in case of error
  55373. */
  55374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55375. /**
  55376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55377. * @param data contains the texture data
  55378. * @param texture defines the BabylonJS internal texture
  55379. * @param callback defines the method to call once ready to upload
  55380. */
  55381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55382. }
  55383. }
  55384. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55385. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55386. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55387. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55388. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55389. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55390. }
  55391. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55392. import { Scene } from "babylonjs/scene";
  55393. import { Texture } from "babylonjs/Materials/Textures/texture";
  55394. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55395. /**
  55396. * 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.
  55397. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55398. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55399. */
  55400. export class CustomProceduralTexture extends ProceduralTexture {
  55401. private _animate;
  55402. private _time;
  55403. private _config;
  55404. private _texturePath;
  55405. /**
  55406. * Instantiates a new Custom Procedural Texture.
  55407. * 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.
  55408. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55409. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55410. * @param name Define the name of the texture
  55411. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55412. * @param size Define the size of the texture to create
  55413. * @param scene Define the scene the texture belongs to
  55414. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55415. * @param generateMipMaps Define if the texture should creates mip maps or not
  55416. */
  55417. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55418. private _loadJson;
  55419. /**
  55420. * Is the texture ready to be used ? (rendered at least once)
  55421. * @returns true if ready, otherwise, false.
  55422. */
  55423. isReady(): boolean;
  55424. /**
  55425. * Render the texture to its associated render target.
  55426. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55427. */
  55428. render(useCameraPostProcess?: boolean): void;
  55429. /**
  55430. * Update the list of dependant textures samplers in the shader.
  55431. */
  55432. updateTextures(): void;
  55433. /**
  55434. * Update the uniform values of the procedural texture in the shader.
  55435. */
  55436. updateShaderUniforms(): void;
  55437. /**
  55438. * Define if the texture animates or not.
  55439. */
  55440. animate: boolean;
  55441. }
  55442. }
  55443. declare module "babylonjs/Shaders/noise.fragment" {
  55444. /** @hidden */
  55445. export var noisePixelShader: {
  55446. name: string;
  55447. shader: string;
  55448. };
  55449. }
  55450. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55451. import { Nullable } from "babylonjs/types";
  55452. import { Scene } from "babylonjs/scene";
  55453. import { Texture } from "babylonjs/Materials/Textures/texture";
  55454. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55455. import "babylonjs/Shaders/noise.fragment";
  55456. /**
  55457. * Class used to generate noise procedural textures
  55458. */
  55459. export class NoiseProceduralTexture extends ProceduralTexture {
  55460. private _time;
  55461. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55462. brightness: number;
  55463. /** Defines the number of octaves to process */
  55464. octaves: number;
  55465. /** Defines the level of persistence (0.8 by default) */
  55466. persistence: number;
  55467. /** Gets or sets animation speed factor (default is 1) */
  55468. animationSpeedFactor: number;
  55469. /**
  55470. * Creates a new NoiseProceduralTexture
  55471. * @param name defines the name fo the texture
  55472. * @param size defines the size of the texture (default is 256)
  55473. * @param scene defines the hosting scene
  55474. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55475. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55476. */
  55477. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55478. private _updateShaderUniforms;
  55479. protected _getDefines(): string;
  55480. /** Generate the current state of the procedural texture */
  55481. render(useCameraPostProcess?: boolean): void;
  55482. /**
  55483. * Serializes this noise procedural texture
  55484. * @returns a serialized noise procedural texture object
  55485. */
  55486. serialize(): any;
  55487. /**
  55488. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55489. * @param parsedTexture defines parsed texture data
  55490. * @param scene defines the current scene
  55491. * @param rootUrl defines the root URL containing noise procedural texture information
  55492. * @returns a parsed NoiseProceduralTexture
  55493. */
  55494. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55495. }
  55496. }
  55497. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55498. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55499. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55500. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55501. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55502. }
  55503. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55504. import { Nullable } from "babylonjs/types";
  55505. import { Scene } from "babylonjs/scene";
  55506. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55507. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55508. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55509. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55510. /**
  55511. * Raw cube texture where the raw buffers are passed in
  55512. */
  55513. export class RawCubeTexture extends CubeTexture {
  55514. /**
  55515. * Creates a cube texture where the raw buffers are passed in.
  55516. * @param scene defines the scene the texture is attached to
  55517. * @param data defines the array of data to use to create each face
  55518. * @param size defines the size of the textures
  55519. * @param format defines the format of the data
  55520. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55521. * @param generateMipMaps defines if the engine should generate the mip levels
  55522. * @param invertY defines if data must be stored with Y axis inverted
  55523. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55524. * @param compression defines the compression used (null by default)
  55525. */
  55526. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55527. /**
  55528. * Updates the raw cube texture.
  55529. * @param data defines the data to store
  55530. * @param format defines the data format
  55531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55532. * @param invertY defines if data must be stored with Y axis inverted
  55533. * @param compression defines the compression used (null by default)
  55534. * @param level defines which level of the texture to update
  55535. */
  55536. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55537. /**
  55538. * Updates a raw cube texture with RGBD encoded data.
  55539. * @param data defines the array of data [mipmap][face] to use to create each face
  55540. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55541. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55542. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55543. * @returns a promsie that resolves when the operation is complete
  55544. */
  55545. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55546. /**
  55547. * Clones the raw cube texture.
  55548. * @return a new cube texture
  55549. */
  55550. clone(): CubeTexture;
  55551. /** @hidden */
  55552. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55553. }
  55554. }
  55555. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55556. import { Scene } from "babylonjs/scene";
  55557. import { Texture } from "babylonjs/Materials/Textures/texture";
  55558. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55559. /**
  55560. * Class used to store 3D textures containing user data
  55561. */
  55562. export class RawTexture3D extends Texture {
  55563. /** Gets or sets the texture format to use */
  55564. format: number;
  55565. private _engine;
  55566. /**
  55567. * Create a new RawTexture3D
  55568. * @param data defines the data of the texture
  55569. * @param width defines the width of the texture
  55570. * @param height defines the height of the texture
  55571. * @param depth defines the depth of the texture
  55572. * @param format defines the texture format to use
  55573. * @param scene defines the hosting scene
  55574. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55575. * @param invertY defines if texture must be stored with Y axis inverted
  55576. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55577. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55578. */
  55579. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55580. /** Gets or sets the texture format to use */
  55581. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55582. /**
  55583. * Update the texture with new data
  55584. * @param data defines the data to store in the texture
  55585. */
  55586. update(data: ArrayBufferView): void;
  55587. }
  55588. }
  55589. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55590. import { Scene } from "babylonjs/scene";
  55591. import { Texture } from "babylonjs/Materials/Textures/texture";
  55592. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55593. /**
  55594. * Class used to store 2D array textures containing user data
  55595. */
  55596. export class RawTexture2DArray extends Texture {
  55597. /** Gets or sets the texture format to use */
  55598. format: number;
  55599. private _engine;
  55600. /**
  55601. * Create a new RawTexture2DArray
  55602. * @param data defines the data of the texture
  55603. * @param width defines the width of the texture
  55604. * @param height defines the height of the texture
  55605. * @param depth defines the number of layers of the texture
  55606. * @param format defines the texture format to use
  55607. * @param scene defines the hosting scene
  55608. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55609. * @param invertY defines if texture must be stored with Y axis inverted
  55610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55611. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55612. */
  55613. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55614. /** Gets or sets the texture format to use */
  55615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55616. /**
  55617. * Update the texture with new data
  55618. * @param data defines the data to store in the texture
  55619. */
  55620. update(data: ArrayBufferView): void;
  55621. }
  55622. }
  55623. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55624. import { Scene } from "babylonjs/scene";
  55625. import { Plane } from "babylonjs/Maths/math.plane";
  55626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55627. /**
  55628. * Creates a refraction texture used by refraction channel of the standard material.
  55629. * It is like a mirror but to see through a material.
  55630. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55631. */
  55632. export class RefractionTexture extends RenderTargetTexture {
  55633. /**
  55634. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55635. * 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.
  55636. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55637. */
  55638. refractionPlane: Plane;
  55639. /**
  55640. * Define how deep under the surface we should see.
  55641. */
  55642. depth: number;
  55643. /**
  55644. * Creates a refraction texture used by refraction channel of the standard material.
  55645. * It is like a mirror but to see through a material.
  55646. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55647. * @param name Define the texture name
  55648. * @param size Define the size of the underlying texture
  55649. * @param scene Define the scene the refraction belongs to
  55650. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55651. */
  55652. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55653. /**
  55654. * Clone the refraction texture.
  55655. * @returns the cloned texture
  55656. */
  55657. clone(): RefractionTexture;
  55658. /**
  55659. * Serialize the texture to a JSON representation you could use in Parse later on
  55660. * @returns the serialized JSON representation
  55661. */
  55662. serialize(): any;
  55663. }
  55664. }
  55665. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55666. import { Nullable } from "babylonjs/types";
  55667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55668. import { Matrix } from "babylonjs/Maths/math.vector";
  55669. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55670. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55671. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55672. import { Scene } from "babylonjs/scene";
  55673. /**
  55674. * Defines the options related to the creation of an HtmlElementTexture
  55675. */
  55676. export interface IHtmlElementTextureOptions {
  55677. /**
  55678. * Defines wether mip maps should be created or not.
  55679. */
  55680. generateMipMaps?: boolean;
  55681. /**
  55682. * Defines the sampling mode of the texture.
  55683. */
  55684. samplingMode?: number;
  55685. /**
  55686. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55687. */
  55688. engine: Nullable<ThinEngine>;
  55689. /**
  55690. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55691. */
  55692. scene: Nullable<Scene>;
  55693. }
  55694. /**
  55695. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55696. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55697. * is automatically managed.
  55698. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55699. * in your application.
  55700. *
  55701. * As the update is not automatic, you need to call them manually.
  55702. */
  55703. export class HtmlElementTexture extends BaseTexture {
  55704. /**
  55705. * The texture URL.
  55706. */
  55707. element: HTMLVideoElement | HTMLCanvasElement;
  55708. private static readonly DefaultOptions;
  55709. private _textureMatrix;
  55710. private _engine;
  55711. private _isVideo;
  55712. private _generateMipMaps;
  55713. private _samplingMode;
  55714. /**
  55715. * Instantiates a HtmlElementTexture from the following parameters.
  55716. *
  55717. * @param name Defines the name of the texture
  55718. * @param element Defines the video or canvas the texture is filled with
  55719. * @param options Defines the other none mandatory texture creation options
  55720. */
  55721. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55722. private _createInternalTexture;
  55723. /**
  55724. * Returns the texture matrix used in most of the material.
  55725. */
  55726. getTextureMatrix(): Matrix;
  55727. /**
  55728. * Updates the content of the texture.
  55729. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55730. */
  55731. update(invertY?: Nullable<boolean>): void;
  55732. }
  55733. }
  55734. declare module "babylonjs/Materials/Textures/index" {
  55735. export * from "babylonjs/Materials/Textures/baseTexture";
  55736. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55737. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55738. export * from "babylonjs/Materials/Textures/cubeTexture";
  55739. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55740. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55741. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55742. export * from "babylonjs/Materials/Textures/internalTexture";
  55743. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55744. export * from "babylonjs/Materials/Textures/Loaders/index";
  55745. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55746. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55747. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55748. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55749. export * from "babylonjs/Materials/Textures/rawTexture";
  55750. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55751. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55752. export * from "babylonjs/Materials/Textures/refractionTexture";
  55753. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55754. export * from "babylonjs/Materials/Textures/texture";
  55755. export * from "babylonjs/Materials/Textures/videoTexture";
  55756. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55757. }
  55758. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55759. /**
  55760. * Enum used to define the target of a block
  55761. */
  55762. export enum NodeMaterialBlockTargets {
  55763. /** Vertex shader */
  55764. Vertex = 1,
  55765. /** Fragment shader */
  55766. Fragment = 2,
  55767. /** Neutral */
  55768. Neutral = 4,
  55769. /** Vertex and Fragment */
  55770. VertexAndFragment = 3
  55771. }
  55772. }
  55773. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55774. /**
  55775. * Defines the kind of connection point for node based material
  55776. */
  55777. export enum NodeMaterialBlockConnectionPointTypes {
  55778. /** Float */
  55779. Float = 1,
  55780. /** Int */
  55781. Int = 2,
  55782. /** Vector2 */
  55783. Vector2 = 4,
  55784. /** Vector3 */
  55785. Vector3 = 8,
  55786. /** Vector4 */
  55787. Vector4 = 16,
  55788. /** Color3 */
  55789. Color3 = 32,
  55790. /** Color4 */
  55791. Color4 = 64,
  55792. /** Matrix */
  55793. Matrix = 128,
  55794. /** Detect type based on connection */
  55795. AutoDetect = 1024,
  55796. /** Output type that will be defined by input type */
  55797. BasedOnInput = 2048
  55798. }
  55799. }
  55800. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55801. /**
  55802. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55803. */
  55804. export enum NodeMaterialBlockConnectionPointMode {
  55805. /** Value is an uniform */
  55806. Uniform = 0,
  55807. /** Value is a mesh attribute */
  55808. Attribute = 1,
  55809. /** Value is a varying between vertex and fragment shaders */
  55810. Varying = 2,
  55811. /** Mode is undefined */
  55812. Undefined = 3
  55813. }
  55814. }
  55815. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55816. /**
  55817. * Enum used to define system values e.g. values automatically provided by the system
  55818. */
  55819. export enum NodeMaterialSystemValues {
  55820. /** World */
  55821. World = 1,
  55822. /** View */
  55823. View = 2,
  55824. /** Projection */
  55825. Projection = 3,
  55826. /** ViewProjection */
  55827. ViewProjection = 4,
  55828. /** WorldView */
  55829. WorldView = 5,
  55830. /** WorldViewProjection */
  55831. WorldViewProjection = 6,
  55832. /** CameraPosition */
  55833. CameraPosition = 7,
  55834. /** Fog Color */
  55835. FogColor = 8,
  55836. /** Delta time */
  55837. DeltaTime = 9
  55838. }
  55839. }
  55840. declare module "babylonjs/Materials/Node/Enums/index" {
  55841. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55842. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55843. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55844. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55845. }
  55846. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55848. /**
  55849. * Root class for all node material optimizers
  55850. */
  55851. export class NodeMaterialOptimizer {
  55852. /**
  55853. * Function used to optimize a NodeMaterial graph
  55854. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55855. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55856. */
  55857. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55858. }
  55859. }
  55860. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55864. import { Scene } from "babylonjs/scene";
  55865. /**
  55866. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55867. */
  55868. export class TransformBlock extends NodeMaterialBlock {
  55869. /**
  55870. * Defines the value to use to complement W value to transform it to a Vector4
  55871. */
  55872. complementW: number;
  55873. /**
  55874. * Defines the value to use to complement z value to transform it to a Vector4
  55875. */
  55876. complementZ: number;
  55877. /**
  55878. * Creates a new TransformBlock
  55879. * @param name defines the block name
  55880. */
  55881. constructor(name: string);
  55882. /**
  55883. * Gets the current class name
  55884. * @returns the class name
  55885. */
  55886. getClassName(): string;
  55887. /**
  55888. * Gets the vector input
  55889. */
  55890. readonly vector: NodeMaterialConnectionPoint;
  55891. /**
  55892. * Gets the output component
  55893. */
  55894. readonly output: NodeMaterialConnectionPoint;
  55895. /**
  55896. * Gets the matrix transform input
  55897. */
  55898. readonly transform: NodeMaterialConnectionPoint;
  55899. protected _buildBlock(state: NodeMaterialBuildState): this;
  55900. serialize(): any;
  55901. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55902. protected _dumpPropertiesCode(): string;
  55903. }
  55904. }
  55905. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55909. /**
  55910. * Block used to output the vertex position
  55911. */
  55912. export class VertexOutputBlock extends NodeMaterialBlock {
  55913. /**
  55914. * Creates a new VertexOutputBlock
  55915. * @param name defines the block name
  55916. */
  55917. constructor(name: string);
  55918. /**
  55919. * Gets the current class name
  55920. * @returns the class name
  55921. */
  55922. getClassName(): string;
  55923. /**
  55924. * Gets the vector input component
  55925. */
  55926. readonly vector: NodeMaterialConnectionPoint;
  55927. protected _buildBlock(state: NodeMaterialBuildState): this;
  55928. }
  55929. }
  55930. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55934. /**
  55935. * Block used to output the final color
  55936. */
  55937. export class FragmentOutputBlock extends NodeMaterialBlock {
  55938. /**
  55939. * Create a new FragmentOutputBlock
  55940. * @param name defines the block name
  55941. */
  55942. constructor(name: string);
  55943. /**
  55944. * Gets the current class name
  55945. * @returns the class name
  55946. */
  55947. getClassName(): string;
  55948. /**
  55949. * Gets the rgba input component
  55950. */
  55951. readonly rgba: NodeMaterialConnectionPoint;
  55952. /**
  55953. * Gets the rgb input component
  55954. */
  55955. readonly rgb: NodeMaterialConnectionPoint;
  55956. /**
  55957. * Gets the a input component
  55958. */
  55959. readonly a: NodeMaterialConnectionPoint;
  55960. protected _buildBlock(state: NodeMaterialBuildState): this;
  55961. }
  55962. }
  55963. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55969. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55970. import { Effect } from "babylonjs/Materials/effect";
  55971. import { Mesh } from "babylonjs/Meshes/mesh";
  55972. import { Nullable } from "babylonjs/types";
  55973. import { Scene } from "babylonjs/scene";
  55974. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55975. /**
  55976. * Block used to read a reflection texture from a sampler
  55977. */
  55978. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55979. private _define3DName;
  55980. private _defineCubicName;
  55981. private _defineExplicitName;
  55982. private _defineProjectionName;
  55983. private _defineLocalCubicName;
  55984. private _defineSphericalName;
  55985. private _definePlanarName;
  55986. private _defineEquirectangularName;
  55987. private _defineMirroredEquirectangularFixedName;
  55988. private _defineEquirectangularFixedName;
  55989. private _defineSkyboxName;
  55990. private _cubeSamplerName;
  55991. private _2DSamplerName;
  55992. private _positionUVWName;
  55993. private _directionWName;
  55994. private _reflectionCoordsName;
  55995. private _reflection2DCoordsName;
  55996. private _reflectionColorName;
  55997. private _reflectionMatrixName;
  55998. /**
  55999. * Gets or sets the texture associated with the node
  56000. */
  56001. texture: Nullable<BaseTexture>;
  56002. /**
  56003. * Create a new TextureBlock
  56004. * @param name defines the block name
  56005. */
  56006. constructor(name: string);
  56007. /**
  56008. * Gets the current class name
  56009. * @returns the class name
  56010. */
  56011. getClassName(): string;
  56012. /**
  56013. * Gets the world position input component
  56014. */
  56015. readonly position: NodeMaterialConnectionPoint;
  56016. /**
  56017. * Gets the world position input component
  56018. */
  56019. readonly worldPosition: NodeMaterialConnectionPoint;
  56020. /**
  56021. * Gets the world normal input component
  56022. */
  56023. readonly worldNormal: NodeMaterialConnectionPoint;
  56024. /**
  56025. * Gets the world input component
  56026. */
  56027. readonly world: NodeMaterialConnectionPoint;
  56028. /**
  56029. * Gets the camera (or eye) position component
  56030. */
  56031. readonly cameraPosition: NodeMaterialConnectionPoint;
  56032. /**
  56033. * Gets the view input component
  56034. */
  56035. readonly view: NodeMaterialConnectionPoint;
  56036. /**
  56037. * Gets the rgb output component
  56038. */
  56039. readonly rgb: NodeMaterialConnectionPoint;
  56040. /**
  56041. * Gets the r output component
  56042. */
  56043. readonly r: NodeMaterialConnectionPoint;
  56044. /**
  56045. * Gets the g output component
  56046. */
  56047. readonly g: NodeMaterialConnectionPoint;
  56048. /**
  56049. * Gets the b output component
  56050. */
  56051. readonly b: NodeMaterialConnectionPoint;
  56052. autoConfigure(material: NodeMaterial): void;
  56053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56054. isReady(): boolean;
  56055. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56056. private _injectVertexCode;
  56057. private _writeOutput;
  56058. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56059. protected _dumpPropertiesCode(): string;
  56060. serialize(): any;
  56061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56062. }
  56063. }
  56064. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56066. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56067. import { Scene } from "babylonjs/scene";
  56068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56069. import { Matrix } from "babylonjs/Maths/math.vector";
  56070. import { Mesh } from "babylonjs/Meshes/mesh";
  56071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56072. import { Observable } from "babylonjs/Misc/observable";
  56073. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56074. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56075. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56076. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56077. import { Nullable } from "babylonjs/types";
  56078. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56079. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56080. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56081. /**
  56082. * Interface used to configure the node material editor
  56083. */
  56084. export interface INodeMaterialEditorOptions {
  56085. /** Define the URl to load node editor script */
  56086. editorURL?: string;
  56087. }
  56088. /** @hidden */
  56089. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56090. /** BONES */
  56091. NUM_BONE_INFLUENCERS: number;
  56092. BonesPerMesh: number;
  56093. BONETEXTURE: boolean;
  56094. /** MORPH TARGETS */
  56095. MORPHTARGETS: boolean;
  56096. MORPHTARGETS_NORMAL: boolean;
  56097. MORPHTARGETS_TANGENT: boolean;
  56098. MORPHTARGETS_UV: boolean;
  56099. NUM_MORPH_INFLUENCERS: number;
  56100. /** IMAGE PROCESSING */
  56101. IMAGEPROCESSING: boolean;
  56102. VIGNETTE: boolean;
  56103. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56104. VIGNETTEBLENDMODEOPAQUE: boolean;
  56105. TONEMAPPING: boolean;
  56106. TONEMAPPING_ACES: boolean;
  56107. CONTRAST: boolean;
  56108. EXPOSURE: boolean;
  56109. COLORCURVES: boolean;
  56110. COLORGRADING: boolean;
  56111. COLORGRADING3D: boolean;
  56112. SAMPLER3DGREENDEPTH: boolean;
  56113. SAMPLER3DBGRMAP: boolean;
  56114. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56115. /** MISC. */
  56116. BUMPDIRECTUV: number;
  56117. constructor();
  56118. setValue(name: string, value: boolean): void;
  56119. }
  56120. /**
  56121. * Class used to configure NodeMaterial
  56122. */
  56123. export interface INodeMaterialOptions {
  56124. /**
  56125. * Defines if blocks should emit comments
  56126. */
  56127. emitComments: boolean;
  56128. }
  56129. /**
  56130. * Class used to create a node based material built by assembling shader blocks
  56131. */
  56132. export class NodeMaterial extends PushMaterial {
  56133. private static _BuildIdGenerator;
  56134. private _options;
  56135. private _vertexCompilationState;
  56136. private _fragmentCompilationState;
  56137. private _sharedData;
  56138. private _buildId;
  56139. private _buildWasSuccessful;
  56140. private _cachedWorldViewMatrix;
  56141. private _cachedWorldViewProjectionMatrix;
  56142. private _optimizers;
  56143. private _animationFrame;
  56144. /** Define the URl to load node editor script */
  56145. static EditorURL: string;
  56146. private BJSNODEMATERIALEDITOR;
  56147. /** Get the inspector from bundle or global */
  56148. private _getGlobalNodeMaterialEditor;
  56149. /**
  56150. * 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)
  56151. */
  56152. ignoreAlpha: boolean;
  56153. /**
  56154. * Defines the maximum number of lights that can be used in the material
  56155. */
  56156. maxSimultaneousLights: number;
  56157. /**
  56158. * Observable raised when the material is built
  56159. */
  56160. onBuildObservable: Observable<NodeMaterial>;
  56161. /**
  56162. * Gets or sets the root nodes of the material vertex shader
  56163. */
  56164. _vertexOutputNodes: NodeMaterialBlock[];
  56165. /**
  56166. * Gets or sets the root nodes of the material fragment (pixel) shader
  56167. */
  56168. _fragmentOutputNodes: NodeMaterialBlock[];
  56169. /** Gets or sets options to control the node material overall behavior */
  56170. options: INodeMaterialOptions;
  56171. /**
  56172. * Default configuration related to image processing available in the standard Material.
  56173. */
  56174. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56175. /**
  56176. * Gets the image processing configuration used either in this material.
  56177. */
  56178. /**
  56179. * Sets the Default image processing configuration used either in the this material.
  56180. *
  56181. * If sets to null, the scene one is in use.
  56182. */
  56183. imageProcessingConfiguration: ImageProcessingConfiguration;
  56184. /**
  56185. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56186. */
  56187. attachedBlocks: NodeMaterialBlock[];
  56188. /**
  56189. * Create a new node based material
  56190. * @param name defines the material name
  56191. * @param scene defines the hosting scene
  56192. * @param options defines creation option
  56193. */
  56194. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56195. /**
  56196. * Gets the current class name of the material e.g. "NodeMaterial"
  56197. * @returns the class name
  56198. */
  56199. getClassName(): string;
  56200. /**
  56201. * Keep track of the image processing observer to allow dispose and replace.
  56202. */
  56203. private _imageProcessingObserver;
  56204. /**
  56205. * Attaches a new image processing configuration to the Standard Material.
  56206. * @param configuration
  56207. */
  56208. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56209. /**
  56210. * Get a block by its name
  56211. * @param name defines the name of the block to retrieve
  56212. * @returns the required block or null if not found
  56213. */
  56214. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56215. /**
  56216. * Get a block by its name
  56217. * @param predicate defines the predicate used to find the good candidate
  56218. * @returns the required block or null if not found
  56219. */
  56220. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56221. /**
  56222. * Get an input block by its name
  56223. * @param predicate defines the predicate used to find the good candidate
  56224. * @returns the required input block or null if not found
  56225. */
  56226. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56227. /**
  56228. * Gets the list of input blocks attached to this material
  56229. * @returns an array of InputBlocks
  56230. */
  56231. getInputBlocks(): InputBlock[];
  56232. /**
  56233. * Adds a new optimizer to the list of optimizers
  56234. * @param optimizer defines the optimizers to add
  56235. * @returns the current material
  56236. */
  56237. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56238. /**
  56239. * Remove an optimizer from the list of optimizers
  56240. * @param optimizer defines the optimizers to remove
  56241. * @returns the current material
  56242. */
  56243. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56244. /**
  56245. * Add a new block to the list of output nodes
  56246. * @param node defines the node to add
  56247. * @returns the current material
  56248. */
  56249. addOutputNode(node: NodeMaterialBlock): this;
  56250. /**
  56251. * Remove a block from the list of root nodes
  56252. * @param node defines the node to remove
  56253. * @returns the current material
  56254. */
  56255. removeOutputNode(node: NodeMaterialBlock): this;
  56256. private _addVertexOutputNode;
  56257. private _removeVertexOutputNode;
  56258. private _addFragmentOutputNode;
  56259. private _removeFragmentOutputNode;
  56260. /**
  56261. * Specifies if the material will require alpha blending
  56262. * @returns a boolean specifying if alpha blending is needed
  56263. */
  56264. needAlphaBlending(): boolean;
  56265. /**
  56266. * Specifies if this material should be rendered in alpha test mode
  56267. * @returns a boolean specifying if an alpha test is needed.
  56268. */
  56269. needAlphaTesting(): boolean;
  56270. private _initializeBlock;
  56271. private _resetDualBlocks;
  56272. /**
  56273. * Build the material and generates the inner effect
  56274. * @param verbose defines if the build should log activity
  56275. */
  56276. build(verbose?: boolean): void;
  56277. /**
  56278. * Runs an otpimization phase to try to improve the shader code
  56279. */
  56280. optimize(): void;
  56281. private _prepareDefinesForAttributes;
  56282. /**
  56283. * Get if the submesh is ready to be used and all its information available.
  56284. * Child classes can use it to update shaders
  56285. * @param mesh defines the mesh to check
  56286. * @param subMesh defines which submesh to check
  56287. * @param useInstances specifies that instances should be used
  56288. * @returns a boolean indicating that the submesh is ready or not
  56289. */
  56290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56291. /**
  56292. * Get a string representing the shaders built by the current node graph
  56293. */
  56294. readonly compiledShaders: string;
  56295. /**
  56296. * Binds the world matrix to the material
  56297. * @param world defines the world transformation matrix
  56298. */
  56299. bindOnlyWorldMatrix(world: Matrix): void;
  56300. /**
  56301. * Binds the submesh to this material by preparing the effect and shader to draw
  56302. * @param world defines the world transformation matrix
  56303. * @param mesh defines the mesh containing the submesh
  56304. * @param subMesh defines the submesh to bind the material to
  56305. */
  56306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56307. /**
  56308. * Gets the active textures from the material
  56309. * @returns an array of textures
  56310. */
  56311. getActiveTextures(): BaseTexture[];
  56312. /**
  56313. * Gets the list of texture blocks
  56314. * @returns an array of texture blocks
  56315. */
  56316. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56317. /**
  56318. * Specifies if the material uses a texture
  56319. * @param texture defines the texture to check against the material
  56320. * @returns a boolean specifying if the material uses the texture
  56321. */
  56322. hasTexture(texture: BaseTexture): boolean;
  56323. /**
  56324. * Disposes the material
  56325. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56326. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56327. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56328. */
  56329. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56330. /** Creates the node editor window. */
  56331. private _createNodeEditor;
  56332. /**
  56333. * Launch the node material editor
  56334. * @param config Define the configuration of the editor
  56335. * @return a promise fulfilled when the node editor is visible
  56336. */
  56337. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56338. /**
  56339. * Clear the current material
  56340. */
  56341. clear(): void;
  56342. /**
  56343. * Clear the current material and set it to a default state
  56344. */
  56345. setToDefault(): void;
  56346. /**
  56347. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56348. * @param url defines the url to load from
  56349. * @returns a promise that will fullfil when the material is fully loaded
  56350. */
  56351. loadAsync(url: string): Promise<void>;
  56352. private _gatherBlocks;
  56353. /**
  56354. * Generate a string containing the code declaration required to create an equivalent of this material
  56355. * @returns a string
  56356. */
  56357. generateCode(): string;
  56358. /**
  56359. * Serializes this material in a JSON representation
  56360. * @returns the serialized material object
  56361. */
  56362. serialize(): any;
  56363. private _restoreConnections;
  56364. /**
  56365. * Clear the current graph and load a new one from a serialization object
  56366. * @param source defines the JSON representation of the material
  56367. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56368. */
  56369. loadFromSerialization(source: any, rootUrl?: string): void;
  56370. /**
  56371. * Creates a node material from parsed material data
  56372. * @param source defines the JSON representation of the material
  56373. * @param scene defines the hosting scene
  56374. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56375. * @returns a new node material
  56376. */
  56377. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56378. /**
  56379. * Creates a new node material set to default basic configuration
  56380. * @param name defines the name of the material
  56381. * @param scene defines the hosting scene
  56382. * @returns a new NodeMaterial
  56383. */
  56384. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56385. }
  56386. }
  56387. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56390. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56393. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56394. import { Effect } from "babylonjs/Materials/effect";
  56395. import { Mesh } from "babylonjs/Meshes/mesh";
  56396. import { Nullable } from "babylonjs/types";
  56397. import { Texture } from "babylonjs/Materials/Textures/texture";
  56398. import { Scene } from "babylonjs/scene";
  56399. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56400. /**
  56401. * Block used to read a texture from a sampler
  56402. */
  56403. export class TextureBlock extends NodeMaterialBlock {
  56404. private _defineName;
  56405. private _linearDefineName;
  56406. private _samplerName;
  56407. private _transformedUVName;
  56408. private _textureTransformName;
  56409. private _textureInfoName;
  56410. private _mainUVName;
  56411. private _mainUVDefineName;
  56412. /**
  56413. * Gets or sets the texture associated with the node
  56414. */
  56415. texture: Nullable<Texture>;
  56416. /**
  56417. * Create a new TextureBlock
  56418. * @param name defines the block name
  56419. */
  56420. constructor(name: string);
  56421. /**
  56422. * Gets the current class name
  56423. * @returns the class name
  56424. */
  56425. getClassName(): string;
  56426. /**
  56427. * Gets the uv input component
  56428. */
  56429. readonly uv: NodeMaterialConnectionPoint;
  56430. /**
  56431. * Gets the rgba output component
  56432. */
  56433. readonly rgba: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the rgb output component
  56436. */
  56437. readonly rgb: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the r output component
  56440. */
  56441. readonly r: NodeMaterialConnectionPoint;
  56442. /**
  56443. * Gets the g output component
  56444. */
  56445. readonly g: NodeMaterialConnectionPoint;
  56446. /**
  56447. * Gets the b output component
  56448. */
  56449. readonly b: NodeMaterialConnectionPoint;
  56450. /**
  56451. * Gets the a output component
  56452. */
  56453. readonly a: NodeMaterialConnectionPoint;
  56454. readonly target: NodeMaterialBlockTargets;
  56455. autoConfigure(material: NodeMaterial): void;
  56456. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56457. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56458. isReady(): boolean;
  56459. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56460. private readonly _isMixed;
  56461. private _injectVertexCode;
  56462. private _writeOutput;
  56463. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56464. protected _dumpPropertiesCode(): string;
  56465. serialize(): any;
  56466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56467. }
  56468. }
  56469. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56470. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56472. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56473. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56474. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56475. import { Scene } from "babylonjs/scene";
  56476. /**
  56477. * Class used to store shared data between 2 NodeMaterialBuildState
  56478. */
  56479. export class NodeMaterialBuildStateSharedData {
  56480. /**
  56481. * Gets the list of emitted varyings
  56482. */
  56483. temps: string[];
  56484. /**
  56485. * Gets the list of emitted varyings
  56486. */
  56487. varyings: string[];
  56488. /**
  56489. * Gets the varying declaration string
  56490. */
  56491. varyingDeclaration: string;
  56492. /**
  56493. * Input blocks
  56494. */
  56495. inputBlocks: InputBlock[];
  56496. /**
  56497. * Input blocks
  56498. */
  56499. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56500. /**
  56501. * Bindable blocks (Blocks that need to set data to the effect)
  56502. */
  56503. bindableBlocks: NodeMaterialBlock[];
  56504. /**
  56505. * List of blocks that can provide a compilation fallback
  56506. */
  56507. blocksWithFallbacks: NodeMaterialBlock[];
  56508. /**
  56509. * List of blocks that can provide a define update
  56510. */
  56511. blocksWithDefines: NodeMaterialBlock[];
  56512. /**
  56513. * List of blocks that can provide a repeatable content
  56514. */
  56515. repeatableContentBlocks: NodeMaterialBlock[];
  56516. /**
  56517. * List of blocks that can provide a dynamic list of uniforms
  56518. */
  56519. dynamicUniformBlocks: NodeMaterialBlock[];
  56520. /**
  56521. * List of blocks that can block the isReady function for the material
  56522. */
  56523. blockingBlocks: NodeMaterialBlock[];
  56524. /**
  56525. * Gets the list of animated inputs
  56526. */
  56527. animatedInputs: InputBlock[];
  56528. /**
  56529. * Build Id used to avoid multiple recompilations
  56530. */
  56531. buildId: number;
  56532. /** List of emitted variables */
  56533. variableNames: {
  56534. [key: string]: number;
  56535. };
  56536. /** List of emitted defines */
  56537. defineNames: {
  56538. [key: string]: number;
  56539. };
  56540. /** Should emit comments? */
  56541. emitComments: boolean;
  56542. /** Emit build activity */
  56543. verbose: boolean;
  56544. /** Gets or sets the hosting scene */
  56545. scene: Scene;
  56546. /**
  56547. * Gets the compilation hints emitted at compilation time
  56548. */
  56549. hints: {
  56550. needWorldViewMatrix: boolean;
  56551. needWorldViewProjectionMatrix: boolean;
  56552. needAlphaBlending: boolean;
  56553. needAlphaTesting: boolean;
  56554. };
  56555. /**
  56556. * List of compilation checks
  56557. */
  56558. checks: {
  56559. emitVertex: boolean;
  56560. emitFragment: boolean;
  56561. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56562. };
  56563. /** Creates a new shared data */
  56564. constructor();
  56565. /**
  56566. * Emits console errors and exceptions if there is a failing check
  56567. */
  56568. emitErrors(): void;
  56569. }
  56570. }
  56571. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56572. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56573. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56574. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56575. /**
  56576. * Class used to store node based material build state
  56577. */
  56578. export class NodeMaterialBuildState {
  56579. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56580. supportUniformBuffers: boolean;
  56581. /**
  56582. * Gets the list of emitted attributes
  56583. */
  56584. attributes: string[];
  56585. /**
  56586. * Gets the list of emitted uniforms
  56587. */
  56588. uniforms: string[];
  56589. /**
  56590. * Gets the list of emitted constants
  56591. */
  56592. constants: string[];
  56593. /**
  56594. * Gets the list of emitted samplers
  56595. */
  56596. samplers: string[];
  56597. /**
  56598. * Gets the list of emitted functions
  56599. */
  56600. functions: {
  56601. [key: string]: string;
  56602. };
  56603. /**
  56604. * Gets the list of emitted extensions
  56605. */
  56606. extensions: {
  56607. [key: string]: string;
  56608. };
  56609. /**
  56610. * Gets the target of the compilation state
  56611. */
  56612. target: NodeMaterialBlockTargets;
  56613. /**
  56614. * Gets the list of emitted counters
  56615. */
  56616. counters: {
  56617. [key: string]: number;
  56618. };
  56619. /**
  56620. * Shared data between multiple NodeMaterialBuildState instances
  56621. */
  56622. sharedData: NodeMaterialBuildStateSharedData;
  56623. /** @hidden */
  56624. _vertexState: NodeMaterialBuildState;
  56625. /** @hidden */
  56626. _attributeDeclaration: string;
  56627. /** @hidden */
  56628. _uniformDeclaration: string;
  56629. /** @hidden */
  56630. _constantDeclaration: string;
  56631. /** @hidden */
  56632. _samplerDeclaration: string;
  56633. /** @hidden */
  56634. _varyingTransfer: string;
  56635. private _repeatableContentAnchorIndex;
  56636. /** @hidden */
  56637. _builtCompilationString: string;
  56638. /**
  56639. * Gets the emitted compilation strings
  56640. */
  56641. compilationString: string;
  56642. /**
  56643. * Finalize the compilation strings
  56644. * @param state defines the current compilation state
  56645. */
  56646. finalize(state: NodeMaterialBuildState): void;
  56647. /** @hidden */
  56648. readonly _repeatableContentAnchor: string;
  56649. /** @hidden */
  56650. _getFreeVariableName(prefix: string): string;
  56651. /** @hidden */
  56652. _getFreeDefineName(prefix: string): string;
  56653. /** @hidden */
  56654. _excludeVariableName(name: string): void;
  56655. /** @hidden */
  56656. _emit2DSampler(name: string): void;
  56657. /** @hidden */
  56658. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56659. /** @hidden */
  56660. _emitExtension(name: string, extension: string): void;
  56661. /** @hidden */
  56662. _emitFunction(name: string, code: string, comments: string): void;
  56663. /** @hidden */
  56664. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56665. replaceStrings?: {
  56666. search: RegExp;
  56667. replace: string;
  56668. }[];
  56669. repeatKey?: string;
  56670. }): string;
  56671. /** @hidden */
  56672. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56673. repeatKey?: string;
  56674. removeAttributes?: boolean;
  56675. removeUniforms?: boolean;
  56676. removeVaryings?: boolean;
  56677. removeIfDef?: boolean;
  56678. replaceStrings?: {
  56679. search: RegExp;
  56680. replace: string;
  56681. }[];
  56682. }, storeKey?: string): void;
  56683. /** @hidden */
  56684. _registerTempVariable(name: string): boolean;
  56685. /** @hidden */
  56686. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56687. /** @hidden */
  56688. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56689. /** @hidden */
  56690. _emitFloat(value: number): string;
  56691. }
  56692. }
  56693. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56694. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56696. import { Nullable } from "babylonjs/types";
  56697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56698. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56699. import { Effect } from "babylonjs/Materials/effect";
  56700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56701. import { Mesh } from "babylonjs/Meshes/mesh";
  56702. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56703. import { Scene } from "babylonjs/scene";
  56704. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56705. /**
  56706. * Defines a block that can be used inside a node based material
  56707. */
  56708. export class NodeMaterialBlock {
  56709. private _buildId;
  56710. private _buildTarget;
  56711. private _target;
  56712. private _isFinalMerger;
  56713. private _isInput;
  56714. protected _isUnique: boolean;
  56715. /** @hidden */
  56716. _codeVariableName: string;
  56717. /** @hidden */
  56718. _inputs: NodeMaterialConnectionPoint[];
  56719. /** @hidden */
  56720. _outputs: NodeMaterialConnectionPoint[];
  56721. /** @hidden */
  56722. _preparationId: number;
  56723. /**
  56724. * Gets or sets the name of the block
  56725. */
  56726. name: string;
  56727. /**
  56728. * Gets or sets the unique id of the node
  56729. */
  56730. uniqueId: number;
  56731. /**
  56732. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56733. */
  56734. readonly isUnique: boolean;
  56735. /**
  56736. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56737. */
  56738. readonly isFinalMerger: boolean;
  56739. /**
  56740. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56741. */
  56742. readonly isInput: boolean;
  56743. /**
  56744. * Gets or sets the build Id
  56745. */
  56746. buildId: number;
  56747. /**
  56748. * Gets or sets the target of the block
  56749. */
  56750. target: NodeMaterialBlockTargets;
  56751. /**
  56752. * Gets the list of input points
  56753. */
  56754. readonly inputs: NodeMaterialConnectionPoint[];
  56755. /** Gets the list of output points */
  56756. readonly outputs: NodeMaterialConnectionPoint[];
  56757. /**
  56758. * Find an input by its name
  56759. * @param name defines the name of the input to look for
  56760. * @returns the input or null if not found
  56761. */
  56762. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56763. /**
  56764. * Find an output by its name
  56765. * @param name defines the name of the outputto look for
  56766. * @returns the output or null if not found
  56767. */
  56768. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56769. /**
  56770. * Creates a new NodeMaterialBlock
  56771. * @param name defines the block name
  56772. * @param target defines the target of that block (Vertex by default)
  56773. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56774. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56775. */
  56776. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56777. /**
  56778. * Initialize the block and prepare the context for build
  56779. * @param state defines the state that will be used for the build
  56780. */
  56781. initialize(state: NodeMaterialBuildState): void;
  56782. /**
  56783. * Bind data to effect. Will only be called for blocks with isBindable === true
  56784. * @param effect defines the effect to bind data to
  56785. * @param nodeMaterial defines the hosting NodeMaterial
  56786. * @param mesh defines the mesh that will be rendered
  56787. */
  56788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56789. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56790. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56791. protected _writeFloat(value: number): string;
  56792. /**
  56793. * Gets the current class name e.g. "NodeMaterialBlock"
  56794. * @returns the class name
  56795. */
  56796. getClassName(): string;
  56797. /**
  56798. * Register a new input. Must be called inside a block constructor
  56799. * @param name defines the connection point name
  56800. * @param type defines the connection point type
  56801. * @param isOptional defines a boolean indicating that this input can be omitted
  56802. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56803. * @returns the current block
  56804. */
  56805. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56806. /**
  56807. * Register a new output. Must be called inside a block constructor
  56808. * @param name defines the connection point name
  56809. * @param type defines the connection point type
  56810. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56811. * @returns the current block
  56812. */
  56813. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56814. /**
  56815. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56816. * @param forOutput defines an optional connection point to check compatibility with
  56817. * @returns the first available input or null
  56818. */
  56819. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56820. /**
  56821. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56822. * @param forBlock defines an optional block to check compatibility with
  56823. * @returns the first available input or null
  56824. */
  56825. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56826. /**
  56827. * Gets the sibling of the given output
  56828. * @param current defines the current output
  56829. * @returns the next output in the list or null
  56830. */
  56831. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56832. /**
  56833. * Connect current block with another block
  56834. * @param other defines the block to connect with
  56835. * @param options define the various options to help pick the right connections
  56836. * @returns the current block
  56837. */
  56838. connectTo(other: NodeMaterialBlock, options?: {
  56839. input?: string;
  56840. output?: string;
  56841. outputSwizzle?: string;
  56842. }): this | undefined;
  56843. protected _buildBlock(state: NodeMaterialBuildState): void;
  56844. /**
  56845. * Add uniforms, samplers and uniform buffers at compilation time
  56846. * @param state defines the state to update
  56847. * @param nodeMaterial defines the node material requesting the update
  56848. * @param defines defines the material defines to update
  56849. * @param uniformBuffers defines the list of uniform buffer names
  56850. */
  56851. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56852. /**
  56853. * Add potential fallbacks if shader compilation fails
  56854. * @param mesh defines the mesh to be rendered
  56855. * @param fallbacks defines the current prioritized list of fallbacks
  56856. */
  56857. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56858. /**
  56859. * Initialize defines for shader compilation
  56860. * @param mesh defines the mesh to be rendered
  56861. * @param nodeMaterial defines the node material requesting the update
  56862. * @param defines defines the material defines to update
  56863. * @param useInstances specifies that instances should be used
  56864. */
  56865. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56866. /**
  56867. * Update defines for shader compilation
  56868. * @param mesh defines the mesh to be rendered
  56869. * @param nodeMaterial defines the node material requesting the update
  56870. * @param defines defines the material defines to update
  56871. * @param useInstances specifies that instances should be used
  56872. */
  56873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56874. /**
  56875. * Lets the block try to connect some inputs automatically
  56876. * @param material defines the hosting NodeMaterial
  56877. */
  56878. autoConfigure(material: NodeMaterial): void;
  56879. /**
  56880. * Function called when a block is declared as repeatable content generator
  56881. * @param vertexShaderState defines the current compilation state for the vertex shader
  56882. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56883. * @param mesh defines the mesh to be rendered
  56884. * @param defines defines the material defines to update
  56885. */
  56886. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56887. /**
  56888. * Checks if the block is ready
  56889. * @param mesh defines the mesh to be rendered
  56890. * @param nodeMaterial defines the node material requesting the update
  56891. * @param defines defines the material defines to update
  56892. * @param useInstances specifies that instances should be used
  56893. * @returns true if the block is ready
  56894. */
  56895. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56896. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56897. private _processBuild;
  56898. /**
  56899. * Compile the current node and generate the shader code
  56900. * @param state defines the current compilation state (uniforms, samplers, current string)
  56901. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56902. * @returns true if already built
  56903. */
  56904. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56905. protected _inputRename(name: string): string;
  56906. protected _outputRename(name: string): string;
  56907. protected _dumpPropertiesCode(): string;
  56908. /** @hidden */
  56909. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56910. /** @hidden */
  56911. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56912. /**
  56913. * Clone the current block to a new identical block
  56914. * @param scene defines the hosting scene
  56915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56916. * @returns a copy of the current block
  56917. */
  56918. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56919. /**
  56920. * Serializes this block in a JSON representation
  56921. * @returns the serialized block object
  56922. */
  56923. serialize(): any;
  56924. /** @hidden */
  56925. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56926. /**
  56927. * Release resources
  56928. */
  56929. dispose(): void;
  56930. }
  56931. }
  56932. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56933. /**
  56934. * Enum defining the type of animations supported by InputBlock
  56935. */
  56936. export enum AnimatedInputBlockTypes {
  56937. /** No animation */
  56938. None = 0,
  56939. /** Time based animation. Will only work for floats */
  56940. Time = 1
  56941. }
  56942. }
  56943. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56945. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56946. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56947. import { Nullable } from "babylonjs/types";
  56948. import { Effect } from "babylonjs/Materials/effect";
  56949. import { Matrix } from "babylonjs/Maths/math.vector";
  56950. import { Scene } from "babylonjs/scene";
  56951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56953. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56954. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56955. /**
  56956. * Block used to expose an input value
  56957. */
  56958. export class InputBlock extends NodeMaterialBlock {
  56959. private _mode;
  56960. private _associatedVariableName;
  56961. private _storedValue;
  56962. private _valueCallback;
  56963. private _type;
  56964. private _animationType;
  56965. /** Gets or set a value used to limit the range of float values */
  56966. min: number;
  56967. /** Gets or set a value used to limit the range of float values */
  56968. max: number;
  56969. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56970. matrixMode: number;
  56971. /** @hidden */
  56972. _systemValue: Nullable<NodeMaterialSystemValues>;
  56973. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56974. visibleInInspector: boolean;
  56975. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56976. isConstant: boolean;
  56977. /**
  56978. * Gets or sets the connection point type (default is float)
  56979. */
  56980. readonly type: NodeMaterialBlockConnectionPointTypes;
  56981. /**
  56982. * Creates a new InputBlock
  56983. * @param name defines the block name
  56984. * @param target defines the target of that block (Vertex by default)
  56985. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56986. */
  56987. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56988. /**
  56989. * Gets the output component
  56990. */
  56991. readonly output: NodeMaterialConnectionPoint;
  56992. /**
  56993. * Set the source of this connection point to a vertex attribute
  56994. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56995. * @returns the current connection point
  56996. */
  56997. setAsAttribute(attributeName?: string): InputBlock;
  56998. /**
  56999. * Set the source of this connection point to a system value
  57000. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57001. * @returns the current connection point
  57002. */
  57003. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57004. /**
  57005. * Gets or sets the value of that point.
  57006. * Please note that this value will be ignored if valueCallback is defined
  57007. */
  57008. value: any;
  57009. /**
  57010. * Gets or sets a callback used to get the value of that point.
  57011. * Please note that setting this value will force the connection point to ignore the value property
  57012. */
  57013. valueCallback: () => any;
  57014. /**
  57015. * Gets or sets the associated variable name in the shader
  57016. */
  57017. associatedVariableName: string;
  57018. /** Gets or sets the type of animation applied to the input */
  57019. animationType: AnimatedInputBlockTypes;
  57020. /**
  57021. * Gets a boolean indicating that this connection point not defined yet
  57022. */
  57023. readonly isUndefined: boolean;
  57024. /**
  57025. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57026. * In this case the connection point name must be the name of the uniform to use.
  57027. * Can only be set on inputs
  57028. */
  57029. isUniform: boolean;
  57030. /**
  57031. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57032. * In this case the connection point name must be the name of the attribute to use
  57033. * Can only be set on inputs
  57034. */
  57035. isAttribute: boolean;
  57036. /**
  57037. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57038. * Can only be set on exit points
  57039. */
  57040. isVarying: boolean;
  57041. /**
  57042. * Gets a boolean indicating that the current connection point is a system value
  57043. */
  57044. readonly isSystemValue: boolean;
  57045. /**
  57046. * Gets or sets the current well known value or null if not defined as a system value
  57047. */
  57048. systemValue: Nullable<NodeMaterialSystemValues>;
  57049. /**
  57050. * Gets the current class name
  57051. * @returns the class name
  57052. */
  57053. getClassName(): string;
  57054. /**
  57055. * Animate the input if animationType !== None
  57056. * @param scene defines the rendering scene
  57057. */
  57058. animate(scene: Scene): void;
  57059. private _emitDefine;
  57060. initialize(state: NodeMaterialBuildState): void;
  57061. /**
  57062. * Set the input block to its default value (based on its type)
  57063. */
  57064. setDefaultValue(): void;
  57065. private _emitConstant;
  57066. private _emit;
  57067. /** @hidden */
  57068. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57069. /** @hidden */
  57070. _transmit(effect: Effect, scene: Scene): void;
  57071. protected _buildBlock(state: NodeMaterialBuildState): void;
  57072. protected _dumpPropertiesCode(): string;
  57073. serialize(): any;
  57074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57075. }
  57076. }
  57077. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57078. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57079. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57080. import { Nullable } from "babylonjs/types";
  57081. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57082. import { Observable } from "babylonjs/Misc/observable";
  57083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57084. /**
  57085. * Enum used to define the compatibility state between two connection points
  57086. */
  57087. export enum NodeMaterialConnectionPointCompatibilityStates {
  57088. /** Points are compatibles */
  57089. Compatible = 0,
  57090. /** Points are incompatible because of their types */
  57091. TypeIncompatible = 1,
  57092. /** Points are incompatible because of their targets (vertex vs fragment) */
  57093. TargetIncompatible = 2
  57094. }
  57095. /**
  57096. * Defines a connection point for a block
  57097. */
  57098. export class NodeMaterialConnectionPoint {
  57099. /** @hidden */
  57100. _ownerBlock: NodeMaterialBlock;
  57101. /** @hidden */
  57102. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57103. private _endpoints;
  57104. private _associatedVariableName;
  57105. /** @hidden */
  57106. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57107. /** @hidden */
  57108. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57109. private _type;
  57110. /** @hidden */
  57111. _enforceAssociatedVariableName: boolean;
  57112. /**
  57113. * Gets or sets the additional types supported by this connection point
  57114. */
  57115. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57116. /**
  57117. * Gets or sets the additional types excluded by this connection point
  57118. */
  57119. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57120. /**
  57121. * Observable triggered when this point is connected
  57122. */
  57123. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57124. /**
  57125. * Gets or sets the associated variable name in the shader
  57126. */
  57127. associatedVariableName: string;
  57128. /**
  57129. * Gets or sets the connection point type (default is float)
  57130. */
  57131. type: NodeMaterialBlockConnectionPointTypes;
  57132. /**
  57133. * Gets or sets the connection point name
  57134. */
  57135. name: string;
  57136. /**
  57137. * Gets or sets a boolean indicating that this connection point can be omitted
  57138. */
  57139. isOptional: boolean;
  57140. /**
  57141. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57142. */
  57143. define: string;
  57144. /** @hidden */
  57145. _prioritizeVertex: boolean;
  57146. private _target;
  57147. /** Gets or sets the target of that connection point */
  57148. target: NodeMaterialBlockTargets;
  57149. /**
  57150. * Gets a boolean indicating that the current point is connected
  57151. */
  57152. readonly isConnected: boolean;
  57153. /**
  57154. * Gets a boolean indicating that the current point is connected to an input block
  57155. */
  57156. readonly isConnectedToInputBlock: boolean;
  57157. /**
  57158. * Gets a the connected input block (if any)
  57159. */
  57160. readonly connectInputBlock: Nullable<InputBlock>;
  57161. /** Get the other side of the connection (if any) */
  57162. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57163. /** Get the block that owns this connection point */
  57164. readonly ownerBlock: NodeMaterialBlock;
  57165. /** Get the block connected on the other side of this connection (if any) */
  57166. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57167. /** Get the block connected on the endpoints of this connection (if any) */
  57168. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57169. /** Gets the list of connected endpoints */
  57170. readonly endpoints: NodeMaterialConnectionPoint[];
  57171. /** Gets a boolean indicating if that output point is connected to at least one input */
  57172. readonly hasEndpoints: boolean;
  57173. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57174. readonly isConnectedInVertexShader: boolean;
  57175. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57176. readonly isConnectedInFragmentShader: boolean;
  57177. /**
  57178. * Creates a new connection point
  57179. * @param name defines the connection point name
  57180. * @param ownerBlock defines the block hosting this connection point
  57181. */
  57182. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57183. /**
  57184. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57185. * @returns the class name
  57186. */
  57187. getClassName(): string;
  57188. /**
  57189. * Gets a boolean indicating if the current point can be connected to another point
  57190. * @param connectionPoint defines the other connection point
  57191. * @returns a boolean
  57192. */
  57193. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57194. /**
  57195. * Gets a number indicating if the current point can be connected to another point
  57196. * @param connectionPoint defines the other connection point
  57197. * @returns a number defining the compatibility state
  57198. */
  57199. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57200. /**
  57201. * Connect this point to another connection point
  57202. * @param connectionPoint defines the other connection point
  57203. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57204. * @returns the current connection point
  57205. */
  57206. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57207. /**
  57208. * Disconnect this point from one of his endpoint
  57209. * @param endpoint defines the other connection point
  57210. * @returns the current connection point
  57211. */
  57212. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57213. /**
  57214. * Serializes this point in a JSON representation
  57215. * @returns the serialized point object
  57216. */
  57217. serialize(): any;
  57218. /**
  57219. * Release resources
  57220. */
  57221. dispose(): void;
  57222. }
  57223. }
  57224. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57228. import { Mesh } from "babylonjs/Meshes/mesh";
  57229. import { Effect } from "babylonjs/Materials/effect";
  57230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57231. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57232. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57233. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57234. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57235. /**
  57236. * Block used to add support for vertex skinning (bones)
  57237. */
  57238. export class BonesBlock extends NodeMaterialBlock {
  57239. /**
  57240. * Creates a new BonesBlock
  57241. * @param name defines the block name
  57242. */
  57243. constructor(name: string);
  57244. /**
  57245. * Initialize the block and prepare the context for build
  57246. * @param state defines the state that will be used for the build
  57247. */
  57248. initialize(state: NodeMaterialBuildState): void;
  57249. /**
  57250. * Gets the current class name
  57251. * @returns the class name
  57252. */
  57253. getClassName(): string;
  57254. /**
  57255. * Gets the matrix indices input component
  57256. */
  57257. readonly matricesIndices: NodeMaterialConnectionPoint;
  57258. /**
  57259. * Gets the matrix weights input component
  57260. */
  57261. readonly matricesWeights: NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the extra matrix indices input component
  57264. */
  57265. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57266. /**
  57267. * Gets the extra matrix weights input component
  57268. */
  57269. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57270. /**
  57271. * Gets the world input component
  57272. */
  57273. readonly world: NodeMaterialConnectionPoint;
  57274. /**
  57275. * Gets the output component
  57276. */
  57277. readonly output: NodeMaterialConnectionPoint;
  57278. autoConfigure(material: NodeMaterial): void;
  57279. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57282. protected _buildBlock(state: NodeMaterialBuildState): this;
  57283. }
  57284. }
  57285. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57290. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57291. /**
  57292. * Block used to add support for instances
  57293. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57294. */
  57295. export class InstancesBlock extends NodeMaterialBlock {
  57296. /**
  57297. * Creates a new InstancesBlock
  57298. * @param name defines the block name
  57299. */
  57300. constructor(name: string);
  57301. /**
  57302. * Gets the current class name
  57303. * @returns the class name
  57304. */
  57305. getClassName(): string;
  57306. /**
  57307. * Gets the first world row input component
  57308. */
  57309. readonly world0: NodeMaterialConnectionPoint;
  57310. /**
  57311. * Gets the second world row input component
  57312. */
  57313. readonly world1: NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the third world row input component
  57316. */
  57317. readonly world2: NodeMaterialConnectionPoint;
  57318. /**
  57319. * Gets the forth world row input component
  57320. */
  57321. readonly world3: NodeMaterialConnectionPoint;
  57322. /**
  57323. * Gets the world input component
  57324. */
  57325. readonly world: NodeMaterialConnectionPoint;
  57326. /**
  57327. * Gets the output component
  57328. */
  57329. readonly output: NodeMaterialConnectionPoint;
  57330. autoConfigure(material: NodeMaterial): void;
  57331. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57332. protected _buildBlock(state: NodeMaterialBuildState): this;
  57333. }
  57334. }
  57335. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57336. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57337. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57338. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57340. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57341. import { Effect } from "babylonjs/Materials/effect";
  57342. import { Mesh } from "babylonjs/Meshes/mesh";
  57343. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57344. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57345. /**
  57346. * Block used to add morph targets support to vertex shader
  57347. */
  57348. export class MorphTargetsBlock extends NodeMaterialBlock {
  57349. private _repeatableContentAnchor;
  57350. private _repeatebleContentGenerated;
  57351. /**
  57352. * Create a new MorphTargetsBlock
  57353. * @param name defines the block name
  57354. */
  57355. constructor(name: string);
  57356. /**
  57357. * Gets the current class name
  57358. * @returns the class name
  57359. */
  57360. getClassName(): string;
  57361. /**
  57362. * Gets the position input component
  57363. */
  57364. readonly position: NodeMaterialConnectionPoint;
  57365. /**
  57366. * Gets the normal input component
  57367. */
  57368. readonly normal: NodeMaterialConnectionPoint;
  57369. /**
  57370. * Gets the tangent input component
  57371. */
  57372. readonly tangent: NodeMaterialConnectionPoint;
  57373. /**
  57374. * Gets the tangent input component
  57375. */
  57376. readonly uv: NodeMaterialConnectionPoint;
  57377. /**
  57378. * Gets the position output component
  57379. */
  57380. readonly positionOutput: NodeMaterialConnectionPoint;
  57381. /**
  57382. * Gets the normal output component
  57383. */
  57384. readonly normalOutput: NodeMaterialConnectionPoint;
  57385. /**
  57386. * Gets the tangent output component
  57387. */
  57388. readonly tangentOutput: NodeMaterialConnectionPoint;
  57389. /**
  57390. * Gets the tangent output component
  57391. */
  57392. readonly uvOutput: NodeMaterialConnectionPoint;
  57393. initialize(state: NodeMaterialBuildState): void;
  57394. autoConfigure(material: NodeMaterial): void;
  57395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57397. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57398. protected _buildBlock(state: NodeMaterialBuildState): this;
  57399. }
  57400. }
  57401. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57405. import { Nullable } from "babylonjs/types";
  57406. import { Scene } from "babylonjs/scene";
  57407. import { Effect } from "babylonjs/Materials/effect";
  57408. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57409. import { Mesh } from "babylonjs/Meshes/mesh";
  57410. import { Light } from "babylonjs/Lights/light";
  57411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57412. /**
  57413. * Block used to get data information from a light
  57414. */
  57415. export class LightInformationBlock extends NodeMaterialBlock {
  57416. private _lightDataUniformName;
  57417. private _lightColorUniformName;
  57418. private _lightTypeDefineName;
  57419. /**
  57420. * Gets or sets the light associated with this block
  57421. */
  57422. light: Nullable<Light>;
  57423. /**
  57424. * Creates a new LightInformationBlock
  57425. * @param name defines the block name
  57426. */
  57427. constructor(name: string);
  57428. /**
  57429. * Gets the current class name
  57430. * @returns the class name
  57431. */
  57432. getClassName(): string;
  57433. /**
  57434. * Gets the world position input component
  57435. */
  57436. readonly worldPosition: NodeMaterialConnectionPoint;
  57437. /**
  57438. * Gets the direction output component
  57439. */
  57440. readonly direction: NodeMaterialConnectionPoint;
  57441. /**
  57442. * Gets the direction output component
  57443. */
  57444. readonly color: NodeMaterialConnectionPoint;
  57445. /**
  57446. * Gets the direction output component
  57447. */
  57448. readonly intensity: NodeMaterialConnectionPoint;
  57449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57450. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57451. protected _buildBlock(state: NodeMaterialBuildState): this;
  57452. serialize(): any;
  57453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57454. }
  57455. }
  57456. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57457. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57458. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57459. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57460. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57461. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57462. }
  57463. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57468. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57469. import { Effect } from "babylonjs/Materials/effect";
  57470. import { Mesh } from "babylonjs/Meshes/mesh";
  57471. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57472. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57473. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57474. /**
  57475. * Block used to add image processing support to fragment shader
  57476. */
  57477. export class ImageProcessingBlock extends NodeMaterialBlock {
  57478. /**
  57479. * Create a new ImageProcessingBlock
  57480. * @param name defines the block name
  57481. */
  57482. constructor(name: string);
  57483. /**
  57484. * Gets the current class name
  57485. * @returns the class name
  57486. */
  57487. getClassName(): string;
  57488. /**
  57489. * Gets the color input component
  57490. */
  57491. readonly color: NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the output component
  57494. */
  57495. readonly output: NodeMaterialConnectionPoint;
  57496. /**
  57497. * Initialize the block and prepare the context for build
  57498. * @param state defines the state that will be used for the build
  57499. */
  57500. initialize(state: NodeMaterialBuildState): void;
  57501. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57504. protected _buildBlock(state: NodeMaterialBuildState): this;
  57505. }
  57506. }
  57507. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57511. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57513. import { Effect } from "babylonjs/Materials/effect";
  57514. import { Mesh } from "babylonjs/Meshes/mesh";
  57515. import { Scene } from "babylonjs/scene";
  57516. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57517. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57518. /**
  57519. * Block used to pertub normals based on a normal map
  57520. */
  57521. export class PerturbNormalBlock extends NodeMaterialBlock {
  57522. private _tangentSpaceParameterName;
  57523. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57524. invertX: boolean;
  57525. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57526. invertY: boolean;
  57527. /**
  57528. * Create a new PerturbNormalBlock
  57529. * @param name defines the block name
  57530. */
  57531. constructor(name: string);
  57532. /**
  57533. * Gets the current class name
  57534. * @returns the class name
  57535. */
  57536. getClassName(): string;
  57537. /**
  57538. * Gets the world position input component
  57539. */
  57540. readonly worldPosition: NodeMaterialConnectionPoint;
  57541. /**
  57542. * Gets the world normal input component
  57543. */
  57544. readonly worldNormal: NodeMaterialConnectionPoint;
  57545. /**
  57546. * Gets the uv input component
  57547. */
  57548. readonly uv: NodeMaterialConnectionPoint;
  57549. /**
  57550. * Gets the normal map color input component
  57551. */
  57552. readonly normalMapColor: NodeMaterialConnectionPoint;
  57553. /**
  57554. * Gets the strength input component
  57555. */
  57556. readonly strength: NodeMaterialConnectionPoint;
  57557. /**
  57558. * Gets the output component
  57559. */
  57560. readonly output: NodeMaterialConnectionPoint;
  57561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57563. autoConfigure(material: NodeMaterial): void;
  57564. protected _buildBlock(state: NodeMaterialBuildState): this;
  57565. protected _dumpPropertiesCode(): string;
  57566. serialize(): any;
  57567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57568. }
  57569. }
  57570. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57574. /**
  57575. * Block used to discard a pixel if a value is smaller than a cutoff
  57576. */
  57577. export class DiscardBlock extends NodeMaterialBlock {
  57578. /**
  57579. * Create a new DiscardBlock
  57580. * @param name defines the block name
  57581. */
  57582. constructor(name: string);
  57583. /**
  57584. * Gets the current class name
  57585. * @returns the class name
  57586. */
  57587. getClassName(): string;
  57588. /**
  57589. * Gets the color input component
  57590. */
  57591. readonly value: NodeMaterialConnectionPoint;
  57592. /**
  57593. * Gets the cutoff input component
  57594. */
  57595. readonly cutoff: NodeMaterialConnectionPoint;
  57596. protected _buildBlock(state: NodeMaterialBuildState): this;
  57597. }
  57598. }
  57599. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57603. /**
  57604. * Block used to test if the fragment shader is front facing
  57605. */
  57606. export class FrontFacingBlock extends NodeMaterialBlock {
  57607. /**
  57608. * Creates a new FrontFacingBlock
  57609. * @param name defines the block name
  57610. */
  57611. constructor(name: string);
  57612. /**
  57613. * Gets the current class name
  57614. * @returns the class name
  57615. */
  57616. getClassName(): string;
  57617. /**
  57618. * Gets the output component
  57619. */
  57620. readonly output: NodeMaterialConnectionPoint;
  57621. protected _buildBlock(state: NodeMaterialBuildState): this;
  57622. }
  57623. }
  57624. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57625. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57626. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57627. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57628. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57629. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57630. }
  57631. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57632. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57633. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57634. import { Mesh } from "babylonjs/Meshes/mesh";
  57635. import { Effect } from "babylonjs/Materials/effect";
  57636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57638. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57639. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57640. /**
  57641. * Block used to add support for scene fog
  57642. */
  57643. export class FogBlock extends NodeMaterialBlock {
  57644. private _fogDistanceName;
  57645. private _fogParameters;
  57646. /**
  57647. * Create a new FogBlock
  57648. * @param name defines the block name
  57649. */
  57650. constructor(name: string);
  57651. /**
  57652. * Gets the current class name
  57653. * @returns the class name
  57654. */
  57655. getClassName(): string;
  57656. /**
  57657. * Gets the world position input component
  57658. */
  57659. readonly worldPosition: NodeMaterialConnectionPoint;
  57660. /**
  57661. * Gets the view input component
  57662. */
  57663. readonly view: NodeMaterialConnectionPoint;
  57664. /**
  57665. * Gets the color input component
  57666. */
  57667. readonly input: NodeMaterialConnectionPoint;
  57668. /**
  57669. * Gets the fog color input component
  57670. */
  57671. readonly fogColor: NodeMaterialConnectionPoint;
  57672. /**
  57673. * Gets the output component
  57674. */
  57675. readonly output: NodeMaterialConnectionPoint;
  57676. autoConfigure(material: NodeMaterial): void;
  57677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57679. protected _buildBlock(state: NodeMaterialBuildState): this;
  57680. }
  57681. }
  57682. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57685. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57687. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57688. import { Effect } from "babylonjs/Materials/effect";
  57689. import { Mesh } from "babylonjs/Meshes/mesh";
  57690. import { Light } from "babylonjs/Lights/light";
  57691. import { Nullable } from "babylonjs/types";
  57692. import { Scene } from "babylonjs/scene";
  57693. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57694. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57695. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57696. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57697. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57698. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57699. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57700. /**
  57701. * Block used to add light in the fragment shader
  57702. */
  57703. export class LightBlock extends NodeMaterialBlock {
  57704. private _lightId;
  57705. /**
  57706. * Gets or sets the light associated with this block
  57707. */
  57708. light: Nullable<Light>;
  57709. /**
  57710. * Create a new LightBlock
  57711. * @param name defines the block name
  57712. */
  57713. constructor(name: string);
  57714. /**
  57715. * Gets the current class name
  57716. * @returns the class name
  57717. */
  57718. getClassName(): string;
  57719. /**
  57720. * Gets the world position input component
  57721. */
  57722. readonly worldPosition: NodeMaterialConnectionPoint;
  57723. /**
  57724. * Gets the world normal input component
  57725. */
  57726. readonly worldNormal: NodeMaterialConnectionPoint;
  57727. /**
  57728. * Gets the camera (or eye) position component
  57729. */
  57730. readonly cameraPosition: NodeMaterialConnectionPoint;
  57731. /**
  57732. * Gets the glossiness component
  57733. */
  57734. readonly glossiness: NodeMaterialConnectionPoint;
  57735. /**
  57736. * Gets the glossinness power component
  57737. */
  57738. readonly glossPower: NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the diffuse color component
  57741. */
  57742. readonly diffuseColor: NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the specular color component
  57745. */
  57746. readonly specularColor: NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the diffuse output component
  57749. */
  57750. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57751. /**
  57752. * Gets the specular output component
  57753. */
  57754. readonly specularOutput: NodeMaterialConnectionPoint;
  57755. autoConfigure(material: NodeMaterial): void;
  57756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57757. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57759. private _injectVertexCode;
  57760. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57761. serialize(): any;
  57762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57763. }
  57764. }
  57765. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57766. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57767. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57768. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57769. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57770. }
  57771. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57772. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57773. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57774. }
  57775. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57779. /**
  57780. * Block used to multiply 2 values
  57781. */
  57782. export class MultiplyBlock extends NodeMaterialBlock {
  57783. /**
  57784. * Creates a new MultiplyBlock
  57785. * @param name defines the block name
  57786. */
  57787. constructor(name: string);
  57788. /**
  57789. * Gets the current class name
  57790. * @returns the class name
  57791. */
  57792. getClassName(): string;
  57793. /**
  57794. * Gets the left operand input component
  57795. */
  57796. readonly left: NodeMaterialConnectionPoint;
  57797. /**
  57798. * Gets the right operand input component
  57799. */
  57800. readonly right: NodeMaterialConnectionPoint;
  57801. /**
  57802. * Gets the output component
  57803. */
  57804. readonly output: NodeMaterialConnectionPoint;
  57805. protected _buildBlock(state: NodeMaterialBuildState): this;
  57806. }
  57807. }
  57808. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57812. /**
  57813. * Block used to add 2 vectors
  57814. */
  57815. export class AddBlock extends NodeMaterialBlock {
  57816. /**
  57817. * Creates a new AddBlock
  57818. * @param name defines the block name
  57819. */
  57820. constructor(name: string);
  57821. /**
  57822. * Gets the current class name
  57823. * @returns the class name
  57824. */
  57825. getClassName(): string;
  57826. /**
  57827. * Gets the left operand input component
  57828. */
  57829. readonly left: NodeMaterialConnectionPoint;
  57830. /**
  57831. * Gets the right operand input component
  57832. */
  57833. readonly right: NodeMaterialConnectionPoint;
  57834. /**
  57835. * Gets the output component
  57836. */
  57837. readonly output: NodeMaterialConnectionPoint;
  57838. protected _buildBlock(state: NodeMaterialBuildState): this;
  57839. }
  57840. }
  57841. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57845. /**
  57846. * Block used to scale a vector by a float
  57847. */
  57848. export class ScaleBlock extends NodeMaterialBlock {
  57849. /**
  57850. * Creates a new ScaleBlock
  57851. * @param name defines the block name
  57852. */
  57853. constructor(name: string);
  57854. /**
  57855. * Gets the current class name
  57856. * @returns the class name
  57857. */
  57858. getClassName(): string;
  57859. /**
  57860. * Gets the input component
  57861. */
  57862. readonly input: NodeMaterialConnectionPoint;
  57863. /**
  57864. * Gets the factor input component
  57865. */
  57866. readonly factor: NodeMaterialConnectionPoint;
  57867. /**
  57868. * Gets the output component
  57869. */
  57870. readonly output: NodeMaterialConnectionPoint;
  57871. protected _buildBlock(state: NodeMaterialBuildState): this;
  57872. }
  57873. }
  57874. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57878. import { Scene } from "babylonjs/scene";
  57879. /**
  57880. * Block used to clamp a float
  57881. */
  57882. export class ClampBlock extends NodeMaterialBlock {
  57883. /** Gets or sets the minimum range */
  57884. minimum: number;
  57885. /** Gets or sets the maximum range */
  57886. maximum: number;
  57887. /**
  57888. * Creates a new ClampBlock
  57889. * @param name defines the block name
  57890. */
  57891. constructor(name: string);
  57892. /**
  57893. * Gets the current class name
  57894. * @returns the class name
  57895. */
  57896. getClassName(): string;
  57897. /**
  57898. * Gets the value input component
  57899. */
  57900. readonly value: NodeMaterialConnectionPoint;
  57901. /**
  57902. * Gets the output component
  57903. */
  57904. readonly output: NodeMaterialConnectionPoint;
  57905. protected _buildBlock(state: NodeMaterialBuildState): this;
  57906. protected _dumpPropertiesCode(): string;
  57907. serialize(): any;
  57908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57909. }
  57910. }
  57911. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57915. /**
  57916. * Block used to apply a cross product between 2 vectors
  57917. */
  57918. export class CrossBlock extends NodeMaterialBlock {
  57919. /**
  57920. * Creates a new CrossBlock
  57921. * @param name defines the block name
  57922. */
  57923. constructor(name: string);
  57924. /**
  57925. * Gets the current class name
  57926. * @returns the class name
  57927. */
  57928. getClassName(): string;
  57929. /**
  57930. * Gets the left operand input component
  57931. */
  57932. readonly left: NodeMaterialConnectionPoint;
  57933. /**
  57934. * Gets the right operand input component
  57935. */
  57936. readonly right: NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the output component
  57939. */
  57940. readonly output: NodeMaterialConnectionPoint;
  57941. protected _buildBlock(state: NodeMaterialBuildState): this;
  57942. }
  57943. }
  57944. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57948. /**
  57949. * Block used to apply a dot product between 2 vectors
  57950. */
  57951. export class DotBlock extends NodeMaterialBlock {
  57952. /**
  57953. * Creates a new DotBlock
  57954. * @param name defines the block name
  57955. */
  57956. constructor(name: string);
  57957. /**
  57958. * Gets the current class name
  57959. * @returns the class name
  57960. */
  57961. getClassName(): string;
  57962. /**
  57963. * Gets the left operand input component
  57964. */
  57965. readonly left: NodeMaterialConnectionPoint;
  57966. /**
  57967. * Gets the right operand input component
  57968. */
  57969. readonly right: NodeMaterialConnectionPoint;
  57970. /**
  57971. * Gets the output component
  57972. */
  57973. readonly output: NodeMaterialConnectionPoint;
  57974. protected _buildBlock(state: NodeMaterialBuildState): this;
  57975. }
  57976. }
  57977. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57981. import { Vector2 } from "babylonjs/Maths/math.vector";
  57982. import { Scene } from "babylonjs/scene";
  57983. /**
  57984. * Block used to remap a float from a range to a new one
  57985. */
  57986. export class RemapBlock extends NodeMaterialBlock {
  57987. /**
  57988. * Gets or sets the source range
  57989. */
  57990. sourceRange: Vector2;
  57991. /**
  57992. * Gets or sets the target range
  57993. */
  57994. targetRange: Vector2;
  57995. /**
  57996. * Creates a new RemapBlock
  57997. * @param name defines the block name
  57998. */
  57999. constructor(name: string);
  58000. /**
  58001. * Gets the current class name
  58002. * @returns the class name
  58003. */
  58004. getClassName(): string;
  58005. /**
  58006. * Gets the input component
  58007. */
  58008. readonly input: NodeMaterialConnectionPoint;
  58009. /**
  58010. * Gets the source min input component
  58011. */
  58012. readonly sourceMin: NodeMaterialConnectionPoint;
  58013. /**
  58014. * Gets the source max input component
  58015. */
  58016. readonly sourceMax: NodeMaterialConnectionPoint;
  58017. /**
  58018. * Gets the target min input component
  58019. */
  58020. readonly targetMin: NodeMaterialConnectionPoint;
  58021. /**
  58022. * Gets the target max input component
  58023. */
  58024. readonly targetMax: NodeMaterialConnectionPoint;
  58025. /**
  58026. * Gets the output component
  58027. */
  58028. readonly output: NodeMaterialConnectionPoint;
  58029. protected _buildBlock(state: NodeMaterialBuildState): this;
  58030. protected _dumpPropertiesCode(): string;
  58031. serialize(): any;
  58032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58033. }
  58034. }
  58035. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58039. /**
  58040. * Block used to normalize a vector
  58041. */
  58042. export class NormalizeBlock extends NodeMaterialBlock {
  58043. /**
  58044. * Creates a new NormalizeBlock
  58045. * @param name defines the block name
  58046. */
  58047. constructor(name: string);
  58048. /**
  58049. * Gets the current class name
  58050. * @returns the class name
  58051. */
  58052. getClassName(): string;
  58053. /**
  58054. * Gets the input component
  58055. */
  58056. readonly input: NodeMaterialConnectionPoint;
  58057. /**
  58058. * Gets the output component
  58059. */
  58060. readonly output: NodeMaterialConnectionPoint;
  58061. protected _buildBlock(state: NodeMaterialBuildState): this;
  58062. }
  58063. }
  58064. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58068. import { Scene } from "babylonjs/scene";
  58069. /**
  58070. * Operations supported by the Trigonometry block
  58071. */
  58072. export enum TrigonometryBlockOperations {
  58073. /** Cos */
  58074. Cos = 0,
  58075. /** Sin */
  58076. Sin = 1,
  58077. /** Abs */
  58078. Abs = 2,
  58079. /** Exp */
  58080. Exp = 3,
  58081. /** Exp2 */
  58082. Exp2 = 4,
  58083. /** Round */
  58084. Round = 5,
  58085. /** Floor */
  58086. Floor = 6,
  58087. /** Ceiling */
  58088. Ceiling = 7,
  58089. /** Square root */
  58090. Sqrt = 8,
  58091. /** Log */
  58092. Log = 9,
  58093. /** Tangent */
  58094. Tan = 10,
  58095. /** Arc tangent */
  58096. ArcTan = 11,
  58097. /** Arc cosinus */
  58098. ArcCos = 12,
  58099. /** Arc sinus */
  58100. ArcSin = 13,
  58101. /** Fraction */
  58102. Fract = 14,
  58103. /** Sign */
  58104. Sign = 15,
  58105. /** To radians (from degrees) */
  58106. Radians = 16,
  58107. /** To degrees (from radians) */
  58108. Degrees = 17
  58109. }
  58110. /**
  58111. * Block used to apply trigonometry operation to floats
  58112. */
  58113. export class TrigonometryBlock extends NodeMaterialBlock {
  58114. /**
  58115. * Gets or sets the operation applied by the block
  58116. */
  58117. operation: TrigonometryBlockOperations;
  58118. /**
  58119. * Creates a new TrigonometryBlock
  58120. * @param name defines the block name
  58121. */
  58122. constructor(name: string);
  58123. /**
  58124. * Gets the current class name
  58125. * @returns the class name
  58126. */
  58127. getClassName(): string;
  58128. /**
  58129. * Gets the input component
  58130. */
  58131. readonly input: NodeMaterialConnectionPoint;
  58132. /**
  58133. * Gets the output component
  58134. */
  58135. readonly output: NodeMaterialConnectionPoint;
  58136. protected _buildBlock(state: NodeMaterialBuildState): this;
  58137. serialize(): any;
  58138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58139. }
  58140. }
  58141. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58145. /**
  58146. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58147. */
  58148. export class ColorMergerBlock extends NodeMaterialBlock {
  58149. /**
  58150. * Create a new ColorMergerBlock
  58151. * @param name defines the block name
  58152. */
  58153. constructor(name: string);
  58154. /**
  58155. * Gets the current class name
  58156. * @returns the class name
  58157. */
  58158. getClassName(): string;
  58159. /**
  58160. * Gets the r component (input)
  58161. */
  58162. readonly r: NodeMaterialConnectionPoint;
  58163. /**
  58164. * Gets the g component (input)
  58165. */
  58166. readonly g: NodeMaterialConnectionPoint;
  58167. /**
  58168. * Gets the b component (input)
  58169. */
  58170. readonly b: NodeMaterialConnectionPoint;
  58171. /**
  58172. * Gets the a component (input)
  58173. */
  58174. readonly a: NodeMaterialConnectionPoint;
  58175. /**
  58176. * Gets the rgba component (output)
  58177. */
  58178. readonly rgba: NodeMaterialConnectionPoint;
  58179. /**
  58180. * Gets the rgb component (output)
  58181. */
  58182. readonly rgb: NodeMaterialConnectionPoint;
  58183. protected _buildBlock(state: NodeMaterialBuildState): this;
  58184. }
  58185. }
  58186. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58188. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58189. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58190. /**
  58191. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58192. */
  58193. export class VectorMergerBlock extends NodeMaterialBlock {
  58194. /**
  58195. * Create a new VectorMergerBlock
  58196. * @param name defines the block name
  58197. */
  58198. constructor(name: string);
  58199. /**
  58200. * Gets the current class name
  58201. * @returns the class name
  58202. */
  58203. getClassName(): string;
  58204. /**
  58205. * Gets the x component (input)
  58206. */
  58207. readonly x: NodeMaterialConnectionPoint;
  58208. /**
  58209. * Gets the y component (input)
  58210. */
  58211. readonly y: NodeMaterialConnectionPoint;
  58212. /**
  58213. * Gets the z component (input)
  58214. */
  58215. readonly z: NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the w component (input)
  58218. */
  58219. readonly w: NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the xyzw component (output)
  58222. */
  58223. readonly xyzw: NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the xyz component (output)
  58226. */
  58227. readonly xyz: NodeMaterialConnectionPoint;
  58228. /**
  58229. * Gets the xy component (output)
  58230. */
  58231. readonly xy: NodeMaterialConnectionPoint;
  58232. protected _buildBlock(state: NodeMaterialBuildState): this;
  58233. }
  58234. }
  58235. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58239. /**
  58240. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58241. */
  58242. export class ColorSplitterBlock extends NodeMaterialBlock {
  58243. /**
  58244. * Create a new ColorSplitterBlock
  58245. * @param name defines the block name
  58246. */
  58247. constructor(name: string);
  58248. /**
  58249. * Gets the current class name
  58250. * @returns the class name
  58251. */
  58252. getClassName(): string;
  58253. /**
  58254. * Gets the rgba component (input)
  58255. */
  58256. readonly rgba: NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the rgb component (input)
  58259. */
  58260. readonly rgbIn: NodeMaterialConnectionPoint;
  58261. /**
  58262. * Gets the rgb component (output)
  58263. */
  58264. readonly rgbOut: NodeMaterialConnectionPoint;
  58265. /**
  58266. * Gets the r component (output)
  58267. */
  58268. readonly r: NodeMaterialConnectionPoint;
  58269. /**
  58270. * Gets the g component (output)
  58271. */
  58272. readonly g: NodeMaterialConnectionPoint;
  58273. /**
  58274. * Gets the b component (output)
  58275. */
  58276. readonly b: NodeMaterialConnectionPoint;
  58277. /**
  58278. * Gets the a component (output)
  58279. */
  58280. readonly a: NodeMaterialConnectionPoint;
  58281. protected _inputRename(name: string): string;
  58282. protected _outputRename(name: string): string;
  58283. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58284. }
  58285. }
  58286. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58290. /**
  58291. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58292. */
  58293. export class VectorSplitterBlock extends NodeMaterialBlock {
  58294. /**
  58295. * Create a new VectorSplitterBlock
  58296. * @param name defines the block name
  58297. */
  58298. constructor(name: string);
  58299. /**
  58300. * Gets the current class name
  58301. * @returns the class name
  58302. */
  58303. getClassName(): string;
  58304. /**
  58305. * Gets the xyzw component (input)
  58306. */
  58307. readonly xyzw: NodeMaterialConnectionPoint;
  58308. /**
  58309. * Gets the xyz component (input)
  58310. */
  58311. readonly xyzIn: NodeMaterialConnectionPoint;
  58312. /**
  58313. * Gets the xy component (input)
  58314. */
  58315. readonly xyIn: NodeMaterialConnectionPoint;
  58316. /**
  58317. * Gets the xyz component (output)
  58318. */
  58319. readonly xyzOut: NodeMaterialConnectionPoint;
  58320. /**
  58321. * Gets the xy component (output)
  58322. */
  58323. readonly xyOut: NodeMaterialConnectionPoint;
  58324. /**
  58325. * Gets the x component (output)
  58326. */
  58327. readonly x: NodeMaterialConnectionPoint;
  58328. /**
  58329. * Gets the y component (output)
  58330. */
  58331. readonly y: NodeMaterialConnectionPoint;
  58332. /**
  58333. * Gets the z component (output)
  58334. */
  58335. readonly z: NodeMaterialConnectionPoint;
  58336. /**
  58337. * Gets the w component (output)
  58338. */
  58339. readonly w: NodeMaterialConnectionPoint;
  58340. protected _inputRename(name: string): string;
  58341. protected _outputRename(name: string): string;
  58342. protected _buildBlock(state: NodeMaterialBuildState): this;
  58343. }
  58344. }
  58345. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58349. /**
  58350. * Block used to lerp between 2 values
  58351. */
  58352. export class LerpBlock extends NodeMaterialBlock {
  58353. /**
  58354. * Creates a new LerpBlock
  58355. * @param name defines the block name
  58356. */
  58357. constructor(name: string);
  58358. /**
  58359. * Gets the current class name
  58360. * @returns the class name
  58361. */
  58362. getClassName(): string;
  58363. /**
  58364. * Gets the left operand input component
  58365. */
  58366. readonly left: NodeMaterialConnectionPoint;
  58367. /**
  58368. * Gets the right operand input component
  58369. */
  58370. readonly right: NodeMaterialConnectionPoint;
  58371. /**
  58372. * Gets the gradient operand input component
  58373. */
  58374. readonly gradient: NodeMaterialConnectionPoint;
  58375. /**
  58376. * Gets the output component
  58377. */
  58378. readonly output: NodeMaterialConnectionPoint;
  58379. protected _buildBlock(state: NodeMaterialBuildState): this;
  58380. }
  58381. }
  58382. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58386. /**
  58387. * Block used to divide 2 vectors
  58388. */
  58389. export class DivideBlock extends NodeMaterialBlock {
  58390. /**
  58391. * Creates a new DivideBlock
  58392. * @param name defines the block name
  58393. */
  58394. constructor(name: string);
  58395. /**
  58396. * Gets the current class name
  58397. * @returns the class name
  58398. */
  58399. getClassName(): string;
  58400. /**
  58401. * Gets the left operand input component
  58402. */
  58403. readonly left: NodeMaterialConnectionPoint;
  58404. /**
  58405. * Gets the right operand input component
  58406. */
  58407. readonly right: NodeMaterialConnectionPoint;
  58408. /**
  58409. * Gets the output component
  58410. */
  58411. readonly output: NodeMaterialConnectionPoint;
  58412. protected _buildBlock(state: NodeMaterialBuildState): this;
  58413. }
  58414. }
  58415. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58419. /**
  58420. * Block used to subtract 2 vectors
  58421. */
  58422. export class SubtractBlock extends NodeMaterialBlock {
  58423. /**
  58424. * Creates a new SubtractBlock
  58425. * @param name defines the block name
  58426. */
  58427. constructor(name: string);
  58428. /**
  58429. * Gets the current class name
  58430. * @returns the class name
  58431. */
  58432. getClassName(): string;
  58433. /**
  58434. * Gets the left operand input component
  58435. */
  58436. readonly left: NodeMaterialConnectionPoint;
  58437. /**
  58438. * Gets the right operand input component
  58439. */
  58440. readonly right: NodeMaterialConnectionPoint;
  58441. /**
  58442. * Gets the output component
  58443. */
  58444. readonly output: NodeMaterialConnectionPoint;
  58445. protected _buildBlock(state: NodeMaterialBuildState): this;
  58446. }
  58447. }
  58448. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58452. /**
  58453. * Block used to step a value
  58454. */
  58455. export class StepBlock extends NodeMaterialBlock {
  58456. /**
  58457. * Creates a new StepBlock
  58458. * @param name defines the block name
  58459. */
  58460. constructor(name: string);
  58461. /**
  58462. * Gets the current class name
  58463. * @returns the class name
  58464. */
  58465. getClassName(): string;
  58466. /**
  58467. * Gets the value operand input component
  58468. */
  58469. readonly value: NodeMaterialConnectionPoint;
  58470. /**
  58471. * Gets the edge operand input component
  58472. */
  58473. readonly edge: NodeMaterialConnectionPoint;
  58474. /**
  58475. * Gets the output component
  58476. */
  58477. readonly output: NodeMaterialConnectionPoint;
  58478. protected _buildBlock(state: NodeMaterialBuildState): this;
  58479. }
  58480. }
  58481. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58485. /**
  58486. * Block used to get the opposite (1 - x) of a value
  58487. */
  58488. export class OneMinusBlock extends NodeMaterialBlock {
  58489. /**
  58490. * Creates a new OneMinusBlock
  58491. * @param name defines the block name
  58492. */
  58493. constructor(name: string);
  58494. /**
  58495. * Gets the current class name
  58496. * @returns the class name
  58497. */
  58498. getClassName(): string;
  58499. /**
  58500. * Gets the input component
  58501. */
  58502. readonly input: NodeMaterialConnectionPoint;
  58503. /**
  58504. * Gets the output component
  58505. */
  58506. readonly output: NodeMaterialConnectionPoint;
  58507. protected _buildBlock(state: NodeMaterialBuildState): this;
  58508. }
  58509. }
  58510. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58514. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58515. /**
  58516. * Block used to get the view direction
  58517. */
  58518. export class ViewDirectionBlock extends NodeMaterialBlock {
  58519. /**
  58520. * Creates a new ViewDirectionBlock
  58521. * @param name defines the block name
  58522. */
  58523. constructor(name: string);
  58524. /**
  58525. * Gets the current class name
  58526. * @returns the class name
  58527. */
  58528. getClassName(): string;
  58529. /**
  58530. * Gets the world position component
  58531. */
  58532. readonly worldPosition: NodeMaterialConnectionPoint;
  58533. /**
  58534. * Gets the camera position component
  58535. */
  58536. readonly cameraPosition: NodeMaterialConnectionPoint;
  58537. /**
  58538. * Gets the output component
  58539. */
  58540. readonly output: NodeMaterialConnectionPoint;
  58541. autoConfigure(material: NodeMaterial): void;
  58542. protected _buildBlock(state: NodeMaterialBuildState): this;
  58543. }
  58544. }
  58545. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58549. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58550. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58551. /**
  58552. * Block used to compute fresnel value
  58553. */
  58554. export class FresnelBlock extends NodeMaterialBlock {
  58555. /**
  58556. * Create a new FresnelBlock
  58557. * @param name defines the block name
  58558. */
  58559. constructor(name: string);
  58560. /**
  58561. * Gets the current class name
  58562. * @returns the class name
  58563. */
  58564. getClassName(): string;
  58565. /**
  58566. * Gets the world normal input component
  58567. */
  58568. readonly worldNormal: NodeMaterialConnectionPoint;
  58569. /**
  58570. * Gets the view direction input component
  58571. */
  58572. readonly viewDirection: NodeMaterialConnectionPoint;
  58573. /**
  58574. * Gets the bias input component
  58575. */
  58576. readonly bias: NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the camera (or eye) position component
  58579. */
  58580. readonly power: NodeMaterialConnectionPoint;
  58581. /**
  58582. * Gets the fresnel output component
  58583. */
  58584. readonly fresnel: NodeMaterialConnectionPoint;
  58585. autoConfigure(material: NodeMaterial): void;
  58586. protected _buildBlock(state: NodeMaterialBuildState): this;
  58587. }
  58588. }
  58589. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58593. /**
  58594. * Block used to get the max of 2 values
  58595. */
  58596. export class MaxBlock extends NodeMaterialBlock {
  58597. /**
  58598. * Creates a new MaxBlock
  58599. * @param name defines the block name
  58600. */
  58601. constructor(name: string);
  58602. /**
  58603. * Gets the current class name
  58604. * @returns the class name
  58605. */
  58606. getClassName(): string;
  58607. /**
  58608. * Gets the left operand input component
  58609. */
  58610. readonly left: NodeMaterialConnectionPoint;
  58611. /**
  58612. * Gets the right operand input component
  58613. */
  58614. readonly right: NodeMaterialConnectionPoint;
  58615. /**
  58616. * Gets the output component
  58617. */
  58618. readonly output: NodeMaterialConnectionPoint;
  58619. protected _buildBlock(state: NodeMaterialBuildState): this;
  58620. }
  58621. }
  58622. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58626. /**
  58627. * Block used to get the min of 2 values
  58628. */
  58629. export class MinBlock extends NodeMaterialBlock {
  58630. /**
  58631. * Creates a new MinBlock
  58632. * @param name defines the block name
  58633. */
  58634. constructor(name: string);
  58635. /**
  58636. * Gets the current class name
  58637. * @returns the class name
  58638. */
  58639. getClassName(): string;
  58640. /**
  58641. * Gets the left operand input component
  58642. */
  58643. readonly left: NodeMaterialConnectionPoint;
  58644. /**
  58645. * Gets the right operand input component
  58646. */
  58647. readonly right: NodeMaterialConnectionPoint;
  58648. /**
  58649. * Gets the output component
  58650. */
  58651. readonly output: NodeMaterialConnectionPoint;
  58652. protected _buildBlock(state: NodeMaterialBuildState): this;
  58653. }
  58654. }
  58655. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58659. /**
  58660. * Block used to get the distance between 2 values
  58661. */
  58662. export class DistanceBlock extends NodeMaterialBlock {
  58663. /**
  58664. * Creates a new DistanceBlock
  58665. * @param name defines the block name
  58666. */
  58667. constructor(name: string);
  58668. /**
  58669. * Gets the current class name
  58670. * @returns the class name
  58671. */
  58672. getClassName(): string;
  58673. /**
  58674. * Gets the left operand input component
  58675. */
  58676. readonly left: NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the right operand input component
  58679. */
  58680. readonly right: NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the output component
  58683. */
  58684. readonly output: NodeMaterialConnectionPoint;
  58685. protected _buildBlock(state: NodeMaterialBuildState): this;
  58686. }
  58687. }
  58688. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58692. /**
  58693. * Block used to get the length of a vector
  58694. */
  58695. export class LengthBlock extends NodeMaterialBlock {
  58696. /**
  58697. * Creates a new LengthBlock
  58698. * @param name defines the block name
  58699. */
  58700. constructor(name: string);
  58701. /**
  58702. * Gets the current class name
  58703. * @returns the class name
  58704. */
  58705. getClassName(): string;
  58706. /**
  58707. * Gets the value input component
  58708. */
  58709. readonly value: NodeMaterialConnectionPoint;
  58710. /**
  58711. * Gets the output component
  58712. */
  58713. readonly output: NodeMaterialConnectionPoint;
  58714. protected _buildBlock(state: NodeMaterialBuildState): this;
  58715. }
  58716. }
  58717. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58721. /**
  58722. * Block used to get negative version of a value (i.e. x * -1)
  58723. */
  58724. export class NegateBlock extends NodeMaterialBlock {
  58725. /**
  58726. * Creates a new NegateBlock
  58727. * @param name defines the block name
  58728. */
  58729. constructor(name: string);
  58730. /**
  58731. * Gets the current class name
  58732. * @returns the class name
  58733. */
  58734. getClassName(): string;
  58735. /**
  58736. * Gets the value input component
  58737. */
  58738. readonly value: NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the output component
  58741. */
  58742. readonly output: NodeMaterialConnectionPoint;
  58743. protected _buildBlock(state: NodeMaterialBuildState): this;
  58744. }
  58745. }
  58746. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58750. /**
  58751. * Block used to get the value of the first parameter raised to the power of the second
  58752. */
  58753. export class PowBlock extends NodeMaterialBlock {
  58754. /**
  58755. * Creates a new PowBlock
  58756. * @param name defines the block name
  58757. */
  58758. constructor(name: string);
  58759. /**
  58760. * Gets the current class name
  58761. * @returns the class name
  58762. */
  58763. getClassName(): string;
  58764. /**
  58765. * Gets the value operand input component
  58766. */
  58767. readonly value: NodeMaterialConnectionPoint;
  58768. /**
  58769. * Gets the power operand input component
  58770. */
  58771. readonly power: NodeMaterialConnectionPoint;
  58772. /**
  58773. * Gets the output component
  58774. */
  58775. readonly output: NodeMaterialConnectionPoint;
  58776. protected _buildBlock(state: NodeMaterialBuildState): this;
  58777. }
  58778. }
  58779. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58783. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58784. /**
  58785. * Block used to get a random number
  58786. */
  58787. export class RandomNumberBlock extends NodeMaterialBlock {
  58788. /**
  58789. * Creates a new RandomNumberBlock
  58790. * @param name defines the block name
  58791. */
  58792. constructor(name: string);
  58793. /**
  58794. * Gets the current class name
  58795. * @returns the class name
  58796. */
  58797. getClassName(): string;
  58798. /**
  58799. * Gets the seed input component
  58800. */
  58801. readonly seed: NodeMaterialConnectionPoint;
  58802. /**
  58803. * Gets the output component
  58804. */
  58805. readonly output: NodeMaterialConnectionPoint;
  58806. protected _buildBlock(state: NodeMaterialBuildState): this;
  58807. }
  58808. }
  58809. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58811. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58812. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58813. /**
  58814. * Block used to compute arc tangent of 2 values
  58815. */
  58816. export class ArcTan2Block extends NodeMaterialBlock {
  58817. /**
  58818. * Creates a new ArcTan2Block
  58819. * @param name defines the block name
  58820. */
  58821. constructor(name: string);
  58822. /**
  58823. * Gets the current class name
  58824. * @returns the class name
  58825. */
  58826. getClassName(): string;
  58827. /**
  58828. * Gets the x operand input component
  58829. */
  58830. readonly x: NodeMaterialConnectionPoint;
  58831. /**
  58832. * Gets the y operand input component
  58833. */
  58834. readonly y: NodeMaterialConnectionPoint;
  58835. /**
  58836. * Gets the output component
  58837. */
  58838. readonly output: NodeMaterialConnectionPoint;
  58839. protected _buildBlock(state: NodeMaterialBuildState): this;
  58840. }
  58841. }
  58842. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  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 smooth step a value
  58848. */
  58849. export class SmoothStepBlock extends NodeMaterialBlock {
  58850. /**
  58851. * Creates a new SmoothStepBlock
  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 value operand input component
  58862. */
  58863. readonly value: NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the first edge operand input component
  58866. */
  58867. readonly edge0: NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the second edge operand input component
  58870. */
  58871. readonly edge1: NodeMaterialConnectionPoint;
  58872. /**
  58873. * Gets the output component
  58874. */
  58875. readonly output: NodeMaterialConnectionPoint;
  58876. protected _buildBlock(state: NodeMaterialBuildState): this;
  58877. }
  58878. }
  58879. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58883. /**
  58884. * Block used to get the reciprocal (1 / x) of a value
  58885. */
  58886. export class ReciprocalBlock extends NodeMaterialBlock {
  58887. /**
  58888. * Creates a new ReciprocalBlock
  58889. * @param name defines the block name
  58890. */
  58891. constructor(name: string);
  58892. /**
  58893. * Gets the current class name
  58894. * @returns the class name
  58895. */
  58896. getClassName(): string;
  58897. /**
  58898. * Gets the input component
  58899. */
  58900. readonly input: 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/replaceColorBlock" {
  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 replace a color by another one
  58914. */
  58915. export class ReplaceColorBlock extends NodeMaterialBlock {
  58916. /**
  58917. * Creates a new ReplaceColorBlock
  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 value input component
  58928. */
  58929. readonly value: NodeMaterialConnectionPoint;
  58930. /**
  58931. * Gets the reference input component
  58932. */
  58933. readonly reference: NodeMaterialConnectionPoint;
  58934. /**
  58935. * Gets the distance input component
  58936. */
  58937. readonly distance: NodeMaterialConnectionPoint;
  58938. /**
  58939. * Gets the replacement input component
  58940. */
  58941. readonly replacement: NodeMaterialConnectionPoint;
  58942. /**
  58943. * Gets the output component
  58944. */
  58945. readonly output: NodeMaterialConnectionPoint;
  58946. protected _buildBlock(state: NodeMaterialBuildState): this;
  58947. }
  58948. }
  58949. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58953. /**
  58954. * Block used to posterize a value
  58955. * @see https://en.wikipedia.org/wiki/Posterization
  58956. */
  58957. export class PosterizeBlock extends NodeMaterialBlock {
  58958. /**
  58959. * Creates a new PosterizeBlock
  58960. * @param name defines the block name
  58961. */
  58962. constructor(name: string);
  58963. /**
  58964. * Gets the current class name
  58965. * @returns the class name
  58966. */
  58967. getClassName(): string;
  58968. /**
  58969. * Gets the value input component
  58970. */
  58971. readonly value: NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the steps input component
  58974. */
  58975. readonly steps: NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the output component
  58978. */
  58979. readonly output: NodeMaterialConnectionPoint;
  58980. protected _buildBlock(state: NodeMaterialBuildState): this;
  58981. }
  58982. }
  58983. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58987. import { Scene } from "babylonjs/scene";
  58988. /**
  58989. * Operations supported by the Wave block
  58990. */
  58991. export enum WaveBlockKind {
  58992. /** SawTooth */
  58993. SawTooth = 0,
  58994. /** Square */
  58995. Square = 1,
  58996. /** Triangle */
  58997. Triangle = 2
  58998. }
  58999. /**
  59000. * Block used to apply wave operation to floats
  59001. */
  59002. export class WaveBlock extends NodeMaterialBlock {
  59003. /**
  59004. * Gets or sets the kibnd of wave to be applied by the block
  59005. */
  59006. kind: WaveBlockKind;
  59007. /**
  59008. * Creates a new WaveBlock
  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 input component
  59019. */
  59020. readonly input: NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the output component
  59023. */
  59024. readonly output: NodeMaterialConnectionPoint;
  59025. protected _buildBlock(state: NodeMaterialBuildState): this;
  59026. serialize(): any;
  59027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59028. }
  59029. }
  59030. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59034. import { Color3 } from "babylonjs/Maths/math.color";
  59035. import { Scene } from "babylonjs/scene";
  59036. /**
  59037. * Class used to store a color step for the GradientBlock
  59038. */
  59039. export class GradientBlockColorStep {
  59040. /**
  59041. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59042. */
  59043. step: number;
  59044. /**
  59045. * Gets or sets the color associated with this step
  59046. */
  59047. color: Color3;
  59048. /**
  59049. * Creates a new GradientBlockColorStep
  59050. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59051. * @param color defines the color associated with this step
  59052. */
  59053. constructor(
  59054. /**
  59055. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59056. */
  59057. step: number,
  59058. /**
  59059. * Gets or sets the color associated with this step
  59060. */
  59061. color: Color3);
  59062. }
  59063. /**
  59064. * Block used to return a color from a gradient based on an input value between 0 and 1
  59065. */
  59066. export class GradientBlock extends NodeMaterialBlock {
  59067. /**
  59068. * Gets or sets the list of color steps
  59069. */
  59070. colorSteps: GradientBlockColorStep[];
  59071. /**
  59072. * Creates a new GradientBlock
  59073. * @param name defines the block name
  59074. */
  59075. constructor(name: string);
  59076. /**
  59077. * Gets the current class name
  59078. * @returns the class name
  59079. */
  59080. getClassName(): string;
  59081. /**
  59082. * Gets the gradient input component
  59083. */
  59084. readonly gradient: NodeMaterialConnectionPoint;
  59085. /**
  59086. * Gets the output component
  59087. */
  59088. readonly output: NodeMaterialConnectionPoint;
  59089. private _writeColorConstant;
  59090. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59091. serialize(): any;
  59092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59093. protected _dumpPropertiesCode(): string;
  59094. }
  59095. }
  59096. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59100. /**
  59101. * Block used to normalize lerp between 2 values
  59102. */
  59103. export class NLerpBlock extends NodeMaterialBlock {
  59104. /**
  59105. * Creates a new NLerpBlock
  59106. * @param name defines the block name
  59107. */
  59108. constructor(name: string);
  59109. /**
  59110. * Gets the current class name
  59111. * @returns the class name
  59112. */
  59113. getClassName(): string;
  59114. /**
  59115. * Gets the left operand input component
  59116. */
  59117. readonly left: NodeMaterialConnectionPoint;
  59118. /**
  59119. * Gets the right operand input component
  59120. */
  59121. readonly right: NodeMaterialConnectionPoint;
  59122. /**
  59123. * Gets the gradient operand input component
  59124. */
  59125. readonly gradient: NodeMaterialConnectionPoint;
  59126. /**
  59127. * Gets the output component
  59128. */
  59129. readonly output: NodeMaterialConnectionPoint;
  59130. protected _buildBlock(state: NodeMaterialBuildState): this;
  59131. }
  59132. }
  59133. declare module "babylonjs/Materials/Node/Blocks/index" {
  59134. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59135. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59136. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59137. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59138. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59139. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59140. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59141. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59142. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59143. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59144. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59145. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59146. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59147. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59148. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59149. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59150. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59151. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59152. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59153. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59154. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59155. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59156. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59157. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59158. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59159. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59160. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59161. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59162. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59163. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59164. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59165. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59166. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59167. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59168. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59169. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59170. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59171. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59172. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59173. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59174. }
  59175. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59176. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59177. }
  59178. declare module "babylonjs/Materials/Node/index" {
  59179. export * from "babylonjs/Materials/Node/Enums/index";
  59180. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59181. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59182. export * from "babylonjs/Materials/Node/nodeMaterial";
  59183. export * from "babylonjs/Materials/Node/Blocks/index";
  59184. export * from "babylonjs/Materials/Node/Optimizers/index";
  59185. }
  59186. declare module "babylonjs/Materials/effectRenderer" {
  59187. import { Nullable } from "babylonjs/types";
  59188. import { Texture } from "babylonjs/Materials/Textures/texture";
  59189. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59190. import { Viewport } from "babylonjs/Maths/math.viewport";
  59191. import { Observable } from "babylonjs/Misc/observable";
  59192. import { Effect } from "babylonjs/Materials/effect";
  59193. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59194. import "babylonjs/Shaders/postprocess.vertex";
  59195. /**
  59196. * Effect Render Options
  59197. */
  59198. export interface IEffectRendererOptions {
  59199. /**
  59200. * Defines the vertices positions.
  59201. */
  59202. positions?: number[];
  59203. /**
  59204. * Defines the indices.
  59205. */
  59206. indices?: number[];
  59207. }
  59208. /**
  59209. * Helper class to render one or more effects
  59210. */
  59211. export class EffectRenderer {
  59212. private engine;
  59213. private static _DefaultOptions;
  59214. private _vertexBuffers;
  59215. private _indexBuffer;
  59216. private _ringBufferIndex;
  59217. private _ringScreenBuffer;
  59218. private _fullscreenViewport;
  59219. private _getNextFrameBuffer;
  59220. /**
  59221. * Creates an effect renderer
  59222. * @param engine the engine to use for rendering
  59223. * @param options defines the options of the effect renderer
  59224. */
  59225. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59226. /**
  59227. * Sets the current viewport in normalized coordinates 0-1
  59228. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59229. */
  59230. setViewport(viewport?: Viewport): void;
  59231. /**
  59232. * Binds the embedded attributes buffer to the effect.
  59233. * @param effect Defines the effect to bind the attributes for
  59234. */
  59235. bindBuffers(effect: Effect): void;
  59236. /**
  59237. * Sets the current effect wrapper to use during draw.
  59238. * The effect needs to be ready before calling this api.
  59239. * This also sets the default full screen position attribute.
  59240. * @param effectWrapper Defines the effect to draw with
  59241. */
  59242. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59243. /**
  59244. * Draws a full screen quad.
  59245. */
  59246. draw(): void;
  59247. /**
  59248. * renders one or more effects to a specified texture
  59249. * @param effectWrappers list of effects to renderer
  59250. * @param outputTexture texture to draw to, if null it will render to the screen
  59251. */
  59252. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59253. /**
  59254. * Disposes of the effect renderer
  59255. */
  59256. dispose(): void;
  59257. }
  59258. /**
  59259. * Options to create an EffectWrapper
  59260. */
  59261. interface EffectWrapperCreationOptions {
  59262. /**
  59263. * Engine to use to create the effect
  59264. */
  59265. engine: ThinEngine;
  59266. /**
  59267. * Fragment shader for the effect
  59268. */
  59269. fragmentShader: string;
  59270. /**
  59271. * Vertex shader for the effect
  59272. */
  59273. vertexShader?: string;
  59274. /**
  59275. * Attributes to use in the shader
  59276. */
  59277. attributeNames?: Array<string>;
  59278. /**
  59279. * Uniforms to use in the shader
  59280. */
  59281. uniformNames?: Array<string>;
  59282. /**
  59283. * Texture sampler names to use in the shader
  59284. */
  59285. samplerNames?: Array<string>;
  59286. /**
  59287. * The friendly name of the effect displayed in Spector.
  59288. */
  59289. name?: string;
  59290. }
  59291. /**
  59292. * Wraps an effect to be used for rendering
  59293. */
  59294. export class EffectWrapper {
  59295. /**
  59296. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59297. */
  59298. onApplyObservable: Observable<{}>;
  59299. /**
  59300. * The underlying effect
  59301. */
  59302. effect: Effect;
  59303. /**
  59304. * Creates an effect to be renderer
  59305. * @param creationOptions options to create the effect
  59306. */
  59307. constructor(creationOptions: EffectWrapperCreationOptions);
  59308. /**
  59309. * Disposes of the effect wrapper
  59310. */
  59311. dispose(): void;
  59312. }
  59313. }
  59314. declare module "babylonjs/Materials/index" {
  59315. export * from "babylonjs/Materials/Background/index";
  59316. export * from "babylonjs/Materials/colorCurves";
  59317. export * from "babylonjs/Materials/iEffectFallbacks";
  59318. export * from "babylonjs/Materials/effectFallbacks";
  59319. export * from "babylonjs/Materials/effect";
  59320. export * from "babylonjs/Materials/fresnelParameters";
  59321. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59322. export * from "babylonjs/Materials/material";
  59323. export * from "babylonjs/Materials/materialDefines";
  59324. export * from "babylonjs/Materials/materialHelper";
  59325. export * from "babylonjs/Materials/multiMaterial";
  59326. export * from "babylonjs/Materials/PBR/index";
  59327. export * from "babylonjs/Materials/pushMaterial";
  59328. export * from "babylonjs/Materials/shaderMaterial";
  59329. export * from "babylonjs/Materials/standardMaterial";
  59330. export * from "babylonjs/Materials/Textures/index";
  59331. export * from "babylonjs/Materials/uniformBuffer";
  59332. export * from "babylonjs/Materials/materialFlags";
  59333. export * from "babylonjs/Materials/Node/index";
  59334. export * from "babylonjs/Materials/effectRenderer";
  59335. }
  59336. declare module "babylonjs/Maths/index" {
  59337. export * from "babylonjs/Maths/math.scalar";
  59338. export * from "babylonjs/Maths/math";
  59339. export * from "babylonjs/Maths/sphericalPolynomial";
  59340. }
  59341. declare module "babylonjs/Misc/workerPool" {
  59342. import { IDisposable } from "babylonjs/scene";
  59343. /**
  59344. * Helper class to push actions to a pool of workers.
  59345. */
  59346. export class WorkerPool implements IDisposable {
  59347. private _workerInfos;
  59348. private _pendingActions;
  59349. /**
  59350. * Constructor
  59351. * @param workers Array of workers to use for actions
  59352. */
  59353. constructor(workers: Array<Worker>);
  59354. /**
  59355. * Terminates all workers and clears any pending actions.
  59356. */
  59357. dispose(): void;
  59358. /**
  59359. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59360. * pended until a worker has completed its action.
  59361. * @param action The action to perform. Call onComplete when the action is complete.
  59362. */
  59363. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59364. private _execute;
  59365. }
  59366. }
  59367. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59368. import { IDisposable } from "babylonjs/scene";
  59369. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59370. /**
  59371. * Configuration for Draco compression
  59372. */
  59373. export interface IDracoCompressionConfiguration {
  59374. /**
  59375. * Configuration for the decoder.
  59376. */
  59377. decoder: {
  59378. /**
  59379. * The url to the WebAssembly module.
  59380. */
  59381. wasmUrl?: string;
  59382. /**
  59383. * The url to the WebAssembly binary.
  59384. */
  59385. wasmBinaryUrl?: string;
  59386. /**
  59387. * The url to the fallback JavaScript module.
  59388. */
  59389. fallbackUrl?: string;
  59390. };
  59391. }
  59392. /**
  59393. * Draco compression (https://google.github.io/draco/)
  59394. *
  59395. * This class wraps the Draco module.
  59396. *
  59397. * **Encoder**
  59398. *
  59399. * The encoder is not currently implemented.
  59400. *
  59401. * **Decoder**
  59402. *
  59403. * 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.
  59404. *
  59405. * To update the configuration, use the following code:
  59406. * ```javascript
  59407. * DracoCompression.Configuration = {
  59408. * decoder: {
  59409. * wasmUrl: "<url to the WebAssembly library>",
  59410. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59411. * fallbackUrl: "<url to the fallback JavaScript library>",
  59412. * }
  59413. * };
  59414. * ```
  59415. *
  59416. * 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.
  59417. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59418. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59419. *
  59420. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59421. * ```javascript
  59422. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59423. * ```
  59424. *
  59425. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59426. */
  59427. export class DracoCompression implements IDisposable {
  59428. private _workerPoolPromise?;
  59429. private _decoderModulePromise?;
  59430. /**
  59431. * The configuration. Defaults to the following urls:
  59432. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59433. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59434. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59435. */
  59436. static Configuration: IDracoCompressionConfiguration;
  59437. /**
  59438. * Returns true if the decoder configuration is available.
  59439. */
  59440. static readonly DecoderAvailable: boolean;
  59441. /**
  59442. * Default number of workers to create when creating the draco compression object.
  59443. */
  59444. static DefaultNumWorkers: number;
  59445. private static GetDefaultNumWorkers;
  59446. private static _Default;
  59447. /**
  59448. * Default instance for the draco compression object.
  59449. */
  59450. static readonly Default: DracoCompression;
  59451. /**
  59452. * Constructor
  59453. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59454. */
  59455. constructor(numWorkers?: number);
  59456. /**
  59457. * Stop all async operations and release resources.
  59458. */
  59459. dispose(): void;
  59460. /**
  59461. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59462. * @returns a promise that resolves when ready
  59463. */
  59464. whenReadyAsync(): Promise<void>;
  59465. /**
  59466. * Decode Draco compressed mesh data to vertex data.
  59467. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59468. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59469. * @returns A promise that resolves with the decoded vertex data
  59470. */
  59471. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59472. [kind: string]: number;
  59473. }): Promise<VertexData>;
  59474. }
  59475. }
  59476. declare module "babylonjs/Meshes/Compression/index" {
  59477. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59478. }
  59479. declare module "babylonjs/Meshes/csg" {
  59480. import { Nullable } from "babylonjs/types";
  59481. import { Scene } from "babylonjs/scene";
  59482. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59483. import { Mesh } from "babylonjs/Meshes/mesh";
  59484. import { Material } from "babylonjs/Materials/material";
  59485. /**
  59486. * Class for building Constructive Solid Geometry
  59487. */
  59488. export class CSG {
  59489. private polygons;
  59490. /**
  59491. * The world matrix
  59492. */
  59493. matrix: Matrix;
  59494. /**
  59495. * Stores the position
  59496. */
  59497. position: Vector3;
  59498. /**
  59499. * Stores the rotation
  59500. */
  59501. rotation: Vector3;
  59502. /**
  59503. * Stores the rotation quaternion
  59504. */
  59505. rotationQuaternion: Nullable<Quaternion>;
  59506. /**
  59507. * Stores the scaling vector
  59508. */
  59509. scaling: Vector3;
  59510. /**
  59511. * Convert the Mesh to CSG
  59512. * @param mesh The Mesh to convert to CSG
  59513. * @returns A new CSG from the Mesh
  59514. */
  59515. static FromMesh(mesh: Mesh): CSG;
  59516. /**
  59517. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59518. * @param polygons Polygons used to construct a CSG solid
  59519. */
  59520. private static FromPolygons;
  59521. /**
  59522. * Clones, or makes a deep copy, of the CSG
  59523. * @returns A new CSG
  59524. */
  59525. clone(): CSG;
  59526. /**
  59527. * Unions this CSG with another CSG
  59528. * @param csg The CSG to union against this CSG
  59529. * @returns The unioned CSG
  59530. */
  59531. union(csg: CSG): CSG;
  59532. /**
  59533. * Unions this CSG with another CSG in place
  59534. * @param csg The CSG to union against this CSG
  59535. */
  59536. unionInPlace(csg: CSG): void;
  59537. /**
  59538. * Subtracts this CSG with another CSG
  59539. * @param csg The CSG to subtract against this CSG
  59540. * @returns A new CSG
  59541. */
  59542. subtract(csg: CSG): CSG;
  59543. /**
  59544. * Subtracts this CSG with another CSG in place
  59545. * @param csg The CSG to subtact against this CSG
  59546. */
  59547. subtractInPlace(csg: CSG): void;
  59548. /**
  59549. * Intersect this CSG with another CSG
  59550. * @param csg The CSG to intersect against this CSG
  59551. * @returns A new CSG
  59552. */
  59553. intersect(csg: CSG): CSG;
  59554. /**
  59555. * Intersects this CSG with another CSG in place
  59556. * @param csg The CSG to intersect against this CSG
  59557. */
  59558. intersectInPlace(csg: CSG): void;
  59559. /**
  59560. * Return a new CSG solid with solid and empty space switched. This solid is
  59561. * not modified.
  59562. * @returns A new CSG solid with solid and empty space switched
  59563. */
  59564. inverse(): CSG;
  59565. /**
  59566. * Inverses the CSG in place
  59567. */
  59568. inverseInPlace(): void;
  59569. /**
  59570. * This is used to keep meshes transformations so they can be restored
  59571. * when we build back a Babylon Mesh
  59572. * NB : All CSG operations are performed in world coordinates
  59573. * @param csg The CSG to copy the transform attributes from
  59574. * @returns This CSG
  59575. */
  59576. copyTransformAttributes(csg: CSG): CSG;
  59577. /**
  59578. * Build Raw mesh from CSG
  59579. * Coordinates here are in world space
  59580. * @param name The name of the mesh geometry
  59581. * @param scene The Scene
  59582. * @param keepSubMeshes Specifies if the submeshes should be kept
  59583. * @returns A new Mesh
  59584. */
  59585. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59586. /**
  59587. * Build Mesh from CSG taking material and transforms into account
  59588. * @param name The name of the Mesh
  59589. * @param material The material of the Mesh
  59590. * @param scene The Scene
  59591. * @param keepSubMeshes Specifies if submeshes should be kept
  59592. * @returns The new Mesh
  59593. */
  59594. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59595. }
  59596. }
  59597. declare module "babylonjs/Meshes/trailMesh" {
  59598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59599. import { Mesh } from "babylonjs/Meshes/mesh";
  59600. import { Scene } from "babylonjs/scene";
  59601. /**
  59602. * Class used to create a trail following a mesh
  59603. */
  59604. export class TrailMesh extends Mesh {
  59605. private _generator;
  59606. private _autoStart;
  59607. private _running;
  59608. private _diameter;
  59609. private _length;
  59610. private _sectionPolygonPointsCount;
  59611. private _sectionVectors;
  59612. private _sectionNormalVectors;
  59613. private _beforeRenderObserver;
  59614. /**
  59615. * @constructor
  59616. * @param name The value used by scene.getMeshByName() to do a lookup.
  59617. * @param generator The mesh to generate a trail.
  59618. * @param scene The scene to add this mesh to.
  59619. * @param diameter Diameter of trailing mesh. Default is 1.
  59620. * @param length Length of trailing mesh. Default is 60.
  59621. * @param autoStart Automatically start trailing mesh. Default true.
  59622. */
  59623. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59624. /**
  59625. * "TrailMesh"
  59626. * @returns "TrailMesh"
  59627. */
  59628. getClassName(): string;
  59629. private _createMesh;
  59630. /**
  59631. * Start trailing mesh.
  59632. */
  59633. start(): void;
  59634. /**
  59635. * Stop trailing mesh.
  59636. */
  59637. stop(): void;
  59638. /**
  59639. * Update trailing mesh geometry.
  59640. */
  59641. update(): void;
  59642. /**
  59643. * Returns a new TrailMesh object.
  59644. * @param name is a string, the name given to the new mesh
  59645. * @param newGenerator use new generator object for cloned trail mesh
  59646. * @returns a new mesh
  59647. */
  59648. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59649. /**
  59650. * Serializes this trail mesh
  59651. * @param serializationObject object to write serialization to
  59652. */
  59653. serialize(serializationObject: any): void;
  59654. /**
  59655. * Parses a serialized trail mesh
  59656. * @param parsedMesh the serialized mesh
  59657. * @param scene the scene to create the trail mesh in
  59658. * @returns the created trail mesh
  59659. */
  59660. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59661. }
  59662. }
  59663. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59664. import { Nullable } from "babylonjs/types";
  59665. import { Scene } from "babylonjs/scene";
  59666. import { Vector4 } from "babylonjs/Maths/math.vector";
  59667. import { Color4 } from "babylonjs/Maths/math.color";
  59668. import { Mesh } from "babylonjs/Meshes/mesh";
  59669. /**
  59670. * Class containing static functions to help procedurally build meshes
  59671. */
  59672. export class TiledBoxBuilder {
  59673. /**
  59674. * Creates a box mesh
  59675. * 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)
  59676. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59680. * @param name defines the name of the mesh
  59681. * @param options defines the options used to create the mesh
  59682. * @param scene defines the hosting scene
  59683. * @returns the box mesh
  59684. */
  59685. static CreateTiledBox(name: string, options: {
  59686. pattern?: number;
  59687. width?: number;
  59688. height?: number;
  59689. depth?: number;
  59690. tileSize?: number;
  59691. tileWidth?: number;
  59692. tileHeight?: number;
  59693. alignHorizontal?: number;
  59694. alignVertical?: number;
  59695. faceUV?: Vector4[];
  59696. faceColors?: Color4[];
  59697. sideOrientation?: number;
  59698. updatable?: boolean;
  59699. }, scene?: Nullable<Scene>): Mesh;
  59700. }
  59701. }
  59702. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59703. import { Vector4 } from "babylonjs/Maths/math.vector";
  59704. import { Mesh } from "babylonjs/Meshes/mesh";
  59705. /**
  59706. * Class containing static functions to help procedurally build meshes
  59707. */
  59708. export class TorusKnotBuilder {
  59709. /**
  59710. * Creates a torus knot mesh
  59711. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59712. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59713. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59714. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59718. * @param name defines the name of the mesh
  59719. * @param options defines the options used to create the mesh
  59720. * @param scene defines the hosting scene
  59721. * @returns the torus knot mesh
  59722. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59723. */
  59724. static CreateTorusKnot(name: string, options: {
  59725. radius?: number;
  59726. tube?: number;
  59727. radialSegments?: number;
  59728. tubularSegments?: number;
  59729. p?: number;
  59730. q?: number;
  59731. updatable?: boolean;
  59732. sideOrientation?: number;
  59733. frontUVs?: Vector4;
  59734. backUVs?: Vector4;
  59735. }, scene: any): Mesh;
  59736. }
  59737. }
  59738. declare module "babylonjs/Meshes/polygonMesh" {
  59739. import { Scene } from "babylonjs/scene";
  59740. import { Vector2 } from "babylonjs/Maths/math.vector";
  59741. import { Mesh } from "babylonjs/Meshes/mesh";
  59742. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59743. import { Path2 } from "babylonjs/Maths/math.path";
  59744. /**
  59745. * Polygon
  59746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59747. */
  59748. export class Polygon {
  59749. /**
  59750. * Creates a rectangle
  59751. * @param xmin bottom X coord
  59752. * @param ymin bottom Y coord
  59753. * @param xmax top X coord
  59754. * @param ymax top Y coord
  59755. * @returns points that make the resulting rectation
  59756. */
  59757. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59758. /**
  59759. * Creates a circle
  59760. * @param radius radius of circle
  59761. * @param cx scale in x
  59762. * @param cy scale in y
  59763. * @param numberOfSides number of sides that make up the circle
  59764. * @returns points that make the resulting circle
  59765. */
  59766. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59767. /**
  59768. * Creates a polygon from input string
  59769. * @param input Input polygon data
  59770. * @returns the parsed points
  59771. */
  59772. static Parse(input: string): Vector2[];
  59773. /**
  59774. * Starts building a polygon from x and y coordinates
  59775. * @param x x coordinate
  59776. * @param y y coordinate
  59777. * @returns the started path2
  59778. */
  59779. static StartingAt(x: number, y: number): Path2;
  59780. }
  59781. /**
  59782. * Builds a polygon
  59783. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59784. */
  59785. export class PolygonMeshBuilder {
  59786. private _points;
  59787. private _outlinepoints;
  59788. private _holes;
  59789. private _name;
  59790. private _scene;
  59791. private _epoints;
  59792. private _eholes;
  59793. private _addToepoint;
  59794. /**
  59795. * Babylon reference to the earcut plugin.
  59796. */
  59797. bjsEarcut: any;
  59798. /**
  59799. * Creates a PolygonMeshBuilder
  59800. * @param name name of the builder
  59801. * @param contours Path of the polygon
  59802. * @param scene scene to add to when creating the mesh
  59803. * @param earcutInjection can be used to inject your own earcut reference
  59804. */
  59805. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59806. /**
  59807. * Adds a whole within the polygon
  59808. * @param hole Array of points defining the hole
  59809. * @returns this
  59810. */
  59811. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59812. /**
  59813. * Creates the polygon
  59814. * @param updatable If the mesh should be updatable
  59815. * @param depth The depth of the mesh created
  59816. * @returns the created mesh
  59817. */
  59818. build(updatable?: boolean, depth?: number): Mesh;
  59819. /**
  59820. * Creates the polygon
  59821. * @param depth The depth of the mesh created
  59822. * @returns the created VertexData
  59823. */
  59824. buildVertexData(depth?: number): VertexData;
  59825. /**
  59826. * Adds a side to the polygon
  59827. * @param positions points that make the polygon
  59828. * @param normals normals of the polygon
  59829. * @param uvs uvs of the polygon
  59830. * @param indices indices of the polygon
  59831. * @param bounds bounds of the polygon
  59832. * @param points points of the polygon
  59833. * @param depth depth of the polygon
  59834. * @param flip flip of the polygon
  59835. */
  59836. private addSide;
  59837. }
  59838. }
  59839. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59840. import { Scene } from "babylonjs/scene";
  59841. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59842. import { Color4 } from "babylonjs/Maths/math.color";
  59843. import { Mesh } from "babylonjs/Meshes/mesh";
  59844. import { Nullable } from "babylonjs/types";
  59845. /**
  59846. * Class containing static functions to help procedurally build meshes
  59847. */
  59848. export class PolygonBuilder {
  59849. /**
  59850. * Creates a polygon mesh
  59851. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59852. * * 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
  59853. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59856. * * Remember you can only change the shape positions, not their number when updating a polygon
  59857. * @param name defines the name of the mesh
  59858. * @param options defines the options used to create the mesh
  59859. * @param scene defines the hosting scene
  59860. * @param earcutInjection can be used to inject your own earcut reference
  59861. * @returns the polygon mesh
  59862. */
  59863. static CreatePolygon(name: string, options: {
  59864. shape: Vector3[];
  59865. holes?: Vector3[][];
  59866. depth?: number;
  59867. faceUV?: Vector4[];
  59868. faceColors?: Color4[];
  59869. updatable?: boolean;
  59870. sideOrientation?: number;
  59871. frontUVs?: Vector4;
  59872. backUVs?: Vector4;
  59873. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59874. /**
  59875. * Creates an extruded polygon mesh, with depth in the Y direction.
  59876. * * 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)
  59877. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59878. * @param name defines the name of the mesh
  59879. * @param options defines the options used to create the mesh
  59880. * @param scene defines the hosting scene
  59881. * @param earcutInjection can be used to inject your own earcut reference
  59882. * @returns the polygon mesh
  59883. */
  59884. static ExtrudePolygon(name: string, options: {
  59885. shape: Vector3[];
  59886. holes?: Vector3[][];
  59887. depth?: number;
  59888. faceUV?: Vector4[];
  59889. faceColors?: Color4[];
  59890. updatable?: boolean;
  59891. sideOrientation?: number;
  59892. frontUVs?: Vector4;
  59893. backUVs?: Vector4;
  59894. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59895. }
  59896. }
  59897. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59898. import { Scene } from "babylonjs/scene";
  59899. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59900. import { Mesh } from "babylonjs/Meshes/mesh";
  59901. import { Nullable } from "babylonjs/types";
  59902. /**
  59903. * Class containing static functions to help procedurally build meshes
  59904. */
  59905. export class LatheBuilder {
  59906. /**
  59907. * Creates lathe mesh.
  59908. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59909. * * 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
  59910. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59911. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59912. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59913. * * 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
  59914. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59915. * * 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
  59916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59920. * @param name defines the name of the mesh
  59921. * @param options defines the options used to create the mesh
  59922. * @param scene defines the hosting scene
  59923. * @returns the lathe mesh
  59924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59925. */
  59926. static CreateLathe(name: string, options: {
  59927. shape: Vector3[];
  59928. radius?: number;
  59929. tessellation?: number;
  59930. clip?: number;
  59931. arc?: number;
  59932. closed?: boolean;
  59933. updatable?: boolean;
  59934. sideOrientation?: number;
  59935. frontUVs?: Vector4;
  59936. backUVs?: Vector4;
  59937. cap?: number;
  59938. invertUV?: boolean;
  59939. }, scene?: Nullable<Scene>): Mesh;
  59940. }
  59941. }
  59942. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59943. import { Nullable } from "babylonjs/types";
  59944. import { Scene } from "babylonjs/scene";
  59945. import { Vector4 } from "babylonjs/Maths/math.vector";
  59946. import { Mesh } from "babylonjs/Meshes/mesh";
  59947. /**
  59948. * Class containing static functions to help procedurally build meshes
  59949. */
  59950. export class TiledPlaneBuilder {
  59951. /**
  59952. * Creates a tiled plane mesh
  59953. * * The parameter `pattern` will, depending on value, do nothing or
  59954. * * * flip (reflect about central vertical) alternate tiles across and up
  59955. * * * flip every tile on alternate rows
  59956. * * * rotate (180 degs) alternate tiles across and up
  59957. * * * rotate every tile on alternate rows
  59958. * * * flip and rotate alternate tiles across and up
  59959. * * * flip and rotate every tile on alternate rows
  59960. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59961. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59964. * * 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)
  59965. * * 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)
  59966. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59967. * @param name defines the name of the mesh
  59968. * @param options defines the options used to create the mesh
  59969. * @param scene defines the hosting scene
  59970. * @returns the box mesh
  59971. */
  59972. static CreateTiledPlane(name: string, options: {
  59973. pattern?: number;
  59974. tileSize?: number;
  59975. tileWidth?: number;
  59976. tileHeight?: number;
  59977. size?: number;
  59978. width?: number;
  59979. height?: number;
  59980. alignHorizontal?: number;
  59981. alignVertical?: number;
  59982. sideOrientation?: number;
  59983. frontUVs?: Vector4;
  59984. backUVs?: Vector4;
  59985. updatable?: boolean;
  59986. }, scene?: Nullable<Scene>): Mesh;
  59987. }
  59988. }
  59989. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59990. import { Nullable } from "babylonjs/types";
  59991. import { Scene } from "babylonjs/scene";
  59992. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59993. import { Mesh } from "babylonjs/Meshes/mesh";
  59994. /**
  59995. * Class containing static functions to help procedurally build meshes
  59996. */
  59997. export class TubeBuilder {
  59998. /**
  59999. * Creates a tube mesh.
  60000. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60001. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60002. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60003. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60004. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60005. * * 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)
  60006. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60007. * * 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
  60008. * * 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
  60009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60013. * @param name defines the name of the mesh
  60014. * @param options defines the options used to create the mesh
  60015. * @param scene defines the hosting scene
  60016. * @returns the tube mesh
  60017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60018. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60019. */
  60020. static CreateTube(name: string, options: {
  60021. path: Vector3[];
  60022. radius?: number;
  60023. tessellation?: number;
  60024. radiusFunction?: {
  60025. (i: number, distance: number): number;
  60026. };
  60027. cap?: number;
  60028. arc?: number;
  60029. updatable?: boolean;
  60030. sideOrientation?: number;
  60031. frontUVs?: Vector4;
  60032. backUVs?: Vector4;
  60033. instance?: Mesh;
  60034. invertUV?: boolean;
  60035. }, scene?: Nullable<Scene>): Mesh;
  60036. }
  60037. }
  60038. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60039. import { Scene } from "babylonjs/scene";
  60040. import { Vector4 } from "babylonjs/Maths/math.vector";
  60041. import { Mesh } from "babylonjs/Meshes/mesh";
  60042. import { Nullable } from "babylonjs/types";
  60043. /**
  60044. * Class containing static functions to help procedurally build meshes
  60045. */
  60046. export class IcoSphereBuilder {
  60047. /**
  60048. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60049. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60050. * * 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`)
  60051. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60052. * * 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
  60053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60056. * @param name defines the name of the mesh
  60057. * @param options defines the options used to create the mesh
  60058. * @param scene defines the hosting scene
  60059. * @returns the icosahedron mesh
  60060. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60061. */
  60062. static CreateIcoSphere(name: string, options: {
  60063. radius?: number;
  60064. radiusX?: number;
  60065. radiusY?: number;
  60066. radiusZ?: number;
  60067. flat?: boolean;
  60068. subdivisions?: number;
  60069. sideOrientation?: number;
  60070. frontUVs?: Vector4;
  60071. backUVs?: Vector4;
  60072. updatable?: boolean;
  60073. }, scene?: Nullable<Scene>): Mesh;
  60074. }
  60075. }
  60076. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60077. import { Vector3 } from "babylonjs/Maths/math.vector";
  60078. import { Mesh } from "babylonjs/Meshes/mesh";
  60079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60080. /**
  60081. * Class containing static functions to help procedurally build meshes
  60082. */
  60083. export class DecalBuilder {
  60084. /**
  60085. * Creates a decal mesh.
  60086. * 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
  60087. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60088. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60089. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60090. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60091. * @param name defines the name of the mesh
  60092. * @param sourceMesh defines the mesh where the decal must be applied
  60093. * @param options defines the options used to create the mesh
  60094. * @param scene defines the hosting scene
  60095. * @returns the decal mesh
  60096. * @see https://doc.babylonjs.com/how_to/decals
  60097. */
  60098. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60099. position?: Vector3;
  60100. normal?: Vector3;
  60101. size?: Vector3;
  60102. angle?: number;
  60103. }): Mesh;
  60104. }
  60105. }
  60106. declare module "babylonjs/Meshes/meshBuilder" {
  60107. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60108. import { Nullable } from "babylonjs/types";
  60109. import { Scene } from "babylonjs/scene";
  60110. import { Mesh } from "babylonjs/Meshes/mesh";
  60111. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60112. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60114. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60115. import { Plane } from "babylonjs/Maths/math.plane";
  60116. /**
  60117. * Class containing static functions to help procedurally build meshes
  60118. */
  60119. export class MeshBuilder {
  60120. /**
  60121. * Creates a box mesh
  60122. * * The parameter `size` sets the size (float) of each box side (default 1)
  60123. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60124. * * 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)
  60125. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60129. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60130. * @param name defines the name of the mesh
  60131. * @param options defines the options used to create the mesh
  60132. * @param scene defines the hosting scene
  60133. * @returns the box mesh
  60134. */
  60135. static CreateBox(name: string, options: {
  60136. size?: number;
  60137. width?: number;
  60138. height?: number;
  60139. depth?: number;
  60140. faceUV?: Vector4[];
  60141. faceColors?: Color4[];
  60142. sideOrientation?: number;
  60143. frontUVs?: Vector4;
  60144. backUVs?: Vector4;
  60145. updatable?: boolean;
  60146. }, scene?: Nullable<Scene>): Mesh;
  60147. /**
  60148. * Creates a tiled box mesh
  60149. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60151. * @param name defines the name of the mesh
  60152. * @param options defines the options used to create the mesh
  60153. * @param scene defines the hosting scene
  60154. * @returns the tiled box mesh
  60155. */
  60156. static CreateTiledBox(name: string, options: {
  60157. pattern?: number;
  60158. size?: number;
  60159. width?: number;
  60160. height?: number;
  60161. depth: number;
  60162. tileSize?: number;
  60163. tileWidth?: number;
  60164. tileHeight?: number;
  60165. faceUV?: Vector4[];
  60166. faceColors?: Color4[];
  60167. alignHorizontal?: number;
  60168. alignVertical?: number;
  60169. sideOrientation?: number;
  60170. updatable?: boolean;
  60171. }, scene?: Nullable<Scene>): Mesh;
  60172. /**
  60173. * Creates a sphere mesh
  60174. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60175. * * 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`)
  60176. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60177. * * 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
  60178. * * 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)
  60179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60182. * @param name defines the name of the mesh
  60183. * @param options defines the options used to create the mesh
  60184. * @param scene defines the hosting scene
  60185. * @returns the sphere mesh
  60186. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60187. */
  60188. static CreateSphere(name: string, options: {
  60189. segments?: number;
  60190. diameter?: number;
  60191. diameterX?: number;
  60192. diameterY?: number;
  60193. diameterZ?: number;
  60194. arc?: number;
  60195. slice?: number;
  60196. sideOrientation?: number;
  60197. frontUVs?: Vector4;
  60198. backUVs?: Vector4;
  60199. updatable?: boolean;
  60200. }, scene?: Nullable<Scene>): Mesh;
  60201. /**
  60202. * Creates a plane polygonal mesh. By default, this is a disc
  60203. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60204. * * 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
  60205. * * 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
  60206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60209. * @param name defines the name of the mesh
  60210. * @param options defines the options used to create the mesh
  60211. * @param scene defines the hosting scene
  60212. * @returns the plane polygonal mesh
  60213. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60214. */
  60215. static CreateDisc(name: string, options: {
  60216. radius?: number;
  60217. tessellation?: number;
  60218. arc?: number;
  60219. updatable?: boolean;
  60220. sideOrientation?: number;
  60221. frontUVs?: Vector4;
  60222. backUVs?: Vector4;
  60223. }, scene?: Nullable<Scene>): Mesh;
  60224. /**
  60225. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60226. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60227. * * 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`)
  60228. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60229. * * 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
  60230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60233. * @param name defines the name of the mesh
  60234. * @param options defines the options used to create the mesh
  60235. * @param scene defines the hosting scene
  60236. * @returns the icosahedron mesh
  60237. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60238. */
  60239. static CreateIcoSphere(name: string, options: {
  60240. radius?: number;
  60241. radiusX?: number;
  60242. radiusY?: number;
  60243. radiusZ?: number;
  60244. flat?: boolean;
  60245. subdivisions?: number;
  60246. sideOrientation?: number;
  60247. frontUVs?: Vector4;
  60248. backUVs?: Vector4;
  60249. updatable?: boolean;
  60250. }, scene?: Nullable<Scene>): Mesh;
  60251. /**
  60252. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60253. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60254. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60255. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60256. * * 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
  60257. * * 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
  60258. * * 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
  60259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60261. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60262. * * 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
  60263. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60264. * * 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
  60265. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60267. * @param name defines the name of the mesh
  60268. * @param options defines the options used to create the mesh
  60269. * @param scene defines the hosting scene
  60270. * @returns the ribbon mesh
  60271. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60272. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60273. */
  60274. static CreateRibbon(name: string, options: {
  60275. pathArray: Vector3[][];
  60276. closeArray?: boolean;
  60277. closePath?: boolean;
  60278. offset?: number;
  60279. updatable?: boolean;
  60280. sideOrientation?: number;
  60281. frontUVs?: Vector4;
  60282. backUVs?: Vector4;
  60283. instance?: Mesh;
  60284. invertUV?: boolean;
  60285. uvs?: Vector2[];
  60286. colors?: Color4[];
  60287. }, scene?: Nullable<Scene>): Mesh;
  60288. /**
  60289. * Creates a cylinder or a cone mesh
  60290. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60291. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60292. * * 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.
  60293. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60294. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60295. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60296. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60297. * * 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).
  60298. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60299. * * 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).
  60300. * * 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
  60301. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60302. * * 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
  60303. * * 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.
  60304. * * If `enclose` is false, a ring surface is one element.
  60305. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60306. * * 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
  60307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60310. * @param name defines the name of the mesh
  60311. * @param options defines the options used to create the mesh
  60312. * @param scene defines the hosting scene
  60313. * @returns the cylinder mesh
  60314. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60315. */
  60316. static CreateCylinder(name: string, options: {
  60317. height?: number;
  60318. diameterTop?: number;
  60319. diameterBottom?: number;
  60320. diameter?: number;
  60321. tessellation?: number;
  60322. subdivisions?: number;
  60323. arc?: number;
  60324. faceColors?: Color4[];
  60325. faceUV?: Vector4[];
  60326. updatable?: boolean;
  60327. hasRings?: boolean;
  60328. enclose?: boolean;
  60329. cap?: number;
  60330. sideOrientation?: number;
  60331. frontUVs?: Vector4;
  60332. backUVs?: Vector4;
  60333. }, scene?: Nullable<Scene>): Mesh;
  60334. /**
  60335. * Creates a torus mesh
  60336. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60337. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60338. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60342. * @param name defines the name of the mesh
  60343. * @param options defines the options used to create the mesh
  60344. * @param scene defines the hosting scene
  60345. * @returns the torus mesh
  60346. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60347. */
  60348. static CreateTorus(name: string, options: {
  60349. diameter?: number;
  60350. thickness?: number;
  60351. tessellation?: number;
  60352. updatable?: boolean;
  60353. sideOrientation?: number;
  60354. frontUVs?: Vector4;
  60355. backUVs?: Vector4;
  60356. }, scene?: Nullable<Scene>): Mesh;
  60357. /**
  60358. * Creates a torus knot mesh
  60359. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60360. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60361. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60362. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60366. * @param name defines the name of the mesh
  60367. * @param options defines the options used to create the mesh
  60368. * @param scene defines the hosting scene
  60369. * @returns the torus knot mesh
  60370. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60371. */
  60372. static CreateTorusKnot(name: string, options: {
  60373. radius?: number;
  60374. tube?: number;
  60375. radialSegments?: number;
  60376. tubularSegments?: number;
  60377. p?: number;
  60378. q?: number;
  60379. updatable?: boolean;
  60380. sideOrientation?: number;
  60381. frontUVs?: Vector4;
  60382. backUVs?: Vector4;
  60383. }, scene?: Nullable<Scene>): Mesh;
  60384. /**
  60385. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60386. * * 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
  60387. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60388. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60389. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60390. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60391. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60392. * * 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
  60393. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60396. * @param name defines the name of the new line system
  60397. * @param options defines the options used to create the line system
  60398. * @param scene defines the hosting scene
  60399. * @returns a new line system mesh
  60400. */
  60401. static CreateLineSystem(name: string, options: {
  60402. lines: Vector3[][];
  60403. updatable?: boolean;
  60404. instance?: Nullable<LinesMesh>;
  60405. colors?: Nullable<Color4[][]>;
  60406. useVertexAlpha?: boolean;
  60407. }, scene: Nullable<Scene>): LinesMesh;
  60408. /**
  60409. * Creates a line mesh
  60410. * 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
  60411. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60412. * * The parameter `points` is an array successive Vector3
  60413. * * 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
  60414. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60415. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60416. * * When updating an instance, remember that only point positions can change, not the number of points
  60417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60419. * @param name defines the name of the new line system
  60420. * @param options defines the options used to create the line system
  60421. * @param scene defines the hosting scene
  60422. * @returns a new line mesh
  60423. */
  60424. static CreateLines(name: string, options: {
  60425. points: Vector3[];
  60426. updatable?: boolean;
  60427. instance?: Nullable<LinesMesh>;
  60428. colors?: Color4[];
  60429. useVertexAlpha?: boolean;
  60430. }, scene?: Nullable<Scene>): LinesMesh;
  60431. /**
  60432. * Creates a dashed line mesh
  60433. * * 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
  60434. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60435. * * The parameter `points` is an array successive Vector3
  60436. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60437. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60438. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60439. * * 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
  60440. * * When updating an instance, remember that only point positions can change, not the number of points
  60441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60442. * @param name defines the name of the mesh
  60443. * @param options defines the options used to create the mesh
  60444. * @param scene defines the hosting scene
  60445. * @returns the dashed line mesh
  60446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60447. */
  60448. static CreateDashedLines(name: string, options: {
  60449. points: Vector3[];
  60450. dashSize?: number;
  60451. gapSize?: number;
  60452. dashNb?: number;
  60453. updatable?: boolean;
  60454. instance?: LinesMesh;
  60455. }, scene?: Nullable<Scene>): LinesMesh;
  60456. /**
  60457. * 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.
  60458. * * 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.
  60459. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60460. * * 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.
  60461. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60462. * * 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
  60463. * * 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
  60464. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60467. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60469. * @param name defines the name of the mesh
  60470. * @param options defines the options used to create the mesh
  60471. * @param scene defines the hosting scene
  60472. * @returns the extruded shape mesh
  60473. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60475. */
  60476. static ExtrudeShape(name: string, options: {
  60477. shape: Vector3[];
  60478. path: Vector3[];
  60479. scale?: number;
  60480. rotation?: number;
  60481. cap?: number;
  60482. updatable?: boolean;
  60483. sideOrientation?: number;
  60484. frontUVs?: Vector4;
  60485. backUVs?: Vector4;
  60486. instance?: Mesh;
  60487. invertUV?: boolean;
  60488. }, scene?: Nullable<Scene>): Mesh;
  60489. /**
  60490. * Creates an custom extruded shape mesh.
  60491. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60492. * * 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.
  60493. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60494. * * 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
  60495. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60496. * * 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
  60497. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60498. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60499. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60500. * * 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
  60501. * * 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
  60502. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60507. * @param name defines the name of the mesh
  60508. * @param options defines the options used to create the mesh
  60509. * @param scene defines the hosting scene
  60510. * @returns the custom extruded shape mesh
  60511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60512. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60514. */
  60515. static ExtrudeShapeCustom(name: string, options: {
  60516. shape: Vector3[];
  60517. path: Vector3[];
  60518. scaleFunction?: any;
  60519. rotationFunction?: any;
  60520. ribbonCloseArray?: boolean;
  60521. ribbonClosePath?: boolean;
  60522. cap?: number;
  60523. updatable?: boolean;
  60524. sideOrientation?: number;
  60525. frontUVs?: Vector4;
  60526. backUVs?: Vector4;
  60527. instance?: Mesh;
  60528. invertUV?: boolean;
  60529. }, scene?: Nullable<Scene>): Mesh;
  60530. /**
  60531. * Creates lathe mesh.
  60532. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60533. * * 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
  60534. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60535. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60536. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60537. * * 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
  60538. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60539. * * 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
  60540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60544. * @param name defines the name of the mesh
  60545. * @param options defines the options used to create the mesh
  60546. * @param scene defines the hosting scene
  60547. * @returns the lathe mesh
  60548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60549. */
  60550. static CreateLathe(name: string, options: {
  60551. shape: Vector3[];
  60552. radius?: number;
  60553. tessellation?: number;
  60554. clip?: number;
  60555. arc?: number;
  60556. closed?: boolean;
  60557. updatable?: boolean;
  60558. sideOrientation?: number;
  60559. frontUVs?: Vector4;
  60560. backUVs?: Vector4;
  60561. cap?: number;
  60562. invertUV?: boolean;
  60563. }, scene?: Nullable<Scene>): Mesh;
  60564. /**
  60565. * Creates a tiled plane mesh
  60566. * * You can set a limited pattern arrangement with the tiles
  60567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60570. * @param name defines the name of the mesh
  60571. * @param options defines the options used to create the mesh
  60572. * @param scene defines the hosting scene
  60573. * @returns the plane mesh
  60574. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60575. */
  60576. static CreateTiledPlane(name: string, options: {
  60577. pattern?: number;
  60578. tileSize?: number;
  60579. tileWidth?: number;
  60580. tileHeight?: number;
  60581. size?: number;
  60582. width?: number;
  60583. height?: number;
  60584. alignHorizontal?: number;
  60585. alignVertical?: number;
  60586. sideOrientation?: number;
  60587. frontUVs?: Vector4;
  60588. backUVs?: Vector4;
  60589. updatable?: boolean;
  60590. }, scene?: Nullable<Scene>): Mesh;
  60591. /**
  60592. * Creates a plane mesh
  60593. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60594. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60595. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60599. * @param name defines the name of the mesh
  60600. * @param options defines the options used to create the mesh
  60601. * @param scene defines the hosting scene
  60602. * @returns the plane mesh
  60603. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60604. */
  60605. static CreatePlane(name: string, options: {
  60606. size?: number;
  60607. width?: number;
  60608. height?: number;
  60609. sideOrientation?: number;
  60610. frontUVs?: Vector4;
  60611. backUVs?: Vector4;
  60612. updatable?: boolean;
  60613. sourcePlane?: Plane;
  60614. }, scene?: Nullable<Scene>): Mesh;
  60615. /**
  60616. * Creates a ground mesh
  60617. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60618. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60620. * @param name defines the name of the mesh
  60621. * @param options defines the options used to create the mesh
  60622. * @param scene defines the hosting scene
  60623. * @returns the ground mesh
  60624. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60625. */
  60626. static CreateGround(name: string, options: {
  60627. width?: number;
  60628. height?: number;
  60629. subdivisions?: number;
  60630. subdivisionsX?: number;
  60631. subdivisionsY?: number;
  60632. updatable?: boolean;
  60633. }, scene?: Nullable<Scene>): Mesh;
  60634. /**
  60635. * Creates a tiled ground mesh
  60636. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60637. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60638. * * 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
  60639. * * 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
  60640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60641. * @param name defines the name of the mesh
  60642. * @param options defines the options used to create the mesh
  60643. * @param scene defines the hosting scene
  60644. * @returns the tiled ground mesh
  60645. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60646. */
  60647. static CreateTiledGround(name: string, options: {
  60648. xmin: number;
  60649. zmin: number;
  60650. xmax: number;
  60651. zmax: number;
  60652. subdivisions?: {
  60653. w: number;
  60654. h: number;
  60655. };
  60656. precision?: {
  60657. w: number;
  60658. h: number;
  60659. };
  60660. updatable?: boolean;
  60661. }, scene?: Nullable<Scene>): Mesh;
  60662. /**
  60663. * Creates a ground mesh from a height map
  60664. * * The parameter `url` sets the URL of the height map image resource.
  60665. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60666. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60667. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60668. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60669. * * 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.
  60670. * * 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).
  60671. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60673. * @param name defines the name of the mesh
  60674. * @param url defines the url to the height map
  60675. * @param options defines the options used to create the mesh
  60676. * @param scene defines the hosting scene
  60677. * @returns the ground mesh
  60678. * @see https://doc.babylonjs.com/babylon101/height_map
  60679. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60680. */
  60681. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60682. width?: number;
  60683. height?: number;
  60684. subdivisions?: number;
  60685. minHeight?: number;
  60686. maxHeight?: number;
  60687. colorFilter?: Color3;
  60688. alphaFilter?: number;
  60689. updatable?: boolean;
  60690. onReady?: (mesh: GroundMesh) => void;
  60691. }, scene?: Nullable<Scene>): GroundMesh;
  60692. /**
  60693. * Creates a polygon mesh
  60694. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60695. * * 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
  60696. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60699. * * Remember you can only change the shape positions, not their number when updating a polygon
  60700. * @param name defines the name of the mesh
  60701. * @param options defines the options used to create the mesh
  60702. * @param scene defines the hosting scene
  60703. * @param earcutInjection can be used to inject your own earcut reference
  60704. * @returns the polygon mesh
  60705. */
  60706. static CreatePolygon(name: string, options: {
  60707. shape: Vector3[];
  60708. holes?: Vector3[][];
  60709. depth?: number;
  60710. faceUV?: Vector4[];
  60711. faceColors?: Color4[];
  60712. updatable?: boolean;
  60713. sideOrientation?: number;
  60714. frontUVs?: Vector4;
  60715. backUVs?: Vector4;
  60716. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60717. /**
  60718. * Creates an extruded polygon mesh, with depth in the Y direction.
  60719. * * 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)
  60720. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60721. * @param name defines the name of the mesh
  60722. * @param options defines the options used to create the mesh
  60723. * @param scene defines the hosting scene
  60724. * @param earcutInjection can be used to inject your own earcut reference
  60725. * @returns the polygon mesh
  60726. */
  60727. static ExtrudePolygon(name: string, options: {
  60728. shape: Vector3[];
  60729. holes?: Vector3[][];
  60730. depth?: number;
  60731. faceUV?: Vector4[];
  60732. faceColors?: Color4[];
  60733. updatable?: boolean;
  60734. sideOrientation?: number;
  60735. frontUVs?: Vector4;
  60736. backUVs?: Vector4;
  60737. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60738. /**
  60739. * Creates a tube mesh.
  60740. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60741. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60742. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60743. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60744. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60745. * * 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)
  60746. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60747. * * 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
  60748. * * 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
  60749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60753. * @param name defines the name of the mesh
  60754. * @param options defines the options used to create the mesh
  60755. * @param scene defines the hosting scene
  60756. * @returns the tube mesh
  60757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60758. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60759. */
  60760. static CreateTube(name: string, options: {
  60761. path: Vector3[];
  60762. radius?: number;
  60763. tessellation?: number;
  60764. radiusFunction?: {
  60765. (i: number, distance: number): number;
  60766. };
  60767. cap?: number;
  60768. arc?: number;
  60769. updatable?: boolean;
  60770. sideOrientation?: number;
  60771. frontUVs?: Vector4;
  60772. backUVs?: Vector4;
  60773. instance?: Mesh;
  60774. invertUV?: boolean;
  60775. }, scene?: Nullable<Scene>): Mesh;
  60776. /**
  60777. * Creates a polyhedron mesh
  60778. * * 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
  60779. * * The parameter `size` (positive float, default 1) sets the polygon size
  60780. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60781. * * 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`
  60782. * * 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
  60783. * * 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)`)
  60784. * * 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
  60785. * * 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
  60786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60789. * @param name defines the name of the mesh
  60790. * @param options defines the options used to create the mesh
  60791. * @param scene defines the hosting scene
  60792. * @returns the polyhedron mesh
  60793. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60794. */
  60795. static CreatePolyhedron(name: string, options: {
  60796. type?: number;
  60797. size?: number;
  60798. sizeX?: number;
  60799. sizeY?: number;
  60800. sizeZ?: number;
  60801. custom?: any;
  60802. faceUV?: Vector4[];
  60803. faceColors?: Color4[];
  60804. flat?: boolean;
  60805. updatable?: boolean;
  60806. sideOrientation?: number;
  60807. frontUVs?: Vector4;
  60808. backUVs?: Vector4;
  60809. }, scene?: Nullable<Scene>): Mesh;
  60810. /**
  60811. * Creates a decal mesh.
  60812. * 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
  60813. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60814. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60815. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60816. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60817. * @param name defines the name of the mesh
  60818. * @param sourceMesh defines the mesh where the decal must be applied
  60819. * @param options defines the options used to create the mesh
  60820. * @param scene defines the hosting scene
  60821. * @returns the decal mesh
  60822. * @see https://doc.babylonjs.com/how_to/decals
  60823. */
  60824. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60825. position?: Vector3;
  60826. normal?: Vector3;
  60827. size?: Vector3;
  60828. angle?: number;
  60829. }): Mesh;
  60830. }
  60831. }
  60832. declare module "babylonjs/Meshes/meshSimplification" {
  60833. import { Mesh } from "babylonjs/Meshes/mesh";
  60834. /**
  60835. * A simplifier interface for future simplification implementations
  60836. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60837. */
  60838. export interface ISimplifier {
  60839. /**
  60840. * Simplification of a given mesh according to the given settings.
  60841. * Since this requires computation, it is assumed that the function runs async.
  60842. * @param settings The settings of the simplification, including quality and distance
  60843. * @param successCallback A callback that will be called after the mesh was simplified.
  60844. * @param errorCallback in case of an error, this callback will be called. optional.
  60845. */
  60846. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60847. }
  60848. /**
  60849. * Expected simplification settings.
  60850. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60851. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60852. */
  60853. export interface ISimplificationSettings {
  60854. /**
  60855. * Gets or sets the expected quality
  60856. */
  60857. quality: number;
  60858. /**
  60859. * Gets or sets the distance when this optimized version should be used
  60860. */
  60861. distance: number;
  60862. /**
  60863. * Gets an already optimized mesh
  60864. */
  60865. optimizeMesh?: boolean;
  60866. }
  60867. /**
  60868. * Class used to specify simplification options
  60869. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60870. */
  60871. export class SimplificationSettings implements ISimplificationSettings {
  60872. /** expected quality */
  60873. quality: number;
  60874. /** distance when this optimized version should be used */
  60875. distance: number;
  60876. /** already optimized mesh */
  60877. optimizeMesh?: boolean | undefined;
  60878. /**
  60879. * Creates a SimplificationSettings
  60880. * @param quality expected quality
  60881. * @param distance distance when this optimized version should be used
  60882. * @param optimizeMesh already optimized mesh
  60883. */
  60884. constructor(
  60885. /** expected quality */
  60886. quality: number,
  60887. /** distance when this optimized version should be used */
  60888. distance: number,
  60889. /** already optimized mesh */
  60890. optimizeMesh?: boolean | undefined);
  60891. }
  60892. /**
  60893. * Interface used to define a simplification task
  60894. */
  60895. export interface ISimplificationTask {
  60896. /**
  60897. * Array of settings
  60898. */
  60899. settings: Array<ISimplificationSettings>;
  60900. /**
  60901. * Simplification type
  60902. */
  60903. simplificationType: SimplificationType;
  60904. /**
  60905. * Mesh to simplify
  60906. */
  60907. mesh: Mesh;
  60908. /**
  60909. * Callback called on success
  60910. */
  60911. successCallback?: () => void;
  60912. /**
  60913. * Defines if parallel processing can be used
  60914. */
  60915. parallelProcessing: boolean;
  60916. }
  60917. /**
  60918. * Queue used to order the simplification tasks
  60919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60920. */
  60921. export class SimplificationQueue {
  60922. private _simplificationArray;
  60923. /**
  60924. * Gets a boolean indicating that the process is still running
  60925. */
  60926. running: boolean;
  60927. /**
  60928. * Creates a new queue
  60929. */
  60930. constructor();
  60931. /**
  60932. * Adds a new simplification task
  60933. * @param task defines a task to add
  60934. */
  60935. addTask(task: ISimplificationTask): void;
  60936. /**
  60937. * Execute next task
  60938. */
  60939. executeNext(): void;
  60940. /**
  60941. * Execute a simplification task
  60942. * @param task defines the task to run
  60943. */
  60944. runSimplification(task: ISimplificationTask): void;
  60945. private getSimplifier;
  60946. }
  60947. /**
  60948. * The implemented types of simplification
  60949. * At the moment only Quadratic Error Decimation is implemented
  60950. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60951. */
  60952. export enum SimplificationType {
  60953. /** Quadratic error decimation */
  60954. QUADRATIC = 0
  60955. }
  60956. }
  60957. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60958. import { Scene } from "babylonjs/scene";
  60959. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60960. import { ISceneComponent } from "babylonjs/sceneComponent";
  60961. module "babylonjs/scene" {
  60962. interface Scene {
  60963. /** @hidden (Backing field) */
  60964. _simplificationQueue: SimplificationQueue;
  60965. /**
  60966. * Gets or sets the simplification queue attached to the scene
  60967. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60968. */
  60969. simplificationQueue: SimplificationQueue;
  60970. }
  60971. }
  60972. module "babylonjs/Meshes/mesh" {
  60973. interface Mesh {
  60974. /**
  60975. * Simplify the mesh according to the given array of settings.
  60976. * Function will return immediately and will simplify async
  60977. * @param settings a collection of simplification settings
  60978. * @param parallelProcessing should all levels calculate parallel or one after the other
  60979. * @param simplificationType the type of simplification to run
  60980. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60981. * @returns the current mesh
  60982. */
  60983. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60984. }
  60985. }
  60986. /**
  60987. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60988. * created in a scene
  60989. */
  60990. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60991. /**
  60992. * The component name helpfull to identify the component in the list of scene components.
  60993. */
  60994. readonly name: string;
  60995. /**
  60996. * The scene the component belongs to.
  60997. */
  60998. scene: Scene;
  60999. /**
  61000. * Creates a new instance of the component for the given scene
  61001. * @param scene Defines the scene to register the component in
  61002. */
  61003. constructor(scene: Scene);
  61004. /**
  61005. * Registers the component in a given scene
  61006. */
  61007. register(): void;
  61008. /**
  61009. * Rebuilds the elements related to this component in case of
  61010. * context lost for instance.
  61011. */
  61012. rebuild(): void;
  61013. /**
  61014. * Disposes the component and the associated ressources
  61015. */
  61016. dispose(): void;
  61017. private _beforeCameraUpdate;
  61018. }
  61019. }
  61020. declare module "babylonjs/Meshes/Builders/index" {
  61021. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61022. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61023. export * from "babylonjs/Meshes/Builders/discBuilder";
  61024. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61025. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61026. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61027. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61028. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61029. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61030. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61031. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61032. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61033. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61034. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61035. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61036. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61037. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61038. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61039. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61040. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61041. }
  61042. declare module "babylonjs/Meshes/index" {
  61043. export * from "babylonjs/Meshes/abstractMesh";
  61044. export * from "babylonjs/Meshes/buffer";
  61045. export * from "babylonjs/Meshes/Compression/index";
  61046. export * from "babylonjs/Meshes/csg";
  61047. export * from "babylonjs/Meshes/geometry";
  61048. export * from "babylonjs/Meshes/groundMesh";
  61049. export * from "babylonjs/Meshes/trailMesh";
  61050. export * from "babylonjs/Meshes/instancedMesh";
  61051. export * from "babylonjs/Meshes/linesMesh";
  61052. export * from "babylonjs/Meshes/mesh";
  61053. export * from "babylonjs/Meshes/mesh.vertexData";
  61054. export * from "babylonjs/Meshes/meshBuilder";
  61055. export * from "babylonjs/Meshes/meshSimplification";
  61056. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61057. export * from "babylonjs/Meshes/polygonMesh";
  61058. export * from "babylonjs/Meshes/subMesh";
  61059. export * from "babylonjs/Meshes/meshLODLevel";
  61060. export * from "babylonjs/Meshes/transformNode";
  61061. export * from "babylonjs/Meshes/Builders/index";
  61062. export * from "babylonjs/Meshes/dataBuffer";
  61063. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61064. }
  61065. declare module "babylonjs/Morph/index" {
  61066. export * from "babylonjs/Morph/morphTarget";
  61067. export * from "babylonjs/Morph/morphTargetManager";
  61068. }
  61069. declare module "babylonjs/Navigation/INavigationEngine" {
  61070. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61071. import { Vector3 } from "babylonjs/Maths/math";
  61072. import { Mesh } from "babylonjs/Meshes/mesh";
  61073. import { Scene } from "babylonjs/scene";
  61074. /**
  61075. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61076. */
  61077. export interface INavigationEnginePlugin {
  61078. /**
  61079. * plugin name
  61080. */
  61081. name: string;
  61082. /**
  61083. * Creates a navigation mesh
  61084. * @param meshes array of all the geometry used to compute the navigatio mesh
  61085. * @param parameters bunch of parameters used to filter geometry
  61086. */
  61087. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61088. /**
  61089. * Create a navigation mesh debug mesh
  61090. * @param scene is where the mesh will be added
  61091. * @returns debug display mesh
  61092. */
  61093. createDebugNavMesh(scene: Scene): Mesh;
  61094. /**
  61095. * Get a navigation mesh constrained position, closest to the parameter position
  61096. * @param position world position
  61097. * @returns the closest point to position constrained by the navigation mesh
  61098. */
  61099. getClosestPoint(position: Vector3): Vector3;
  61100. /**
  61101. * Get a navigation mesh constrained position, within a particular radius
  61102. * @param position world position
  61103. * @param maxRadius the maximum distance to the constrained world position
  61104. * @returns the closest point to position constrained by the navigation mesh
  61105. */
  61106. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61107. /**
  61108. * Compute the final position from a segment made of destination-position
  61109. * @param position world position
  61110. * @param destination world position
  61111. * @returns the resulting point along the navmesh
  61112. */
  61113. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61114. /**
  61115. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61116. * @param start world position
  61117. * @param end world position
  61118. * @returns array containing world position composing the path
  61119. */
  61120. computePath(start: Vector3, end: Vector3): Vector3[];
  61121. /**
  61122. * If this plugin is supported
  61123. * @returns true if plugin is supported
  61124. */
  61125. isSupported(): boolean;
  61126. /**
  61127. * Create a new Crowd so you can add agents
  61128. * @param maxAgents the maximum agent count in the crowd
  61129. * @param maxAgentRadius the maximum radius an agent can have
  61130. * @param scene to attach the crowd to
  61131. * @returns the crowd you can add agents to
  61132. */
  61133. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61134. /**
  61135. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61136. * The queries will try to find a solution within those bounds
  61137. * default is (1,1,1)
  61138. * @param extent x,y,z value that define the extent around the queries point of reference
  61139. */
  61140. setDefaultQueryExtent(extent: Vector3): void;
  61141. /**
  61142. * Get the Bounding box extent specified by setDefaultQueryExtent
  61143. * @returns the box extent values
  61144. */
  61145. getDefaultQueryExtent(): Vector3;
  61146. /**
  61147. * Release all resources
  61148. */
  61149. dispose(): void;
  61150. }
  61151. /**
  61152. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61153. */
  61154. export interface ICrowd {
  61155. /**
  61156. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61157. * You can attach anything to that node. The node position is updated in the scene update tick.
  61158. * @param pos world position that will be constrained by the navigation mesh
  61159. * @param parameters agent parameters
  61160. * @param transform hooked to the agent that will be update by the scene
  61161. * @returns agent index
  61162. */
  61163. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61164. /**
  61165. * Returns the agent position in world space
  61166. * @param index agent index returned by addAgent
  61167. * @returns world space position
  61168. */
  61169. getAgentPosition(index: number): Vector3;
  61170. /**
  61171. * Gets the agent velocity in world space
  61172. * @param index agent index returned by addAgent
  61173. * @returns world space velocity
  61174. */
  61175. getAgentVelocity(index: number): Vector3;
  61176. /**
  61177. * remove a particular agent previously created
  61178. * @param index agent index returned by addAgent
  61179. */
  61180. removeAgent(index: number): void;
  61181. /**
  61182. * get the list of all agents attached to this crowd
  61183. * @returns list of agent indices
  61184. */
  61185. getAgents(): number[];
  61186. /**
  61187. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61188. * @param deltaTime in seconds
  61189. */
  61190. update(deltaTime: number): void;
  61191. /**
  61192. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61193. * @param index agent index returned by addAgent
  61194. * @param destination targeted world position
  61195. */
  61196. agentGoto(index: number, destination: Vector3): void;
  61197. /**
  61198. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61199. * The queries will try to find a solution within those bounds
  61200. * default is (1,1,1)
  61201. * @param extent x,y,z value that define the extent around the queries point of reference
  61202. */
  61203. setDefaultQueryExtent(extent: Vector3): void;
  61204. /**
  61205. * Get the Bounding box extent specified by setDefaultQueryExtent
  61206. * @returns the box extent values
  61207. */
  61208. getDefaultQueryExtent(): Vector3;
  61209. /**
  61210. * Release all resources
  61211. */
  61212. dispose(): void;
  61213. }
  61214. /**
  61215. * Configures an agent
  61216. */
  61217. export interface IAgentParameters {
  61218. /**
  61219. * Agent radius. [Limit: >= 0]
  61220. */
  61221. radius: number;
  61222. /**
  61223. * Agent height. [Limit: > 0]
  61224. */
  61225. height: number;
  61226. /**
  61227. * Maximum allowed acceleration. [Limit: >= 0]
  61228. */
  61229. maxAcceleration: number;
  61230. /**
  61231. * Maximum allowed speed. [Limit: >= 0]
  61232. */
  61233. maxSpeed: number;
  61234. /**
  61235. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61236. */
  61237. collisionQueryRange: number;
  61238. /**
  61239. * The path visibility optimization range. [Limit: > 0]
  61240. */
  61241. pathOptimizationRange: number;
  61242. /**
  61243. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61244. */
  61245. separationWeight: number;
  61246. }
  61247. /**
  61248. * Configures the navigation mesh creation
  61249. */
  61250. export interface INavMeshParameters {
  61251. /**
  61252. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61253. */
  61254. cs: number;
  61255. /**
  61256. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61257. */
  61258. ch: number;
  61259. /**
  61260. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61261. */
  61262. walkableSlopeAngle: number;
  61263. /**
  61264. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61265. * be considered walkable. [Limit: >= 3] [Units: vx]
  61266. */
  61267. walkableHeight: number;
  61268. /**
  61269. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61270. */
  61271. walkableClimb: number;
  61272. /**
  61273. * The distance to erode/shrink the walkable area of the heightfield away from
  61274. * obstructions. [Limit: >=0] [Units: vx]
  61275. */
  61276. walkableRadius: number;
  61277. /**
  61278. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61279. */
  61280. maxEdgeLen: number;
  61281. /**
  61282. * The maximum distance a simplfied contour's border edges should deviate
  61283. * the original raw contour. [Limit: >=0] [Units: vx]
  61284. */
  61285. maxSimplificationError: number;
  61286. /**
  61287. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61288. */
  61289. minRegionArea: number;
  61290. /**
  61291. * Any regions with a span count smaller than this value will, if possible,
  61292. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61293. */
  61294. mergeRegionArea: number;
  61295. /**
  61296. * The maximum number of vertices allowed for polygons generated during the
  61297. * contour to polygon conversion process. [Limit: >= 3]
  61298. */
  61299. maxVertsPerPoly: number;
  61300. /**
  61301. * Sets the sampling distance to use when generating the detail mesh.
  61302. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61303. */
  61304. detailSampleDist: number;
  61305. /**
  61306. * The maximum distance the detail mesh surface should deviate from heightfield
  61307. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61308. */
  61309. detailSampleMaxError: number;
  61310. }
  61311. }
  61312. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61313. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61314. import { Mesh } from "babylonjs/Meshes/mesh";
  61315. import { Scene } from "babylonjs/scene";
  61316. import { Vector3 } from "babylonjs/Maths/math";
  61317. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61318. /**
  61319. * RecastJS navigation plugin
  61320. */
  61321. export class RecastJSPlugin implements INavigationEnginePlugin {
  61322. /**
  61323. * Reference to the Recast library
  61324. */
  61325. bjsRECAST: any;
  61326. /**
  61327. * plugin name
  61328. */
  61329. name: string;
  61330. /**
  61331. * the first navmesh created. We might extend this to support multiple navmeshes
  61332. */
  61333. navMesh: any;
  61334. /**
  61335. * Initializes the recastJS plugin
  61336. * @param recastInjection can be used to inject your own recast reference
  61337. */
  61338. constructor(recastInjection?: any);
  61339. /**
  61340. * Creates a navigation mesh
  61341. * @param meshes array of all the geometry used to compute the navigatio mesh
  61342. * @param parameters bunch of parameters used to filter geometry
  61343. */
  61344. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61345. /**
  61346. * Create a navigation mesh debug mesh
  61347. * @param scene is where the mesh will be added
  61348. * @returns debug display mesh
  61349. */
  61350. createDebugNavMesh(scene: Scene): Mesh;
  61351. /**
  61352. * Get a navigation mesh constrained position, closest to the parameter position
  61353. * @param position world position
  61354. * @returns the closest point to position constrained by the navigation mesh
  61355. */
  61356. getClosestPoint(position: Vector3): Vector3;
  61357. /**
  61358. * Get a navigation mesh constrained position, within a particular radius
  61359. * @param position world position
  61360. * @param maxRadius the maximum distance to the constrained world position
  61361. * @returns the closest point to position constrained by the navigation mesh
  61362. */
  61363. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61364. /**
  61365. * Compute the final position from a segment made of destination-position
  61366. * @param position world position
  61367. * @param destination world position
  61368. * @returns the resulting point along the navmesh
  61369. */
  61370. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61371. /**
  61372. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61373. * @param start world position
  61374. * @param end world position
  61375. * @returns array containing world position composing the path
  61376. */
  61377. computePath(start: Vector3, end: Vector3): Vector3[];
  61378. /**
  61379. * Create a new Crowd so you can add agents
  61380. * @param maxAgents the maximum agent count in the crowd
  61381. * @param maxAgentRadius the maximum radius an agent can have
  61382. * @param scene to attach the crowd to
  61383. * @returns the crowd you can add agents to
  61384. */
  61385. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61386. /**
  61387. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61388. * The queries will try to find a solution within those bounds
  61389. * default is (1,1,1)
  61390. * @param extent x,y,z value that define the extent around the queries point of reference
  61391. */
  61392. setDefaultQueryExtent(extent: Vector3): void;
  61393. /**
  61394. * Get the Bounding box extent specified by setDefaultQueryExtent
  61395. * @returns the box extent values
  61396. */
  61397. getDefaultQueryExtent(): Vector3;
  61398. /**
  61399. * Disposes
  61400. */
  61401. dispose(): void;
  61402. /**
  61403. * If this plugin is supported
  61404. * @returns true if plugin is supported
  61405. */
  61406. isSupported(): boolean;
  61407. }
  61408. /**
  61409. * Recast detour crowd implementation
  61410. */
  61411. export class RecastJSCrowd implements ICrowd {
  61412. /**
  61413. * Recast/detour plugin
  61414. */
  61415. bjsRECASTPlugin: RecastJSPlugin;
  61416. /**
  61417. * Link to the detour crowd
  61418. */
  61419. recastCrowd: any;
  61420. /**
  61421. * One transform per agent
  61422. */
  61423. transforms: TransformNode[];
  61424. /**
  61425. * All agents created
  61426. */
  61427. agents: number[];
  61428. /**
  61429. * Link to the scene is kept to unregister the crowd from the scene
  61430. */
  61431. private _scene;
  61432. /**
  61433. * Observer for crowd updates
  61434. */
  61435. private _onBeforeAnimationsObserver;
  61436. /**
  61437. * Constructor
  61438. * @param plugin recastJS plugin
  61439. * @param maxAgents the maximum agent count in the crowd
  61440. * @param maxAgentRadius the maximum radius an agent can have
  61441. * @param scene to attach the crowd to
  61442. * @returns the crowd you can add agents to
  61443. */
  61444. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61445. /**
  61446. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61447. * You can attach anything to that node. The node position is updated in the scene update tick.
  61448. * @param pos world position that will be constrained by the navigation mesh
  61449. * @param parameters agent parameters
  61450. * @param transform hooked to the agent that will be update by the scene
  61451. * @returns agent index
  61452. */
  61453. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61454. /**
  61455. * Returns the agent position in world space
  61456. * @param index agent index returned by addAgent
  61457. * @returns world space position
  61458. */
  61459. getAgentPosition(index: number): Vector3;
  61460. /**
  61461. * Returns the agent velocity in world space
  61462. * @param index agent index returned by addAgent
  61463. * @returns world space velocity
  61464. */
  61465. getAgentVelocity(index: number): Vector3;
  61466. /**
  61467. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61468. * @param index agent index returned by addAgent
  61469. * @param destination targeted world position
  61470. */
  61471. agentGoto(index: number, destination: Vector3): void;
  61472. /**
  61473. * remove a particular agent previously created
  61474. * @param index agent index returned by addAgent
  61475. */
  61476. removeAgent(index: number): void;
  61477. /**
  61478. * get the list of all agents attached to this crowd
  61479. * @returns list of agent indices
  61480. */
  61481. getAgents(): number[];
  61482. /**
  61483. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61484. * @param deltaTime in seconds
  61485. */
  61486. update(deltaTime: number): void;
  61487. /**
  61488. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61489. * The queries will try to find a solution within those bounds
  61490. * default is (1,1,1)
  61491. * @param extent x,y,z value that define the extent around the queries point of reference
  61492. */
  61493. setDefaultQueryExtent(extent: Vector3): void;
  61494. /**
  61495. * Get the Bounding box extent specified by setDefaultQueryExtent
  61496. * @returns the box extent values
  61497. */
  61498. getDefaultQueryExtent(): Vector3;
  61499. /**
  61500. * Release all resources
  61501. */
  61502. dispose(): void;
  61503. }
  61504. }
  61505. declare module "babylonjs/Navigation/Plugins/index" {
  61506. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61507. }
  61508. declare module "babylonjs/Navigation/index" {
  61509. export * from "babylonjs/Navigation/INavigationEngine";
  61510. export * from "babylonjs/Navigation/Plugins/index";
  61511. }
  61512. declare module "babylonjs/Offline/database" {
  61513. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61514. /**
  61515. * Class used to enable access to IndexedDB
  61516. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61517. */
  61518. export class Database implements IOfflineProvider {
  61519. private _callbackManifestChecked;
  61520. private _currentSceneUrl;
  61521. private _db;
  61522. private _enableSceneOffline;
  61523. private _enableTexturesOffline;
  61524. private _manifestVersionFound;
  61525. private _mustUpdateRessources;
  61526. private _hasReachedQuota;
  61527. private _isSupported;
  61528. private _idbFactory;
  61529. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61530. private static IsUASupportingBlobStorage;
  61531. /**
  61532. * Gets a boolean indicating if Database storate is enabled (off by default)
  61533. */
  61534. static IDBStorageEnabled: boolean;
  61535. /**
  61536. * Gets a boolean indicating if scene must be saved in the database
  61537. */
  61538. readonly enableSceneOffline: boolean;
  61539. /**
  61540. * Gets a boolean indicating if textures must be saved in the database
  61541. */
  61542. readonly enableTexturesOffline: boolean;
  61543. /**
  61544. * Creates a new Database
  61545. * @param urlToScene defines the url to load the scene
  61546. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61547. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61548. */
  61549. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61550. private static _ParseURL;
  61551. private static _ReturnFullUrlLocation;
  61552. private _checkManifestFile;
  61553. /**
  61554. * Open the database and make it available
  61555. * @param successCallback defines the callback to call on success
  61556. * @param errorCallback defines the callback to call on error
  61557. */
  61558. open(successCallback: () => void, errorCallback: () => void): void;
  61559. /**
  61560. * Loads an image from the database
  61561. * @param url defines the url to load from
  61562. * @param image defines the target DOM image
  61563. */
  61564. loadImage(url: string, image: HTMLImageElement): void;
  61565. private _loadImageFromDBAsync;
  61566. private _saveImageIntoDBAsync;
  61567. private _checkVersionFromDB;
  61568. private _loadVersionFromDBAsync;
  61569. private _saveVersionIntoDBAsync;
  61570. /**
  61571. * Loads a file from database
  61572. * @param url defines the URL to load from
  61573. * @param sceneLoaded defines a callback to call on success
  61574. * @param progressCallBack defines a callback to call when progress changed
  61575. * @param errorCallback defines a callback to call on error
  61576. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61577. */
  61578. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61579. private _loadFileAsync;
  61580. private _saveFileAsync;
  61581. /**
  61582. * Validates if xhr data is correct
  61583. * @param xhr defines the request to validate
  61584. * @param dataType defines the expected data type
  61585. * @returns true if data is correct
  61586. */
  61587. private static _ValidateXHRData;
  61588. }
  61589. }
  61590. declare module "babylonjs/Offline/index" {
  61591. export * from "babylonjs/Offline/database";
  61592. export * from "babylonjs/Offline/IOfflineProvider";
  61593. }
  61594. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61595. /** @hidden */
  61596. export var gpuUpdateParticlesPixelShader: {
  61597. name: string;
  61598. shader: string;
  61599. };
  61600. }
  61601. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61602. /** @hidden */
  61603. export var gpuUpdateParticlesVertexShader: {
  61604. name: string;
  61605. shader: string;
  61606. };
  61607. }
  61608. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61609. /** @hidden */
  61610. export var clipPlaneFragmentDeclaration2: {
  61611. name: string;
  61612. shader: string;
  61613. };
  61614. }
  61615. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61616. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61617. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61618. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61619. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61620. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61621. /** @hidden */
  61622. export var gpuRenderParticlesPixelShader: {
  61623. name: string;
  61624. shader: string;
  61625. };
  61626. }
  61627. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61628. /** @hidden */
  61629. export var clipPlaneVertexDeclaration2: {
  61630. name: string;
  61631. shader: string;
  61632. };
  61633. }
  61634. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61635. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61637. /** @hidden */
  61638. export var gpuRenderParticlesVertexShader: {
  61639. name: string;
  61640. shader: string;
  61641. };
  61642. }
  61643. declare module "babylonjs/Particles/gpuParticleSystem" {
  61644. import { Nullable } from "babylonjs/types";
  61645. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61646. import { Observable } from "babylonjs/Misc/observable";
  61647. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61648. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61649. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61650. import { Scene, IDisposable } from "babylonjs/scene";
  61651. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61652. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61653. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61654. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61655. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61656. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61657. /**
  61658. * This represents a GPU particle system in Babylon
  61659. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61660. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61661. */
  61662. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61663. /**
  61664. * The layer mask we are rendering the particles through.
  61665. */
  61666. layerMask: number;
  61667. private _capacity;
  61668. private _activeCount;
  61669. private _currentActiveCount;
  61670. private _accumulatedCount;
  61671. private _renderEffect;
  61672. private _updateEffect;
  61673. private _buffer0;
  61674. private _buffer1;
  61675. private _spriteBuffer;
  61676. private _updateVAO;
  61677. private _renderVAO;
  61678. private _targetIndex;
  61679. private _sourceBuffer;
  61680. private _targetBuffer;
  61681. private _engine;
  61682. private _currentRenderId;
  61683. private _started;
  61684. private _stopped;
  61685. private _timeDelta;
  61686. private _randomTexture;
  61687. private _randomTexture2;
  61688. private _attributesStrideSize;
  61689. private _updateEffectOptions;
  61690. private _randomTextureSize;
  61691. private _actualFrame;
  61692. private readonly _rawTextureWidth;
  61693. /**
  61694. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61695. */
  61696. static readonly IsSupported: boolean;
  61697. /**
  61698. * An event triggered when the system is disposed.
  61699. */
  61700. onDisposeObservable: Observable<GPUParticleSystem>;
  61701. /**
  61702. * Gets the maximum number of particles active at the same time.
  61703. * @returns The max number of active particles.
  61704. */
  61705. getCapacity(): number;
  61706. /**
  61707. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61708. * to override the particles.
  61709. */
  61710. forceDepthWrite: boolean;
  61711. /**
  61712. * Gets or set the number of active particles
  61713. */
  61714. activeParticleCount: number;
  61715. private _preWarmDone;
  61716. /**
  61717. * Is this system ready to be used/rendered
  61718. * @return true if the system is ready
  61719. */
  61720. isReady(): boolean;
  61721. /**
  61722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61723. * @returns True if it has been started, otherwise false.
  61724. */
  61725. isStarted(): boolean;
  61726. /**
  61727. * Starts the particle system and begins to emit
  61728. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61729. */
  61730. start(delay?: number): void;
  61731. /**
  61732. * Stops the particle system.
  61733. */
  61734. stop(): void;
  61735. /**
  61736. * Remove all active particles
  61737. */
  61738. reset(): void;
  61739. /**
  61740. * Returns the string "GPUParticleSystem"
  61741. * @returns a string containing the class name
  61742. */
  61743. getClassName(): string;
  61744. private _colorGradientsTexture;
  61745. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61746. /**
  61747. * Adds a new color gradient
  61748. * @param gradient defines the gradient to use (between 0 and 1)
  61749. * @param color1 defines the color to affect to the specified gradient
  61750. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61751. * @returns the current particle system
  61752. */
  61753. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61754. /**
  61755. * Remove a specific color gradient
  61756. * @param gradient defines the gradient to remove
  61757. * @returns the current particle system
  61758. */
  61759. removeColorGradient(gradient: number): GPUParticleSystem;
  61760. private _angularSpeedGradientsTexture;
  61761. private _sizeGradientsTexture;
  61762. private _velocityGradientsTexture;
  61763. private _limitVelocityGradientsTexture;
  61764. private _dragGradientsTexture;
  61765. private _addFactorGradient;
  61766. /**
  61767. * Adds a new size gradient
  61768. * @param gradient defines the gradient to use (between 0 and 1)
  61769. * @param factor defines the size factor to affect to the specified gradient
  61770. * @returns the current particle system
  61771. */
  61772. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61773. /**
  61774. * Remove a specific size gradient
  61775. * @param gradient defines the gradient to remove
  61776. * @returns the current particle system
  61777. */
  61778. removeSizeGradient(gradient: number): GPUParticleSystem;
  61779. /**
  61780. * Adds a new angular speed gradient
  61781. * @param gradient defines the gradient to use (between 0 and 1)
  61782. * @param factor defines the angular speed to affect to the specified gradient
  61783. * @returns the current particle system
  61784. */
  61785. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61786. /**
  61787. * Remove a specific angular speed gradient
  61788. * @param gradient defines the gradient to remove
  61789. * @returns the current particle system
  61790. */
  61791. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61792. /**
  61793. * Adds a new velocity gradient
  61794. * @param gradient defines the gradient to use (between 0 and 1)
  61795. * @param factor defines the velocity to affect to the specified gradient
  61796. * @returns the current particle system
  61797. */
  61798. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61799. /**
  61800. * Remove a specific velocity gradient
  61801. * @param gradient defines the gradient to remove
  61802. * @returns the current particle system
  61803. */
  61804. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61805. /**
  61806. * Adds a new limit velocity gradient
  61807. * @param gradient defines the gradient to use (between 0 and 1)
  61808. * @param factor defines the limit velocity value to affect to the specified gradient
  61809. * @returns the current particle system
  61810. */
  61811. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61812. /**
  61813. * Remove a specific limit velocity gradient
  61814. * @param gradient defines the gradient to remove
  61815. * @returns the current particle system
  61816. */
  61817. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61818. /**
  61819. * Adds a new drag gradient
  61820. * @param gradient defines the gradient to use (between 0 and 1)
  61821. * @param factor defines the drag value to affect to the specified gradient
  61822. * @returns the current particle system
  61823. */
  61824. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61825. /**
  61826. * Remove a specific drag gradient
  61827. * @param gradient defines the gradient to remove
  61828. * @returns the current particle system
  61829. */
  61830. removeDragGradient(gradient: number): GPUParticleSystem;
  61831. /**
  61832. * Not supported by GPUParticleSystem
  61833. * @param gradient defines the gradient to use (between 0 and 1)
  61834. * @param factor defines the emit rate value to affect to the specified gradient
  61835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61836. * @returns the current particle system
  61837. */
  61838. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61839. /**
  61840. * Not supported by GPUParticleSystem
  61841. * @param gradient defines the gradient to remove
  61842. * @returns the current particle system
  61843. */
  61844. removeEmitRateGradient(gradient: number): IParticleSystem;
  61845. /**
  61846. * Not supported by GPUParticleSystem
  61847. * @param gradient defines the gradient to use (between 0 and 1)
  61848. * @param factor defines the start size value to affect to the specified gradient
  61849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61850. * @returns the current particle system
  61851. */
  61852. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61853. /**
  61854. * Not supported by GPUParticleSystem
  61855. * @param gradient defines the gradient to remove
  61856. * @returns the current particle system
  61857. */
  61858. removeStartSizeGradient(gradient: number): IParticleSystem;
  61859. /**
  61860. * Not supported by GPUParticleSystem
  61861. * @param gradient defines the gradient to use (between 0 and 1)
  61862. * @param min defines the color remap minimal range
  61863. * @param max defines the color remap maximal range
  61864. * @returns the current particle system
  61865. */
  61866. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61867. /**
  61868. * Not supported by GPUParticleSystem
  61869. * @param gradient defines the gradient to remove
  61870. * @returns the current particle system
  61871. */
  61872. removeColorRemapGradient(): IParticleSystem;
  61873. /**
  61874. * Not supported by GPUParticleSystem
  61875. * @param gradient defines the gradient to use (between 0 and 1)
  61876. * @param min defines the alpha remap minimal range
  61877. * @param max defines the alpha remap maximal range
  61878. * @returns the current particle system
  61879. */
  61880. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61881. /**
  61882. * Not supported by GPUParticleSystem
  61883. * @param gradient defines the gradient to remove
  61884. * @returns the current particle system
  61885. */
  61886. removeAlphaRemapGradient(): IParticleSystem;
  61887. /**
  61888. * Not supported by GPUParticleSystem
  61889. * @param gradient defines the gradient to use (between 0 and 1)
  61890. * @param color defines the color to affect to the specified gradient
  61891. * @returns the current particle system
  61892. */
  61893. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61894. /**
  61895. * Not supported by GPUParticleSystem
  61896. * @param gradient defines the gradient to remove
  61897. * @returns the current particle system
  61898. */
  61899. removeRampGradient(): IParticleSystem;
  61900. /**
  61901. * Not supported by GPUParticleSystem
  61902. * @returns the list of ramp gradients
  61903. */
  61904. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61905. /**
  61906. * Not supported by GPUParticleSystem
  61907. * Gets or sets a boolean indicating that ramp gradients must be used
  61908. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61909. */
  61910. useRampGradients: boolean;
  61911. /**
  61912. * Not supported by GPUParticleSystem
  61913. * @param gradient defines the gradient to use (between 0 and 1)
  61914. * @param factor defines the life time factor to affect to the specified gradient
  61915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61916. * @returns the current particle system
  61917. */
  61918. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61919. /**
  61920. * Not supported by GPUParticleSystem
  61921. * @param gradient defines the gradient to remove
  61922. * @returns the current particle system
  61923. */
  61924. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61925. /**
  61926. * Instantiates a GPU particle system.
  61927. * 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.
  61928. * @param name The name of the particle system
  61929. * @param options The options used to create the system
  61930. * @param scene The scene the particle system belongs to
  61931. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61932. */
  61933. constructor(name: string, options: Partial<{
  61934. capacity: number;
  61935. randomTextureSize: number;
  61936. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61937. protected _reset(): void;
  61938. private _createUpdateVAO;
  61939. private _createRenderVAO;
  61940. private _initialize;
  61941. /** @hidden */
  61942. _recreateUpdateEffect(): void;
  61943. /** @hidden */
  61944. _recreateRenderEffect(): void;
  61945. /**
  61946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61947. * @param preWarm defines if we are in the pre-warmimg phase
  61948. */
  61949. animate(preWarm?: boolean): void;
  61950. private _createFactorGradientTexture;
  61951. private _createSizeGradientTexture;
  61952. private _createAngularSpeedGradientTexture;
  61953. private _createVelocityGradientTexture;
  61954. private _createLimitVelocityGradientTexture;
  61955. private _createDragGradientTexture;
  61956. private _createColorGradientTexture;
  61957. /**
  61958. * Renders the particle system in its current state
  61959. * @param preWarm defines if the system should only update the particles but not render them
  61960. * @returns the current number of particles
  61961. */
  61962. render(preWarm?: boolean): number;
  61963. /**
  61964. * Rebuilds the particle system
  61965. */
  61966. rebuild(): void;
  61967. private _releaseBuffers;
  61968. private _releaseVAOs;
  61969. /**
  61970. * Disposes the particle system and free the associated resources
  61971. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61972. */
  61973. dispose(disposeTexture?: boolean): void;
  61974. /**
  61975. * Clones the particle system.
  61976. * @param name The name of the cloned object
  61977. * @param newEmitter The new emitter to use
  61978. * @returns the cloned particle system
  61979. */
  61980. clone(name: string, newEmitter: any): GPUParticleSystem;
  61981. /**
  61982. * Serializes the particle system to a JSON object.
  61983. * @returns the JSON object
  61984. */
  61985. serialize(): any;
  61986. /**
  61987. * Parses a JSON object to create a GPU particle system.
  61988. * @param parsedParticleSystem The JSON object to parse
  61989. * @param scene The scene to create the particle system in
  61990. * @param rootUrl The root url to use to load external dependencies like texture
  61991. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61992. * @returns the parsed GPU particle system
  61993. */
  61994. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61995. }
  61996. }
  61997. declare module "babylonjs/Particles/particleSystemSet" {
  61998. import { Nullable } from "babylonjs/types";
  61999. import { Color3 } from "babylonjs/Maths/math.color";
  62000. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62002. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62003. import { Scene, IDisposable } from "babylonjs/scene";
  62004. /**
  62005. * Represents a set of particle systems working together to create a specific effect
  62006. */
  62007. export class ParticleSystemSet implements IDisposable {
  62008. /**
  62009. * Gets or sets base Assets URL
  62010. */
  62011. static BaseAssetsUrl: string;
  62012. private _emitterCreationOptions;
  62013. private _emitterNode;
  62014. /**
  62015. * Gets the particle system list
  62016. */
  62017. systems: IParticleSystem[];
  62018. /**
  62019. * Gets the emitter node used with this set
  62020. */
  62021. readonly emitterNode: Nullable<TransformNode>;
  62022. /**
  62023. * Creates a new emitter mesh as a sphere
  62024. * @param options defines the options used to create the sphere
  62025. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62026. * @param scene defines the hosting scene
  62027. */
  62028. setEmitterAsSphere(options: {
  62029. diameter: number;
  62030. segments: number;
  62031. color: Color3;
  62032. }, renderingGroupId: number, scene: Scene): void;
  62033. /**
  62034. * Starts all particle systems of the set
  62035. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62036. */
  62037. start(emitter?: AbstractMesh): void;
  62038. /**
  62039. * Release all associated resources
  62040. */
  62041. dispose(): void;
  62042. /**
  62043. * Serialize the set into a JSON compatible object
  62044. * @returns a JSON compatible representation of the set
  62045. */
  62046. serialize(): any;
  62047. /**
  62048. * Parse a new ParticleSystemSet from a serialized source
  62049. * @param data defines a JSON compatible representation of the set
  62050. * @param scene defines the hosting scene
  62051. * @param gpu defines if we want GPU particles or CPU particles
  62052. * @returns a new ParticleSystemSet
  62053. */
  62054. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62055. }
  62056. }
  62057. declare module "babylonjs/Particles/particleHelper" {
  62058. import { Nullable } from "babylonjs/types";
  62059. import { Scene } from "babylonjs/scene";
  62060. import { Vector3 } from "babylonjs/Maths/math.vector";
  62061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62062. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62063. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62064. /**
  62065. * This class is made for on one-liner static method to help creating particle system set.
  62066. */
  62067. export class ParticleHelper {
  62068. /**
  62069. * Gets or sets base Assets URL
  62070. */
  62071. static BaseAssetsUrl: string;
  62072. /**
  62073. * Create a default particle system that you can tweak
  62074. * @param emitter defines the emitter to use
  62075. * @param capacity defines the system capacity (default is 500 particles)
  62076. * @param scene defines the hosting scene
  62077. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62078. * @returns the new Particle system
  62079. */
  62080. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62081. /**
  62082. * This is the main static method (one-liner) of this helper to create different particle systems
  62083. * @param type This string represents the type to the particle system to create
  62084. * @param scene The scene where the particle system should live
  62085. * @param gpu If the system will use gpu
  62086. * @returns the ParticleSystemSet created
  62087. */
  62088. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62089. /**
  62090. * Static function used to export a particle system to a ParticleSystemSet variable.
  62091. * Please note that the emitter shape is not exported
  62092. * @param systems defines the particle systems to export
  62093. * @returns the created particle system set
  62094. */
  62095. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62096. }
  62097. }
  62098. declare module "babylonjs/Particles/particleSystemComponent" {
  62099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62100. import { Effect } from "babylonjs/Materials/effect";
  62101. import "babylonjs/Shaders/particles.vertex";
  62102. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62103. module "babylonjs/Engines/engine" {
  62104. interface Engine {
  62105. /**
  62106. * Create an effect to use with particle systems.
  62107. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62108. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62109. * @param uniformsNames defines a list of attribute names
  62110. * @param samplers defines an array of string used to represent textures
  62111. * @param defines defines the string containing the defines to use to compile the shaders
  62112. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62113. * @param onCompiled defines a function to call when the effect creation is successful
  62114. * @param onError defines a function to call when the effect creation has failed
  62115. * @returns the new Effect
  62116. */
  62117. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62118. }
  62119. }
  62120. module "babylonjs/Meshes/mesh" {
  62121. interface Mesh {
  62122. /**
  62123. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62124. * @returns an array of IParticleSystem
  62125. */
  62126. getEmittedParticleSystems(): IParticleSystem[];
  62127. /**
  62128. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62129. * @returns an array of IParticleSystem
  62130. */
  62131. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62132. }
  62133. }
  62134. /**
  62135. * @hidden
  62136. */
  62137. export var _IDoNeedToBeInTheBuild: number;
  62138. }
  62139. declare module "babylonjs/Particles/pointsCloudSystem" {
  62140. import { Color4 } from "babylonjs/Maths/math";
  62141. import { Mesh } from "babylonjs/Meshes/mesh";
  62142. import { Scene, IDisposable } from "babylonjs/scene";
  62143. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62144. /** Defines the 4 color options */
  62145. export enum PointColor {
  62146. /** color value */
  62147. Color = 2,
  62148. /** uv value */
  62149. UV = 1,
  62150. /** random value */
  62151. Random = 0,
  62152. /** stated value */
  62153. Stated = 3
  62154. }
  62155. /**
  62156. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62157. * 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.
  62158. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62159. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62160. *
  62161. * Full documentation here : TO BE ENTERED
  62162. */
  62163. export class PointsCloudSystem implements IDisposable {
  62164. /**
  62165. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62166. * Example : var p = SPS.particles[i];
  62167. */
  62168. particles: CloudPoint[];
  62169. /**
  62170. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62171. */
  62172. nbParticles: number;
  62173. /**
  62174. * This a counter for your own usage. It's not set by any SPS functions.
  62175. */
  62176. counter: number;
  62177. /**
  62178. * The PCS name. This name is also given to the underlying mesh.
  62179. */
  62180. name: string;
  62181. /**
  62182. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62183. */
  62184. mesh: Mesh;
  62185. /**
  62186. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62187. * Please read :
  62188. */
  62189. vars: any;
  62190. /**
  62191. * @hidden
  62192. */
  62193. _size: number;
  62194. private _scene;
  62195. private _promises;
  62196. private _positions;
  62197. private _indices;
  62198. private _normals;
  62199. private _colors;
  62200. private _uvs;
  62201. private _indices32;
  62202. private _positions32;
  62203. private _colors32;
  62204. private _uvs32;
  62205. private _updatable;
  62206. private _isVisibilityBoxLocked;
  62207. private _alwaysVisible;
  62208. private _groups;
  62209. private _groupCounter;
  62210. private _computeParticleColor;
  62211. private _computeParticleTexture;
  62212. private _computeParticleRotation;
  62213. private _computeBoundingBox;
  62214. private _isReady;
  62215. /**
  62216. * Creates a PCS (Points Cloud System) object
  62217. * @param name (String) is the PCS name, this will be the underlying mesh name
  62218. * @param pointSize (number) is the size for each point
  62219. * @param scene (Scene) is the scene in which the PCS is added
  62220. * @param options defines the options of the PCS e.g.
  62221. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62222. */
  62223. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62224. updatable?: boolean;
  62225. });
  62226. /**
  62227. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62228. * If no points were added to the PCS, the returned mesh is just a single point.
  62229. * @returns a promise for the created mesh
  62230. */
  62231. buildMeshAsync(): Promise<Mesh>;
  62232. /**
  62233. * @hidden
  62234. */
  62235. private _buildMesh;
  62236. private _addParticle;
  62237. private _randomUnitVector;
  62238. private _getColorIndicesForCoord;
  62239. private _setPointsColorOrUV;
  62240. private _colorFromTexture;
  62241. private _calculateDensity;
  62242. /**
  62243. * Adds points to the PCS in random positions within a unit sphere
  62244. * @param nb (positive integer) the number of particles to be created from this model
  62245. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62246. * @returns the number of groups in the system
  62247. */
  62248. addPoints(nb: number, pointFunction?: any): number;
  62249. /**
  62250. * Adds points to the PCS from the surface of the model shape
  62251. * @param mesh is any Mesh object that will be used as a surface model for the points
  62252. * @param nb (positive integer) the number of particles to be created from this model
  62253. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62254. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62255. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62256. * @returns the number of groups in the system
  62257. */
  62258. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62259. /**
  62260. * Adds points to the PCS inside the model shape
  62261. * @param mesh is any Mesh object that will be used as a surface model for the points
  62262. * @param nb (positive integer) the number of particles to be created from this model
  62263. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62264. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62265. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62266. * @returns the number of groups in the system
  62267. */
  62268. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62269. /**
  62270. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62271. * This method calls `updateParticle()` for each particle of the SPS.
  62272. * For an animated SPS, it is usually called within the render loop.
  62273. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62274. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62275. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62276. * @returns the PCS.
  62277. */
  62278. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62279. /**
  62280. * Disposes the PCS.
  62281. */
  62282. dispose(): void;
  62283. /**
  62284. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62285. * doc :
  62286. * @returns the PCS.
  62287. */
  62288. refreshVisibleSize(): PointsCloudSystem;
  62289. /**
  62290. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62291. * @param size the size (float) of the visibility box
  62292. * note : this doesn't lock the PCS mesh bounding box.
  62293. * doc :
  62294. */
  62295. setVisibilityBox(size: number): void;
  62296. /**
  62297. * Gets whether the PCS is always visible or not
  62298. * doc :
  62299. */
  62300. /**
  62301. * Sets the PCS as always visible or not
  62302. * doc :
  62303. */
  62304. isAlwaysVisible: boolean;
  62305. /**
  62306. * Tells to `setParticles()` to compute the particle rotations or not
  62307. * Default value : false. The PCS is faster when it's set to false
  62308. * Note : particle rotations are only applied to parent particles
  62309. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62310. */
  62311. computeParticleRotation: boolean;
  62312. /**
  62313. * Tells to `setParticles()` to compute the particle colors or not.
  62314. * Default value : true. The PCS is faster when it's set to false.
  62315. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62316. */
  62317. /**
  62318. * Gets if `setParticles()` computes the particle colors or not.
  62319. * Default value : false. The PCS is faster when it's set to false.
  62320. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62321. */
  62322. computeParticleColor: boolean;
  62323. /**
  62324. * Gets if `setParticles()` computes the particle textures or not.
  62325. * Default value : false. The PCS is faster when it's set to false.
  62326. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62327. */
  62328. computeParticleTexture: boolean;
  62329. /**
  62330. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62331. */
  62332. /**
  62333. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62334. */
  62335. computeBoundingBox: boolean;
  62336. /**
  62337. * This function does nothing. It may be overwritten to set all the particle first values.
  62338. * The PCS doesn't call this function, you may have to call it by your own.
  62339. * doc :
  62340. */
  62341. initParticles(): void;
  62342. /**
  62343. * This function does nothing. It may be overwritten to recycle a particle
  62344. * The PCS doesn't call this function, you can to call it
  62345. * doc :
  62346. * @param particle The particle to recycle
  62347. * @returns the recycled particle
  62348. */
  62349. recycleParticle(particle: CloudPoint): CloudPoint;
  62350. /**
  62351. * Updates a particle : this function should be overwritten by the user.
  62352. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62353. * doc :
  62354. * @example : just set a particle position or velocity and recycle conditions
  62355. * @param particle The particle to update
  62356. * @returns the updated particle
  62357. */
  62358. updateParticle(particle: CloudPoint): CloudPoint;
  62359. /**
  62360. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62361. * This does nothing and may be overwritten by the user.
  62362. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62363. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62364. * @param update the boolean update value actually passed to setParticles()
  62365. */
  62366. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62367. /**
  62368. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62369. * This will be passed three parameters.
  62370. * This does nothing and may be overwritten by the user.
  62371. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62372. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62373. * @param update the boolean update value actually passed to setParticles()
  62374. */
  62375. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62376. }
  62377. }
  62378. declare module "babylonjs/Particles/cloudPoint" {
  62379. import { Nullable } from "babylonjs/types";
  62380. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62381. import { Mesh } from "babylonjs/Meshes/mesh";
  62382. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62383. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62384. /**
  62385. * Represents one particle of a points cloud system.
  62386. */
  62387. export class CloudPoint {
  62388. /**
  62389. * particle global index
  62390. */
  62391. idx: number;
  62392. /**
  62393. * The color of the particle
  62394. */
  62395. color: Nullable<Color4>;
  62396. /**
  62397. * The world space position of the particle.
  62398. */
  62399. position: Vector3;
  62400. /**
  62401. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62402. */
  62403. rotation: Vector3;
  62404. /**
  62405. * The world space rotation quaternion of the particle.
  62406. */
  62407. rotationQuaternion: Nullable<Quaternion>;
  62408. /**
  62409. * The uv of the particle.
  62410. */
  62411. uv: Nullable<Vector2>;
  62412. /**
  62413. * The current speed of the particle.
  62414. */
  62415. velocity: Vector3;
  62416. /**
  62417. * The pivot point in the particle local space.
  62418. */
  62419. pivot: Vector3;
  62420. /**
  62421. * Must the particle be translated from its pivot point in its local space ?
  62422. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62423. * Default : false
  62424. */
  62425. translateFromPivot: boolean;
  62426. /**
  62427. * Index of this particle in the global "positions" array (Internal use)
  62428. * @hidden
  62429. */
  62430. _pos: number;
  62431. /**
  62432. * @hidden Index of this particle in the global "indices" array (Internal use)
  62433. */
  62434. _ind: number;
  62435. /**
  62436. * Group this particle belongs to
  62437. */
  62438. _group: PointsGroup;
  62439. /**
  62440. * Group id of this particle
  62441. */
  62442. groupId: number;
  62443. /**
  62444. * Index of the particle in its group id (Internal use)
  62445. */
  62446. idxInGroup: number;
  62447. /**
  62448. * @hidden Particle BoundingInfo object (Internal use)
  62449. */
  62450. _boundingInfo: BoundingInfo;
  62451. /**
  62452. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62453. */
  62454. _pcs: PointsCloudSystem;
  62455. /**
  62456. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62457. */
  62458. _stillInvisible: boolean;
  62459. /**
  62460. * @hidden Last computed particle rotation matrix
  62461. */
  62462. _rotationMatrix: number[];
  62463. /**
  62464. * Parent particle Id, if any.
  62465. * Default null.
  62466. */
  62467. parentId: Nullable<number>;
  62468. /**
  62469. * @hidden Internal global position in the PCS.
  62470. */
  62471. _globalPosition: Vector3;
  62472. /**
  62473. * Creates a Point Cloud object.
  62474. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62475. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62476. * @param group (PointsGroup) is the group the particle belongs to
  62477. * @param groupId (integer) is the group identifier in the PCS.
  62478. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62479. * @param pcs defines the PCS it is associated to
  62480. */
  62481. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62482. /**
  62483. * get point size
  62484. */
  62485. /**
  62486. * Set point size
  62487. */
  62488. size: Vector3;
  62489. /**
  62490. * Legacy support, changed quaternion to rotationQuaternion
  62491. */
  62492. /**
  62493. * Legacy support, changed quaternion to rotationQuaternion
  62494. */
  62495. quaternion: Nullable<Quaternion>;
  62496. /**
  62497. * Returns a boolean. True if the particle intersects a mesh, else false
  62498. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62499. * @param target is the object (point or mesh) what the intersection is computed against
  62500. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62501. * @returns true if it intersects
  62502. */
  62503. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62504. /**
  62505. * get the rotation matrix of the particle
  62506. * @hidden
  62507. */
  62508. getRotationMatrix(m: Matrix): void;
  62509. }
  62510. /**
  62511. * Represents a group of points in a points cloud system
  62512. * * PCS internal tool, don't use it manually.
  62513. */
  62514. export class PointsGroup {
  62515. /**
  62516. * The group id
  62517. * @hidden
  62518. */
  62519. groupID: number;
  62520. /**
  62521. * image data for group (internal use)
  62522. * @hidden
  62523. */
  62524. _groupImageData: Nullable<ArrayBufferView>;
  62525. /**
  62526. * Image Width (internal use)
  62527. * @hidden
  62528. */
  62529. _groupImgWidth: number;
  62530. /**
  62531. * Image Height (internal use)
  62532. * @hidden
  62533. */
  62534. _groupImgHeight: number;
  62535. /**
  62536. * Custom position function (internal use)
  62537. * @hidden
  62538. */
  62539. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62540. /**
  62541. * density per facet for surface points
  62542. * @hidden
  62543. */
  62544. _groupDensity: number[];
  62545. /**
  62546. * Only when points are colored by texture carries pointer to texture list array
  62547. * @hidden
  62548. */
  62549. _textureNb: number;
  62550. /**
  62551. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62552. * PCS internal tool, don't use it manually.
  62553. * @hidden
  62554. */
  62555. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62556. }
  62557. }
  62558. declare module "babylonjs/Particles/index" {
  62559. export * from "babylonjs/Particles/baseParticleSystem";
  62560. export * from "babylonjs/Particles/EmitterTypes/index";
  62561. export * from "babylonjs/Particles/gpuParticleSystem";
  62562. export * from "babylonjs/Particles/IParticleSystem";
  62563. export * from "babylonjs/Particles/particle";
  62564. export * from "babylonjs/Particles/particleHelper";
  62565. export * from "babylonjs/Particles/particleSystem";
  62566. export * from "babylonjs/Particles/particleSystemComponent";
  62567. export * from "babylonjs/Particles/particleSystemSet";
  62568. export * from "babylonjs/Particles/solidParticle";
  62569. export * from "babylonjs/Particles/solidParticleSystem";
  62570. export * from "babylonjs/Particles/cloudPoint";
  62571. export * from "babylonjs/Particles/pointsCloudSystem";
  62572. export * from "babylonjs/Particles/subEmitter";
  62573. }
  62574. declare module "babylonjs/Physics/physicsEngineComponent" {
  62575. import { Nullable } from "babylonjs/types";
  62576. import { Observable, Observer } from "babylonjs/Misc/observable";
  62577. import { Vector3 } from "babylonjs/Maths/math.vector";
  62578. import { Mesh } from "babylonjs/Meshes/mesh";
  62579. import { ISceneComponent } from "babylonjs/sceneComponent";
  62580. import { Scene } from "babylonjs/scene";
  62581. import { Node } from "babylonjs/node";
  62582. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62583. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62584. module "babylonjs/scene" {
  62585. interface Scene {
  62586. /** @hidden (Backing field) */
  62587. _physicsEngine: Nullable<IPhysicsEngine>;
  62588. /**
  62589. * Gets the current physics engine
  62590. * @returns a IPhysicsEngine or null if none attached
  62591. */
  62592. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62593. /**
  62594. * Enables physics to the current scene
  62595. * @param gravity defines the scene's gravity for the physics engine
  62596. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62597. * @return a boolean indicating if the physics engine was initialized
  62598. */
  62599. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62600. /**
  62601. * Disables and disposes the physics engine associated with the scene
  62602. */
  62603. disablePhysicsEngine(): void;
  62604. /**
  62605. * Gets a boolean indicating if there is an active physics engine
  62606. * @returns a boolean indicating if there is an active physics engine
  62607. */
  62608. isPhysicsEnabled(): boolean;
  62609. /**
  62610. * Deletes a physics compound impostor
  62611. * @param compound defines the compound to delete
  62612. */
  62613. deleteCompoundImpostor(compound: any): void;
  62614. /**
  62615. * An event triggered when physic simulation is about to be run
  62616. */
  62617. onBeforePhysicsObservable: Observable<Scene>;
  62618. /**
  62619. * An event triggered when physic simulation has been done
  62620. */
  62621. onAfterPhysicsObservable: Observable<Scene>;
  62622. }
  62623. }
  62624. module "babylonjs/Meshes/abstractMesh" {
  62625. interface AbstractMesh {
  62626. /** @hidden */
  62627. _physicsImpostor: Nullable<PhysicsImpostor>;
  62628. /**
  62629. * Gets or sets impostor used for physic simulation
  62630. * @see http://doc.babylonjs.com/features/physics_engine
  62631. */
  62632. physicsImpostor: Nullable<PhysicsImpostor>;
  62633. /**
  62634. * Gets the current physics impostor
  62635. * @see http://doc.babylonjs.com/features/physics_engine
  62636. * @returns a physics impostor or null
  62637. */
  62638. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62639. /** Apply a physic impulse to the mesh
  62640. * @param force defines the force to apply
  62641. * @param contactPoint defines where to apply the force
  62642. * @returns the current mesh
  62643. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62644. */
  62645. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62646. /**
  62647. * Creates a physic joint between two meshes
  62648. * @param otherMesh defines the other mesh to use
  62649. * @param pivot1 defines the pivot to use on this mesh
  62650. * @param pivot2 defines the pivot to use on the other mesh
  62651. * @param options defines additional options (can be plugin dependent)
  62652. * @returns the current mesh
  62653. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62654. */
  62655. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62656. /** @hidden */
  62657. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62658. }
  62659. }
  62660. /**
  62661. * Defines the physics engine scene component responsible to manage a physics engine
  62662. */
  62663. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62664. /**
  62665. * The component name helpful to identify the component in the list of scene components.
  62666. */
  62667. readonly name: string;
  62668. /**
  62669. * The scene the component belongs to.
  62670. */
  62671. scene: Scene;
  62672. /**
  62673. * Creates a new instance of the component for the given scene
  62674. * @param scene Defines the scene to register the component in
  62675. */
  62676. constructor(scene: Scene);
  62677. /**
  62678. * Registers the component in a given scene
  62679. */
  62680. register(): void;
  62681. /**
  62682. * Rebuilds the elements related to this component in case of
  62683. * context lost for instance.
  62684. */
  62685. rebuild(): void;
  62686. /**
  62687. * Disposes the component and the associated ressources
  62688. */
  62689. dispose(): void;
  62690. }
  62691. }
  62692. declare module "babylonjs/Physics/physicsHelper" {
  62693. import { Nullable } from "babylonjs/types";
  62694. import { Vector3 } from "babylonjs/Maths/math.vector";
  62695. import { Mesh } from "babylonjs/Meshes/mesh";
  62696. import { Scene } from "babylonjs/scene";
  62697. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62698. /**
  62699. * A helper for physics simulations
  62700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62701. */
  62702. export class PhysicsHelper {
  62703. private _scene;
  62704. private _physicsEngine;
  62705. /**
  62706. * Initializes the Physics helper
  62707. * @param scene Babylon.js scene
  62708. */
  62709. constructor(scene: Scene);
  62710. /**
  62711. * Applies a radial explosion impulse
  62712. * @param origin the origin of the explosion
  62713. * @param radiusOrEventOptions the radius or the options of radial explosion
  62714. * @param strength the explosion strength
  62715. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62716. * @returns A physics radial explosion event, or null
  62717. */
  62718. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62719. /**
  62720. * Applies a radial explosion force
  62721. * @param origin the origin of the explosion
  62722. * @param radiusOrEventOptions the radius or the options of radial explosion
  62723. * @param strength the explosion strength
  62724. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62725. * @returns A physics radial explosion event, or null
  62726. */
  62727. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62728. /**
  62729. * Creates a gravitational field
  62730. * @param origin the origin of the explosion
  62731. * @param radiusOrEventOptions the radius or the options of radial explosion
  62732. * @param strength the explosion strength
  62733. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62734. * @returns A physics gravitational field event, or null
  62735. */
  62736. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62737. /**
  62738. * Creates a physics updraft event
  62739. * @param origin the origin of the updraft
  62740. * @param radiusOrEventOptions the radius or the options of the updraft
  62741. * @param strength the strength of the updraft
  62742. * @param height the height of the updraft
  62743. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62744. * @returns A physics updraft event, or null
  62745. */
  62746. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62747. /**
  62748. * Creates a physics vortex event
  62749. * @param origin the of the vortex
  62750. * @param radiusOrEventOptions the radius or the options of the vortex
  62751. * @param strength the strength of the vortex
  62752. * @param height the height of the vortex
  62753. * @returns a Physics vortex event, or null
  62754. * A physics vortex event or null
  62755. */
  62756. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62757. }
  62758. /**
  62759. * Represents a physics radial explosion event
  62760. */
  62761. class PhysicsRadialExplosionEvent {
  62762. private _scene;
  62763. private _options;
  62764. private _sphere;
  62765. private _dataFetched;
  62766. /**
  62767. * Initializes a radial explosioin event
  62768. * @param _scene BabylonJS scene
  62769. * @param _options The options for the vortex event
  62770. */
  62771. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62772. /**
  62773. * Returns the data related to the radial explosion event (sphere).
  62774. * @returns The radial explosion event data
  62775. */
  62776. getData(): PhysicsRadialExplosionEventData;
  62777. /**
  62778. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62779. * @param impostor A physics imposter
  62780. * @param origin the origin of the explosion
  62781. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62782. */
  62783. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62784. /**
  62785. * Triggers affecterd impostors callbacks
  62786. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62787. */
  62788. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62789. /**
  62790. * Disposes the sphere.
  62791. * @param force Specifies if the sphere should be disposed by force
  62792. */
  62793. dispose(force?: boolean): void;
  62794. /*** Helpers ***/
  62795. private _prepareSphere;
  62796. private _intersectsWithSphere;
  62797. }
  62798. /**
  62799. * Represents a gravitational field event
  62800. */
  62801. class PhysicsGravitationalFieldEvent {
  62802. private _physicsHelper;
  62803. private _scene;
  62804. private _origin;
  62805. private _options;
  62806. private _tickCallback;
  62807. private _sphere;
  62808. private _dataFetched;
  62809. /**
  62810. * Initializes the physics gravitational field event
  62811. * @param _physicsHelper A physics helper
  62812. * @param _scene BabylonJS scene
  62813. * @param _origin The origin position of the gravitational field event
  62814. * @param _options The options for the vortex event
  62815. */
  62816. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62817. /**
  62818. * Returns the data related to the gravitational field event (sphere).
  62819. * @returns A gravitational field event
  62820. */
  62821. getData(): PhysicsGravitationalFieldEventData;
  62822. /**
  62823. * Enables the gravitational field.
  62824. */
  62825. enable(): void;
  62826. /**
  62827. * Disables the gravitational field.
  62828. */
  62829. disable(): void;
  62830. /**
  62831. * Disposes the sphere.
  62832. * @param force The force to dispose from the gravitational field event
  62833. */
  62834. dispose(force?: boolean): void;
  62835. private _tick;
  62836. }
  62837. /**
  62838. * Represents a physics updraft event
  62839. */
  62840. class PhysicsUpdraftEvent {
  62841. private _scene;
  62842. private _origin;
  62843. private _options;
  62844. private _physicsEngine;
  62845. private _originTop;
  62846. private _originDirection;
  62847. private _tickCallback;
  62848. private _cylinder;
  62849. private _cylinderPosition;
  62850. private _dataFetched;
  62851. /**
  62852. * Initializes the physics updraft event
  62853. * @param _scene BabylonJS scene
  62854. * @param _origin The origin position of the updraft
  62855. * @param _options The options for the updraft event
  62856. */
  62857. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62858. /**
  62859. * Returns the data related to the updraft event (cylinder).
  62860. * @returns A physics updraft event
  62861. */
  62862. getData(): PhysicsUpdraftEventData;
  62863. /**
  62864. * Enables the updraft.
  62865. */
  62866. enable(): void;
  62867. /**
  62868. * Disables the updraft.
  62869. */
  62870. disable(): void;
  62871. /**
  62872. * Disposes the cylinder.
  62873. * @param force Specifies if the updraft should be disposed by force
  62874. */
  62875. dispose(force?: boolean): void;
  62876. private getImpostorHitData;
  62877. private _tick;
  62878. /*** Helpers ***/
  62879. private _prepareCylinder;
  62880. private _intersectsWithCylinder;
  62881. }
  62882. /**
  62883. * Represents a physics vortex event
  62884. */
  62885. class PhysicsVortexEvent {
  62886. private _scene;
  62887. private _origin;
  62888. private _options;
  62889. private _physicsEngine;
  62890. private _originTop;
  62891. private _tickCallback;
  62892. private _cylinder;
  62893. private _cylinderPosition;
  62894. private _dataFetched;
  62895. /**
  62896. * Initializes the physics vortex event
  62897. * @param _scene The BabylonJS scene
  62898. * @param _origin The origin position of the vortex
  62899. * @param _options The options for the vortex event
  62900. */
  62901. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62902. /**
  62903. * Returns the data related to the vortex event (cylinder).
  62904. * @returns The physics vortex event data
  62905. */
  62906. getData(): PhysicsVortexEventData;
  62907. /**
  62908. * Enables the vortex.
  62909. */
  62910. enable(): void;
  62911. /**
  62912. * Disables the cortex.
  62913. */
  62914. disable(): void;
  62915. /**
  62916. * Disposes the sphere.
  62917. * @param force
  62918. */
  62919. dispose(force?: boolean): void;
  62920. private getImpostorHitData;
  62921. private _tick;
  62922. /*** Helpers ***/
  62923. private _prepareCylinder;
  62924. private _intersectsWithCylinder;
  62925. }
  62926. /**
  62927. * Options fot the radial explosion event
  62928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62929. */
  62930. export class PhysicsRadialExplosionEventOptions {
  62931. /**
  62932. * The radius of the sphere for the radial explosion.
  62933. */
  62934. radius: number;
  62935. /**
  62936. * The strenth of the explosion.
  62937. */
  62938. strength: number;
  62939. /**
  62940. * The strenght of the force in correspondence to the distance of the affected object
  62941. */
  62942. falloff: PhysicsRadialImpulseFalloff;
  62943. /**
  62944. * Sphere options for the radial explosion.
  62945. */
  62946. sphere: {
  62947. segments: number;
  62948. diameter: number;
  62949. };
  62950. /**
  62951. * Sphere options for the radial explosion.
  62952. */
  62953. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62954. }
  62955. /**
  62956. * Options fot the updraft event
  62957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62958. */
  62959. export class PhysicsUpdraftEventOptions {
  62960. /**
  62961. * The radius of the cylinder for the vortex
  62962. */
  62963. radius: number;
  62964. /**
  62965. * The strenth of the updraft.
  62966. */
  62967. strength: number;
  62968. /**
  62969. * The height of the cylinder for the updraft.
  62970. */
  62971. height: number;
  62972. /**
  62973. * The mode for the the updraft.
  62974. */
  62975. updraftMode: PhysicsUpdraftMode;
  62976. }
  62977. /**
  62978. * Options fot the vortex event
  62979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62980. */
  62981. export class PhysicsVortexEventOptions {
  62982. /**
  62983. * The radius of the cylinder for the vortex
  62984. */
  62985. radius: number;
  62986. /**
  62987. * The strenth of the vortex.
  62988. */
  62989. strength: number;
  62990. /**
  62991. * The height of the cylinder for the vortex.
  62992. */
  62993. height: number;
  62994. /**
  62995. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62996. */
  62997. centripetalForceThreshold: number;
  62998. /**
  62999. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63000. */
  63001. centripetalForceMultiplier: number;
  63002. /**
  63003. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63004. */
  63005. centrifugalForceMultiplier: number;
  63006. /**
  63007. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63008. */
  63009. updraftForceMultiplier: number;
  63010. }
  63011. /**
  63012. * The strenght of the force in correspondence to the distance of the affected object
  63013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63014. */
  63015. export enum PhysicsRadialImpulseFalloff {
  63016. /** Defines that impulse is constant in strength across it's whole radius */
  63017. Constant = 0,
  63018. /** Defines that impulse gets weaker if it's further from the origin */
  63019. Linear = 1
  63020. }
  63021. /**
  63022. * The strength of the force in correspondence to the distance of the affected object
  63023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63024. */
  63025. export enum PhysicsUpdraftMode {
  63026. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63027. Center = 0,
  63028. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63029. Perpendicular = 1
  63030. }
  63031. /**
  63032. * Interface for a physics hit data
  63033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63034. */
  63035. export interface PhysicsHitData {
  63036. /**
  63037. * The force applied at the contact point
  63038. */
  63039. force: Vector3;
  63040. /**
  63041. * The contact point
  63042. */
  63043. contactPoint: Vector3;
  63044. /**
  63045. * The distance from the origin to the contact point
  63046. */
  63047. distanceFromOrigin: number;
  63048. }
  63049. /**
  63050. * Interface for radial explosion event data
  63051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63052. */
  63053. export interface PhysicsRadialExplosionEventData {
  63054. /**
  63055. * A sphere used for the radial explosion event
  63056. */
  63057. sphere: Mesh;
  63058. }
  63059. /**
  63060. * Interface for gravitational field event data
  63061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63062. */
  63063. export interface PhysicsGravitationalFieldEventData {
  63064. /**
  63065. * A sphere mesh used for the gravitational field event
  63066. */
  63067. sphere: Mesh;
  63068. }
  63069. /**
  63070. * Interface for updraft event data
  63071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63072. */
  63073. export interface PhysicsUpdraftEventData {
  63074. /**
  63075. * A cylinder used for the updraft event
  63076. */
  63077. cylinder: Mesh;
  63078. }
  63079. /**
  63080. * Interface for vortex event data
  63081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63082. */
  63083. export interface PhysicsVortexEventData {
  63084. /**
  63085. * A cylinder used for the vortex event
  63086. */
  63087. cylinder: Mesh;
  63088. }
  63089. /**
  63090. * Interface for an affected physics impostor
  63091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63092. */
  63093. export interface PhysicsAffectedImpostorWithData {
  63094. /**
  63095. * The impostor affected by the effect
  63096. */
  63097. impostor: PhysicsImpostor;
  63098. /**
  63099. * The data about the hit/horce from the explosion
  63100. */
  63101. hitData: PhysicsHitData;
  63102. }
  63103. }
  63104. declare module "babylonjs/Physics/Plugins/index" {
  63105. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63106. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63107. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63108. }
  63109. declare module "babylonjs/Physics/index" {
  63110. export * from "babylonjs/Physics/IPhysicsEngine";
  63111. export * from "babylonjs/Physics/physicsEngine";
  63112. export * from "babylonjs/Physics/physicsEngineComponent";
  63113. export * from "babylonjs/Physics/physicsHelper";
  63114. export * from "babylonjs/Physics/physicsImpostor";
  63115. export * from "babylonjs/Physics/physicsJoint";
  63116. export * from "babylonjs/Physics/Plugins/index";
  63117. }
  63118. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63119. /** @hidden */
  63120. export var blackAndWhitePixelShader: {
  63121. name: string;
  63122. shader: string;
  63123. };
  63124. }
  63125. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63126. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63127. import { Camera } from "babylonjs/Cameras/camera";
  63128. import { Engine } from "babylonjs/Engines/engine";
  63129. import "babylonjs/Shaders/blackAndWhite.fragment";
  63130. /**
  63131. * Post process used to render in black and white
  63132. */
  63133. export class BlackAndWhitePostProcess extends PostProcess {
  63134. /**
  63135. * Linear about to convert he result to black and white (default: 1)
  63136. */
  63137. degree: number;
  63138. /**
  63139. * Creates a black and white post process
  63140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63141. * @param name The name of the effect.
  63142. * @param options The required width/height ratio to downsize to before computing the render pass.
  63143. * @param camera The camera to apply the render pass to.
  63144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63145. * @param engine The engine which the post process will be applied. (default: current engine)
  63146. * @param reusable If the post process can be reused on the same frame. (default: false)
  63147. */
  63148. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63149. }
  63150. }
  63151. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63152. import { Nullable } from "babylonjs/types";
  63153. import { Camera } from "babylonjs/Cameras/camera";
  63154. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63155. import { Engine } from "babylonjs/Engines/engine";
  63156. /**
  63157. * This represents a set of one or more post processes in Babylon.
  63158. * A post process can be used to apply a shader to a texture after it is rendered.
  63159. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63160. */
  63161. export class PostProcessRenderEffect {
  63162. private _postProcesses;
  63163. private _getPostProcesses;
  63164. private _singleInstance;
  63165. private _cameras;
  63166. private _indicesForCamera;
  63167. /**
  63168. * Name of the effect
  63169. * @hidden
  63170. */
  63171. _name: string;
  63172. /**
  63173. * Instantiates a post process render effect.
  63174. * A post process can be used to apply a shader to a texture after it is rendered.
  63175. * @param engine The engine the effect is tied to
  63176. * @param name The name of the effect
  63177. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63178. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63179. */
  63180. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63181. /**
  63182. * Checks if all the post processes in the effect are supported.
  63183. */
  63184. readonly isSupported: boolean;
  63185. /**
  63186. * Updates the current state of the effect
  63187. * @hidden
  63188. */
  63189. _update(): void;
  63190. /**
  63191. * Attaches the effect on cameras
  63192. * @param cameras The camera to attach to.
  63193. * @hidden
  63194. */
  63195. _attachCameras(cameras: Camera): void;
  63196. /**
  63197. * Attaches the effect on cameras
  63198. * @param cameras The camera to attach to.
  63199. * @hidden
  63200. */
  63201. _attachCameras(cameras: Camera[]): void;
  63202. /**
  63203. * Detaches the effect on cameras
  63204. * @param cameras The camera to detatch from.
  63205. * @hidden
  63206. */
  63207. _detachCameras(cameras: Camera): void;
  63208. /**
  63209. * Detatches the effect on cameras
  63210. * @param cameras The camera to detatch from.
  63211. * @hidden
  63212. */
  63213. _detachCameras(cameras: Camera[]): void;
  63214. /**
  63215. * Enables the effect on given cameras
  63216. * @param cameras The camera to enable.
  63217. * @hidden
  63218. */
  63219. _enable(cameras: Camera): void;
  63220. /**
  63221. * Enables the effect on given cameras
  63222. * @param cameras The camera to enable.
  63223. * @hidden
  63224. */
  63225. _enable(cameras: Nullable<Camera[]>): void;
  63226. /**
  63227. * Disables the effect on the given cameras
  63228. * @param cameras The camera to disable.
  63229. * @hidden
  63230. */
  63231. _disable(cameras: Camera): void;
  63232. /**
  63233. * Disables the effect on the given cameras
  63234. * @param cameras The camera to disable.
  63235. * @hidden
  63236. */
  63237. _disable(cameras: Nullable<Camera[]>): void;
  63238. /**
  63239. * Gets a list of the post processes contained in the effect.
  63240. * @param camera The camera to get the post processes on.
  63241. * @returns The list of the post processes in the effect.
  63242. */
  63243. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63244. }
  63245. }
  63246. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63247. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63248. /** @hidden */
  63249. export var extractHighlightsPixelShader: {
  63250. name: string;
  63251. shader: string;
  63252. };
  63253. }
  63254. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63255. import { Nullable } from "babylonjs/types";
  63256. import { Camera } from "babylonjs/Cameras/camera";
  63257. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63258. import { Engine } from "babylonjs/Engines/engine";
  63259. import "babylonjs/Shaders/extractHighlights.fragment";
  63260. /**
  63261. * 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.
  63262. */
  63263. export class ExtractHighlightsPostProcess extends PostProcess {
  63264. /**
  63265. * The luminance threshold, pixels below this value will be set to black.
  63266. */
  63267. threshold: number;
  63268. /** @hidden */
  63269. _exposure: number;
  63270. /**
  63271. * Post process which has the input texture to be used when performing highlight extraction
  63272. * @hidden
  63273. */
  63274. _inputPostProcess: Nullable<PostProcess>;
  63275. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63276. }
  63277. }
  63278. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63279. /** @hidden */
  63280. export var bloomMergePixelShader: {
  63281. name: string;
  63282. shader: string;
  63283. };
  63284. }
  63285. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63286. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63287. import { Nullable } from "babylonjs/types";
  63288. import { Engine } from "babylonjs/Engines/engine";
  63289. import { Camera } from "babylonjs/Cameras/camera";
  63290. import "babylonjs/Shaders/bloomMerge.fragment";
  63291. /**
  63292. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63293. */
  63294. export class BloomMergePostProcess extends PostProcess {
  63295. /** Weight of the bloom to be added to the original input. */
  63296. weight: number;
  63297. /**
  63298. * Creates a new instance of @see BloomMergePostProcess
  63299. * @param name The name of the effect.
  63300. * @param originalFromInput Post process which's input will be used for the merge.
  63301. * @param blurred Blurred highlights post process which's output will be used.
  63302. * @param weight Weight of the bloom to be added to the original input.
  63303. * @param options The required width/height ratio to downsize to before computing the render pass.
  63304. * @param camera The camera to apply the render pass to.
  63305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63306. * @param engine The engine which the post process will be applied. (default: current engine)
  63307. * @param reusable If the post process can be reused on the same frame. (default: false)
  63308. * @param textureType Type of textures used when performing the post process. (default: 0)
  63309. * @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)
  63310. */
  63311. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63312. /** Weight of the bloom to be added to the original input. */
  63313. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63314. }
  63315. }
  63316. declare module "babylonjs/PostProcesses/bloomEffect" {
  63317. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63318. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63319. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63320. import { Camera } from "babylonjs/Cameras/camera";
  63321. import { Scene } from "babylonjs/scene";
  63322. /**
  63323. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63324. */
  63325. export class BloomEffect extends PostProcessRenderEffect {
  63326. private bloomScale;
  63327. /**
  63328. * @hidden Internal
  63329. */
  63330. _effects: Array<PostProcess>;
  63331. /**
  63332. * @hidden Internal
  63333. */
  63334. _downscale: ExtractHighlightsPostProcess;
  63335. private _blurX;
  63336. private _blurY;
  63337. private _merge;
  63338. /**
  63339. * The luminance threshold to find bright areas of the image to bloom.
  63340. */
  63341. threshold: number;
  63342. /**
  63343. * The strength of the bloom.
  63344. */
  63345. weight: number;
  63346. /**
  63347. * Specifies the size of the bloom blur kernel, relative to the final output size
  63348. */
  63349. kernel: number;
  63350. /**
  63351. * Creates a new instance of @see BloomEffect
  63352. * @param scene The scene the effect belongs to.
  63353. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63354. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63355. * @param bloomWeight The the strength of bloom.
  63356. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63357. * @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)
  63358. */
  63359. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63360. /**
  63361. * Disposes each of the internal effects for a given camera.
  63362. * @param camera The camera to dispose the effect on.
  63363. */
  63364. disposeEffects(camera: Camera): void;
  63365. /**
  63366. * @hidden Internal
  63367. */
  63368. _updateEffects(): void;
  63369. /**
  63370. * Internal
  63371. * @returns if all the contained post processes are ready.
  63372. * @hidden
  63373. */
  63374. _isReady(): boolean;
  63375. }
  63376. }
  63377. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63378. /** @hidden */
  63379. export var chromaticAberrationPixelShader: {
  63380. name: string;
  63381. shader: string;
  63382. };
  63383. }
  63384. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63385. import { Vector2 } from "babylonjs/Maths/math.vector";
  63386. import { Nullable } from "babylonjs/types";
  63387. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63388. import { Camera } from "babylonjs/Cameras/camera";
  63389. import { Engine } from "babylonjs/Engines/engine";
  63390. import "babylonjs/Shaders/chromaticAberration.fragment";
  63391. /**
  63392. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63393. */
  63394. export class ChromaticAberrationPostProcess extends PostProcess {
  63395. /**
  63396. * The amount of seperation of rgb channels (default: 30)
  63397. */
  63398. aberrationAmount: number;
  63399. /**
  63400. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63401. */
  63402. radialIntensity: number;
  63403. /**
  63404. * 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))
  63405. */
  63406. direction: Vector2;
  63407. /**
  63408. * 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))
  63409. */
  63410. centerPosition: Vector2;
  63411. /**
  63412. * Creates a new instance ChromaticAberrationPostProcess
  63413. * @param name The name of the effect.
  63414. * @param screenWidth The width of the screen to apply the effect on.
  63415. * @param screenHeight The height of the screen to apply the effect on.
  63416. * @param options The required width/height ratio to downsize to before computing the render pass.
  63417. * @param camera The camera to apply the render pass to.
  63418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63419. * @param engine The engine which the post process will be applied. (default: current engine)
  63420. * @param reusable If the post process can be reused on the same frame. (default: false)
  63421. * @param textureType Type of textures used when performing the post process. (default: 0)
  63422. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  63423. */
  63424. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63425. }
  63426. }
  63427. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63428. /** @hidden */
  63429. export var circleOfConfusionPixelShader: {
  63430. name: string;
  63431. shader: string;
  63432. };
  63433. }
  63434. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63435. import { Nullable } from "babylonjs/types";
  63436. import { Engine } from "babylonjs/Engines/engine";
  63437. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63438. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63439. import { Camera } from "babylonjs/Cameras/camera";
  63440. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63441. /**
  63442. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63443. */
  63444. export class CircleOfConfusionPostProcess extends PostProcess {
  63445. /**
  63446. * 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.
  63447. */
  63448. lensSize: number;
  63449. /**
  63450. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63451. */
  63452. fStop: number;
  63453. /**
  63454. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63455. */
  63456. focusDistance: number;
  63457. /**
  63458. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63459. */
  63460. focalLength: number;
  63461. private _depthTexture;
  63462. /**
  63463. * Creates a new instance CircleOfConfusionPostProcess
  63464. * @param name The name of the effect.
  63465. * @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.
  63466. * @param options The required width/height ratio to downsize to before computing the render pass.
  63467. * @param camera The camera to apply the render pass to.
  63468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63469. * @param engine The engine which the post process will be applied. (default: current engine)
  63470. * @param reusable If the post process can be reused on the same frame. (default: false)
  63471. * @param textureType Type of textures used when performing the post process. (default: 0)
  63472. * @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)
  63473. */
  63474. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63475. /**
  63476. * 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.
  63477. */
  63478. depthTexture: RenderTargetTexture;
  63479. }
  63480. }
  63481. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63482. /** @hidden */
  63483. export var colorCorrectionPixelShader: {
  63484. name: string;
  63485. shader: string;
  63486. };
  63487. }
  63488. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63490. import { Engine } from "babylonjs/Engines/engine";
  63491. import { Camera } from "babylonjs/Cameras/camera";
  63492. import "babylonjs/Shaders/colorCorrection.fragment";
  63493. /**
  63494. *
  63495. * This post-process allows the modification of rendered colors by using
  63496. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63497. *
  63498. * The object needs to be provided an url to a texture containing the color
  63499. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63500. * Use an image editing software to tweak the LUT to match your needs.
  63501. *
  63502. * For an example of a color LUT, see here:
  63503. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63504. * For explanations on color grading, see here:
  63505. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63506. *
  63507. */
  63508. export class ColorCorrectionPostProcess extends PostProcess {
  63509. private _colorTableTexture;
  63510. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63511. }
  63512. }
  63513. declare module "babylonjs/Shaders/convolution.fragment" {
  63514. /** @hidden */
  63515. export var convolutionPixelShader: {
  63516. name: string;
  63517. shader: string;
  63518. };
  63519. }
  63520. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63522. import { Nullable } from "babylonjs/types";
  63523. import { Camera } from "babylonjs/Cameras/camera";
  63524. import { Engine } from "babylonjs/Engines/engine";
  63525. import "babylonjs/Shaders/convolution.fragment";
  63526. /**
  63527. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63528. * input texture to perform effects such as edge detection or sharpening
  63529. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63530. */
  63531. export class ConvolutionPostProcess extends PostProcess {
  63532. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63533. kernel: number[];
  63534. /**
  63535. * Creates a new instance ConvolutionPostProcess
  63536. * @param name The name of the effect.
  63537. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63538. * @param options The required width/height ratio to downsize to before computing the render pass.
  63539. * @param camera The camera to apply the render pass to.
  63540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63541. * @param engine The engine which the post process will be applied. (default: current engine)
  63542. * @param reusable If the post process can be reused on the same frame. (default: false)
  63543. * @param textureType Type of textures used when performing the post process. (default: 0)
  63544. */
  63545. constructor(name: string,
  63546. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63547. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63548. /**
  63549. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63550. */
  63551. static EdgeDetect0Kernel: number[];
  63552. /**
  63553. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63554. */
  63555. static EdgeDetect1Kernel: number[];
  63556. /**
  63557. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63558. */
  63559. static EdgeDetect2Kernel: number[];
  63560. /**
  63561. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63562. */
  63563. static SharpenKernel: number[];
  63564. /**
  63565. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63566. */
  63567. static EmbossKernel: number[];
  63568. /**
  63569. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63570. */
  63571. static GaussianKernel: number[];
  63572. }
  63573. }
  63574. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63575. import { Nullable } from "babylonjs/types";
  63576. import { Vector2 } from "babylonjs/Maths/math.vector";
  63577. import { Camera } from "babylonjs/Cameras/camera";
  63578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63579. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63580. import { Engine } from "babylonjs/Engines/engine";
  63581. import { Scene } from "babylonjs/scene";
  63582. /**
  63583. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63584. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63585. * based on samples that have a large difference in distance than the center pixel.
  63586. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63587. */
  63588. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63589. direction: Vector2;
  63590. /**
  63591. * Creates a new instance CircleOfConfusionPostProcess
  63592. * @param name The name of the effect.
  63593. * @param scene The scene the effect belongs to.
  63594. * @param direction The direction the blur should be applied.
  63595. * @param kernel The size of the kernel used to blur.
  63596. * @param options The required width/height ratio to downsize to before computing the render pass.
  63597. * @param camera The camera to apply the render pass to.
  63598. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63599. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63601. * @param engine The engine which the post process will be applied. (default: current engine)
  63602. * @param reusable If the post process can be reused on the same frame. (default: false)
  63603. * @param textureType Type of textures used when performing the post process. (default: 0)
  63604. * @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)
  63605. */
  63606. 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);
  63607. }
  63608. }
  63609. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63610. /** @hidden */
  63611. export var depthOfFieldMergePixelShader: {
  63612. name: string;
  63613. shader: string;
  63614. };
  63615. }
  63616. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63617. import { Nullable } from "babylonjs/types";
  63618. import { Camera } from "babylonjs/Cameras/camera";
  63619. import { Effect } from "babylonjs/Materials/effect";
  63620. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63621. import { Engine } from "babylonjs/Engines/engine";
  63622. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63623. /**
  63624. * Options to be set when merging outputs from the default pipeline.
  63625. */
  63626. export class DepthOfFieldMergePostProcessOptions {
  63627. /**
  63628. * The original image to merge on top of
  63629. */
  63630. originalFromInput: PostProcess;
  63631. /**
  63632. * Parameters to perform the merge of the depth of field effect
  63633. */
  63634. depthOfField?: {
  63635. circleOfConfusion: PostProcess;
  63636. blurSteps: Array<PostProcess>;
  63637. };
  63638. /**
  63639. * Parameters to perform the merge of bloom effect
  63640. */
  63641. bloom?: {
  63642. blurred: PostProcess;
  63643. weight: number;
  63644. };
  63645. }
  63646. /**
  63647. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63648. */
  63649. export class DepthOfFieldMergePostProcess extends PostProcess {
  63650. private blurSteps;
  63651. /**
  63652. * Creates a new instance of DepthOfFieldMergePostProcess
  63653. * @param name The name of the effect.
  63654. * @param originalFromInput Post process which's input will be used for the merge.
  63655. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63656. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63657. * @param options The required width/height ratio to downsize to before computing the render pass.
  63658. * @param camera The camera to apply the render pass to.
  63659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63660. * @param engine The engine which the post process will be applied. (default: current engine)
  63661. * @param reusable If the post process can be reused on the same frame. (default: false)
  63662. * @param textureType Type of textures used when performing the post process. (default: 0)
  63663. * @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)
  63664. */
  63665. 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);
  63666. /**
  63667. * Updates the effect with the current post process compile time values and recompiles the shader.
  63668. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63669. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63670. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63671. * @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
  63672. * @param onCompiled Called when the shader has been compiled.
  63673. * @param onError Called if there is an error when compiling a shader.
  63674. */
  63675. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63676. }
  63677. }
  63678. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63679. import { Nullable } from "babylonjs/types";
  63680. import { Camera } from "babylonjs/Cameras/camera";
  63681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63682. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63683. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63684. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63685. import { Scene } from "babylonjs/scene";
  63686. /**
  63687. * Specifies the level of max blur that should be applied when using the depth of field effect
  63688. */
  63689. export enum DepthOfFieldEffectBlurLevel {
  63690. /**
  63691. * Subtle blur
  63692. */
  63693. Low = 0,
  63694. /**
  63695. * Medium blur
  63696. */
  63697. Medium = 1,
  63698. /**
  63699. * Large blur
  63700. */
  63701. High = 2
  63702. }
  63703. /**
  63704. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63705. */
  63706. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63707. private _circleOfConfusion;
  63708. /**
  63709. * @hidden Internal, blurs from high to low
  63710. */
  63711. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63712. private _depthOfFieldBlurY;
  63713. private _dofMerge;
  63714. /**
  63715. * @hidden Internal post processes in depth of field effect
  63716. */
  63717. _effects: Array<PostProcess>;
  63718. /**
  63719. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63720. */
  63721. focalLength: number;
  63722. /**
  63723. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63724. */
  63725. fStop: number;
  63726. /**
  63727. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63728. */
  63729. focusDistance: number;
  63730. /**
  63731. * 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.
  63732. */
  63733. lensSize: number;
  63734. /**
  63735. * Creates a new instance DepthOfFieldEffect
  63736. * @param scene The scene the effect belongs to.
  63737. * @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.
  63738. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63739. * @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)
  63740. */
  63741. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63742. /**
  63743. * Get the current class name of the current effet
  63744. * @returns "DepthOfFieldEffect"
  63745. */
  63746. getClassName(): string;
  63747. /**
  63748. * 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.
  63749. */
  63750. depthTexture: RenderTargetTexture;
  63751. /**
  63752. * Disposes each of the internal effects for a given camera.
  63753. * @param camera The camera to dispose the effect on.
  63754. */
  63755. disposeEffects(camera: Camera): void;
  63756. /**
  63757. * @hidden Internal
  63758. */
  63759. _updateEffects(): void;
  63760. /**
  63761. * Internal
  63762. * @returns if all the contained post processes are ready.
  63763. * @hidden
  63764. */
  63765. _isReady(): boolean;
  63766. }
  63767. }
  63768. declare module "babylonjs/Shaders/displayPass.fragment" {
  63769. /** @hidden */
  63770. export var displayPassPixelShader: {
  63771. name: string;
  63772. shader: string;
  63773. };
  63774. }
  63775. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63776. import { Nullable } from "babylonjs/types";
  63777. import { Camera } from "babylonjs/Cameras/camera";
  63778. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63779. import { Engine } from "babylonjs/Engines/engine";
  63780. import "babylonjs/Shaders/displayPass.fragment";
  63781. /**
  63782. * DisplayPassPostProcess which produces an output the same as it's input
  63783. */
  63784. export class DisplayPassPostProcess extends PostProcess {
  63785. /**
  63786. * Creates the DisplayPassPostProcess
  63787. * @param name The name of the effect.
  63788. * @param options The required width/height ratio to downsize to before computing the render pass.
  63789. * @param camera The camera to apply the render pass to.
  63790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63791. * @param engine The engine which the post process will be applied. (default: current engine)
  63792. * @param reusable If the post process can be reused on the same frame. (default: false)
  63793. */
  63794. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63795. }
  63796. }
  63797. declare module "babylonjs/Shaders/filter.fragment" {
  63798. /** @hidden */
  63799. export var filterPixelShader: {
  63800. name: string;
  63801. shader: string;
  63802. };
  63803. }
  63804. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63805. import { Nullable } from "babylonjs/types";
  63806. import { Matrix } from "babylonjs/Maths/math.vector";
  63807. import { Camera } from "babylonjs/Cameras/camera";
  63808. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63809. import { Engine } from "babylonjs/Engines/engine";
  63810. import "babylonjs/Shaders/filter.fragment";
  63811. /**
  63812. * Applies a kernel filter to the image
  63813. */
  63814. export class FilterPostProcess extends PostProcess {
  63815. /** The matrix to be applied to the image */
  63816. kernelMatrix: Matrix;
  63817. /**
  63818. *
  63819. * @param name The name of the effect.
  63820. * @param kernelMatrix The matrix to be applied to the image
  63821. * @param options The required width/height ratio to downsize to before computing the render pass.
  63822. * @param camera The camera to apply the render pass to.
  63823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63824. * @param engine The engine which the post process will be applied. (default: current engine)
  63825. * @param reusable If the post process can be reused on the same frame. (default: false)
  63826. */
  63827. constructor(name: string,
  63828. /** The matrix to be applied to the image */
  63829. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63830. }
  63831. }
  63832. declare module "babylonjs/Shaders/fxaa.fragment" {
  63833. /** @hidden */
  63834. export var fxaaPixelShader: {
  63835. name: string;
  63836. shader: string;
  63837. };
  63838. }
  63839. declare module "babylonjs/Shaders/fxaa.vertex" {
  63840. /** @hidden */
  63841. export var fxaaVertexShader: {
  63842. name: string;
  63843. shader: string;
  63844. };
  63845. }
  63846. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63847. import { Nullable } from "babylonjs/types";
  63848. import { Camera } from "babylonjs/Cameras/camera";
  63849. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63850. import { Engine } from "babylonjs/Engines/engine";
  63851. import "babylonjs/Shaders/fxaa.fragment";
  63852. import "babylonjs/Shaders/fxaa.vertex";
  63853. /**
  63854. * Fxaa post process
  63855. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63856. */
  63857. export class FxaaPostProcess extends PostProcess {
  63858. /** @hidden */
  63859. texelWidth: number;
  63860. /** @hidden */
  63861. texelHeight: number;
  63862. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63863. private _getDefines;
  63864. }
  63865. }
  63866. declare module "babylonjs/Shaders/grain.fragment" {
  63867. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63868. /** @hidden */
  63869. export var grainPixelShader: {
  63870. name: string;
  63871. shader: string;
  63872. };
  63873. }
  63874. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63875. import { Nullable } from "babylonjs/types";
  63876. import { Camera } from "babylonjs/Cameras/camera";
  63877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63878. import { Engine } from "babylonjs/Engines/engine";
  63879. import "babylonjs/Shaders/grain.fragment";
  63880. /**
  63881. * The GrainPostProcess adds noise to the image at mid luminance levels
  63882. */
  63883. export class GrainPostProcess extends PostProcess {
  63884. /**
  63885. * The intensity of the grain added (default: 30)
  63886. */
  63887. intensity: number;
  63888. /**
  63889. * If the grain should be randomized on every frame
  63890. */
  63891. animated: boolean;
  63892. /**
  63893. * Creates a new instance of @see GrainPostProcess
  63894. * @param name The name of the effect.
  63895. * @param options The required width/height ratio to downsize to before computing the render pass.
  63896. * @param camera The camera to apply the render pass to.
  63897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63898. * @param engine The engine which the post process will be applied. (default: current engine)
  63899. * @param reusable If the post process can be reused on the same frame. (default: false)
  63900. * @param textureType Type of textures used when performing the post process. (default: 0)
  63901. * @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)
  63902. */
  63903. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63904. }
  63905. }
  63906. declare module "babylonjs/Shaders/highlights.fragment" {
  63907. /** @hidden */
  63908. export var highlightsPixelShader: {
  63909. name: string;
  63910. shader: string;
  63911. };
  63912. }
  63913. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63914. import { Nullable } from "babylonjs/types";
  63915. import { Camera } from "babylonjs/Cameras/camera";
  63916. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63917. import { Engine } from "babylonjs/Engines/engine";
  63918. import "babylonjs/Shaders/highlights.fragment";
  63919. /**
  63920. * Extracts highlights from the image
  63921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63922. */
  63923. export class HighlightsPostProcess extends PostProcess {
  63924. /**
  63925. * Extracts highlights from the image
  63926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63927. * @param name The name of the effect.
  63928. * @param options The required width/height ratio to downsize to before computing the render pass.
  63929. * @param camera The camera to apply the render pass to.
  63930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63931. * @param engine The engine which the post process will be applied. (default: current engine)
  63932. * @param reusable If the post process can be reused on the same frame. (default: false)
  63933. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63934. */
  63935. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63936. }
  63937. }
  63938. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63939. /** @hidden */
  63940. export var mrtFragmentDeclaration: {
  63941. name: string;
  63942. shader: string;
  63943. };
  63944. }
  63945. declare module "babylonjs/Shaders/geometry.fragment" {
  63946. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63947. /** @hidden */
  63948. export var geometryPixelShader: {
  63949. name: string;
  63950. shader: string;
  63951. };
  63952. }
  63953. declare module "babylonjs/Shaders/geometry.vertex" {
  63954. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63956. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63957. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63958. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63959. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63960. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63961. /** @hidden */
  63962. export var geometryVertexShader: {
  63963. name: string;
  63964. shader: string;
  63965. };
  63966. }
  63967. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63968. import { Matrix } from "babylonjs/Maths/math.vector";
  63969. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63970. import { Mesh } from "babylonjs/Meshes/mesh";
  63971. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63972. import { Effect } from "babylonjs/Materials/effect";
  63973. import { Scene } from "babylonjs/scene";
  63974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63975. import "babylonjs/Shaders/geometry.fragment";
  63976. import "babylonjs/Shaders/geometry.vertex";
  63977. /** @hidden */
  63978. interface ISavedTransformationMatrix {
  63979. world: Matrix;
  63980. viewProjection: Matrix;
  63981. }
  63982. /**
  63983. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63984. */
  63985. export class GeometryBufferRenderer {
  63986. /**
  63987. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63988. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63989. */
  63990. static readonly POSITION_TEXTURE_TYPE: number;
  63991. /**
  63992. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63993. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63994. */
  63995. static readonly VELOCITY_TEXTURE_TYPE: number;
  63996. /**
  63997. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63998. * in order to compute objects velocities when enableVelocity is set to "true"
  63999. * @hidden
  64000. */
  64001. _previousTransformationMatrices: {
  64002. [index: number]: ISavedTransformationMatrix;
  64003. };
  64004. /**
  64005. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64006. * in order to compute objects velocities when enableVelocity is set to "true"
  64007. * @hidden
  64008. */
  64009. _previousBonesTransformationMatrices: {
  64010. [index: number]: Float32Array;
  64011. };
  64012. /**
  64013. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64014. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64015. */
  64016. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64017. private _scene;
  64018. private _multiRenderTarget;
  64019. private _ratio;
  64020. private _enablePosition;
  64021. private _enableVelocity;
  64022. private _positionIndex;
  64023. private _velocityIndex;
  64024. protected _effect: Effect;
  64025. protected _cachedDefines: string;
  64026. /**
  64027. * Set the render list (meshes to be rendered) used in the G buffer.
  64028. */
  64029. renderList: Mesh[];
  64030. /**
  64031. * Gets wether or not G buffer are supported by the running hardware.
  64032. * This requires draw buffer supports
  64033. */
  64034. readonly isSupported: boolean;
  64035. /**
  64036. * Returns the index of the given texture type in the G-Buffer textures array
  64037. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64038. * @returns the index of the given texture type in the G-Buffer textures array
  64039. */
  64040. getTextureIndex(textureType: number): number;
  64041. /**
  64042. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64043. */
  64044. /**
  64045. * Sets whether or not objects positions are enabled for the G buffer.
  64046. */
  64047. enablePosition: boolean;
  64048. /**
  64049. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64050. */
  64051. /**
  64052. * Sets wether or not objects velocities are enabled for the G buffer.
  64053. */
  64054. enableVelocity: boolean;
  64055. /**
  64056. * Gets the scene associated with the buffer.
  64057. */
  64058. readonly scene: Scene;
  64059. /**
  64060. * Gets the ratio used by the buffer during its creation.
  64061. * How big is the buffer related to the main canvas.
  64062. */
  64063. readonly ratio: number;
  64064. /** @hidden */
  64065. static _SceneComponentInitialization: (scene: Scene) => void;
  64066. /**
  64067. * Creates a new G Buffer for the scene
  64068. * @param scene The scene the buffer belongs to
  64069. * @param ratio How big is the buffer related to the main canvas.
  64070. */
  64071. constructor(scene: Scene, ratio?: number);
  64072. /**
  64073. * Checks wether everything is ready to render a submesh to the G buffer.
  64074. * @param subMesh the submesh to check readiness for
  64075. * @param useInstances is the mesh drawn using instance or not
  64076. * @returns true if ready otherwise false
  64077. */
  64078. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64079. /**
  64080. * Gets the current underlying G Buffer.
  64081. * @returns the buffer
  64082. */
  64083. getGBuffer(): MultiRenderTarget;
  64084. /**
  64085. * Gets the number of samples used to render the buffer (anti aliasing).
  64086. */
  64087. /**
  64088. * Sets the number of samples used to render the buffer (anti aliasing).
  64089. */
  64090. samples: number;
  64091. /**
  64092. * Disposes the renderer and frees up associated resources.
  64093. */
  64094. dispose(): void;
  64095. protected _createRenderTargets(): void;
  64096. private _copyBonesTransformationMatrices;
  64097. }
  64098. }
  64099. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64100. import { Nullable } from "babylonjs/types";
  64101. import { Scene } from "babylonjs/scene";
  64102. import { ISceneComponent } from "babylonjs/sceneComponent";
  64103. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64104. module "babylonjs/scene" {
  64105. interface Scene {
  64106. /** @hidden (Backing field) */
  64107. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64108. /**
  64109. * Gets or Sets the current geometry buffer associated to the scene.
  64110. */
  64111. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64112. /**
  64113. * Enables a GeometryBufferRender and associates it with the scene
  64114. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64115. * @returns the GeometryBufferRenderer
  64116. */
  64117. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64118. /**
  64119. * Disables the GeometryBufferRender associated with the scene
  64120. */
  64121. disableGeometryBufferRenderer(): void;
  64122. }
  64123. }
  64124. /**
  64125. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64126. * in several rendering techniques.
  64127. */
  64128. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64129. /**
  64130. * The component name helpful to identify the component in the list of scene components.
  64131. */
  64132. readonly name: string;
  64133. /**
  64134. * The scene the component belongs to.
  64135. */
  64136. scene: Scene;
  64137. /**
  64138. * Creates a new instance of the component for the given scene
  64139. * @param scene Defines the scene to register the component in
  64140. */
  64141. constructor(scene: Scene);
  64142. /**
  64143. * Registers the component in a given scene
  64144. */
  64145. register(): void;
  64146. /**
  64147. * Rebuilds the elements related to this component in case of
  64148. * context lost for instance.
  64149. */
  64150. rebuild(): void;
  64151. /**
  64152. * Disposes the component and the associated ressources
  64153. */
  64154. dispose(): void;
  64155. private _gatherRenderTargets;
  64156. }
  64157. }
  64158. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64159. /** @hidden */
  64160. export var motionBlurPixelShader: {
  64161. name: string;
  64162. shader: string;
  64163. };
  64164. }
  64165. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64166. import { Nullable } from "babylonjs/types";
  64167. import { Camera } from "babylonjs/Cameras/camera";
  64168. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64169. import { Scene } from "babylonjs/scene";
  64170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64171. import "babylonjs/Animations/animatable";
  64172. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64173. import "babylonjs/Shaders/motionBlur.fragment";
  64174. import { Engine } from "babylonjs/Engines/engine";
  64175. /**
  64176. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64177. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64178. * As an example, all you have to do is to create the post-process:
  64179. * var mb = new BABYLON.MotionBlurPostProcess(
  64180. * 'mb', // The name of the effect.
  64181. * scene, // The scene containing the objects to blur according to their velocity.
  64182. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64183. * camera // The camera to apply the render pass to.
  64184. * );
  64185. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64186. */
  64187. export class MotionBlurPostProcess extends PostProcess {
  64188. /**
  64189. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64190. */
  64191. motionStrength: number;
  64192. /**
  64193. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64194. */
  64195. /**
  64196. * Sets the number of iterations to be used for motion blur quality
  64197. */
  64198. motionBlurSamples: number;
  64199. private _motionBlurSamples;
  64200. private _geometryBufferRenderer;
  64201. /**
  64202. * Creates a new instance MotionBlurPostProcess
  64203. * @param name The name of the effect.
  64204. * @param scene The scene containing the objects to blur according to their velocity.
  64205. * @param options The required width/height ratio to downsize to before computing the render pass.
  64206. * @param camera The camera to apply the render pass to.
  64207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64208. * @param engine The engine which the post process will be applied. (default: current engine)
  64209. * @param reusable If the post process can be reused on the same frame. (default: false)
  64210. * @param textureType Type of textures used when performing the post process. (default: 0)
  64211. * @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)
  64212. */
  64213. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64214. /**
  64215. * Excludes the given skinned mesh from computing bones velocities.
  64216. * 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.
  64217. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64218. */
  64219. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64220. /**
  64221. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64222. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64223. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64224. */
  64225. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64226. /**
  64227. * Disposes the post process.
  64228. * @param camera The camera to dispose the post process on.
  64229. */
  64230. dispose(camera?: Camera): void;
  64231. }
  64232. }
  64233. declare module "babylonjs/Shaders/refraction.fragment" {
  64234. /** @hidden */
  64235. export var refractionPixelShader: {
  64236. name: string;
  64237. shader: string;
  64238. };
  64239. }
  64240. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64241. import { Color3 } from "babylonjs/Maths/math.color";
  64242. import { Camera } from "babylonjs/Cameras/camera";
  64243. import { Texture } from "babylonjs/Materials/Textures/texture";
  64244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64245. import { Engine } from "babylonjs/Engines/engine";
  64246. import "babylonjs/Shaders/refraction.fragment";
  64247. /**
  64248. * Post process which applies a refractin texture
  64249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64250. */
  64251. export class RefractionPostProcess extends PostProcess {
  64252. /** the base color of the refraction (used to taint the rendering) */
  64253. color: Color3;
  64254. /** simulated refraction depth */
  64255. depth: number;
  64256. /** the coefficient of the base color (0 to remove base color tainting) */
  64257. colorLevel: number;
  64258. private _refTexture;
  64259. private _ownRefractionTexture;
  64260. /**
  64261. * Gets or sets the refraction texture
  64262. * Please note that you are responsible for disposing the texture if you set it manually
  64263. */
  64264. refractionTexture: Texture;
  64265. /**
  64266. * Initializes the RefractionPostProcess
  64267. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64268. * @param name The name of the effect.
  64269. * @param refractionTextureUrl Url of the refraction texture to use
  64270. * @param color the base color of the refraction (used to taint the rendering)
  64271. * @param depth simulated refraction depth
  64272. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64273. * @param camera The camera to apply the render pass to.
  64274. * @param options The required width/height ratio to downsize to before computing the render pass.
  64275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64276. * @param engine The engine which the post process will be applied. (default: current engine)
  64277. * @param reusable If the post process can be reused on the same frame. (default: false)
  64278. */
  64279. constructor(name: string, refractionTextureUrl: string,
  64280. /** the base color of the refraction (used to taint the rendering) */
  64281. color: Color3,
  64282. /** simulated refraction depth */
  64283. depth: number,
  64284. /** the coefficient of the base color (0 to remove base color tainting) */
  64285. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64286. /**
  64287. * Disposes of the post process
  64288. * @param camera Camera to dispose post process on
  64289. */
  64290. dispose(camera: Camera): void;
  64291. }
  64292. }
  64293. declare module "babylonjs/Shaders/sharpen.fragment" {
  64294. /** @hidden */
  64295. export var sharpenPixelShader: {
  64296. name: string;
  64297. shader: string;
  64298. };
  64299. }
  64300. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64301. import { Nullable } from "babylonjs/types";
  64302. import { Camera } from "babylonjs/Cameras/camera";
  64303. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64304. import "babylonjs/Shaders/sharpen.fragment";
  64305. import { Engine } from "babylonjs/Engines/engine";
  64306. /**
  64307. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64308. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64309. */
  64310. export class SharpenPostProcess extends PostProcess {
  64311. /**
  64312. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64313. */
  64314. colorAmount: number;
  64315. /**
  64316. * How much sharpness should be applied (default: 0.3)
  64317. */
  64318. edgeAmount: number;
  64319. /**
  64320. * Creates a new instance ConvolutionPostProcess
  64321. * @param name The name of the effect.
  64322. * @param options The required width/height ratio to downsize to before computing the render pass.
  64323. * @param camera The camera to apply the render pass to.
  64324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64325. * @param engine The engine which the post process will be applied. (default: current engine)
  64326. * @param reusable If the post process can be reused on the same frame. (default: false)
  64327. * @param textureType Type of textures used when performing the post process. (default: 0)
  64328. * @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)
  64329. */
  64330. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64331. }
  64332. }
  64333. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64334. import { Nullable } from "babylonjs/types";
  64335. import { Camera } from "babylonjs/Cameras/camera";
  64336. import { Engine } from "babylonjs/Engines/engine";
  64337. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64338. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64339. /**
  64340. * PostProcessRenderPipeline
  64341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64342. */
  64343. export class PostProcessRenderPipeline {
  64344. private engine;
  64345. private _renderEffects;
  64346. private _renderEffectsForIsolatedPass;
  64347. /**
  64348. * List of inspectable custom properties (used by the Inspector)
  64349. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64350. */
  64351. inspectableCustomProperties: IInspectable[];
  64352. /**
  64353. * @hidden
  64354. */
  64355. protected _cameras: Camera[];
  64356. /** @hidden */
  64357. _name: string;
  64358. /**
  64359. * Gets pipeline name
  64360. */
  64361. readonly name: string;
  64362. /** Gets the list of attached cameras */
  64363. readonly cameras: Camera[];
  64364. /**
  64365. * Initializes a PostProcessRenderPipeline
  64366. * @param engine engine to add the pipeline to
  64367. * @param name name of the pipeline
  64368. */
  64369. constructor(engine: Engine, name: string);
  64370. /**
  64371. * Gets the class name
  64372. * @returns "PostProcessRenderPipeline"
  64373. */
  64374. getClassName(): string;
  64375. /**
  64376. * If all the render effects in the pipeline are supported
  64377. */
  64378. readonly isSupported: boolean;
  64379. /**
  64380. * Adds an effect to the pipeline
  64381. * @param renderEffect the effect to add
  64382. */
  64383. addEffect(renderEffect: PostProcessRenderEffect): void;
  64384. /** @hidden */
  64385. _rebuild(): void;
  64386. /** @hidden */
  64387. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64388. /** @hidden */
  64389. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64390. /** @hidden */
  64391. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64392. /** @hidden */
  64393. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64394. /** @hidden */
  64395. _attachCameras(cameras: Camera, unique: boolean): void;
  64396. /** @hidden */
  64397. _attachCameras(cameras: Camera[], unique: boolean): void;
  64398. /** @hidden */
  64399. _detachCameras(cameras: Camera): void;
  64400. /** @hidden */
  64401. _detachCameras(cameras: Nullable<Camera[]>): void;
  64402. /** @hidden */
  64403. _update(): void;
  64404. /** @hidden */
  64405. _reset(): void;
  64406. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64407. /**
  64408. * Disposes of the pipeline
  64409. */
  64410. dispose(): void;
  64411. }
  64412. }
  64413. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64414. import { Camera } from "babylonjs/Cameras/camera";
  64415. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64416. /**
  64417. * PostProcessRenderPipelineManager class
  64418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64419. */
  64420. export class PostProcessRenderPipelineManager {
  64421. private _renderPipelines;
  64422. /**
  64423. * Initializes a PostProcessRenderPipelineManager
  64424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64425. */
  64426. constructor();
  64427. /**
  64428. * Gets the list of supported render pipelines
  64429. */
  64430. readonly supportedPipelines: PostProcessRenderPipeline[];
  64431. /**
  64432. * Adds a pipeline to the manager
  64433. * @param renderPipeline The pipeline to add
  64434. */
  64435. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64436. /**
  64437. * Attaches a camera to the pipeline
  64438. * @param renderPipelineName The name of the pipeline to attach to
  64439. * @param cameras the camera to attach
  64440. * @param unique if the camera can be attached multiple times to the pipeline
  64441. */
  64442. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64443. /**
  64444. * Detaches a camera from the pipeline
  64445. * @param renderPipelineName The name of the pipeline to detach from
  64446. * @param cameras the camera to detach
  64447. */
  64448. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64449. /**
  64450. * Enables an effect by name on a pipeline
  64451. * @param renderPipelineName the name of the pipeline to enable the effect in
  64452. * @param renderEffectName the name of the effect to enable
  64453. * @param cameras the cameras that the effect should be enabled on
  64454. */
  64455. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64456. /**
  64457. * Disables an effect by name on a pipeline
  64458. * @param renderPipelineName the name of the pipeline to disable the effect in
  64459. * @param renderEffectName the name of the effect to disable
  64460. * @param cameras the cameras that the effect should be disabled on
  64461. */
  64462. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64463. /**
  64464. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64465. */
  64466. update(): void;
  64467. /** @hidden */
  64468. _rebuild(): void;
  64469. /**
  64470. * Disposes of the manager and pipelines
  64471. */
  64472. dispose(): void;
  64473. }
  64474. }
  64475. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64476. import { ISceneComponent } from "babylonjs/sceneComponent";
  64477. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64478. import { Scene } from "babylonjs/scene";
  64479. module "babylonjs/scene" {
  64480. interface Scene {
  64481. /** @hidden (Backing field) */
  64482. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64483. /**
  64484. * Gets the postprocess render pipeline manager
  64485. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64486. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64487. */
  64488. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64489. }
  64490. }
  64491. /**
  64492. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64493. */
  64494. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64495. /**
  64496. * The component name helpfull to identify the component in the list of scene components.
  64497. */
  64498. readonly name: string;
  64499. /**
  64500. * The scene the component belongs to.
  64501. */
  64502. scene: Scene;
  64503. /**
  64504. * Creates a new instance of the component for the given scene
  64505. * @param scene Defines the scene to register the component in
  64506. */
  64507. constructor(scene: Scene);
  64508. /**
  64509. * Registers the component in a given scene
  64510. */
  64511. register(): void;
  64512. /**
  64513. * Rebuilds the elements related to this component in case of
  64514. * context lost for instance.
  64515. */
  64516. rebuild(): void;
  64517. /**
  64518. * Disposes the component and the associated ressources
  64519. */
  64520. dispose(): void;
  64521. private _gatherRenderTargets;
  64522. }
  64523. }
  64524. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64525. import { Nullable } from "babylonjs/types";
  64526. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64527. import { Camera } from "babylonjs/Cameras/camera";
  64528. import { IDisposable } from "babylonjs/scene";
  64529. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64530. import { Scene } from "babylonjs/scene";
  64531. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64532. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64533. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64534. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64535. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64536. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64537. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64538. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64539. import { Animation } from "babylonjs/Animations/animation";
  64540. /**
  64541. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64542. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64543. */
  64544. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64545. private _scene;
  64546. private _camerasToBeAttached;
  64547. /**
  64548. * ID of the sharpen post process,
  64549. */
  64550. private readonly SharpenPostProcessId;
  64551. /**
  64552. * @ignore
  64553. * ID of the image processing post process;
  64554. */
  64555. readonly ImageProcessingPostProcessId: string;
  64556. /**
  64557. * @ignore
  64558. * ID of the Fast Approximate Anti-Aliasing post process;
  64559. */
  64560. readonly FxaaPostProcessId: string;
  64561. /**
  64562. * ID of the chromatic aberration post process,
  64563. */
  64564. private readonly ChromaticAberrationPostProcessId;
  64565. /**
  64566. * ID of the grain post process
  64567. */
  64568. private readonly GrainPostProcessId;
  64569. /**
  64570. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64571. */
  64572. sharpen: SharpenPostProcess;
  64573. private _sharpenEffect;
  64574. private bloom;
  64575. /**
  64576. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64577. */
  64578. depthOfField: DepthOfFieldEffect;
  64579. /**
  64580. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64581. */
  64582. fxaa: FxaaPostProcess;
  64583. /**
  64584. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64585. */
  64586. imageProcessing: ImageProcessingPostProcess;
  64587. /**
  64588. * Chromatic aberration post process which will shift rgb colors in the image
  64589. */
  64590. chromaticAberration: ChromaticAberrationPostProcess;
  64591. private _chromaticAberrationEffect;
  64592. /**
  64593. * Grain post process which add noise to the image
  64594. */
  64595. grain: GrainPostProcess;
  64596. private _grainEffect;
  64597. /**
  64598. * Glow post process which adds a glow to emissive areas of the image
  64599. */
  64600. private _glowLayer;
  64601. /**
  64602. * Animations which can be used to tweak settings over a period of time
  64603. */
  64604. animations: Animation[];
  64605. private _imageProcessingConfigurationObserver;
  64606. private _sharpenEnabled;
  64607. private _bloomEnabled;
  64608. private _depthOfFieldEnabled;
  64609. private _depthOfFieldBlurLevel;
  64610. private _fxaaEnabled;
  64611. private _imageProcessingEnabled;
  64612. private _defaultPipelineTextureType;
  64613. private _bloomScale;
  64614. private _chromaticAberrationEnabled;
  64615. private _grainEnabled;
  64616. private _buildAllowed;
  64617. /**
  64618. * Gets active scene
  64619. */
  64620. readonly scene: Scene;
  64621. /**
  64622. * Enable or disable the sharpen process from the pipeline
  64623. */
  64624. sharpenEnabled: boolean;
  64625. private _resizeObserver;
  64626. private _hardwareScaleLevel;
  64627. private _bloomKernel;
  64628. /**
  64629. * Specifies the size of the bloom blur kernel, relative to the final output size
  64630. */
  64631. bloomKernel: number;
  64632. /**
  64633. * Specifies the weight of the bloom in the final rendering
  64634. */
  64635. private _bloomWeight;
  64636. /**
  64637. * Specifies the luma threshold for the area that will be blurred by the bloom
  64638. */
  64639. private _bloomThreshold;
  64640. private _hdr;
  64641. /**
  64642. * The strength of the bloom.
  64643. */
  64644. bloomWeight: number;
  64645. /**
  64646. * The strength of the bloom.
  64647. */
  64648. bloomThreshold: number;
  64649. /**
  64650. * The scale of the bloom, lower value will provide better performance.
  64651. */
  64652. bloomScale: number;
  64653. /**
  64654. * Enable or disable the bloom from the pipeline
  64655. */
  64656. bloomEnabled: boolean;
  64657. private _rebuildBloom;
  64658. /**
  64659. * If the depth of field is enabled.
  64660. */
  64661. depthOfFieldEnabled: boolean;
  64662. /**
  64663. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64664. */
  64665. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64666. /**
  64667. * If the anti aliasing is enabled.
  64668. */
  64669. fxaaEnabled: boolean;
  64670. private _samples;
  64671. /**
  64672. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64673. */
  64674. samples: number;
  64675. /**
  64676. * If image processing is enabled.
  64677. */
  64678. imageProcessingEnabled: boolean;
  64679. /**
  64680. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64681. */
  64682. glowLayerEnabled: boolean;
  64683. /**
  64684. * Gets the glow layer (or null if not defined)
  64685. */
  64686. readonly glowLayer: Nullable<GlowLayer>;
  64687. /**
  64688. * Enable or disable the chromaticAberration process from the pipeline
  64689. */
  64690. chromaticAberrationEnabled: boolean;
  64691. /**
  64692. * Enable or disable the grain process from the pipeline
  64693. */
  64694. grainEnabled: boolean;
  64695. /**
  64696. * @constructor
  64697. * @param name - The rendering pipeline name (default: "")
  64698. * @param hdr - If high dynamic range textures should be used (default: true)
  64699. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64700. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64701. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64702. */
  64703. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64704. /**
  64705. * Get the class name
  64706. * @returns "DefaultRenderingPipeline"
  64707. */
  64708. getClassName(): string;
  64709. /**
  64710. * Force the compilation of the entire pipeline.
  64711. */
  64712. prepare(): void;
  64713. private _hasCleared;
  64714. private _prevPostProcess;
  64715. private _prevPrevPostProcess;
  64716. private _setAutoClearAndTextureSharing;
  64717. private _depthOfFieldSceneObserver;
  64718. private _buildPipeline;
  64719. private _disposePostProcesses;
  64720. /**
  64721. * Adds a camera to the pipeline
  64722. * @param camera the camera to be added
  64723. */
  64724. addCamera(camera: Camera): void;
  64725. /**
  64726. * Removes a camera from the pipeline
  64727. * @param camera the camera to remove
  64728. */
  64729. removeCamera(camera: Camera): void;
  64730. /**
  64731. * Dispose of the pipeline and stop all post processes
  64732. */
  64733. dispose(): void;
  64734. /**
  64735. * Serialize the rendering pipeline (Used when exporting)
  64736. * @returns the serialized object
  64737. */
  64738. serialize(): any;
  64739. /**
  64740. * Parse the serialized pipeline
  64741. * @param source Source pipeline.
  64742. * @param scene The scene to load the pipeline to.
  64743. * @param rootUrl The URL of the serialized pipeline.
  64744. * @returns An instantiated pipeline from the serialized object.
  64745. */
  64746. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64747. }
  64748. }
  64749. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64750. /** @hidden */
  64751. export var lensHighlightsPixelShader: {
  64752. name: string;
  64753. shader: string;
  64754. };
  64755. }
  64756. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64757. /** @hidden */
  64758. export var depthOfFieldPixelShader: {
  64759. name: string;
  64760. shader: string;
  64761. };
  64762. }
  64763. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64764. import { Camera } from "babylonjs/Cameras/camera";
  64765. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64766. import { Scene } from "babylonjs/scene";
  64767. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64768. import "babylonjs/Shaders/chromaticAberration.fragment";
  64769. import "babylonjs/Shaders/lensHighlights.fragment";
  64770. import "babylonjs/Shaders/depthOfField.fragment";
  64771. /**
  64772. * BABYLON.JS Chromatic Aberration GLSL Shader
  64773. * Author: Olivier Guyot
  64774. * Separates very slightly R, G and B colors on the edges of the screen
  64775. * Inspired by Francois Tarlier & Martins Upitis
  64776. */
  64777. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64778. /**
  64779. * @ignore
  64780. * The chromatic aberration PostProcess id in the pipeline
  64781. */
  64782. LensChromaticAberrationEffect: string;
  64783. /**
  64784. * @ignore
  64785. * The highlights enhancing PostProcess id in the pipeline
  64786. */
  64787. HighlightsEnhancingEffect: string;
  64788. /**
  64789. * @ignore
  64790. * The depth-of-field PostProcess id in the pipeline
  64791. */
  64792. LensDepthOfFieldEffect: string;
  64793. private _scene;
  64794. private _depthTexture;
  64795. private _grainTexture;
  64796. private _chromaticAberrationPostProcess;
  64797. private _highlightsPostProcess;
  64798. private _depthOfFieldPostProcess;
  64799. private _edgeBlur;
  64800. private _grainAmount;
  64801. private _chromaticAberration;
  64802. private _distortion;
  64803. private _highlightsGain;
  64804. private _highlightsThreshold;
  64805. private _dofDistance;
  64806. private _dofAperture;
  64807. private _dofDarken;
  64808. private _dofPentagon;
  64809. private _blurNoise;
  64810. /**
  64811. * @constructor
  64812. *
  64813. * Effect parameters are as follow:
  64814. * {
  64815. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64816. * edge_blur: number; // from 0 to x (1 for realism)
  64817. * distortion: number; // from 0 to x (1 for realism)
  64818. * grain_amount: number; // from 0 to 1
  64819. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64820. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64821. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64822. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64823. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64824. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64825. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64826. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64827. * }
  64828. * Note: if an effect parameter is unset, effect is disabled
  64829. *
  64830. * @param name The rendering pipeline name
  64831. * @param parameters - An object containing all parameters (see above)
  64832. * @param scene The scene linked to this pipeline
  64833. * @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)
  64834. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64835. */
  64836. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64837. /**
  64838. * Get the class name
  64839. * @returns "LensRenderingPipeline"
  64840. */
  64841. getClassName(): string;
  64842. /**
  64843. * Gets associated scene
  64844. */
  64845. readonly scene: Scene;
  64846. /**
  64847. * Gets or sets the edge blur
  64848. */
  64849. edgeBlur: number;
  64850. /**
  64851. * Gets or sets the grain amount
  64852. */
  64853. grainAmount: number;
  64854. /**
  64855. * Gets or sets the chromatic aberration amount
  64856. */
  64857. chromaticAberration: number;
  64858. /**
  64859. * Gets or sets the depth of field aperture
  64860. */
  64861. dofAperture: number;
  64862. /**
  64863. * Gets or sets the edge distortion
  64864. */
  64865. edgeDistortion: number;
  64866. /**
  64867. * Gets or sets the depth of field distortion
  64868. */
  64869. dofDistortion: number;
  64870. /**
  64871. * Gets or sets the darken out of focus amount
  64872. */
  64873. darkenOutOfFocus: number;
  64874. /**
  64875. * Gets or sets a boolean indicating if blur noise is enabled
  64876. */
  64877. blurNoise: boolean;
  64878. /**
  64879. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64880. */
  64881. pentagonBokeh: boolean;
  64882. /**
  64883. * Gets or sets the highlight grain amount
  64884. */
  64885. highlightsGain: number;
  64886. /**
  64887. * Gets or sets the highlight threshold
  64888. */
  64889. highlightsThreshold: number;
  64890. /**
  64891. * Sets the amount of blur at the edges
  64892. * @param amount blur amount
  64893. */
  64894. setEdgeBlur(amount: number): void;
  64895. /**
  64896. * Sets edge blur to 0
  64897. */
  64898. disableEdgeBlur(): void;
  64899. /**
  64900. * Sets the amout of grain
  64901. * @param amount Amount of grain
  64902. */
  64903. setGrainAmount(amount: number): void;
  64904. /**
  64905. * Set grain amount to 0
  64906. */
  64907. disableGrain(): void;
  64908. /**
  64909. * Sets the chromatic aberration amount
  64910. * @param amount amount of chromatic aberration
  64911. */
  64912. setChromaticAberration(amount: number): void;
  64913. /**
  64914. * Sets chromatic aberration amount to 0
  64915. */
  64916. disableChromaticAberration(): void;
  64917. /**
  64918. * Sets the EdgeDistortion amount
  64919. * @param amount amount of EdgeDistortion
  64920. */
  64921. setEdgeDistortion(amount: number): void;
  64922. /**
  64923. * Sets edge distortion to 0
  64924. */
  64925. disableEdgeDistortion(): void;
  64926. /**
  64927. * Sets the FocusDistance amount
  64928. * @param amount amount of FocusDistance
  64929. */
  64930. setFocusDistance(amount: number): void;
  64931. /**
  64932. * Disables depth of field
  64933. */
  64934. disableDepthOfField(): void;
  64935. /**
  64936. * Sets the Aperture amount
  64937. * @param amount amount of Aperture
  64938. */
  64939. setAperture(amount: number): void;
  64940. /**
  64941. * Sets the DarkenOutOfFocus amount
  64942. * @param amount amount of DarkenOutOfFocus
  64943. */
  64944. setDarkenOutOfFocus(amount: number): void;
  64945. private _pentagonBokehIsEnabled;
  64946. /**
  64947. * Creates a pentagon bokeh effect
  64948. */
  64949. enablePentagonBokeh(): void;
  64950. /**
  64951. * Disables the pentagon bokeh effect
  64952. */
  64953. disablePentagonBokeh(): void;
  64954. /**
  64955. * Enables noise blur
  64956. */
  64957. enableNoiseBlur(): void;
  64958. /**
  64959. * Disables noise blur
  64960. */
  64961. disableNoiseBlur(): void;
  64962. /**
  64963. * Sets the HighlightsGain amount
  64964. * @param amount amount of HighlightsGain
  64965. */
  64966. setHighlightsGain(amount: number): void;
  64967. /**
  64968. * Sets the HighlightsThreshold amount
  64969. * @param amount amount of HighlightsThreshold
  64970. */
  64971. setHighlightsThreshold(amount: number): void;
  64972. /**
  64973. * Disables highlights
  64974. */
  64975. disableHighlights(): void;
  64976. /**
  64977. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64978. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64979. */
  64980. dispose(disableDepthRender?: boolean): void;
  64981. private _createChromaticAberrationPostProcess;
  64982. private _createHighlightsPostProcess;
  64983. private _createDepthOfFieldPostProcess;
  64984. private _createGrainTexture;
  64985. }
  64986. }
  64987. declare module "babylonjs/Shaders/ssao2.fragment" {
  64988. /** @hidden */
  64989. export var ssao2PixelShader: {
  64990. name: string;
  64991. shader: string;
  64992. };
  64993. }
  64994. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64995. /** @hidden */
  64996. export var ssaoCombinePixelShader: {
  64997. name: string;
  64998. shader: string;
  64999. };
  65000. }
  65001. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65002. import { Camera } from "babylonjs/Cameras/camera";
  65003. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65004. import { Scene } from "babylonjs/scene";
  65005. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65006. import "babylonjs/Shaders/ssao2.fragment";
  65007. import "babylonjs/Shaders/ssaoCombine.fragment";
  65008. /**
  65009. * Render pipeline to produce ssao effect
  65010. */
  65011. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65012. /**
  65013. * @ignore
  65014. * The PassPostProcess id in the pipeline that contains the original scene color
  65015. */
  65016. SSAOOriginalSceneColorEffect: string;
  65017. /**
  65018. * @ignore
  65019. * The SSAO PostProcess id in the pipeline
  65020. */
  65021. SSAORenderEffect: string;
  65022. /**
  65023. * @ignore
  65024. * The horizontal blur PostProcess id in the pipeline
  65025. */
  65026. SSAOBlurHRenderEffect: string;
  65027. /**
  65028. * @ignore
  65029. * The vertical blur PostProcess id in the pipeline
  65030. */
  65031. SSAOBlurVRenderEffect: string;
  65032. /**
  65033. * @ignore
  65034. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65035. */
  65036. SSAOCombineRenderEffect: string;
  65037. /**
  65038. * The output strength of the SSAO post-process. Default value is 1.0.
  65039. */
  65040. totalStrength: number;
  65041. /**
  65042. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65043. */
  65044. maxZ: number;
  65045. /**
  65046. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65047. */
  65048. minZAspect: number;
  65049. private _samples;
  65050. /**
  65051. * Number of samples used for the SSAO calculations. Default value is 8
  65052. */
  65053. samples: number;
  65054. private _textureSamples;
  65055. /**
  65056. * Number of samples to use for antialiasing
  65057. */
  65058. textureSamples: number;
  65059. /**
  65060. * Ratio object used for SSAO ratio and blur ratio
  65061. */
  65062. private _ratio;
  65063. /**
  65064. * Dynamically generated sphere sampler.
  65065. */
  65066. private _sampleSphere;
  65067. /**
  65068. * Blur filter offsets
  65069. */
  65070. private _samplerOffsets;
  65071. private _expensiveBlur;
  65072. /**
  65073. * If bilateral blur should be used
  65074. */
  65075. expensiveBlur: boolean;
  65076. /**
  65077. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65078. */
  65079. radius: number;
  65080. /**
  65081. * The base color of the SSAO post-process
  65082. * The final result is "base + ssao" between [0, 1]
  65083. */
  65084. base: number;
  65085. /**
  65086. * Support test.
  65087. */
  65088. static readonly IsSupported: boolean;
  65089. private _scene;
  65090. private _depthTexture;
  65091. private _normalTexture;
  65092. private _randomTexture;
  65093. private _originalColorPostProcess;
  65094. private _ssaoPostProcess;
  65095. private _blurHPostProcess;
  65096. private _blurVPostProcess;
  65097. private _ssaoCombinePostProcess;
  65098. /**
  65099. * Gets active scene
  65100. */
  65101. readonly scene: Scene;
  65102. /**
  65103. * @constructor
  65104. * @param name The rendering pipeline name
  65105. * @param scene The scene linked to this pipeline
  65106. * @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 }
  65107. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65108. */
  65109. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65110. /**
  65111. * Get the class name
  65112. * @returns "SSAO2RenderingPipeline"
  65113. */
  65114. getClassName(): string;
  65115. /**
  65116. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65117. */
  65118. dispose(disableGeometryBufferRenderer?: boolean): void;
  65119. private _createBlurPostProcess;
  65120. /** @hidden */
  65121. _rebuild(): void;
  65122. private _bits;
  65123. private _radicalInverse_VdC;
  65124. private _hammersley;
  65125. private _hemisphereSample_uniform;
  65126. private _generateHemisphere;
  65127. private _createSSAOPostProcess;
  65128. private _createSSAOCombinePostProcess;
  65129. private _createRandomTexture;
  65130. /**
  65131. * Serialize the rendering pipeline (Used when exporting)
  65132. * @returns the serialized object
  65133. */
  65134. serialize(): any;
  65135. /**
  65136. * Parse the serialized pipeline
  65137. * @param source Source pipeline.
  65138. * @param scene The scene to load the pipeline to.
  65139. * @param rootUrl The URL of the serialized pipeline.
  65140. * @returns An instantiated pipeline from the serialized object.
  65141. */
  65142. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65143. }
  65144. }
  65145. declare module "babylonjs/Shaders/ssao.fragment" {
  65146. /** @hidden */
  65147. export var ssaoPixelShader: {
  65148. name: string;
  65149. shader: string;
  65150. };
  65151. }
  65152. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65153. import { Camera } from "babylonjs/Cameras/camera";
  65154. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65155. import { Scene } from "babylonjs/scene";
  65156. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65157. import "babylonjs/Shaders/ssao.fragment";
  65158. import "babylonjs/Shaders/ssaoCombine.fragment";
  65159. /**
  65160. * Render pipeline to produce ssao effect
  65161. */
  65162. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65163. /**
  65164. * @ignore
  65165. * The PassPostProcess id in the pipeline that contains the original scene color
  65166. */
  65167. SSAOOriginalSceneColorEffect: string;
  65168. /**
  65169. * @ignore
  65170. * The SSAO PostProcess id in the pipeline
  65171. */
  65172. SSAORenderEffect: string;
  65173. /**
  65174. * @ignore
  65175. * The horizontal blur PostProcess id in the pipeline
  65176. */
  65177. SSAOBlurHRenderEffect: string;
  65178. /**
  65179. * @ignore
  65180. * The vertical blur PostProcess id in the pipeline
  65181. */
  65182. SSAOBlurVRenderEffect: string;
  65183. /**
  65184. * @ignore
  65185. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65186. */
  65187. SSAOCombineRenderEffect: string;
  65188. /**
  65189. * The output strength of the SSAO post-process. Default value is 1.0.
  65190. */
  65191. totalStrength: number;
  65192. /**
  65193. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65194. */
  65195. radius: number;
  65196. /**
  65197. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65198. * Must not be equal to fallOff and superior to fallOff.
  65199. * Default value is 0.0075
  65200. */
  65201. area: number;
  65202. /**
  65203. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65204. * Must not be equal to area and inferior to area.
  65205. * Default value is 0.000001
  65206. */
  65207. fallOff: number;
  65208. /**
  65209. * The base color of the SSAO post-process
  65210. * The final result is "base + ssao" between [0, 1]
  65211. */
  65212. base: number;
  65213. private _scene;
  65214. private _depthTexture;
  65215. private _randomTexture;
  65216. private _originalColorPostProcess;
  65217. private _ssaoPostProcess;
  65218. private _blurHPostProcess;
  65219. private _blurVPostProcess;
  65220. private _ssaoCombinePostProcess;
  65221. private _firstUpdate;
  65222. /**
  65223. * Gets active scene
  65224. */
  65225. readonly scene: Scene;
  65226. /**
  65227. * @constructor
  65228. * @param name - The rendering pipeline name
  65229. * @param scene - The scene linked to this pipeline
  65230. * @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 }
  65231. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65232. */
  65233. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65234. /**
  65235. * Get the class name
  65236. * @returns "SSAORenderingPipeline"
  65237. */
  65238. getClassName(): string;
  65239. /**
  65240. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65241. */
  65242. dispose(disableDepthRender?: boolean): void;
  65243. private _createBlurPostProcess;
  65244. /** @hidden */
  65245. _rebuild(): void;
  65246. private _createSSAOPostProcess;
  65247. private _createSSAOCombinePostProcess;
  65248. private _createRandomTexture;
  65249. }
  65250. }
  65251. declare module "babylonjs/Shaders/standard.fragment" {
  65252. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65253. /** @hidden */
  65254. export var standardPixelShader: {
  65255. name: string;
  65256. shader: string;
  65257. };
  65258. }
  65259. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65260. import { Nullable } from "babylonjs/types";
  65261. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65262. import { Camera } from "babylonjs/Cameras/camera";
  65263. import { Texture } from "babylonjs/Materials/Textures/texture";
  65264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65265. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65266. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65267. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65268. import { IDisposable } from "babylonjs/scene";
  65269. import { SpotLight } from "babylonjs/Lights/spotLight";
  65270. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65271. import { Scene } from "babylonjs/scene";
  65272. import { Animation } from "babylonjs/Animations/animation";
  65273. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65274. import "babylonjs/Shaders/standard.fragment";
  65275. /**
  65276. * Standard rendering pipeline
  65277. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65278. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65279. */
  65280. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65281. /**
  65282. * Public members
  65283. */
  65284. /**
  65285. * Post-process which contains the original scene color before the pipeline applies all the effects
  65286. */
  65287. originalPostProcess: Nullable<PostProcess>;
  65288. /**
  65289. * Post-process used to down scale an image x4
  65290. */
  65291. downSampleX4PostProcess: Nullable<PostProcess>;
  65292. /**
  65293. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65294. */
  65295. brightPassPostProcess: Nullable<PostProcess>;
  65296. /**
  65297. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65298. */
  65299. blurHPostProcesses: PostProcess[];
  65300. /**
  65301. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65302. */
  65303. blurVPostProcesses: PostProcess[];
  65304. /**
  65305. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65306. */
  65307. textureAdderPostProcess: Nullable<PostProcess>;
  65308. /**
  65309. * Post-process used to create volumetric lighting effect
  65310. */
  65311. volumetricLightPostProcess: Nullable<PostProcess>;
  65312. /**
  65313. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65314. */
  65315. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65316. /**
  65317. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65318. */
  65319. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65320. /**
  65321. * Post-process used to merge the volumetric light effect and the real scene color
  65322. */
  65323. volumetricLightMergePostProces: Nullable<PostProcess>;
  65324. /**
  65325. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65326. */
  65327. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65328. /**
  65329. * Base post-process used to calculate the average luminance of the final image for HDR
  65330. */
  65331. luminancePostProcess: Nullable<PostProcess>;
  65332. /**
  65333. * Post-processes used to create down sample post-processes in order to get
  65334. * the average luminance of the final image for HDR
  65335. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65336. */
  65337. luminanceDownSamplePostProcesses: PostProcess[];
  65338. /**
  65339. * Post-process used to create a HDR effect (light adaptation)
  65340. */
  65341. hdrPostProcess: Nullable<PostProcess>;
  65342. /**
  65343. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65344. */
  65345. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65346. /**
  65347. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65348. */
  65349. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65350. /**
  65351. * Post-process used to merge the final HDR post-process and the real scene color
  65352. */
  65353. hdrFinalPostProcess: Nullable<PostProcess>;
  65354. /**
  65355. * Post-process used to create a lens flare effect
  65356. */
  65357. lensFlarePostProcess: Nullable<PostProcess>;
  65358. /**
  65359. * Post-process that merges the result of the lens flare post-process and the real scene color
  65360. */
  65361. lensFlareComposePostProcess: Nullable<PostProcess>;
  65362. /**
  65363. * Post-process used to create a motion blur effect
  65364. */
  65365. motionBlurPostProcess: Nullable<PostProcess>;
  65366. /**
  65367. * Post-process used to create a depth of field effect
  65368. */
  65369. depthOfFieldPostProcess: Nullable<PostProcess>;
  65370. /**
  65371. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65372. */
  65373. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65374. /**
  65375. * Represents the brightness threshold in order to configure the illuminated surfaces
  65376. */
  65377. brightThreshold: number;
  65378. /**
  65379. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65380. */
  65381. blurWidth: number;
  65382. /**
  65383. * Sets if the blur for highlighted surfaces must be only horizontal
  65384. */
  65385. horizontalBlur: boolean;
  65386. /**
  65387. * Gets the overall exposure used by the pipeline
  65388. */
  65389. /**
  65390. * Sets the overall exposure used by the pipeline
  65391. */
  65392. exposure: number;
  65393. /**
  65394. * Texture used typically to simulate "dirty" on camera lens
  65395. */
  65396. lensTexture: Nullable<Texture>;
  65397. /**
  65398. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65399. */
  65400. volumetricLightCoefficient: number;
  65401. /**
  65402. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65403. */
  65404. volumetricLightPower: number;
  65405. /**
  65406. * Used the set the blur intensity to smooth the volumetric lights
  65407. */
  65408. volumetricLightBlurScale: number;
  65409. /**
  65410. * Light (spot or directional) used to generate the volumetric lights rays
  65411. * The source light must have a shadow generate so the pipeline can get its
  65412. * depth map
  65413. */
  65414. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65415. /**
  65416. * For eye adaptation, represents the minimum luminance the eye can see
  65417. */
  65418. hdrMinimumLuminance: number;
  65419. /**
  65420. * For eye adaptation, represents the decrease luminance speed
  65421. */
  65422. hdrDecreaseRate: number;
  65423. /**
  65424. * For eye adaptation, represents the increase luminance speed
  65425. */
  65426. hdrIncreaseRate: number;
  65427. /**
  65428. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65429. */
  65430. /**
  65431. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65432. */
  65433. hdrAutoExposure: boolean;
  65434. /**
  65435. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65436. */
  65437. lensColorTexture: Nullable<Texture>;
  65438. /**
  65439. * The overall strengh for the lens flare effect
  65440. */
  65441. lensFlareStrength: number;
  65442. /**
  65443. * Dispersion coefficient for lens flare ghosts
  65444. */
  65445. lensFlareGhostDispersal: number;
  65446. /**
  65447. * Main lens flare halo width
  65448. */
  65449. lensFlareHaloWidth: number;
  65450. /**
  65451. * Based on the lens distortion effect, defines how much the lens flare result
  65452. * is distorted
  65453. */
  65454. lensFlareDistortionStrength: number;
  65455. /**
  65456. * Configures the blur intensity used for for lens flare (halo)
  65457. */
  65458. lensFlareBlurWidth: number;
  65459. /**
  65460. * Lens star texture must be used to simulate rays on the flares and is available
  65461. * in the documentation
  65462. */
  65463. lensStarTexture: Nullable<Texture>;
  65464. /**
  65465. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65466. * flare effect by taking account of the dirt texture
  65467. */
  65468. lensFlareDirtTexture: Nullable<Texture>;
  65469. /**
  65470. * Represents the focal length for the depth of field effect
  65471. */
  65472. depthOfFieldDistance: number;
  65473. /**
  65474. * Represents the blur intensity for the blurred part of the depth of field effect
  65475. */
  65476. depthOfFieldBlurWidth: number;
  65477. /**
  65478. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65479. */
  65480. /**
  65481. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65482. */
  65483. motionStrength: number;
  65484. /**
  65485. * Gets wether or not the motion blur post-process is object based or screen based.
  65486. */
  65487. /**
  65488. * Sets wether or not the motion blur post-process should be object based or screen based
  65489. */
  65490. objectBasedMotionBlur: boolean;
  65491. /**
  65492. * List of animations for the pipeline (IAnimatable implementation)
  65493. */
  65494. animations: Animation[];
  65495. /**
  65496. * Private members
  65497. */
  65498. private _scene;
  65499. private _currentDepthOfFieldSource;
  65500. private _basePostProcess;
  65501. private _fixedExposure;
  65502. private _currentExposure;
  65503. private _hdrAutoExposure;
  65504. private _hdrCurrentLuminance;
  65505. private _motionStrength;
  65506. private _isObjectBasedMotionBlur;
  65507. private _floatTextureType;
  65508. private _camerasToBeAttached;
  65509. private _ratio;
  65510. private _bloomEnabled;
  65511. private _depthOfFieldEnabled;
  65512. private _vlsEnabled;
  65513. private _lensFlareEnabled;
  65514. private _hdrEnabled;
  65515. private _motionBlurEnabled;
  65516. private _fxaaEnabled;
  65517. private _motionBlurSamples;
  65518. private _volumetricLightStepsCount;
  65519. private _samples;
  65520. /**
  65521. * @ignore
  65522. * Specifies if the bloom pipeline is enabled
  65523. */
  65524. BloomEnabled: boolean;
  65525. /**
  65526. * @ignore
  65527. * Specifies if the depth of field pipeline is enabed
  65528. */
  65529. DepthOfFieldEnabled: boolean;
  65530. /**
  65531. * @ignore
  65532. * Specifies if the lens flare pipeline is enabed
  65533. */
  65534. LensFlareEnabled: boolean;
  65535. /**
  65536. * @ignore
  65537. * Specifies if the HDR pipeline is enabled
  65538. */
  65539. HDREnabled: boolean;
  65540. /**
  65541. * @ignore
  65542. * Specifies if the volumetric lights scattering effect is enabled
  65543. */
  65544. VLSEnabled: boolean;
  65545. /**
  65546. * @ignore
  65547. * Specifies if the motion blur effect is enabled
  65548. */
  65549. MotionBlurEnabled: boolean;
  65550. /**
  65551. * Specifies if anti-aliasing is enabled
  65552. */
  65553. fxaaEnabled: boolean;
  65554. /**
  65555. * Specifies the number of steps used to calculate the volumetric lights
  65556. * Typically in interval [50, 200]
  65557. */
  65558. volumetricLightStepsCount: number;
  65559. /**
  65560. * Specifies the number of samples used for the motion blur effect
  65561. * Typically in interval [16, 64]
  65562. */
  65563. motionBlurSamples: number;
  65564. /**
  65565. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65566. */
  65567. samples: number;
  65568. /**
  65569. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65570. * @constructor
  65571. * @param name The rendering pipeline name
  65572. * @param scene The scene linked to this pipeline
  65573. * @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)
  65574. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65575. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65576. */
  65577. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65578. private _buildPipeline;
  65579. private _createDownSampleX4PostProcess;
  65580. private _createBrightPassPostProcess;
  65581. private _createBlurPostProcesses;
  65582. private _createTextureAdderPostProcess;
  65583. private _createVolumetricLightPostProcess;
  65584. private _createLuminancePostProcesses;
  65585. private _createHdrPostProcess;
  65586. private _createLensFlarePostProcess;
  65587. private _createDepthOfFieldPostProcess;
  65588. private _createMotionBlurPostProcess;
  65589. private _getDepthTexture;
  65590. private _disposePostProcesses;
  65591. /**
  65592. * Dispose of the pipeline and stop all post processes
  65593. */
  65594. dispose(): void;
  65595. /**
  65596. * Serialize the rendering pipeline (Used when exporting)
  65597. * @returns the serialized object
  65598. */
  65599. serialize(): any;
  65600. /**
  65601. * Parse the serialized pipeline
  65602. * @param source Source pipeline.
  65603. * @param scene The scene to load the pipeline to.
  65604. * @param rootUrl The URL of the serialized pipeline.
  65605. * @returns An instantiated pipeline from the serialized object.
  65606. */
  65607. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65608. /**
  65609. * Luminance steps
  65610. */
  65611. static LuminanceSteps: number;
  65612. }
  65613. }
  65614. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65615. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65616. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65617. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65618. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65619. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65620. }
  65621. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65622. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65623. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65624. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65625. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65626. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65627. }
  65628. declare module "babylonjs/Shaders/tonemap.fragment" {
  65629. /** @hidden */
  65630. export var tonemapPixelShader: {
  65631. name: string;
  65632. shader: string;
  65633. };
  65634. }
  65635. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65636. import { Camera } from "babylonjs/Cameras/camera";
  65637. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65638. import "babylonjs/Shaders/tonemap.fragment";
  65639. import { Engine } from "babylonjs/Engines/engine";
  65640. /** Defines operator used for tonemapping */
  65641. export enum TonemappingOperator {
  65642. /** Hable */
  65643. Hable = 0,
  65644. /** Reinhard */
  65645. Reinhard = 1,
  65646. /** HejiDawson */
  65647. HejiDawson = 2,
  65648. /** Photographic */
  65649. Photographic = 3
  65650. }
  65651. /**
  65652. * Defines a post process to apply tone mapping
  65653. */
  65654. export class TonemapPostProcess extends PostProcess {
  65655. private _operator;
  65656. /** Defines the required exposure adjustement */
  65657. exposureAdjustment: number;
  65658. /**
  65659. * Creates a new TonemapPostProcess
  65660. * @param name defines the name of the postprocess
  65661. * @param _operator defines the operator to use
  65662. * @param exposureAdjustment defines the required exposure adjustement
  65663. * @param camera defines the camera to use (can be null)
  65664. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65665. * @param engine defines the hosting engine (can be ignore if camera is set)
  65666. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65667. */
  65668. constructor(name: string, _operator: TonemappingOperator,
  65669. /** Defines the required exposure adjustement */
  65670. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65671. }
  65672. }
  65673. declare module "babylonjs/Shaders/depth.vertex" {
  65674. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65675. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65676. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65677. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65678. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65679. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65680. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65681. /** @hidden */
  65682. export var depthVertexShader: {
  65683. name: string;
  65684. shader: string;
  65685. };
  65686. }
  65687. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65688. /** @hidden */
  65689. export var volumetricLightScatteringPixelShader: {
  65690. name: string;
  65691. shader: string;
  65692. };
  65693. }
  65694. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65695. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65696. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65698. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65699. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65700. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65701. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65702. /** @hidden */
  65703. export var volumetricLightScatteringPassVertexShader: {
  65704. name: string;
  65705. shader: string;
  65706. };
  65707. }
  65708. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65709. /** @hidden */
  65710. export var volumetricLightScatteringPassPixelShader: {
  65711. name: string;
  65712. shader: string;
  65713. };
  65714. }
  65715. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65716. import { Vector3 } from "babylonjs/Maths/math.vector";
  65717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65718. import { Mesh } from "babylonjs/Meshes/mesh";
  65719. import { Camera } from "babylonjs/Cameras/camera";
  65720. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65721. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65722. import { Scene } from "babylonjs/scene";
  65723. import "babylonjs/Meshes/Builders/planeBuilder";
  65724. import "babylonjs/Shaders/depth.vertex";
  65725. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65726. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65727. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65728. import { Engine } from "babylonjs/Engines/engine";
  65729. /**
  65730. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65731. */
  65732. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65733. private _volumetricLightScatteringPass;
  65734. private _volumetricLightScatteringRTT;
  65735. private _viewPort;
  65736. private _screenCoordinates;
  65737. private _cachedDefines;
  65738. /**
  65739. * If not undefined, the mesh position is computed from the attached node position
  65740. */
  65741. attachedNode: {
  65742. position: Vector3;
  65743. };
  65744. /**
  65745. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65746. */
  65747. customMeshPosition: Vector3;
  65748. /**
  65749. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65750. */
  65751. useCustomMeshPosition: boolean;
  65752. /**
  65753. * If the post-process should inverse the light scattering direction
  65754. */
  65755. invert: boolean;
  65756. /**
  65757. * The internal mesh used by the post-process
  65758. */
  65759. mesh: Mesh;
  65760. /**
  65761. * @hidden
  65762. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65763. */
  65764. useDiffuseColor: boolean;
  65765. /**
  65766. * Array containing the excluded meshes not rendered in the internal pass
  65767. */
  65768. excludedMeshes: AbstractMesh[];
  65769. /**
  65770. * Controls the overall intensity of the post-process
  65771. */
  65772. exposure: number;
  65773. /**
  65774. * Dissipates each sample's contribution in range [0, 1]
  65775. */
  65776. decay: number;
  65777. /**
  65778. * Controls the overall intensity of each sample
  65779. */
  65780. weight: number;
  65781. /**
  65782. * Controls the density of each sample
  65783. */
  65784. density: number;
  65785. /**
  65786. * @constructor
  65787. * @param name The post-process name
  65788. * @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)
  65789. * @param camera The camera that the post-process will be attached to
  65790. * @param mesh The mesh used to create the light scattering
  65791. * @param samples The post-process quality, default 100
  65792. * @param samplingModeThe post-process filtering mode
  65793. * @param engine The babylon engine
  65794. * @param reusable If the post-process is reusable
  65795. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65796. */
  65797. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65798. /**
  65799. * Returns the string "VolumetricLightScatteringPostProcess"
  65800. * @returns "VolumetricLightScatteringPostProcess"
  65801. */
  65802. getClassName(): string;
  65803. private _isReady;
  65804. /**
  65805. * Sets the new light position for light scattering effect
  65806. * @param position The new custom light position
  65807. */
  65808. setCustomMeshPosition(position: Vector3): void;
  65809. /**
  65810. * Returns the light position for light scattering effect
  65811. * @return Vector3 The custom light position
  65812. */
  65813. getCustomMeshPosition(): Vector3;
  65814. /**
  65815. * Disposes the internal assets and detaches the post-process from the camera
  65816. */
  65817. dispose(camera: Camera): void;
  65818. /**
  65819. * Returns the render target texture used by the post-process
  65820. * @return the render target texture used by the post-process
  65821. */
  65822. getPass(): RenderTargetTexture;
  65823. private _meshExcluded;
  65824. private _createPass;
  65825. private _updateMeshScreenCoordinates;
  65826. /**
  65827. * Creates a default mesh for the Volumeric Light Scattering post-process
  65828. * @param name The mesh name
  65829. * @param scene The scene where to create the mesh
  65830. * @return the default mesh
  65831. */
  65832. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65833. }
  65834. }
  65835. declare module "babylonjs/PostProcesses/index" {
  65836. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65837. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65838. export * from "babylonjs/PostProcesses/bloomEffect";
  65839. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65840. export * from "babylonjs/PostProcesses/blurPostProcess";
  65841. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65842. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65843. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65844. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65845. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65846. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65847. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65848. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65849. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65850. export * from "babylonjs/PostProcesses/filterPostProcess";
  65851. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65852. export * from "babylonjs/PostProcesses/grainPostProcess";
  65853. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65854. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65855. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65856. export * from "babylonjs/PostProcesses/passPostProcess";
  65857. export * from "babylonjs/PostProcesses/postProcess";
  65858. export * from "babylonjs/PostProcesses/postProcessManager";
  65859. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65860. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65861. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65862. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65863. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65864. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65865. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65866. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65867. }
  65868. declare module "babylonjs/Probes/index" {
  65869. export * from "babylonjs/Probes/reflectionProbe";
  65870. }
  65871. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65872. import { Scene } from "babylonjs/scene";
  65873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65874. import { SmartArray } from "babylonjs/Misc/smartArray";
  65875. import { ISceneComponent } from "babylonjs/sceneComponent";
  65876. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65877. import "babylonjs/Meshes/Builders/boxBuilder";
  65878. import "babylonjs/Shaders/color.fragment";
  65879. import "babylonjs/Shaders/color.vertex";
  65880. import { Color3 } from "babylonjs/Maths/math.color";
  65881. module "babylonjs/scene" {
  65882. interface Scene {
  65883. /** @hidden (Backing field) */
  65884. _boundingBoxRenderer: BoundingBoxRenderer;
  65885. /** @hidden (Backing field) */
  65886. _forceShowBoundingBoxes: boolean;
  65887. /**
  65888. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65889. */
  65890. forceShowBoundingBoxes: boolean;
  65891. /**
  65892. * Gets the bounding box renderer associated with the scene
  65893. * @returns a BoundingBoxRenderer
  65894. */
  65895. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65896. }
  65897. }
  65898. module "babylonjs/Meshes/abstractMesh" {
  65899. interface AbstractMesh {
  65900. /** @hidden (Backing field) */
  65901. _showBoundingBox: boolean;
  65902. /**
  65903. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65904. */
  65905. showBoundingBox: boolean;
  65906. }
  65907. }
  65908. /**
  65909. * Component responsible of rendering the bounding box of the meshes in a scene.
  65910. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65911. */
  65912. export class BoundingBoxRenderer implements ISceneComponent {
  65913. /**
  65914. * The component name helpfull to identify the component in the list of scene components.
  65915. */
  65916. readonly name: string;
  65917. /**
  65918. * The scene the component belongs to.
  65919. */
  65920. scene: Scene;
  65921. /**
  65922. * Color of the bounding box lines placed in front of an object
  65923. */
  65924. frontColor: Color3;
  65925. /**
  65926. * Color of the bounding box lines placed behind an object
  65927. */
  65928. backColor: Color3;
  65929. /**
  65930. * Defines if the renderer should show the back lines or not
  65931. */
  65932. showBackLines: boolean;
  65933. /**
  65934. * @hidden
  65935. */
  65936. renderList: SmartArray<BoundingBox>;
  65937. private _colorShader;
  65938. private _vertexBuffers;
  65939. private _indexBuffer;
  65940. private _fillIndexBuffer;
  65941. private _fillIndexData;
  65942. /**
  65943. * Instantiates a new bounding box renderer in a scene.
  65944. * @param scene the scene the renderer renders in
  65945. */
  65946. constructor(scene: Scene);
  65947. /**
  65948. * Registers the component in a given scene
  65949. */
  65950. register(): void;
  65951. private _evaluateSubMesh;
  65952. private _activeMesh;
  65953. private _prepareRessources;
  65954. private _createIndexBuffer;
  65955. /**
  65956. * Rebuilds the elements related to this component in case of
  65957. * context lost for instance.
  65958. */
  65959. rebuild(): void;
  65960. /**
  65961. * @hidden
  65962. */
  65963. reset(): void;
  65964. /**
  65965. * Render the bounding boxes of a specific rendering group
  65966. * @param renderingGroupId defines the rendering group to render
  65967. */
  65968. render(renderingGroupId: number): void;
  65969. /**
  65970. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65971. * @param mesh Define the mesh to render the occlusion bounding box for
  65972. */
  65973. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65974. /**
  65975. * Dispose and release the resources attached to this renderer.
  65976. */
  65977. dispose(): void;
  65978. }
  65979. }
  65980. declare module "babylonjs/Shaders/depth.fragment" {
  65981. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65982. /** @hidden */
  65983. export var depthPixelShader: {
  65984. name: string;
  65985. shader: string;
  65986. };
  65987. }
  65988. declare module "babylonjs/Rendering/depthRenderer" {
  65989. import { Nullable } from "babylonjs/types";
  65990. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65991. import { Scene } from "babylonjs/scene";
  65992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65993. import { Camera } from "babylonjs/Cameras/camera";
  65994. import "babylonjs/Shaders/depth.fragment";
  65995. import "babylonjs/Shaders/depth.vertex";
  65996. /**
  65997. * This represents a depth renderer in Babylon.
  65998. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65999. */
  66000. export class DepthRenderer {
  66001. private _scene;
  66002. private _depthMap;
  66003. private _effect;
  66004. private readonly _storeNonLinearDepth;
  66005. private readonly _clearColor;
  66006. /** Get if the depth renderer is using packed depth or not */
  66007. readonly isPacked: boolean;
  66008. private _cachedDefines;
  66009. private _camera;
  66010. /**
  66011. * Specifiess that the depth renderer will only be used within
  66012. * the camera it is created for.
  66013. * This can help forcing its rendering during the camera processing.
  66014. */
  66015. useOnlyInActiveCamera: boolean;
  66016. /** @hidden */
  66017. static _SceneComponentInitialization: (scene: Scene) => void;
  66018. /**
  66019. * Instantiates a depth renderer
  66020. * @param scene The scene the renderer belongs to
  66021. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66022. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66023. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66024. */
  66025. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66026. /**
  66027. * Creates the depth rendering effect and checks if the effect is ready.
  66028. * @param subMesh The submesh to be used to render the depth map of
  66029. * @param useInstances If multiple world instances should be used
  66030. * @returns if the depth renderer is ready to render the depth map
  66031. */
  66032. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66033. /**
  66034. * Gets the texture which the depth map will be written to.
  66035. * @returns The depth map texture
  66036. */
  66037. getDepthMap(): RenderTargetTexture;
  66038. /**
  66039. * Disposes of the depth renderer.
  66040. */
  66041. dispose(): void;
  66042. }
  66043. }
  66044. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66045. import { Nullable } from "babylonjs/types";
  66046. import { Scene } from "babylonjs/scene";
  66047. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66048. import { Camera } from "babylonjs/Cameras/camera";
  66049. import { ISceneComponent } from "babylonjs/sceneComponent";
  66050. module "babylonjs/scene" {
  66051. interface Scene {
  66052. /** @hidden (Backing field) */
  66053. _depthRenderer: {
  66054. [id: string]: DepthRenderer;
  66055. };
  66056. /**
  66057. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66058. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66059. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66060. * @returns the created depth renderer
  66061. */
  66062. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66063. /**
  66064. * Disables a depth renderer for a given camera
  66065. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66066. */
  66067. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66068. }
  66069. }
  66070. /**
  66071. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66072. * in several rendering techniques.
  66073. */
  66074. export class DepthRendererSceneComponent implements ISceneComponent {
  66075. /**
  66076. * The component name helpfull to identify the component in the list of scene components.
  66077. */
  66078. readonly name: string;
  66079. /**
  66080. * The scene the component belongs to.
  66081. */
  66082. scene: Scene;
  66083. /**
  66084. * Creates a new instance of the component for the given scene
  66085. * @param scene Defines the scene to register the component in
  66086. */
  66087. constructor(scene: Scene);
  66088. /**
  66089. * Registers the component in a given scene
  66090. */
  66091. register(): void;
  66092. /**
  66093. * Rebuilds the elements related to this component in case of
  66094. * context lost for instance.
  66095. */
  66096. rebuild(): void;
  66097. /**
  66098. * Disposes the component and the associated ressources
  66099. */
  66100. dispose(): void;
  66101. private _gatherRenderTargets;
  66102. private _gatherActiveCameraRenderTargets;
  66103. }
  66104. }
  66105. declare module "babylonjs/Shaders/outline.fragment" {
  66106. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66107. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66108. /** @hidden */
  66109. export var outlinePixelShader: {
  66110. name: string;
  66111. shader: string;
  66112. };
  66113. }
  66114. declare module "babylonjs/Shaders/outline.vertex" {
  66115. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66116. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66117. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66118. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66119. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66121. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66122. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66123. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66124. /** @hidden */
  66125. export var outlineVertexShader: {
  66126. name: string;
  66127. shader: string;
  66128. };
  66129. }
  66130. declare module "babylonjs/Rendering/outlineRenderer" {
  66131. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66132. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66133. import { Scene } from "babylonjs/scene";
  66134. import { ISceneComponent } from "babylonjs/sceneComponent";
  66135. import "babylonjs/Shaders/outline.fragment";
  66136. import "babylonjs/Shaders/outline.vertex";
  66137. module "babylonjs/scene" {
  66138. interface Scene {
  66139. /** @hidden */
  66140. _outlineRenderer: OutlineRenderer;
  66141. /**
  66142. * Gets the outline renderer associated with the scene
  66143. * @returns a OutlineRenderer
  66144. */
  66145. getOutlineRenderer(): OutlineRenderer;
  66146. }
  66147. }
  66148. module "babylonjs/Meshes/abstractMesh" {
  66149. interface AbstractMesh {
  66150. /** @hidden (Backing field) */
  66151. _renderOutline: boolean;
  66152. /**
  66153. * Gets or sets a boolean indicating if the outline must be rendered as well
  66154. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66155. */
  66156. renderOutline: boolean;
  66157. /** @hidden (Backing field) */
  66158. _renderOverlay: boolean;
  66159. /**
  66160. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66161. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66162. */
  66163. renderOverlay: boolean;
  66164. }
  66165. }
  66166. /**
  66167. * This class is responsible to draw bothe outline/overlay of meshes.
  66168. * It should not be used directly but through the available method on mesh.
  66169. */
  66170. export class OutlineRenderer implements ISceneComponent {
  66171. /**
  66172. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66173. */
  66174. private static _StencilReference;
  66175. /**
  66176. * The name of the component. Each component must have a unique name.
  66177. */
  66178. name: string;
  66179. /**
  66180. * The scene the component belongs to.
  66181. */
  66182. scene: Scene;
  66183. /**
  66184. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66185. */
  66186. zOffset: number;
  66187. private _engine;
  66188. private _effect;
  66189. private _cachedDefines;
  66190. private _savedDepthWrite;
  66191. /**
  66192. * Instantiates a new outline renderer. (There could be only one per scene).
  66193. * @param scene Defines the scene it belongs to
  66194. */
  66195. constructor(scene: Scene);
  66196. /**
  66197. * Register the component to one instance of a scene.
  66198. */
  66199. register(): void;
  66200. /**
  66201. * Rebuilds the elements related to this component in case of
  66202. * context lost for instance.
  66203. */
  66204. rebuild(): void;
  66205. /**
  66206. * Disposes the component and the associated ressources.
  66207. */
  66208. dispose(): void;
  66209. /**
  66210. * Renders the outline in the canvas.
  66211. * @param subMesh Defines the sumesh to render
  66212. * @param batch Defines the batch of meshes in case of instances
  66213. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66214. */
  66215. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66216. /**
  66217. * Returns whether or not the outline renderer is ready for a given submesh.
  66218. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66219. * @param subMesh Defines the submesh to check readyness for
  66220. * @param useInstances Defines wheter wee are trying to render instances or not
  66221. * @returns true if ready otherwise false
  66222. */
  66223. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66224. private _beforeRenderingMesh;
  66225. private _afterRenderingMesh;
  66226. }
  66227. }
  66228. declare module "babylonjs/Rendering/index" {
  66229. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66230. export * from "babylonjs/Rendering/depthRenderer";
  66231. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66232. export * from "babylonjs/Rendering/edgesRenderer";
  66233. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66234. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66235. export * from "babylonjs/Rendering/outlineRenderer";
  66236. export * from "babylonjs/Rendering/renderingGroup";
  66237. export * from "babylonjs/Rendering/renderingManager";
  66238. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66239. }
  66240. declare module "babylonjs/Sprites/spritePackedManager" {
  66241. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66242. import { Scene } from "babylonjs/scene";
  66243. /**
  66244. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66245. * @see http://doc.babylonjs.com/babylon101/sprites
  66246. */
  66247. export class SpritePackedManager extends SpriteManager {
  66248. /** defines the packed manager's name */
  66249. name: string;
  66250. /**
  66251. * Creates a new sprite manager from a packed sprite sheet
  66252. * @param name defines the manager's name
  66253. * @param imgUrl defines the sprite sheet url
  66254. * @param capacity defines the maximum allowed number of sprites
  66255. * @param scene defines the hosting scene
  66256. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66257. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66258. * @param samplingMode defines the smapling mode to use with spritesheet
  66259. * @param fromPacked set to true; do not alter
  66260. */
  66261. constructor(
  66262. /** defines the packed manager's name */
  66263. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66264. }
  66265. }
  66266. declare module "babylonjs/Sprites/index" {
  66267. export * from "babylonjs/Sprites/sprite";
  66268. export * from "babylonjs/Sprites/spriteManager";
  66269. export * from "babylonjs/Sprites/spritePackedManager";
  66270. export * from "babylonjs/Sprites/spriteSceneComponent";
  66271. }
  66272. declare module "babylonjs/States/index" {
  66273. export * from "babylonjs/States/alphaCullingState";
  66274. export * from "babylonjs/States/depthCullingState";
  66275. export * from "babylonjs/States/stencilState";
  66276. }
  66277. declare module "babylonjs/Misc/assetsManager" {
  66278. import { Scene } from "babylonjs/scene";
  66279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66280. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66281. import { Skeleton } from "babylonjs/Bones/skeleton";
  66282. import { Observable } from "babylonjs/Misc/observable";
  66283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66284. import { Texture } from "babylonjs/Materials/Textures/texture";
  66285. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66286. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66287. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66288. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66289. /**
  66290. * Defines the list of states available for a task inside a AssetsManager
  66291. */
  66292. export enum AssetTaskState {
  66293. /**
  66294. * Initialization
  66295. */
  66296. INIT = 0,
  66297. /**
  66298. * Running
  66299. */
  66300. RUNNING = 1,
  66301. /**
  66302. * Done
  66303. */
  66304. DONE = 2,
  66305. /**
  66306. * Error
  66307. */
  66308. ERROR = 3
  66309. }
  66310. /**
  66311. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66312. */
  66313. export abstract class AbstractAssetTask {
  66314. /**
  66315. * Task name
  66316. */ name: string;
  66317. /**
  66318. * Callback called when the task is successful
  66319. */
  66320. onSuccess: (task: any) => void;
  66321. /**
  66322. * Callback called when the task is not successful
  66323. */
  66324. onError: (task: any, message?: string, exception?: any) => void;
  66325. /**
  66326. * Creates a new AssetsManager
  66327. * @param name defines the name of the task
  66328. */
  66329. constructor(
  66330. /**
  66331. * Task name
  66332. */ name: string);
  66333. private _isCompleted;
  66334. private _taskState;
  66335. private _errorObject;
  66336. /**
  66337. * Get if the task is completed
  66338. */
  66339. readonly isCompleted: boolean;
  66340. /**
  66341. * Gets the current state of the task
  66342. */
  66343. readonly taskState: AssetTaskState;
  66344. /**
  66345. * Gets the current error object (if task is in error)
  66346. */
  66347. readonly errorObject: {
  66348. message?: string;
  66349. exception?: any;
  66350. };
  66351. /**
  66352. * Internal only
  66353. * @hidden
  66354. */
  66355. _setErrorObject(message?: string, exception?: any): void;
  66356. /**
  66357. * Execute the current task
  66358. * @param scene defines the scene where you want your assets to be loaded
  66359. * @param onSuccess is a callback called when the task is successfully executed
  66360. * @param onError is a callback called if an error occurs
  66361. */
  66362. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66363. /**
  66364. * Execute the current task
  66365. * @param scene defines the scene where you want your assets to be loaded
  66366. * @param onSuccess is a callback called when the task is successfully executed
  66367. * @param onError is a callback called if an error occurs
  66368. */
  66369. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66370. /**
  66371. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66372. * This can be used with failed tasks that have the reason for failure fixed.
  66373. */
  66374. reset(): void;
  66375. private onErrorCallback;
  66376. private onDoneCallback;
  66377. }
  66378. /**
  66379. * Define the interface used by progress events raised during assets loading
  66380. */
  66381. export interface IAssetsProgressEvent {
  66382. /**
  66383. * Defines the number of remaining tasks to process
  66384. */
  66385. remainingCount: number;
  66386. /**
  66387. * Defines the total number of tasks
  66388. */
  66389. totalCount: number;
  66390. /**
  66391. * Defines the task that was just processed
  66392. */
  66393. task: AbstractAssetTask;
  66394. }
  66395. /**
  66396. * Class used to share progress information about assets loading
  66397. */
  66398. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66399. /**
  66400. * Defines the number of remaining tasks to process
  66401. */
  66402. remainingCount: number;
  66403. /**
  66404. * Defines the total number of tasks
  66405. */
  66406. totalCount: number;
  66407. /**
  66408. * Defines the task that was just processed
  66409. */
  66410. task: AbstractAssetTask;
  66411. /**
  66412. * Creates a AssetsProgressEvent
  66413. * @param remainingCount defines the number of remaining tasks to process
  66414. * @param totalCount defines the total number of tasks
  66415. * @param task defines the task that was just processed
  66416. */
  66417. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66418. }
  66419. /**
  66420. * Define a task used by AssetsManager to load meshes
  66421. */
  66422. export class MeshAssetTask extends AbstractAssetTask {
  66423. /**
  66424. * Defines the name of the task
  66425. */
  66426. name: string;
  66427. /**
  66428. * Defines the list of mesh's names you want to load
  66429. */
  66430. meshesNames: any;
  66431. /**
  66432. * Defines the root url to use as a base to load your meshes and associated resources
  66433. */
  66434. rootUrl: string;
  66435. /**
  66436. * Defines the filename of the scene to load from
  66437. */
  66438. sceneFilename: string;
  66439. /**
  66440. * Gets the list of loaded meshes
  66441. */
  66442. loadedMeshes: Array<AbstractMesh>;
  66443. /**
  66444. * Gets the list of loaded particle systems
  66445. */
  66446. loadedParticleSystems: Array<IParticleSystem>;
  66447. /**
  66448. * Gets the list of loaded skeletons
  66449. */
  66450. loadedSkeletons: Array<Skeleton>;
  66451. /**
  66452. * Gets the list of loaded animation groups
  66453. */
  66454. loadedAnimationGroups: Array<AnimationGroup>;
  66455. /**
  66456. * Callback called when the task is successful
  66457. */
  66458. onSuccess: (task: MeshAssetTask) => void;
  66459. /**
  66460. * Callback called when the task is successful
  66461. */
  66462. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66463. /**
  66464. * Creates a new MeshAssetTask
  66465. * @param name defines the name of the task
  66466. * @param meshesNames defines the list of mesh's names you want to load
  66467. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66468. * @param sceneFilename defines the filename of the scene to load from
  66469. */
  66470. constructor(
  66471. /**
  66472. * Defines the name of the task
  66473. */
  66474. name: string,
  66475. /**
  66476. * Defines the list of mesh's names you want to load
  66477. */
  66478. meshesNames: any,
  66479. /**
  66480. * Defines the root url to use as a base to load your meshes and associated resources
  66481. */
  66482. rootUrl: string,
  66483. /**
  66484. * Defines the filename of the scene to load from
  66485. */
  66486. sceneFilename: string);
  66487. /**
  66488. * Execute the current task
  66489. * @param scene defines the scene where you want your assets to be loaded
  66490. * @param onSuccess is a callback called when the task is successfully executed
  66491. * @param onError is a callback called if an error occurs
  66492. */
  66493. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66494. }
  66495. /**
  66496. * Define a task used by AssetsManager to load text content
  66497. */
  66498. export class TextFileAssetTask extends AbstractAssetTask {
  66499. /**
  66500. * Defines the name of the task
  66501. */
  66502. name: string;
  66503. /**
  66504. * Defines the location of the file to load
  66505. */
  66506. url: string;
  66507. /**
  66508. * Gets the loaded text string
  66509. */
  66510. text: string;
  66511. /**
  66512. * Callback called when the task is successful
  66513. */
  66514. onSuccess: (task: TextFileAssetTask) => void;
  66515. /**
  66516. * Callback called when the task is successful
  66517. */
  66518. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66519. /**
  66520. * Creates a new TextFileAssetTask object
  66521. * @param name defines the name of the task
  66522. * @param url defines the location of the file to load
  66523. */
  66524. constructor(
  66525. /**
  66526. * Defines the name of the task
  66527. */
  66528. name: string,
  66529. /**
  66530. * Defines the location of the file to load
  66531. */
  66532. url: string);
  66533. /**
  66534. * Execute the current task
  66535. * @param scene defines the scene where you want your assets to be loaded
  66536. * @param onSuccess is a callback called when the task is successfully executed
  66537. * @param onError is a callback called if an error occurs
  66538. */
  66539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66540. }
  66541. /**
  66542. * Define a task used by AssetsManager to load binary data
  66543. */
  66544. export class BinaryFileAssetTask extends AbstractAssetTask {
  66545. /**
  66546. * Defines the name of the task
  66547. */
  66548. name: string;
  66549. /**
  66550. * Defines the location of the file to load
  66551. */
  66552. url: string;
  66553. /**
  66554. * Gets the lodaded data (as an array buffer)
  66555. */
  66556. data: ArrayBuffer;
  66557. /**
  66558. * Callback called when the task is successful
  66559. */
  66560. onSuccess: (task: BinaryFileAssetTask) => void;
  66561. /**
  66562. * Callback called when the task is successful
  66563. */
  66564. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66565. /**
  66566. * Creates a new BinaryFileAssetTask object
  66567. * @param name defines the name of the new task
  66568. * @param url defines the location of the file to load
  66569. */
  66570. constructor(
  66571. /**
  66572. * Defines the name of the task
  66573. */
  66574. name: string,
  66575. /**
  66576. * Defines the location of the file to load
  66577. */
  66578. url: string);
  66579. /**
  66580. * Execute the current task
  66581. * @param scene defines the scene where you want your assets to be loaded
  66582. * @param onSuccess is a callback called when the task is successfully executed
  66583. * @param onError is a callback called if an error occurs
  66584. */
  66585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66586. }
  66587. /**
  66588. * Define a task used by AssetsManager to load images
  66589. */
  66590. export class ImageAssetTask extends AbstractAssetTask {
  66591. /**
  66592. * Defines the name of the task
  66593. */
  66594. name: string;
  66595. /**
  66596. * Defines the location of the image to load
  66597. */
  66598. url: string;
  66599. /**
  66600. * Gets the loaded images
  66601. */
  66602. image: HTMLImageElement;
  66603. /**
  66604. * Callback called when the task is successful
  66605. */
  66606. onSuccess: (task: ImageAssetTask) => void;
  66607. /**
  66608. * Callback called when the task is successful
  66609. */
  66610. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66611. /**
  66612. * Creates a new ImageAssetTask
  66613. * @param name defines the name of the task
  66614. * @param url defines the location of the image to load
  66615. */
  66616. constructor(
  66617. /**
  66618. * Defines the name of the task
  66619. */
  66620. name: string,
  66621. /**
  66622. * Defines the location of the image to load
  66623. */
  66624. url: string);
  66625. /**
  66626. * Execute the current task
  66627. * @param scene defines the scene where you want your assets to be loaded
  66628. * @param onSuccess is a callback called when the task is successfully executed
  66629. * @param onError is a callback called if an error occurs
  66630. */
  66631. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66632. }
  66633. /**
  66634. * Defines the interface used by texture loading tasks
  66635. */
  66636. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66637. /**
  66638. * Gets the loaded texture
  66639. */
  66640. texture: TEX;
  66641. }
  66642. /**
  66643. * Define a task used by AssetsManager to load 2D textures
  66644. */
  66645. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66646. /**
  66647. * Defines the name of the task
  66648. */
  66649. name: string;
  66650. /**
  66651. * Defines the location of the file to load
  66652. */
  66653. url: string;
  66654. /**
  66655. * Defines if mipmap should not be generated (default is false)
  66656. */
  66657. noMipmap?: boolean | undefined;
  66658. /**
  66659. * Defines if texture must be inverted on Y axis (default is false)
  66660. */
  66661. invertY?: boolean | undefined;
  66662. /**
  66663. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66664. */
  66665. samplingMode: number;
  66666. /**
  66667. * Gets the loaded texture
  66668. */
  66669. texture: Texture;
  66670. /**
  66671. * Callback called when the task is successful
  66672. */
  66673. onSuccess: (task: TextureAssetTask) => void;
  66674. /**
  66675. * Callback called when the task is successful
  66676. */
  66677. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66678. /**
  66679. * Creates a new TextureAssetTask object
  66680. * @param name defines the name of the task
  66681. * @param url defines the location of the file to load
  66682. * @param noMipmap defines if mipmap should not be generated (default is false)
  66683. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66684. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66685. */
  66686. constructor(
  66687. /**
  66688. * Defines the name of the task
  66689. */
  66690. name: string,
  66691. /**
  66692. * Defines the location of the file to load
  66693. */
  66694. url: string,
  66695. /**
  66696. * Defines if mipmap should not be generated (default is false)
  66697. */
  66698. noMipmap?: boolean | undefined,
  66699. /**
  66700. * Defines if texture must be inverted on Y axis (default is false)
  66701. */
  66702. invertY?: boolean | undefined,
  66703. /**
  66704. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66705. */
  66706. samplingMode?: number);
  66707. /**
  66708. * Execute the current task
  66709. * @param scene defines the scene where you want your assets to be loaded
  66710. * @param onSuccess is a callback called when the task is successfully executed
  66711. * @param onError is a callback called if an error occurs
  66712. */
  66713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66714. }
  66715. /**
  66716. * Define a task used by AssetsManager to load cube textures
  66717. */
  66718. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66719. /**
  66720. * Defines the name of the task
  66721. */
  66722. name: string;
  66723. /**
  66724. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66725. */
  66726. url: string;
  66727. /**
  66728. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66729. */
  66730. extensions?: string[] | undefined;
  66731. /**
  66732. * Defines if mipmaps should not be generated (default is false)
  66733. */
  66734. noMipmap?: boolean | undefined;
  66735. /**
  66736. * Defines the explicit list of files (undefined by default)
  66737. */
  66738. files?: string[] | undefined;
  66739. /**
  66740. * Gets the loaded texture
  66741. */
  66742. texture: CubeTexture;
  66743. /**
  66744. * Callback called when the task is successful
  66745. */
  66746. onSuccess: (task: CubeTextureAssetTask) => void;
  66747. /**
  66748. * Callback called when the task is successful
  66749. */
  66750. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66751. /**
  66752. * Creates a new CubeTextureAssetTask
  66753. * @param name defines the name of the task
  66754. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66755. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66756. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66757. * @param files defines the explicit list of files (undefined by default)
  66758. */
  66759. constructor(
  66760. /**
  66761. * Defines the name of the task
  66762. */
  66763. name: string,
  66764. /**
  66765. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66766. */
  66767. url: string,
  66768. /**
  66769. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66770. */
  66771. extensions?: string[] | undefined,
  66772. /**
  66773. * Defines if mipmaps should not be generated (default is false)
  66774. */
  66775. noMipmap?: boolean | undefined,
  66776. /**
  66777. * Defines the explicit list of files (undefined by default)
  66778. */
  66779. files?: string[] | undefined);
  66780. /**
  66781. * Execute the current task
  66782. * @param scene defines the scene where you want your assets to be loaded
  66783. * @param onSuccess is a callback called when the task is successfully executed
  66784. * @param onError is a callback called if an error occurs
  66785. */
  66786. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66787. }
  66788. /**
  66789. * Define a task used by AssetsManager to load HDR cube textures
  66790. */
  66791. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66792. /**
  66793. * Defines the name of the task
  66794. */
  66795. name: string;
  66796. /**
  66797. * Defines the location of the file to load
  66798. */
  66799. url: string;
  66800. /**
  66801. * Defines the desired size (the more it increases the longer the generation will be)
  66802. */
  66803. size: number;
  66804. /**
  66805. * Defines if mipmaps should not be generated (default is false)
  66806. */
  66807. noMipmap: boolean;
  66808. /**
  66809. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66810. */
  66811. generateHarmonics: boolean;
  66812. /**
  66813. * 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)
  66814. */
  66815. gammaSpace: boolean;
  66816. /**
  66817. * Internal Use Only
  66818. */
  66819. reserved: boolean;
  66820. /**
  66821. * Gets the loaded texture
  66822. */
  66823. texture: HDRCubeTexture;
  66824. /**
  66825. * Callback called when the task is successful
  66826. */
  66827. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66828. /**
  66829. * Callback called when the task is successful
  66830. */
  66831. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66832. /**
  66833. * Creates a new HDRCubeTextureAssetTask object
  66834. * @param name defines the name of the task
  66835. * @param url defines the location of the file to load
  66836. * @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.
  66837. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66838. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66839. * @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)
  66840. * @param reserved Internal use only
  66841. */
  66842. constructor(
  66843. /**
  66844. * Defines the name of the task
  66845. */
  66846. name: string,
  66847. /**
  66848. * Defines the location of the file to load
  66849. */
  66850. url: string,
  66851. /**
  66852. * Defines the desired size (the more it increases the longer the generation will be)
  66853. */
  66854. size: number,
  66855. /**
  66856. * Defines if mipmaps should not be generated (default is false)
  66857. */
  66858. noMipmap?: boolean,
  66859. /**
  66860. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66861. */
  66862. generateHarmonics?: boolean,
  66863. /**
  66864. * 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)
  66865. */
  66866. gammaSpace?: boolean,
  66867. /**
  66868. * Internal Use Only
  66869. */
  66870. reserved?: boolean);
  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. /**
  66880. * Define a task used by AssetsManager to load Equirectangular cube textures
  66881. */
  66882. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66883. /**
  66884. * Defines the name of the task
  66885. */
  66886. name: string;
  66887. /**
  66888. * Defines the location of the file to load
  66889. */
  66890. url: string;
  66891. /**
  66892. * Defines the desired size (the more it increases the longer the generation will be)
  66893. */
  66894. size: number;
  66895. /**
  66896. * Defines if mipmaps should not be generated (default is false)
  66897. */
  66898. noMipmap: boolean;
  66899. /**
  66900. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66901. * but the standard material would require them in Gamma space) (default is true)
  66902. */
  66903. gammaSpace: boolean;
  66904. /**
  66905. * Gets the loaded texture
  66906. */
  66907. texture: EquiRectangularCubeTexture;
  66908. /**
  66909. * Callback called when the task is successful
  66910. */
  66911. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66912. /**
  66913. * Callback called when the task is successful
  66914. */
  66915. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66916. /**
  66917. * Creates a new EquiRectangularCubeTextureAssetTask object
  66918. * @param name defines the name of the task
  66919. * @param url defines the location of the file to load
  66920. * @param size defines the desired size (the more it increases the longer the generation will be)
  66921. * If the size is omitted this implies you are using a preprocessed cubemap.
  66922. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66923. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66924. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66925. * (default is true)
  66926. */
  66927. constructor(
  66928. /**
  66929. * Defines the name of the task
  66930. */
  66931. name: string,
  66932. /**
  66933. * Defines the location of the file to load
  66934. */
  66935. url: string,
  66936. /**
  66937. * Defines the desired size (the more it increases the longer the generation will be)
  66938. */
  66939. size: number,
  66940. /**
  66941. * Defines if mipmaps should not be generated (default is false)
  66942. */
  66943. noMipmap?: boolean,
  66944. /**
  66945. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66946. * but the standard material would require them in Gamma space) (default is true)
  66947. */
  66948. gammaSpace?: boolean);
  66949. /**
  66950. * Execute the current task
  66951. * @param scene defines the scene where you want your assets to be loaded
  66952. * @param onSuccess is a callback called when the task is successfully executed
  66953. * @param onError is a callback called if an error occurs
  66954. */
  66955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66956. }
  66957. /**
  66958. * This class can be used to easily import assets into a scene
  66959. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66960. */
  66961. export class AssetsManager {
  66962. private _scene;
  66963. private _isLoading;
  66964. protected _tasks: AbstractAssetTask[];
  66965. protected _waitingTasksCount: number;
  66966. protected _totalTasksCount: number;
  66967. /**
  66968. * Callback called when all tasks are processed
  66969. */
  66970. onFinish: (tasks: AbstractAssetTask[]) => void;
  66971. /**
  66972. * Callback called when a task is successful
  66973. */
  66974. onTaskSuccess: (task: AbstractAssetTask) => void;
  66975. /**
  66976. * Callback called when a task had an error
  66977. */
  66978. onTaskError: (task: AbstractAssetTask) => void;
  66979. /**
  66980. * Callback called when a task is done (whatever the result is)
  66981. */
  66982. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66983. /**
  66984. * Observable called when all tasks are processed
  66985. */
  66986. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66987. /**
  66988. * Observable called when a task had an error
  66989. */
  66990. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66991. /**
  66992. * Observable called when all tasks were executed
  66993. */
  66994. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66995. /**
  66996. * Observable called when a task is done (whatever the result is)
  66997. */
  66998. onProgressObservable: Observable<IAssetsProgressEvent>;
  66999. /**
  67000. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67001. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67002. */
  67003. useDefaultLoadingScreen: boolean;
  67004. /**
  67005. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67006. * when all assets have been downloaded.
  67007. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67008. */
  67009. autoHideLoadingUI: boolean;
  67010. /**
  67011. * Creates a new AssetsManager
  67012. * @param scene defines the scene to work on
  67013. */
  67014. constructor(scene: Scene);
  67015. /**
  67016. * Add a MeshAssetTask to the list of active tasks
  67017. * @param taskName defines the name of the new task
  67018. * @param meshesNames defines the name of meshes to load
  67019. * @param rootUrl defines the root url to use to locate files
  67020. * @param sceneFilename defines the filename of the scene file
  67021. * @returns a new MeshAssetTask object
  67022. */
  67023. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67024. /**
  67025. * Add a TextFileAssetTask to the list of active tasks
  67026. * @param taskName defines the name of the new task
  67027. * @param url defines the url of the file to load
  67028. * @returns a new TextFileAssetTask object
  67029. */
  67030. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67031. /**
  67032. * Add a BinaryFileAssetTask to the list of active tasks
  67033. * @param taskName defines the name of the new task
  67034. * @param url defines the url of the file to load
  67035. * @returns a new BinaryFileAssetTask object
  67036. */
  67037. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67038. /**
  67039. * Add a ImageAssetTask to the list of active tasks
  67040. * @param taskName defines the name of the new task
  67041. * @param url defines the url of the file to load
  67042. * @returns a new ImageAssetTask object
  67043. */
  67044. addImageTask(taskName: string, url: string): ImageAssetTask;
  67045. /**
  67046. * Add a TextureAssetTask to the list of active tasks
  67047. * @param taskName defines the name of the new task
  67048. * @param url defines the url of the file to load
  67049. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67050. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67051. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67052. * @returns a new TextureAssetTask object
  67053. */
  67054. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67055. /**
  67056. * Add a CubeTextureAssetTask to the list of active tasks
  67057. * @param taskName defines the name of the new task
  67058. * @param url defines the url of the file to load
  67059. * @param extensions defines the extension to use to load the cube map (can be null)
  67060. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67061. * @param files defines the list of files to load (can be null)
  67062. * @returns a new CubeTextureAssetTask object
  67063. */
  67064. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67065. /**
  67066. *
  67067. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67068. * @param taskName defines the name of the new task
  67069. * @param url defines the url of the file to load
  67070. * @param size defines the size you want for the cubemap (can be null)
  67071. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67072. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67073. * @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)
  67074. * @param reserved Internal use only
  67075. * @returns a new HDRCubeTextureAssetTask object
  67076. */
  67077. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67078. /**
  67079. *
  67080. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67081. * @param taskName defines the name of the new task
  67082. * @param url defines the url of the file to load
  67083. * @param size defines the size you want for the cubemap (can be null)
  67084. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67085. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67086. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67087. * @returns a new EquiRectangularCubeTextureAssetTask object
  67088. */
  67089. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67090. /**
  67091. * Remove a task from the assets manager.
  67092. * @param task the task to remove
  67093. */
  67094. removeTask(task: AbstractAssetTask): void;
  67095. private _decreaseWaitingTasksCount;
  67096. private _runTask;
  67097. /**
  67098. * Reset the AssetsManager and remove all tasks
  67099. * @return the current instance of the AssetsManager
  67100. */
  67101. reset(): AssetsManager;
  67102. /**
  67103. * Start the loading process
  67104. * @return the current instance of the AssetsManager
  67105. */
  67106. load(): AssetsManager;
  67107. /**
  67108. * Start the loading process as an async operation
  67109. * @return a promise returning the list of failed tasks
  67110. */
  67111. loadAsync(): Promise<void>;
  67112. }
  67113. }
  67114. declare module "babylonjs/Misc/deferred" {
  67115. /**
  67116. * Wrapper class for promise with external resolve and reject.
  67117. */
  67118. export class Deferred<T> {
  67119. /**
  67120. * The promise associated with this deferred object.
  67121. */
  67122. readonly promise: Promise<T>;
  67123. private _resolve;
  67124. private _reject;
  67125. /**
  67126. * The resolve method of the promise associated with this deferred object.
  67127. */
  67128. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67129. /**
  67130. * The reject method of the promise associated with this deferred object.
  67131. */
  67132. readonly reject: (reason?: any) => void;
  67133. /**
  67134. * Constructor for this deferred object.
  67135. */
  67136. constructor();
  67137. }
  67138. }
  67139. declare module "babylonjs/Misc/meshExploder" {
  67140. import { Mesh } from "babylonjs/Meshes/mesh";
  67141. /**
  67142. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67143. */
  67144. export class MeshExploder {
  67145. private _centerMesh;
  67146. private _meshes;
  67147. private _meshesOrigins;
  67148. private _toCenterVectors;
  67149. private _scaledDirection;
  67150. private _newPosition;
  67151. private _centerPosition;
  67152. /**
  67153. * Explodes meshes from a center mesh.
  67154. * @param meshes The meshes to explode.
  67155. * @param centerMesh The mesh to be center of explosion.
  67156. */
  67157. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67158. private _setCenterMesh;
  67159. /**
  67160. * Get class name
  67161. * @returns "MeshExploder"
  67162. */
  67163. getClassName(): string;
  67164. /**
  67165. * "Exploded meshes"
  67166. * @returns Array of meshes with the centerMesh at index 0.
  67167. */
  67168. getMeshes(): Array<Mesh>;
  67169. /**
  67170. * Explodes meshes giving a specific direction
  67171. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67172. */
  67173. explode(direction?: number): void;
  67174. }
  67175. }
  67176. declare module "babylonjs/Misc/filesInput" {
  67177. import { Engine } from "babylonjs/Engines/engine";
  67178. import { Scene } from "babylonjs/scene";
  67179. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67180. /**
  67181. * Class used to help managing file picking and drag'n'drop
  67182. */
  67183. export class FilesInput {
  67184. /**
  67185. * List of files ready to be loaded
  67186. */
  67187. static readonly FilesToLoad: {
  67188. [key: string]: File;
  67189. };
  67190. /**
  67191. * Callback called when a file is processed
  67192. */
  67193. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67194. private _engine;
  67195. private _currentScene;
  67196. private _sceneLoadedCallback;
  67197. private _progressCallback;
  67198. private _additionalRenderLoopLogicCallback;
  67199. private _textureLoadingCallback;
  67200. private _startingProcessingFilesCallback;
  67201. private _onReloadCallback;
  67202. private _errorCallback;
  67203. private _elementToMonitor;
  67204. private _sceneFileToLoad;
  67205. private _filesToLoad;
  67206. /**
  67207. * Creates a new FilesInput
  67208. * @param engine defines the rendering engine
  67209. * @param scene defines the hosting scene
  67210. * @param sceneLoadedCallback callback called when scene is loaded
  67211. * @param progressCallback callback called to track progress
  67212. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67213. * @param textureLoadingCallback callback called when a texture is loading
  67214. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67215. * @param onReloadCallback callback called when a reload is requested
  67216. * @param errorCallback callback call if an error occurs
  67217. */
  67218. 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);
  67219. private _dragEnterHandler;
  67220. private _dragOverHandler;
  67221. private _dropHandler;
  67222. /**
  67223. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67224. * @param elementToMonitor defines the DOM element to track
  67225. */
  67226. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67227. /**
  67228. * Release all associated resources
  67229. */
  67230. dispose(): void;
  67231. private renderFunction;
  67232. private drag;
  67233. private drop;
  67234. private _traverseFolder;
  67235. private _processFiles;
  67236. /**
  67237. * Load files from a drop event
  67238. * @param event defines the drop event to use as source
  67239. */
  67240. loadFiles(event: any): void;
  67241. private _processReload;
  67242. /**
  67243. * Reload the current scene from the loaded files
  67244. */
  67245. reload(): void;
  67246. }
  67247. }
  67248. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67249. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67250. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67251. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67252. }
  67253. declare module "babylonjs/Misc/sceneOptimizer" {
  67254. import { Scene, IDisposable } from "babylonjs/scene";
  67255. import { Observable } from "babylonjs/Misc/observable";
  67256. /**
  67257. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67259. */
  67260. export class SceneOptimization {
  67261. /**
  67262. * Defines the priority of this optimization (0 by default which means first in the list)
  67263. */
  67264. priority: number;
  67265. /**
  67266. * Gets a string describing the action executed by the current optimization
  67267. * @returns description string
  67268. */
  67269. getDescription(): string;
  67270. /**
  67271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67272. * @param scene defines the current scene where to apply this optimization
  67273. * @param optimizer defines the current optimizer
  67274. * @returns true if everything that can be done was applied
  67275. */
  67276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67277. /**
  67278. * Creates the SceneOptimization object
  67279. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67280. * @param desc defines the description associated with the optimization
  67281. */
  67282. constructor(
  67283. /**
  67284. * Defines the priority of this optimization (0 by default which means first in the list)
  67285. */
  67286. priority?: number);
  67287. }
  67288. /**
  67289. * Defines an optimization used to reduce the size of render target textures
  67290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67291. */
  67292. export class TextureOptimization extends SceneOptimization {
  67293. /**
  67294. * Defines the priority of this optimization (0 by default which means first in the list)
  67295. */
  67296. priority: number;
  67297. /**
  67298. * 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
  67299. */
  67300. maximumSize: number;
  67301. /**
  67302. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67303. */
  67304. step: number;
  67305. /**
  67306. * Gets a string describing the action executed by the current optimization
  67307. * @returns description string
  67308. */
  67309. getDescription(): string;
  67310. /**
  67311. * Creates the TextureOptimization object
  67312. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67313. * @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
  67314. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67315. */
  67316. constructor(
  67317. /**
  67318. * Defines the priority of this optimization (0 by default which means first in the list)
  67319. */
  67320. priority?: number,
  67321. /**
  67322. * 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
  67323. */
  67324. maximumSize?: number,
  67325. /**
  67326. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67327. */
  67328. step?: number);
  67329. /**
  67330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67331. * @param scene defines the current scene where to apply this optimization
  67332. * @param optimizer defines the current optimizer
  67333. * @returns true if everything that can be done was applied
  67334. */
  67335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67336. }
  67337. /**
  67338. * Defines an optimization used to increase or decrease the rendering resolution
  67339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67340. */
  67341. export class HardwareScalingOptimization extends SceneOptimization {
  67342. /**
  67343. * Defines the priority of this optimization (0 by default which means first in the list)
  67344. */
  67345. priority: number;
  67346. /**
  67347. * Defines the maximum scale to use (2 by default)
  67348. */
  67349. maximumScale: number;
  67350. /**
  67351. * Defines the step to use between two passes (0.5 by default)
  67352. */
  67353. step: number;
  67354. private _currentScale;
  67355. private _directionOffset;
  67356. /**
  67357. * Gets a string describing the action executed by the current optimization
  67358. * @return description string
  67359. */
  67360. getDescription(): string;
  67361. /**
  67362. * Creates the HardwareScalingOptimization object
  67363. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67364. * @param maximumScale defines the maximum scale to use (2 by default)
  67365. * @param step defines the step to use between two passes (0.5 by default)
  67366. */
  67367. constructor(
  67368. /**
  67369. * Defines the priority of this optimization (0 by default which means first in the list)
  67370. */
  67371. priority?: number,
  67372. /**
  67373. * Defines the maximum scale to use (2 by default)
  67374. */
  67375. maximumScale?: number,
  67376. /**
  67377. * Defines the step to use between two passes (0.5 by default)
  67378. */
  67379. step?: number);
  67380. /**
  67381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67382. * @param scene defines the current scene where to apply this optimization
  67383. * @param optimizer defines the current optimizer
  67384. * @returns true if everything that can be done was applied
  67385. */
  67386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67387. }
  67388. /**
  67389. * Defines an optimization used to remove shadows
  67390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67391. */
  67392. export class ShadowsOptimization extends SceneOptimization {
  67393. /**
  67394. * Gets a string describing the action executed by the current optimization
  67395. * @return description string
  67396. */
  67397. getDescription(): string;
  67398. /**
  67399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67400. * @param scene defines the current scene where to apply this optimization
  67401. * @param optimizer defines the current optimizer
  67402. * @returns true if everything that can be done was applied
  67403. */
  67404. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67405. }
  67406. /**
  67407. * Defines an optimization used to turn post-processes off
  67408. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67409. */
  67410. export class PostProcessesOptimization extends SceneOptimization {
  67411. /**
  67412. * Gets a string describing the action executed by the current optimization
  67413. * @return description string
  67414. */
  67415. getDescription(): string;
  67416. /**
  67417. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67418. * @param scene defines the current scene where to apply this optimization
  67419. * @param optimizer defines the current optimizer
  67420. * @returns true if everything that can be done was applied
  67421. */
  67422. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67423. }
  67424. /**
  67425. * Defines an optimization used to turn lens flares off
  67426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67427. */
  67428. export class LensFlaresOptimization extends SceneOptimization {
  67429. /**
  67430. * Gets a string describing the action executed by the current optimization
  67431. * @return description string
  67432. */
  67433. getDescription(): string;
  67434. /**
  67435. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67436. * @param scene defines the current scene where to apply this optimization
  67437. * @param optimizer defines the current optimizer
  67438. * @returns true if everything that can be done was applied
  67439. */
  67440. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67441. }
  67442. /**
  67443. * Defines an optimization based on user defined callback.
  67444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67445. */
  67446. export class CustomOptimization extends SceneOptimization {
  67447. /**
  67448. * Callback called to apply the custom optimization.
  67449. */
  67450. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67451. /**
  67452. * Callback called to get custom description
  67453. */
  67454. onGetDescription: () => string;
  67455. /**
  67456. * Gets a string describing the action executed by the current optimization
  67457. * @returns description string
  67458. */
  67459. getDescription(): string;
  67460. /**
  67461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67462. * @param scene defines the current scene where to apply this optimization
  67463. * @param optimizer defines the current optimizer
  67464. * @returns true if everything that can be done was applied
  67465. */
  67466. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67467. }
  67468. /**
  67469. * Defines an optimization used to turn particles off
  67470. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67471. */
  67472. export class ParticlesOptimization extends SceneOptimization {
  67473. /**
  67474. * Gets a string describing the action executed by the current optimization
  67475. * @return description string
  67476. */
  67477. getDescription(): string;
  67478. /**
  67479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67480. * @param scene defines the current scene where to apply this optimization
  67481. * @param optimizer defines the current optimizer
  67482. * @returns true if everything that can be done was applied
  67483. */
  67484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67485. }
  67486. /**
  67487. * Defines an optimization used to turn render targets off
  67488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67489. */
  67490. export class RenderTargetsOptimization extends SceneOptimization {
  67491. /**
  67492. * Gets a string describing the action executed by the current optimization
  67493. * @return description string
  67494. */
  67495. getDescription(): string;
  67496. /**
  67497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67498. * @param scene defines the current scene where to apply this optimization
  67499. * @param optimizer defines the current optimizer
  67500. * @returns true if everything that can be done was applied
  67501. */
  67502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67503. }
  67504. /**
  67505. * Defines an optimization used to merge meshes with compatible materials
  67506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67507. */
  67508. export class MergeMeshesOptimization extends SceneOptimization {
  67509. private static _UpdateSelectionTree;
  67510. /**
  67511. * Gets or sets a boolean which defines if optimization octree has to be updated
  67512. */
  67513. /**
  67514. * Gets or sets a boolean which defines if optimization octree has to be updated
  67515. */
  67516. static UpdateSelectionTree: boolean;
  67517. /**
  67518. * Gets a string describing the action executed by the current optimization
  67519. * @return description string
  67520. */
  67521. getDescription(): string;
  67522. private _canBeMerged;
  67523. /**
  67524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67525. * @param scene defines the current scene where to apply this optimization
  67526. * @param optimizer defines the current optimizer
  67527. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67528. * @returns true if everything that can be done was applied
  67529. */
  67530. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67531. }
  67532. /**
  67533. * Defines a list of options used by SceneOptimizer
  67534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67535. */
  67536. export class SceneOptimizerOptions {
  67537. /**
  67538. * Defines the target frame rate to reach (60 by default)
  67539. */
  67540. targetFrameRate: number;
  67541. /**
  67542. * Defines the interval between two checkes (2000ms by default)
  67543. */
  67544. trackerDuration: number;
  67545. /**
  67546. * Gets the list of optimizations to apply
  67547. */
  67548. optimizations: SceneOptimization[];
  67549. /**
  67550. * Creates a new list of options used by SceneOptimizer
  67551. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67552. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67553. */
  67554. constructor(
  67555. /**
  67556. * Defines the target frame rate to reach (60 by default)
  67557. */
  67558. targetFrameRate?: number,
  67559. /**
  67560. * Defines the interval between two checkes (2000ms by default)
  67561. */
  67562. trackerDuration?: number);
  67563. /**
  67564. * Add a new optimization
  67565. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67566. * @returns the current SceneOptimizerOptions
  67567. */
  67568. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67569. /**
  67570. * Add a new custom optimization
  67571. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67572. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67573. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67574. * @returns the current SceneOptimizerOptions
  67575. */
  67576. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67577. /**
  67578. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67579. * @param targetFrameRate defines the target frame rate (60 by default)
  67580. * @returns a SceneOptimizerOptions object
  67581. */
  67582. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67583. /**
  67584. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67585. * @param targetFrameRate defines the target frame rate (60 by default)
  67586. * @returns a SceneOptimizerOptions object
  67587. */
  67588. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67589. /**
  67590. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67591. * @param targetFrameRate defines the target frame rate (60 by default)
  67592. * @returns a SceneOptimizerOptions object
  67593. */
  67594. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67595. }
  67596. /**
  67597. * Class used to run optimizations in order to reach a target frame rate
  67598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67599. */
  67600. export class SceneOptimizer implements IDisposable {
  67601. private _isRunning;
  67602. private _options;
  67603. private _scene;
  67604. private _currentPriorityLevel;
  67605. private _targetFrameRate;
  67606. private _trackerDuration;
  67607. private _currentFrameRate;
  67608. private _sceneDisposeObserver;
  67609. private _improvementMode;
  67610. /**
  67611. * Defines an observable called when the optimizer reaches the target frame rate
  67612. */
  67613. onSuccessObservable: Observable<SceneOptimizer>;
  67614. /**
  67615. * Defines an observable called when the optimizer enables an optimization
  67616. */
  67617. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67618. /**
  67619. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67620. */
  67621. onFailureObservable: Observable<SceneOptimizer>;
  67622. /**
  67623. * Gets a boolean indicating if the optimizer is in improvement mode
  67624. */
  67625. readonly isInImprovementMode: boolean;
  67626. /**
  67627. * Gets the current priority level (0 at start)
  67628. */
  67629. readonly currentPriorityLevel: number;
  67630. /**
  67631. * Gets the current frame rate checked by the SceneOptimizer
  67632. */
  67633. readonly currentFrameRate: number;
  67634. /**
  67635. * Gets or sets the current target frame rate (60 by default)
  67636. */
  67637. /**
  67638. * Gets or sets the current target frame rate (60 by default)
  67639. */
  67640. targetFrameRate: number;
  67641. /**
  67642. * Gets or sets the current interval between two checks (every 2000ms by default)
  67643. */
  67644. /**
  67645. * Gets or sets the current interval between two checks (every 2000ms by default)
  67646. */
  67647. trackerDuration: number;
  67648. /**
  67649. * Gets the list of active optimizations
  67650. */
  67651. readonly optimizations: SceneOptimization[];
  67652. /**
  67653. * Creates a new SceneOptimizer
  67654. * @param scene defines the scene to work on
  67655. * @param options defines the options to use with the SceneOptimizer
  67656. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67657. * @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)
  67658. */
  67659. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67660. /**
  67661. * Stops the current optimizer
  67662. */
  67663. stop(): void;
  67664. /**
  67665. * Reset the optimizer to initial step (current priority level = 0)
  67666. */
  67667. reset(): void;
  67668. /**
  67669. * Start the optimizer. By default it will try to reach a specific framerate
  67670. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67671. */
  67672. start(): void;
  67673. private _checkCurrentState;
  67674. /**
  67675. * Release all resources
  67676. */
  67677. dispose(): void;
  67678. /**
  67679. * Helper function to create a SceneOptimizer with one single line of code
  67680. * @param scene defines the scene to work on
  67681. * @param options defines the options to use with the SceneOptimizer
  67682. * @param onSuccess defines a callback to call on success
  67683. * @param onFailure defines a callback to call on failure
  67684. * @returns the new SceneOptimizer object
  67685. */
  67686. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67687. }
  67688. }
  67689. declare module "babylonjs/Misc/sceneSerializer" {
  67690. import { Scene } from "babylonjs/scene";
  67691. /**
  67692. * Class used to serialize a scene into a string
  67693. */
  67694. export class SceneSerializer {
  67695. /**
  67696. * Clear cache used by a previous serialization
  67697. */
  67698. static ClearCache(): void;
  67699. /**
  67700. * Serialize a scene into a JSON compatible object
  67701. * @param scene defines the scene to serialize
  67702. * @returns a JSON compatible object
  67703. */
  67704. static Serialize(scene: Scene): any;
  67705. /**
  67706. * Serialize a mesh into a JSON compatible object
  67707. * @param toSerialize defines the mesh to serialize
  67708. * @param withParents defines if parents must be serialized as well
  67709. * @param withChildren defines if children must be serialized as well
  67710. * @returns a JSON compatible object
  67711. */
  67712. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67713. }
  67714. }
  67715. declare module "babylonjs/Misc/textureTools" {
  67716. import { Texture } from "babylonjs/Materials/Textures/texture";
  67717. /**
  67718. * Class used to host texture specific utilities
  67719. */
  67720. export class TextureTools {
  67721. /**
  67722. * Uses the GPU to create a copy texture rescaled at a given size
  67723. * @param texture Texture to copy from
  67724. * @param width defines the desired width
  67725. * @param height defines the desired height
  67726. * @param useBilinearMode defines if bilinear mode has to be used
  67727. * @return the generated texture
  67728. */
  67729. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67730. }
  67731. }
  67732. declare module "babylonjs/Misc/videoRecorder" {
  67733. import { Nullable } from "babylonjs/types";
  67734. import { Engine } from "babylonjs/Engines/engine";
  67735. /**
  67736. * This represents the different options available for the video capture.
  67737. */
  67738. export interface VideoRecorderOptions {
  67739. /** Defines the mime type of the video. */
  67740. mimeType: string;
  67741. /** Defines the FPS the video should be recorded at. */
  67742. fps: number;
  67743. /** Defines the chunk size for the recording data. */
  67744. recordChunckSize: number;
  67745. /** The audio tracks to attach to the recording. */
  67746. audioTracks?: MediaStreamTrack[];
  67747. }
  67748. /**
  67749. * This can help with recording videos from BabylonJS.
  67750. * This is based on the available WebRTC functionalities of the browser.
  67751. *
  67752. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67753. */
  67754. export class VideoRecorder {
  67755. private static readonly _defaultOptions;
  67756. /**
  67757. * Returns whether or not the VideoRecorder is available in your browser.
  67758. * @param engine Defines the Babylon Engine.
  67759. * @returns true if supported otherwise false.
  67760. */
  67761. static IsSupported(engine: Engine): boolean;
  67762. private readonly _options;
  67763. private _canvas;
  67764. private _mediaRecorder;
  67765. private _recordedChunks;
  67766. private _fileName;
  67767. private _resolve;
  67768. private _reject;
  67769. /**
  67770. * True when a recording is already in progress.
  67771. */
  67772. readonly isRecording: boolean;
  67773. /**
  67774. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67775. * @param engine Defines the BabylonJS Engine you wish to record.
  67776. * @param options Defines options that can be used to customize the capture.
  67777. */
  67778. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67779. /**
  67780. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67781. */
  67782. stopRecording(): void;
  67783. /**
  67784. * Starts recording the canvas for a max duration specified in parameters.
  67785. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67786. * If null no automatic download will start and you can rely on the promise to get the data back.
  67787. * @param maxDuration Defines the maximum recording time in seconds.
  67788. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67789. * @return A promise callback at the end of the recording with the video data in Blob.
  67790. */
  67791. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67792. /**
  67793. * Releases internal resources used during the recording.
  67794. */
  67795. dispose(): void;
  67796. private _handleDataAvailable;
  67797. private _handleError;
  67798. private _handleStop;
  67799. }
  67800. }
  67801. declare module "babylonjs/Misc/screenshotTools" {
  67802. import { Camera } from "babylonjs/Cameras/camera";
  67803. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67804. import { Engine } from "babylonjs/Engines/engine";
  67805. /**
  67806. * Class containing a set of static utilities functions for screenshots
  67807. */
  67808. export class ScreenshotTools {
  67809. /**
  67810. * Captures a screenshot of the current rendering
  67811. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67812. * @param engine defines the rendering engine
  67813. * @param camera defines the source camera
  67814. * @param size This parameter can be set to a single number or to an object with the
  67815. * following (optional) properties: precision, width, height. If a single number is passed,
  67816. * it will be used for both width and height. If an object is passed, the screenshot size
  67817. * will be derived from the parameters. The precision property is a multiplier allowing
  67818. * rendering at a higher or lower resolution
  67819. * @param successCallback defines the callback receives a single parameter which contains the
  67820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67821. * src parameter of an <img> to display it
  67822. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67823. * Check your browser for supported MIME types
  67824. */
  67825. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67826. /**
  67827. * Captures a screenshot of the current rendering
  67828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67829. * @param engine defines the rendering engine
  67830. * @param camera defines the source camera
  67831. * @param size This parameter can be set to a single number or to an object with the
  67832. * following (optional) properties: precision, width, height. If a single number is passed,
  67833. * it will be used for both width and height. If an object is passed, the screenshot size
  67834. * will be derived from the parameters. The precision property is a multiplier allowing
  67835. * rendering at a higher or lower resolution
  67836. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67837. * Check your browser for supported MIME types
  67838. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67839. * to the src parameter of an <img> to display it
  67840. */
  67841. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67842. /**
  67843. * Generates an image screenshot from the specified camera.
  67844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67845. * @param engine The engine to use for rendering
  67846. * @param camera The camera to use for rendering
  67847. * @param size This parameter can be set to a single number or to an object with the
  67848. * following (optional) properties: precision, width, height. If a single number is passed,
  67849. * it will be used for both width and height. If an object is passed, the screenshot size
  67850. * will be derived from the parameters. The precision property is a multiplier allowing
  67851. * rendering at a higher or lower resolution
  67852. * @param successCallback The callback receives a single parameter which contains the
  67853. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67854. * src parameter of an <img> to display it
  67855. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67856. * Check your browser for supported MIME types
  67857. * @param samples Texture samples (default: 1)
  67858. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67859. * @param fileName A name for for the downloaded file.
  67860. */
  67861. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67862. /**
  67863. * Generates an image screenshot from the specified camera.
  67864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67865. * @param engine The engine to use for rendering
  67866. * @param camera The camera to use for rendering
  67867. * @param size This parameter can be set to a single number or to an object with the
  67868. * following (optional) properties: precision, width, height. If a single number is passed,
  67869. * it will be used for both width and height. If an object is passed, the screenshot size
  67870. * will be derived from the parameters. The precision property is a multiplier allowing
  67871. * rendering at a higher or lower resolution
  67872. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67873. * Check your browser for supported MIME types
  67874. * @param samples Texture samples (default: 1)
  67875. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67876. * @param fileName A name for for the downloaded file.
  67877. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67878. * to the src parameter of an <img> to display it
  67879. */
  67880. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67881. /**
  67882. * Gets height and width for screenshot size
  67883. * @private
  67884. */
  67885. private static _getScreenshotSize;
  67886. }
  67887. }
  67888. declare module "babylonjs/Misc/dataReader" {
  67889. /**
  67890. * Interface for a data buffer
  67891. */
  67892. export interface IDataBuffer {
  67893. /**
  67894. * Reads bytes from the data buffer.
  67895. * @param byteOffset The byte offset to read
  67896. * @param byteLength The byte length to read
  67897. * @returns A promise that resolves when the bytes are read
  67898. */
  67899. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67900. /**
  67901. * The byte length of the buffer.
  67902. */
  67903. readonly byteLength: number;
  67904. }
  67905. /**
  67906. * Utility class for reading from a data buffer
  67907. */
  67908. export class DataReader {
  67909. /**
  67910. * The data buffer associated with this data reader.
  67911. */
  67912. readonly buffer: IDataBuffer;
  67913. /**
  67914. * The current byte offset from the beginning of the data buffer.
  67915. */
  67916. byteOffset: number;
  67917. private _dataView;
  67918. private _dataByteOffset;
  67919. /**
  67920. * Constructor
  67921. * @param buffer The buffer to read
  67922. */
  67923. constructor(buffer: IDataBuffer);
  67924. /**
  67925. * Loads the given byte length.
  67926. * @param byteLength The byte length to load
  67927. * @returns A promise that resolves when the load is complete
  67928. */
  67929. loadAsync(byteLength: number): Promise<void>;
  67930. /**
  67931. * Read a unsigned 32-bit integer from the currently loaded data range.
  67932. * @returns The 32-bit integer read
  67933. */
  67934. readUint32(): number;
  67935. /**
  67936. * Read a byte array from the currently loaded data range.
  67937. * @param byteLength The byte length to read
  67938. * @returns The byte array read
  67939. */
  67940. readUint8Array(byteLength: number): Uint8Array;
  67941. /**
  67942. * Read a string from the currently loaded data range.
  67943. * @param byteLength The byte length to read
  67944. * @returns The string read
  67945. */
  67946. readString(byteLength: number): string;
  67947. /**
  67948. * Skips the given byte length the currently loaded data range.
  67949. * @param byteLength The byte length to skip
  67950. */
  67951. skipBytes(byteLength: number): void;
  67952. }
  67953. }
  67954. declare module "babylonjs/Misc/index" {
  67955. export * from "babylonjs/Misc/andOrNotEvaluator";
  67956. export * from "babylonjs/Misc/assetsManager";
  67957. export * from "babylonjs/Misc/dds";
  67958. export * from "babylonjs/Misc/decorators";
  67959. export * from "babylonjs/Misc/deferred";
  67960. export * from "babylonjs/Misc/environmentTextureTools";
  67961. export * from "babylonjs/Misc/meshExploder";
  67962. export * from "babylonjs/Misc/filesInput";
  67963. export * from "babylonjs/Misc/HighDynamicRange/index";
  67964. export * from "babylonjs/Misc/khronosTextureContainer";
  67965. export * from "babylonjs/Misc/observable";
  67966. export * from "babylonjs/Misc/performanceMonitor";
  67967. export * from "babylonjs/Misc/promise";
  67968. export * from "babylonjs/Misc/sceneOptimizer";
  67969. export * from "babylonjs/Misc/sceneSerializer";
  67970. export * from "babylonjs/Misc/smartArray";
  67971. export * from "babylonjs/Misc/stringDictionary";
  67972. export * from "babylonjs/Misc/tags";
  67973. export * from "babylonjs/Misc/textureTools";
  67974. export * from "babylonjs/Misc/tga";
  67975. export * from "babylonjs/Misc/tools";
  67976. export * from "babylonjs/Misc/videoRecorder";
  67977. export * from "babylonjs/Misc/virtualJoystick";
  67978. export * from "babylonjs/Misc/workerPool";
  67979. export * from "babylonjs/Misc/logger";
  67980. export * from "babylonjs/Misc/typeStore";
  67981. export * from "babylonjs/Misc/filesInputStore";
  67982. export * from "babylonjs/Misc/deepCopier";
  67983. export * from "babylonjs/Misc/pivotTools";
  67984. export * from "babylonjs/Misc/precisionDate";
  67985. export * from "babylonjs/Misc/screenshotTools";
  67986. export * from "babylonjs/Misc/typeStore";
  67987. export * from "babylonjs/Misc/webRequest";
  67988. export * from "babylonjs/Misc/iInspectable";
  67989. export * from "babylonjs/Misc/brdfTextureTools";
  67990. export * from "babylonjs/Misc/rgbdTextureTools";
  67991. export * from "babylonjs/Misc/gradients";
  67992. export * from "babylonjs/Misc/perfCounter";
  67993. export * from "babylonjs/Misc/fileRequest";
  67994. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67995. export * from "babylonjs/Misc/retryStrategy";
  67996. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67997. export * from "babylonjs/Misc/canvasGenerator";
  67998. export * from "babylonjs/Misc/fileTools";
  67999. export * from "babylonjs/Misc/stringTools";
  68000. export * from "babylonjs/Misc/dataReader";
  68001. }
  68002. declare module "babylonjs/index" {
  68003. export * from "babylonjs/abstractScene";
  68004. export * from "babylonjs/Actions/index";
  68005. export * from "babylonjs/Animations/index";
  68006. export * from "babylonjs/assetContainer";
  68007. export * from "babylonjs/Audio/index";
  68008. export * from "babylonjs/Behaviors/index";
  68009. export * from "babylonjs/Bones/index";
  68010. export * from "babylonjs/Cameras/index";
  68011. export * from "babylonjs/Collisions/index";
  68012. export * from "babylonjs/Culling/index";
  68013. export * from "babylonjs/Debug/index";
  68014. export * from "babylonjs/Engines/index";
  68015. export * from "babylonjs/Events/index";
  68016. export * from "babylonjs/Gamepads/index";
  68017. export * from "babylonjs/Gizmos/index";
  68018. export * from "babylonjs/Helpers/index";
  68019. export * from "babylonjs/Instrumentation/index";
  68020. export * from "babylonjs/Layers/index";
  68021. export * from "babylonjs/LensFlares/index";
  68022. export * from "babylonjs/Lights/index";
  68023. export * from "babylonjs/Loading/index";
  68024. export * from "babylonjs/Materials/index";
  68025. export * from "babylonjs/Maths/index";
  68026. export * from "babylonjs/Meshes/index";
  68027. export * from "babylonjs/Morph/index";
  68028. export * from "babylonjs/Navigation/index";
  68029. export * from "babylonjs/node";
  68030. export * from "babylonjs/Offline/index";
  68031. export * from "babylonjs/Particles/index";
  68032. export * from "babylonjs/Physics/index";
  68033. export * from "babylonjs/PostProcesses/index";
  68034. export * from "babylonjs/Probes/index";
  68035. export * from "babylonjs/Rendering/index";
  68036. export * from "babylonjs/scene";
  68037. export * from "babylonjs/sceneComponent";
  68038. export * from "babylonjs/Sprites/index";
  68039. export * from "babylonjs/States/index";
  68040. export * from "babylonjs/Misc/index";
  68041. export * from "babylonjs/types";
  68042. }
  68043. declare module "babylonjs/Animations/pathCursor" {
  68044. import { Vector3 } from "babylonjs/Maths/math.vector";
  68045. import { Path2 } from "babylonjs/Maths/math.path";
  68046. /**
  68047. * A cursor which tracks a point on a path
  68048. */
  68049. export class PathCursor {
  68050. private path;
  68051. /**
  68052. * Stores path cursor callbacks for when an onchange event is triggered
  68053. */
  68054. private _onchange;
  68055. /**
  68056. * The value of the path cursor
  68057. */
  68058. value: number;
  68059. /**
  68060. * The animation array of the path cursor
  68061. */
  68062. animations: Animation[];
  68063. /**
  68064. * Initializes the path cursor
  68065. * @param path The path to track
  68066. */
  68067. constructor(path: Path2);
  68068. /**
  68069. * Gets the cursor point on the path
  68070. * @returns A point on the path cursor at the cursor location
  68071. */
  68072. getPoint(): Vector3;
  68073. /**
  68074. * Moves the cursor ahead by the step amount
  68075. * @param step The amount to move the cursor forward
  68076. * @returns This path cursor
  68077. */
  68078. moveAhead(step?: number): PathCursor;
  68079. /**
  68080. * Moves the cursor behind by the step amount
  68081. * @param step The amount to move the cursor back
  68082. * @returns This path cursor
  68083. */
  68084. moveBack(step?: number): PathCursor;
  68085. /**
  68086. * Moves the cursor by the step amount
  68087. * If the step amount is greater than one, an exception is thrown
  68088. * @param step The amount to move the cursor
  68089. * @returns This path cursor
  68090. */
  68091. move(step: number): PathCursor;
  68092. /**
  68093. * Ensures that the value is limited between zero and one
  68094. * @returns This path cursor
  68095. */
  68096. private ensureLimits;
  68097. /**
  68098. * Runs onchange callbacks on change (used by the animation engine)
  68099. * @returns This path cursor
  68100. */
  68101. private raiseOnChange;
  68102. /**
  68103. * Executes a function on change
  68104. * @param f A path cursor onchange callback
  68105. * @returns This path cursor
  68106. */
  68107. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68108. }
  68109. }
  68110. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68111. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68112. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68113. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68114. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68115. }
  68116. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68117. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68118. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68119. }
  68120. declare module "babylonjs/Engines/Processors/index" {
  68121. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68122. export * from "babylonjs/Engines/Processors/Expressions/index";
  68123. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68124. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68125. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68126. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68127. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68128. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68129. }
  68130. declare module "babylonjs/Legacy/legacy" {
  68131. import * as Babylon from "babylonjs/index";
  68132. export * from "babylonjs/index";
  68133. }
  68134. declare module "babylonjs/Shaders/blur.fragment" {
  68135. /** @hidden */
  68136. export var blurPixelShader: {
  68137. name: string;
  68138. shader: string;
  68139. };
  68140. }
  68141. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68142. /** @hidden */
  68143. export var pointCloudVertexDeclaration: {
  68144. name: string;
  68145. shader: string;
  68146. };
  68147. }
  68148. declare module "babylonjs" {
  68149. export * from "babylonjs/Legacy/legacy";
  68150. }
  68151. declare module BABYLON {
  68152. /** Alias type for value that can be null */
  68153. export type Nullable<T> = T | null;
  68154. /**
  68155. * Alias type for number that are floats
  68156. * @ignorenaming
  68157. */
  68158. export type float = number;
  68159. /**
  68160. * Alias type for number that are doubles.
  68161. * @ignorenaming
  68162. */
  68163. export type double = number;
  68164. /**
  68165. * Alias type for number that are integer
  68166. * @ignorenaming
  68167. */
  68168. export type int = number;
  68169. /** Alias type for number array or Float32Array */
  68170. export type FloatArray = number[] | Float32Array;
  68171. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68172. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68173. /**
  68174. * Alias for types that can be used by a Buffer or VertexBuffer.
  68175. */
  68176. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68177. /**
  68178. * Alias type for primitive types
  68179. * @ignorenaming
  68180. */
  68181. type Primitive = undefined | null | boolean | string | number | Function;
  68182. /**
  68183. * Type modifier to make all the properties of an object Readonly
  68184. */
  68185. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68186. /**
  68187. * Type modifier to make all the properties of an object Readonly recursively
  68188. */
  68189. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68190. /**
  68191. * Type modifier to make object properties readonly.
  68192. */
  68193. export type DeepImmutableObject<T> = {
  68194. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68195. };
  68196. /** @hidden */
  68197. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68198. }
  68199. }
  68200. declare module BABYLON {
  68201. /**
  68202. * A class serves as a medium between the observable and its observers
  68203. */
  68204. export class EventState {
  68205. /**
  68206. * Create a new EventState
  68207. * @param mask defines the mask associated with this state
  68208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68209. * @param target defines the original target of the state
  68210. * @param currentTarget defines the current target of the state
  68211. */
  68212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68213. /**
  68214. * Initialize the current event state
  68215. * @param mask defines the mask associated with this state
  68216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68217. * @param target defines the original target of the state
  68218. * @param currentTarget defines the current target of the state
  68219. * @returns the current event state
  68220. */
  68221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68222. /**
  68223. * An Observer can set this property to true to prevent subsequent observers of being notified
  68224. */
  68225. skipNextObservers: boolean;
  68226. /**
  68227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68228. */
  68229. mask: number;
  68230. /**
  68231. * The object that originally notified the event
  68232. */
  68233. target?: any;
  68234. /**
  68235. * The current object in the bubbling phase
  68236. */
  68237. currentTarget?: any;
  68238. /**
  68239. * This will be populated with the return value of the last function that was executed.
  68240. * If it is the first function in the callback chain it will be the event data.
  68241. */
  68242. lastReturnValue?: any;
  68243. }
  68244. /**
  68245. * Represent an Observer registered to a given Observable object.
  68246. */
  68247. export class Observer<T> {
  68248. /**
  68249. * Defines the callback to call when the observer is notified
  68250. */
  68251. callback: (eventData: T, eventState: EventState) => void;
  68252. /**
  68253. * Defines the mask of the observer (used to filter notifications)
  68254. */
  68255. mask: number;
  68256. /**
  68257. * Defines the current scope used to restore the JS context
  68258. */
  68259. scope: any;
  68260. /** @hidden */
  68261. _willBeUnregistered: boolean;
  68262. /**
  68263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68264. */
  68265. unregisterOnNextCall: boolean;
  68266. /**
  68267. * Creates a new observer
  68268. * @param callback defines the callback to call when the observer is notified
  68269. * @param mask defines the mask of the observer (used to filter notifications)
  68270. * @param scope defines the current scope used to restore the JS context
  68271. */
  68272. constructor(
  68273. /**
  68274. * Defines the callback to call when the observer is notified
  68275. */
  68276. callback: (eventData: T, eventState: EventState) => void,
  68277. /**
  68278. * Defines the mask of the observer (used to filter notifications)
  68279. */
  68280. mask: number,
  68281. /**
  68282. * Defines the current scope used to restore the JS context
  68283. */
  68284. scope?: any);
  68285. }
  68286. /**
  68287. * Represent a list of observers registered to multiple Observables object.
  68288. */
  68289. export class MultiObserver<T> {
  68290. private _observers;
  68291. private _observables;
  68292. /**
  68293. * Release associated resources
  68294. */
  68295. dispose(): void;
  68296. /**
  68297. * Raise a callback when one of the observable will notify
  68298. * @param observables defines a list of observables to watch
  68299. * @param callback defines the callback to call on notification
  68300. * @param mask defines the mask used to filter notifications
  68301. * @param scope defines the current scope used to restore the JS context
  68302. * @returns the new MultiObserver
  68303. */
  68304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68305. }
  68306. /**
  68307. * The Observable class is a simple implementation of the Observable pattern.
  68308. *
  68309. * 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.
  68310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68311. * 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).
  68312. * 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.
  68313. */
  68314. export class Observable<T> {
  68315. private _observers;
  68316. private _eventState;
  68317. private _onObserverAdded;
  68318. /**
  68319. * Gets the list of observers
  68320. */
  68321. readonly observers: Array<Observer<T>>;
  68322. /**
  68323. * Creates a new observable
  68324. * @param onObserverAdded defines a callback to call when a new observer is added
  68325. */
  68326. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68327. /**
  68328. * Create a new Observer with the specified callback
  68329. * @param callback the callback that will be executed for that Observer
  68330. * @param mask the mask used to filter observers
  68331. * @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.
  68332. * @param scope optional scope for the callback to be called from
  68333. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68334. * @returns the new observer created for the callback
  68335. */
  68336. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68337. /**
  68338. * Create a new Observer with the specified callback and unregisters after the next notification
  68339. * @param callback the callback that will be executed for that Observer
  68340. * @returns the new observer created for the callback
  68341. */
  68342. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68343. /**
  68344. * Remove an Observer from the Observable object
  68345. * @param observer the instance of the Observer to remove
  68346. * @returns false if it doesn't belong to this Observable
  68347. */
  68348. remove(observer: Nullable<Observer<T>>): boolean;
  68349. /**
  68350. * Remove a callback from the Observable object
  68351. * @param callback the callback to remove
  68352. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68353. * @returns false if it doesn't belong to this Observable
  68354. */
  68355. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68356. private _deferUnregister;
  68357. private _remove;
  68358. /**
  68359. * Moves the observable to the top of the observer list making it get called first when notified
  68360. * @param observer the observer to move
  68361. */
  68362. makeObserverTopPriority(observer: Observer<T>): void;
  68363. /**
  68364. * Moves the observable to the bottom of the observer list making it get called last when notified
  68365. * @param observer the observer to move
  68366. */
  68367. makeObserverBottomPriority(observer: Observer<T>): void;
  68368. /**
  68369. * Notify all Observers by calling their respective callback with the given data
  68370. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68371. * @param eventData defines the data to send to all observers
  68372. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68373. * @param target defines the original target of the state
  68374. * @param currentTarget defines the current target of the state
  68375. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68376. */
  68377. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68378. /**
  68379. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68380. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68381. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68382. * and it is crucial that all callbacks will be executed.
  68383. * The order of the callbacks is kept, callbacks are not executed parallel.
  68384. *
  68385. * @param eventData The data to be sent to each callback
  68386. * @param mask is used to filter observers defaults to -1
  68387. * @param target defines the callback target (see EventState)
  68388. * @param currentTarget defines he current object in the bubbling phase
  68389. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68390. */
  68391. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68392. /**
  68393. * Notify a specific observer
  68394. * @param observer defines the observer to notify
  68395. * @param eventData defines the data to be sent to each callback
  68396. * @param mask is used to filter observers defaults to -1
  68397. */
  68398. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68399. /**
  68400. * Gets a boolean indicating if the observable has at least one observer
  68401. * @returns true is the Observable has at least one Observer registered
  68402. */
  68403. hasObservers(): boolean;
  68404. /**
  68405. * Clear the list of observers
  68406. */
  68407. clear(): void;
  68408. /**
  68409. * Clone the current observable
  68410. * @returns a new observable
  68411. */
  68412. clone(): Observable<T>;
  68413. /**
  68414. * Does this observable handles observer registered with a given mask
  68415. * @param mask defines the mask to be tested
  68416. * @return whether or not one observer registered with the given mask is handeled
  68417. **/
  68418. hasSpecificMask(mask?: number): boolean;
  68419. }
  68420. }
  68421. declare module BABYLON {
  68422. /**
  68423. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68424. * Babylon.js
  68425. */
  68426. export class DomManagement {
  68427. /**
  68428. * Checks if the window object exists
  68429. * @returns true if the window object exists
  68430. */
  68431. static IsWindowObjectExist(): boolean;
  68432. /**
  68433. * Checks if the navigator object exists
  68434. * @returns true if the navigator object exists
  68435. */
  68436. static IsNavigatorAvailable(): boolean;
  68437. /**
  68438. * Extracts text content from a DOM element hierarchy
  68439. * @param element defines the root element
  68440. * @returns a string
  68441. */
  68442. static GetDOMTextContent(element: HTMLElement): string;
  68443. }
  68444. }
  68445. declare module BABYLON {
  68446. /**
  68447. * Logger used througouht the application to allow configuration of
  68448. * the log level required for the messages.
  68449. */
  68450. export class Logger {
  68451. /**
  68452. * No log
  68453. */
  68454. static readonly NoneLogLevel: number;
  68455. /**
  68456. * Only message logs
  68457. */
  68458. static readonly MessageLogLevel: number;
  68459. /**
  68460. * Only warning logs
  68461. */
  68462. static readonly WarningLogLevel: number;
  68463. /**
  68464. * Only error logs
  68465. */
  68466. static readonly ErrorLogLevel: number;
  68467. /**
  68468. * All logs
  68469. */
  68470. static readonly AllLogLevel: number;
  68471. private static _LogCache;
  68472. /**
  68473. * Gets a value indicating the number of loading errors
  68474. * @ignorenaming
  68475. */
  68476. static errorsCount: number;
  68477. /**
  68478. * Callback called when a new log is added
  68479. */
  68480. static OnNewCacheEntry: (entry: string) => void;
  68481. private static _AddLogEntry;
  68482. private static _FormatMessage;
  68483. private static _LogDisabled;
  68484. private static _LogEnabled;
  68485. private static _WarnDisabled;
  68486. private static _WarnEnabled;
  68487. private static _ErrorDisabled;
  68488. private static _ErrorEnabled;
  68489. /**
  68490. * Log a message to the console
  68491. */
  68492. static Log: (message: string) => void;
  68493. /**
  68494. * Write a warning message to the console
  68495. */
  68496. static Warn: (message: string) => void;
  68497. /**
  68498. * Write an error message to the console
  68499. */
  68500. static Error: (message: string) => void;
  68501. /**
  68502. * Gets current log cache (list of logs)
  68503. */
  68504. static readonly LogCache: string;
  68505. /**
  68506. * Clears the log cache
  68507. */
  68508. static ClearLogCache(): void;
  68509. /**
  68510. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68511. */
  68512. static LogLevels: number;
  68513. }
  68514. }
  68515. declare module BABYLON {
  68516. /** @hidden */
  68517. export class _TypeStore {
  68518. /** @hidden */
  68519. static RegisteredTypes: {
  68520. [key: string]: Object;
  68521. };
  68522. /** @hidden */
  68523. static GetClass(fqdn: string): any;
  68524. }
  68525. }
  68526. declare module BABYLON {
  68527. /**
  68528. * Helper to manipulate strings
  68529. */
  68530. export class StringTools {
  68531. /**
  68532. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68533. * @param str Source string
  68534. * @param suffix Suffix to search for in the source string
  68535. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68536. */
  68537. static EndsWith(str: string, suffix: string): boolean;
  68538. /**
  68539. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68540. * @param str Source string
  68541. * @param suffix Suffix to search for in the source string
  68542. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68543. */
  68544. static StartsWith(str: string, suffix: string): boolean;
  68545. /**
  68546. * Decodes a buffer into a string
  68547. * @param buffer The buffer to decode
  68548. * @returns The decoded string
  68549. */
  68550. static Decode(buffer: Uint8Array | Uint16Array): string;
  68551. /**
  68552. * Encode a buffer to a base64 string
  68553. * @param buffer defines the buffer to encode
  68554. * @returns the encoded string
  68555. */
  68556. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68557. }
  68558. }
  68559. declare module BABYLON {
  68560. /**
  68561. * Class containing a set of static utilities functions for deep copy.
  68562. */
  68563. export class DeepCopier {
  68564. /**
  68565. * Tries to copy an object by duplicating every property
  68566. * @param source defines the source object
  68567. * @param destination defines the target object
  68568. * @param doNotCopyList defines a list of properties to avoid
  68569. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68570. */
  68571. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68572. }
  68573. }
  68574. declare module BABYLON {
  68575. /**
  68576. * Class containing a set of static utilities functions for precision date
  68577. */
  68578. export class PrecisionDate {
  68579. /**
  68580. * Gets either window.performance.now() if supported or Date.now() else
  68581. */
  68582. static readonly Now: number;
  68583. }
  68584. }
  68585. declare module BABYLON {
  68586. /** @hidden */
  68587. export class _DevTools {
  68588. static WarnImport(name: string): string;
  68589. }
  68590. }
  68591. declare module BABYLON {
  68592. /**
  68593. * Interface used to define the mechanism to get data from the network
  68594. */
  68595. export interface IWebRequest {
  68596. /**
  68597. * Returns client's response url
  68598. */
  68599. responseURL: string;
  68600. /**
  68601. * Returns client's status
  68602. */
  68603. status: number;
  68604. /**
  68605. * Returns client's status as a text
  68606. */
  68607. statusText: string;
  68608. }
  68609. }
  68610. declare module BABYLON {
  68611. /**
  68612. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68613. */
  68614. export class WebRequest implements IWebRequest {
  68615. private _xhr;
  68616. /**
  68617. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68618. * i.e. when loading files, where the server/service expects an Authorization header
  68619. */
  68620. static CustomRequestHeaders: {
  68621. [key: string]: string;
  68622. };
  68623. /**
  68624. * Add callback functions in this array to update all the requests before they get sent to the network
  68625. */
  68626. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68627. private _injectCustomRequestHeaders;
  68628. /**
  68629. * Gets or sets a function to be called when loading progress changes
  68630. */
  68631. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68632. /**
  68633. * Returns client's state
  68634. */
  68635. readonly readyState: number;
  68636. /**
  68637. * Returns client's status
  68638. */
  68639. readonly status: number;
  68640. /**
  68641. * Returns client's status as a text
  68642. */
  68643. readonly statusText: string;
  68644. /**
  68645. * Returns client's response
  68646. */
  68647. readonly response: any;
  68648. /**
  68649. * Returns client's response url
  68650. */
  68651. readonly responseURL: string;
  68652. /**
  68653. * Returns client's response as text
  68654. */
  68655. readonly responseText: string;
  68656. /**
  68657. * Gets or sets the expected response type
  68658. */
  68659. responseType: XMLHttpRequestResponseType;
  68660. /** @hidden */
  68661. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68662. /** @hidden */
  68663. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68664. /**
  68665. * Cancels any network activity
  68666. */
  68667. abort(): void;
  68668. /**
  68669. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68670. * @param body defines an optional request body
  68671. */
  68672. send(body?: Document | BodyInit | null): void;
  68673. /**
  68674. * Sets the request method, request URL
  68675. * @param method defines the method to use (GET, POST, etc..)
  68676. * @param url defines the url to connect with
  68677. */
  68678. open(method: string, url: string): void;
  68679. /**
  68680. * Sets the value of a request header.
  68681. * @param name The name of the header whose value is to be set
  68682. * @param value The value to set as the body of the header
  68683. */
  68684. setRequestHeader(name: string, value: string): void;
  68685. /**
  68686. * Get the string containing the text of a particular header's value.
  68687. * @param name The name of the header
  68688. * @returns The string containing the text of the given header name
  68689. */
  68690. getResponseHeader(name: string): Nullable<string>;
  68691. }
  68692. }
  68693. declare module BABYLON {
  68694. /**
  68695. * File request interface
  68696. */
  68697. export interface IFileRequest {
  68698. /**
  68699. * Raised when the request is complete (success or error).
  68700. */
  68701. onCompleteObservable: Observable<IFileRequest>;
  68702. /**
  68703. * Aborts the request for a file.
  68704. */
  68705. abort: () => void;
  68706. }
  68707. }
  68708. declare module BABYLON {
  68709. /**
  68710. * Define options used to create a render target texture
  68711. */
  68712. export class RenderTargetCreationOptions {
  68713. /**
  68714. * Specifies is mipmaps must be generated
  68715. */
  68716. generateMipMaps?: boolean;
  68717. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68718. generateDepthBuffer?: boolean;
  68719. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68720. generateStencilBuffer?: boolean;
  68721. /** Defines texture type (int by default) */
  68722. type?: number;
  68723. /** Defines sampling mode (trilinear by default) */
  68724. samplingMode?: number;
  68725. /** Defines format (RGBA by default) */
  68726. format?: number;
  68727. }
  68728. }
  68729. declare module BABYLON {
  68730. /**
  68731. * @hidden
  68732. **/
  68733. export class _TimeToken {
  68734. _startTimeQuery: Nullable<WebGLQuery>;
  68735. _endTimeQuery: Nullable<WebGLQuery>;
  68736. _timeElapsedQuery: Nullable<WebGLQuery>;
  68737. _timeElapsedQueryEnded: boolean;
  68738. }
  68739. }
  68740. declare module BABYLON {
  68741. /** Defines the cross module used constants to avoid circular dependncies */
  68742. export class Constants {
  68743. /** Defines that alpha blending is disabled */
  68744. static readonly ALPHA_DISABLE: number;
  68745. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68746. static readonly ALPHA_ADD: number;
  68747. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68748. static readonly ALPHA_COMBINE: number;
  68749. /** Defines that alpha blending to DEST - SRC * DEST */
  68750. static readonly ALPHA_SUBTRACT: number;
  68751. /** Defines that alpha blending to SRC * DEST */
  68752. static readonly ALPHA_MULTIPLY: number;
  68753. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68754. static readonly ALPHA_MAXIMIZED: number;
  68755. /** Defines that alpha blending to SRC + DEST */
  68756. static readonly ALPHA_ONEONE: number;
  68757. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68758. static readonly ALPHA_PREMULTIPLIED: number;
  68759. /**
  68760. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68761. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68762. */
  68763. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68764. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68765. static readonly ALPHA_INTERPOLATE: number;
  68766. /**
  68767. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68768. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68769. */
  68770. static readonly ALPHA_SCREENMODE: number;
  68771. /**
  68772. * Defines that alpha blending to SRC + DST
  68773. * Alpha will be set to SRC ALPHA + DST ALPHA
  68774. */
  68775. static readonly ALPHA_ONEONE_ONEONE: number;
  68776. /**
  68777. * Defines that alpha blending to SRC * DST ALPHA + DST
  68778. * Alpha will be set to 0
  68779. */
  68780. static readonly ALPHA_ALPHATOCOLOR: number;
  68781. /**
  68782. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68783. */
  68784. static readonly ALPHA_REVERSEONEMINUS: number;
  68785. /**
  68786. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68787. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68788. */
  68789. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68790. /**
  68791. * Defines that alpha blending to SRC + DST
  68792. * Alpha will be set to SRC ALPHA
  68793. */
  68794. static readonly ALPHA_ONEONE_ONEZERO: number;
  68795. /** Defines that alpha blending equation a SUM */
  68796. static readonly ALPHA_EQUATION_ADD: number;
  68797. /** Defines that alpha blending equation a SUBSTRACTION */
  68798. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68799. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68800. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68801. /** Defines that alpha blending equation a MAX operation */
  68802. static readonly ALPHA_EQUATION_MAX: number;
  68803. /** Defines that alpha blending equation a MIN operation */
  68804. static readonly ALPHA_EQUATION_MIN: number;
  68805. /**
  68806. * Defines that alpha blending equation a DARKEN operation:
  68807. * It takes the min of the src and sums the alpha channels.
  68808. */
  68809. static readonly ALPHA_EQUATION_DARKEN: number;
  68810. /** Defines that the ressource is not delayed*/
  68811. static readonly DELAYLOADSTATE_NONE: number;
  68812. /** Defines that the ressource was successfully delay loaded */
  68813. static readonly DELAYLOADSTATE_LOADED: number;
  68814. /** Defines that the ressource is currently delay loading */
  68815. static readonly DELAYLOADSTATE_LOADING: number;
  68816. /** Defines that the ressource is delayed and has not started loading */
  68817. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68818. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68819. static readonly NEVER: number;
  68820. /** 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 */
  68821. static readonly ALWAYS: number;
  68822. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68823. static readonly LESS: number;
  68824. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68825. static readonly EQUAL: number;
  68826. /** 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 */
  68827. static readonly LEQUAL: number;
  68828. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68829. static readonly GREATER: number;
  68830. /** 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 */
  68831. static readonly GEQUAL: number;
  68832. /** 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 */
  68833. static readonly NOTEQUAL: number;
  68834. /** Passed to stencilOperation to specify that stencil value must be kept */
  68835. static readonly KEEP: number;
  68836. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68837. static readonly REPLACE: number;
  68838. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68839. static readonly INCR: number;
  68840. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68841. static readonly DECR: number;
  68842. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68843. static readonly INVERT: number;
  68844. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68845. static readonly INCR_WRAP: number;
  68846. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68847. static readonly DECR_WRAP: number;
  68848. /** Texture is not repeating outside of 0..1 UVs */
  68849. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68850. /** Texture is repeating outside of 0..1 UVs */
  68851. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68852. /** Texture is repeating and mirrored */
  68853. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68854. /** ALPHA */
  68855. static readonly TEXTUREFORMAT_ALPHA: number;
  68856. /** LUMINANCE */
  68857. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68858. /** LUMINANCE_ALPHA */
  68859. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68860. /** RGB */
  68861. static readonly TEXTUREFORMAT_RGB: number;
  68862. /** RGBA */
  68863. static readonly TEXTUREFORMAT_RGBA: number;
  68864. /** RED */
  68865. static readonly TEXTUREFORMAT_RED: number;
  68866. /** RED (2nd reference) */
  68867. static readonly TEXTUREFORMAT_R: number;
  68868. /** RG */
  68869. static readonly TEXTUREFORMAT_RG: number;
  68870. /** RED_INTEGER */
  68871. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68872. /** RED_INTEGER (2nd reference) */
  68873. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68874. /** RG_INTEGER */
  68875. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68876. /** RGB_INTEGER */
  68877. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68878. /** RGBA_INTEGER */
  68879. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68880. /** UNSIGNED_BYTE */
  68881. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68882. /** UNSIGNED_BYTE (2nd reference) */
  68883. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68884. /** FLOAT */
  68885. static readonly TEXTURETYPE_FLOAT: number;
  68886. /** HALF_FLOAT */
  68887. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68888. /** BYTE */
  68889. static readonly TEXTURETYPE_BYTE: number;
  68890. /** SHORT */
  68891. static readonly TEXTURETYPE_SHORT: number;
  68892. /** UNSIGNED_SHORT */
  68893. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68894. /** INT */
  68895. static readonly TEXTURETYPE_INT: number;
  68896. /** UNSIGNED_INT */
  68897. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68898. /** UNSIGNED_SHORT_4_4_4_4 */
  68899. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68900. /** UNSIGNED_SHORT_5_5_5_1 */
  68901. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68902. /** UNSIGNED_SHORT_5_6_5 */
  68903. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68904. /** UNSIGNED_INT_2_10_10_10_REV */
  68905. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68906. /** UNSIGNED_INT_24_8 */
  68907. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68908. /** UNSIGNED_INT_10F_11F_11F_REV */
  68909. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68910. /** UNSIGNED_INT_5_9_9_9_REV */
  68911. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68912. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68913. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68914. /** nearest is mag = nearest and min = nearest and mip = linear */
  68915. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68916. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68917. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68918. /** Trilinear is mag = linear and min = linear and mip = linear */
  68919. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68920. /** nearest is mag = nearest and min = nearest and mip = linear */
  68921. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68922. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68923. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68924. /** Trilinear is mag = linear and min = linear and mip = linear */
  68925. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68926. /** mag = nearest and min = nearest and mip = nearest */
  68927. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68928. /** mag = nearest and min = linear and mip = nearest */
  68929. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68930. /** mag = nearest and min = linear and mip = linear */
  68931. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68932. /** mag = nearest and min = linear and mip = none */
  68933. static readonly TEXTURE_NEAREST_LINEAR: number;
  68934. /** mag = nearest and min = nearest and mip = none */
  68935. static readonly TEXTURE_NEAREST_NEAREST: number;
  68936. /** mag = linear and min = nearest and mip = nearest */
  68937. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68938. /** mag = linear and min = nearest and mip = linear */
  68939. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68940. /** mag = linear and min = linear and mip = none */
  68941. static readonly TEXTURE_LINEAR_LINEAR: number;
  68942. /** mag = linear and min = nearest and mip = none */
  68943. static readonly TEXTURE_LINEAR_NEAREST: number;
  68944. /** Explicit coordinates mode */
  68945. static readonly TEXTURE_EXPLICIT_MODE: number;
  68946. /** Spherical coordinates mode */
  68947. static readonly TEXTURE_SPHERICAL_MODE: number;
  68948. /** Planar coordinates mode */
  68949. static readonly TEXTURE_PLANAR_MODE: number;
  68950. /** Cubic coordinates mode */
  68951. static readonly TEXTURE_CUBIC_MODE: number;
  68952. /** Projection coordinates mode */
  68953. static readonly TEXTURE_PROJECTION_MODE: number;
  68954. /** Skybox coordinates mode */
  68955. static readonly TEXTURE_SKYBOX_MODE: number;
  68956. /** Inverse Cubic coordinates mode */
  68957. static readonly TEXTURE_INVCUBIC_MODE: number;
  68958. /** Equirectangular coordinates mode */
  68959. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68960. /** Equirectangular Fixed coordinates mode */
  68961. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68962. /** Equirectangular Fixed Mirrored coordinates mode */
  68963. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68964. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68965. static readonly SCALEMODE_FLOOR: number;
  68966. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68967. static readonly SCALEMODE_NEAREST: number;
  68968. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68969. static readonly SCALEMODE_CEILING: number;
  68970. /**
  68971. * The dirty texture flag value
  68972. */
  68973. static readonly MATERIAL_TextureDirtyFlag: number;
  68974. /**
  68975. * The dirty light flag value
  68976. */
  68977. static readonly MATERIAL_LightDirtyFlag: number;
  68978. /**
  68979. * The dirty fresnel flag value
  68980. */
  68981. static readonly MATERIAL_FresnelDirtyFlag: number;
  68982. /**
  68983. * The dirty attribute flag value
  68984. */
  68985. static readonly MATERIAL_AttributesDirtyFlag: number;
  68986. /**
  68987. * The dirty misc flag value
  68988. */
  68989. static readonly MATERIAL_MiscDirtyFlag: number;
  68990. /**
  68991. * The all dirty flag value
  68992. */
  68993. static readonly MATERIAL_AllDirtyFlag: number;
  68994. /**
  68995. * Returns the triangle fill mode
  68996. */
  68997. static readonly MATERIAL_TriangleFillMode: number;
  68998. /**
  68999. * Returns the wireframe mode
  69000. */
  69001. static readonly MATERIAL_WireFrameFillMode: number;
  69002. /**
  69003. * Returns the point fill mode
  69004. */
  69005. static readonly MATERIAL_PointFillMode: number;
  69006. /**
  69007. * Returns the point list draw mode
  69008. */
  69009. static readonly MATERIAL_PointListDrawMode: number;
  69010. /**
  69011. * Returns the line list draw mode
  69012. */
  69013. static readonly MATERIAL_LineListDrawMode: number;
  69014. /**
  69015. * Returns the line loop draw mode
  69016. */
  69017. static readonly MATERIAL_LineLoopDrawMode: number;
  69018. /**
  69019. * Returns the line strip draw mode
  69020. */
  69021. static readonly MATERIAL_LineStripDrawMode: number;
  69022. /**
  69023. * Returns the triangle strip draw mode
  69024. */
  69025. static readonly MATERIAL_TriangleStripDrawMode: number;
  69026. /**
  69027. * Returns the triangle fan draw mode
  69028. */
  69029. static readonly MATERIAL_TriangleFanDrawMode: number;
  69030. /**
  69031. * Stores the clock-wise side orientation
  69032. */
  69033. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69034. /**
  69035. * Stores the counter clock-wise side orientation
  69036. */
  69037. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69038. /**
  69039. * Nothing
  69040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69041. */
  69042. static readonly ACTION_NothingTrigger: number;
  69043. /**
  69044. * On pick
  69045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69046. */
  69047. static readonly ACTION_OnPickTrigger: number;
  69048. /**
  69049. * On left pick
  69050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69051. */
  69052. static readonly ACTION_OnLeftPickTrigger: number;
  69053. /**
  69054. * On right pick
  69055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69056. */
  69057. static readonly ACTION_OnRightPickTrigger: number;
  69058. /**
  69059. * On center pick
  69060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69061. */
  69062. static readonly ACTION_OnCenterPickTrigger: number;
  69063. /**
  69064. * On pick down
  69065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69066. */
  69067. static readonly ACTION_OnPickDownTrigger: number;
  69068. /**
  69069. * On double pick
  69070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69071. */
  69072. static readonly ACTION_OnDoublePickTrigger: number;
  69073. /**
  69074. * On pick up
  69075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69076. */
  69077. static readonly ACTION_OnPickUpTrigger: number;
  69078. /**
  69079. * On pick out.
  69080. * This trigger will only be raised if you also declared a OnPickDown
  69081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69082. */
  69083. static readonly ACTION_OnPickOutTrigger: number;
  69084. /**
  69085. * On long press
  69086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69087. */
  69088. static readonly ACTION_OnLongPressTrigger: number;
  69089. /**
  69090. * On pointer over
  69091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69092. */
  69093. static readonly ACTION_OnPointerOverTrigger: number;
  69094. /**
  69095. * On pointer out
  69096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69097. */
  69098. static readonly ACTION_OnPointerOutTrigger: number;
  69099. /**
  69100. * On every frame
  69101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69102. */
  69103. static readonly ACTION_OnEveryFrameTrigger: number;
  69104. /**
  69105. * On intersection enter
  69106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69107. */
  69108. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69109. /**
  69110. * On intersection exit
  69111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69112. */
  69113. static readonly ACTION_OnIntersectionExitTrigger: number;
  69114. /**
  69115. * On key down
  69116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69117. */
  69118. static readonly ACTION_OnKeyDownTrigger: number;
  69119. /**
  69120. * On key up
  69121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69122. */
  69123. static readonly ACTION_OnKeyUpTrigger: number;
  69124. /**
  69125. * Billboard mode will only apply to Y axis
  69126. */
  69127. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69128. /**
  69129. * Billboard mode will apply to all axes
  69130. */
  69131. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69132. /**
  69133. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69134. */
  69135. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69136. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69137. * Test order :
  69138. * Is the bounding sphere outside the frustum ?
  69139. * If not, are the bounding box vertices outside the frustum ?
  69140. * It not, then the cullable object is in the frustum.
  69141. */
  69142. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69143. /** Culling strategy : Bounding Sphere Only.
  69144. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69145. * It's also less accurate than the standard because some not visible objects can still be selected.
  69146. * Test : is the bounding sphere outside the frustum ?
  69147. * If not, then the cullable object is in the frustum.
  69148. */
  69149. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69150. /** Culling strategy : Optimistic Inclusion.
  69151. * This in an inclusion test first, then the standard exclusion test.
  69152. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69153. * 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.
  69154. * Anyway, it's as accurate as the standard strategy.
  69155. * Test :
  69156. * Is the cullable object bounding sphere center in the frustum ?
  69157. * If not, apply the default culling strategy.
  69158. */
  69159. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69160. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69161. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69162. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69163. * 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.
  69164. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69165. * Test :
  69166. * Is the cullable object bounding sphere center in the frustum ?
  69167. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69168. */
  69169. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69170. /**
  69171. * No logging while loading
  69172. */
  69173. static readonly SCENELOADER_NO_LOGGING: number;
  69174. /**
  69175. * Minimal logging while loading
  69176. */
  69177. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69178. /**
  69179. * Summary logging while loading
  69180. */
  69181. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69182. /**
  69183. * Detailled logging while loading
  69184. */
  69185. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69186. }
  69187. }
  69188. declare module BABYLON {
  69189. /**
  69190. * This represents the required contract to create a new type of texture loader.
  69191. */
  69192. export interface IInternalTextureLoader {
  69193. /**
  69194. * Defines wether the loader supports cascade loading the different faces.
  69195. */
  69196. supportCascades: boolean;
  69197. /**
  69198. * This returns if the loader support the current file information.
  69199. * @param extension defines the file extension of the file being loaded
  69200. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69201. * @param fallback defines the fallback internal texture if any
  69202. * @param isBase64 defines whether the texture is encoded as a base64
  69203. * @param isBuffer defines whether the texture data are stored as a buffer
  69204. * @returns true if the loader can load the specified file
  69205. */
  69206. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69207. /**
  69208. * Transform the url before loading if required.
  69209. * @param rootUrl the url of the texture
  69210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69211. * @returns the transformed texture
  69212. */
  69213. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69214. /**
  69215. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69216. * @param rootUrl the url of the texture
  69217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69218. * @returns the fallback texture
  69219. */
  69220. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69221. /**
  69222. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69223. * @param data contains the texture data
  69224. * @param texture defines the BabylonJS internal texture
  69225. * @param createPolynomials will be true if polynomials have been requested
  69226. * @param onLoad defines the callback to trigger once the texture is ready
  69227. * @param onError defines the callback to trigger in case of error
  69228. */
  69229. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69230. /**
  69231. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69232. * @param data contains the texture data
  69233. * @param texture defines the BabylonJS internal texture
  69234. * @param callback defines the method to call once ready to upload
  69235. */
  69236. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69237. }
  69238. }
  69239. declare module BABYLON {
  69240. /**
  69241. * Class used to store and describe the pipeline context associated with an effect
  69242. */
  69243. export interface IPipelineContext {
  69244. /**
  69245. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69246. */
  69247. isAsync: boolean;
  69248. /**
  69249. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69250. */
  69251. isReady: boolean;
  69252. /** @hidden */
  69253. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69254. }
  69255. }
  69256. declare module BABYLON {
  69257. /**
  69258. * Class used to store gfx data (like WebGLBuffer)
  69259. */
  69260. export class DataBuffer {
  69261. /**
  69262. * Gets or sets the number of objects referencing this buffer
  69263. */
  69264. references: number;
  69265. /** Gets or sets the size of the underlying buffer */
  69266. capacity: number;
  69267. /**
  69268. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69269. */
  69270. is32Bits: boolean;
  69271. /**
  69272. * Gets the underlying buffer
  69273. */
  69274. readonly underlyingResource: any;
  69275. }
  69276. }
  69277. declare module BABYLON {
  69278. /** @hidden */
  69279. export interface IShaderProcessor {
  69280. attributeProcessor?: (attribute: string) => string;
  69281. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69282. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69283. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69284. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69285. lineProcessor?: (line: string, isFragment: boolean) => string;
  69286. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69287. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69288. }
  69289. }
  69290. declare module BABYLON {
  69291. /** @hidden */
  69292. export interface ProcessingOptions {
  69293. defines: string[];
  69294. indexParameters: any;
  69295. isFragment: boolean;
  69296. shouldUseHighPrecisionShader: boolean;
  69297. supportsUniformBuffers: boolean;
  69298. shadersRepository: string;
  69299. includesShadersStore: {
  69300. [key: string]: string;
  69301. };
  69302. processor?: IShaderProcessor;
  69303. version: string;
  69304. platformName: string;
  69305. lookForClosingBracketForUniformBuffer?: boolean;
  69306. }
  69307. }
  69308. declare module BABYLON {
  69309. /** @hidden */
  69310. export class ShaderCodeNode {
  69311. line: string;
  69312. children: ShaderCodeNode[];
  69313. additionalDefineKey?: string;
  69314. additionalDefineValue?: string;
  69315. isValid(preprocessors: {
  69316. [key: string]: string;
  69317. }): boolean;
  69318. process(preprocessors: {
  69319. [key: string]: string;
  69320. }, options: ProcessingOptions): string;
  69321. }
  69322. }
  69323. declare module BABYLON {
  69324. /** @hidden */
  69325. export class ShaderCodeCursor {
  69326. private _lines;
  69327. lineIndex: number;
  69328. readonly currentLine: string;
  69329. readonly canRead: boolean;
  69330. lines: string[];
  69331. }
  69332. }
  69333. declare module BABYLON {
  69334. /** @hidden */
  69335. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69336. process(preprocessors: {
  69337. [key: string]: string;
  69338. }, options: ProcessingOptions): string;
  69339. }
  69340. }
  69341. declare module BABYLON {
  69342. /** @hidden */
  69343. export class ShaderDefineExpression {
  69344. isTrue(preprocessors: {
  69345. [key: string]: string;
  69346. }): boolean;
  69347. }
  69348. }
  69349. declare module BABYLON {
  69350. /** @hidden */
  69351. export class ShaderCodeTestNode extends ShaderCodeNode {
  69352. testExpression: ShaderDefineExpression;
  69353. isValid(preprocessors: {
  69354. [key: string]: string;
  69355. }): boolean;
  69356. }
  69357. }
  69358. declare module BABYLON {
  69359. /** @hidden */
  69360. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69361. define: string;
  69362. not: boolean;
  69363. constructor(define: string, not?: boolean);
  69364. isTrue(preprocessors: {
  69365. [key: string]: string;
  69366. }): boolean;
  69367. }
  69368. }
  69369. declare module BABYLON {
  69370. /** @hidden */
  69371. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69372. leftOperand: ShaderDefineExpression;
  69373. rightOperand: ShaderDefineExpression;
  69374. isTrue(preprocessors: {
  69375. [key: string]: string;
  69376. }): boolean;
  69377. }
  69378. }
  69379. declare module BABYLON {
  69380. /** @hidden */
  69381. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69382. leftOperand: ShaderDefineExpression;
  69383. rightOperand: ShaderDefineExpression;
  69384. isTrue(preprocessors: {
  69385. [key: string]: string;
  69386. }): boolean;
  69387. }
  69388. }
  69389. declare module BABYLON {
  69390. /** @hidden */
  69391. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69392. define: string;
  69393. operand: string;
  69394. testValue: string;
  69395. constructor(define: string, operand: string, testValue: string);
  69396. isTrue(preprocessors: {
  69397. [key: string]: string;
  69398. }): boolean;
  69399. }
  69400. }
  69401. declare module BABYLON {
  69402. /**
  69403. * Class used to enable access to offline support
  69404. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69405. */
  69406. export interface IOfflineProvider {
  69407. /**
  69408. * Gets a boolean indicating if scene must be saved in the database
  69409. */
  69410. enableSceneOffline: boolean;
  69411. /**
  69412. * Gets a boolean indicating if textures must be saved in the database
  69413. */
  69414. enableTexturesOffline: boolean;
  69415. /**
  69416. * Open the offline support and make it available
  69417. * @param successCallback defines the callback to call on success
  69418. * @param errorCallback defines the callback to call on error
  69419. */
  69420. open(successCallback: () => void, errorCallback: () => void): void;
  69421. /**
  69422. * Loads an image from the offline support
  69423. * @param url defines the url to load from
  69424. * @param image defines the target DOM image
  69425. */
  69426. loadImage(url: string, image: HTMLImageElement): void;
  69427. /**
  69428. * Loads a file from offline support
  69429. * @param url defines the URL to load from
  69430. * @param sceneLoaded defines a callback to call on success
  69431. * @param progressCallBack defines a callback to call when progress changed
  69432. * @param errorCallback defines a callback to call on error
  69433. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69434. */
  69435. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69436. }
  69437. }
  69438. declare module BABYLON {
  69439. /**
  69440. * Class used to help managing file picking and drag'n'drop
  69441. * File Storage
  69442. */
  69443. export class FilesInputStore {
  69444. /**
  69445. * List of files ready to be loaded
  69446. */
  69447. static FilesToLoad: {
  69448. [key: string]: File;
  69449. };
  69450. }
  69451. }
  69452. declare module BABYLON {
  69453. /**
  69454. * Class used to define a retry strategy when error happens while loading assets
  69455. */
  69456. export class RetryStrategy {
  69457. /**
  69458. * Function used to defines an exponential back off strategy
  69459. * @param maxRetries defines the maximum number of retries (3 by default)
  69460. * @param baseInterval defines the interval between retries
  69461. * @returns the strategy function to use
  69462. */
  69463. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /**
  69468. * @ignore
  69469. * Application error to support additional information when loading a file
  69470. */
  69471. export abstract class BaseError extends Error {
  69472. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69473. }
  69474. }
  69475. declare module BABYLON {
  69476. /** @ignore */
  69477. export class LoadFileError extends BaseError {
  69478. request?: WebRequest;
  69479. file?: File;
  69480. /**
  69481. * Creates a new LoadFileError
  69482. * @param message defines the message of the error
  69483. * @param request defines the optional web request
  69484. * @param file defines the optional file
  69485. */
  69486. constructor(message: string, object?: WebRequest | File);
  69487. }
  69488. /** @ignore */
  69489. export class RequestFileError extends BaseError {
  69490. request: WebRequest;
  69491. /**
  69492. * Creates a new LoadFileError
  69493. * @param message defines the message of the error
  69494. * @param request defines the optional web request
  69495. */
  69496. constructor(message: string, request: WebRequest);
  69497. }
  69498. /** @ignore */
  69499. export class ReadFileError extends BaseError {
  69500. file: File;
  69501. /**
  69502. * Creates a new ReadFileError
  69503. * @param message defines the message of the error
  69504. * @param file defines the optional file
  69505. */
  69506. constructor(message: string, file: File);
  69507. }
  69508. /**
  69509. * @hidden
  69510. */
  69511. export class FileTools {
  69512. /**
  69513. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69514. */
  69515. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69516. /**
  69517. * Gets or sets the base URL to use to load assets
  69518. */
  69519. static BaseUrl: string;
  69520. /**
  69521. * Default behaviour for cors in the application.
  69522. * It can be a string if the expected behavior is identical in the entire app.
  69523. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69524. */
  69525. static CorsBehavior: string | ((url: string | string[]) => string);
  69526. /**
  69527. * Gets or sets a function used to pre-process url before using them to load assets
  69528. */
  69529. static PreprocessUrl: (url: string) => string;
  69530. /**
  69531. * Removes unwanted characters from an url
  69532. * @param url defines the url to clean
  69533. * @returns the cleaned url
  69534. */
  69535. private static _CleanUrl;
  69536. /**
  69537. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69538. * @param url define the url we are trying
  69539. * @param element define the dom element where to configure the cors policy
  69540. */
  69541. static SetCorsBehavior(url: string | string[], element: {
  69542. crossOrigin: string | null;
  69543. }): void;
  69544. /**
  69545. * Loads an image as an HTMLImageElement.
  69546. * @param input url string, ArrayBuffer, or Blob to load
  69547. * @param onLoad callback called when the image successfully loads
  69548. * @param onError callback called when the image fails to load
  69549. * @param offlineProvider offline provider for caching
  69550. * @param mimeType optional mime type
  69551. * @returns the HTMLImageElement of the loaded image
  69552. */
  69553. 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>;
  69554. /**
  69555. * Reads a file from a File object
  69556. * @param file defines the file to load
  69557. * @param onSuccess defines the callback to call when data is loaded
  69558. * @param onProgress defines the callback to call during loading process
  69559. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69560. * @param onError defines the callback to call when an error occurs
  69561. * @returns a file request object
  69562. */
  69563. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69564. /**
  69565. * Loads a file from a url
  69566. * @param url url to load
  69567. * @param onSuccess callback called when the file successfully loads
  69568. * @param onProgress callback called while file is loading (if the server supports this mode)
  69569. * @param offlineProvider defines the offline provider for caching
  69570. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69571. * @param onError callback called when the file fails to load
  69572. * @returns a file request object
  69573. */
  69574. 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;
  69575. /**
  69576. * Loads a file
  69577. * @param url url to load
  69578. * @param onSuccess callback called when the file successfully loads
  69579. * @param onProgress callback called while file is loading (if the server supports this mode)
  69580. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69581. * @param onError callback called when the file fails to load
  69582. * @param onOpened callback called when the web request is opened
  69583. * @returns a file request object
  69584. */
  69585. 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;
  69586. /**
  69587. * Checks if the loaded document was accessed via `file:`-Protocol.
  69588. * @returns boolean
  69589. */
  69590. static IsFileURL(): boolean;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /** @hidden */
  69595. export class ShaderProcessor {
  69596. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69597. private static _ProcessPrecision;
  69598. private static _ExtractOperation;
  69599. private static _BuildSubExpression;
  69600. private static _BuildExpression;
  69601. private static _MoveCursorWithinIf;
  69602. private static _MoveCursor;
  69603. private static _EvaluatePreProcessors;
  69604. private static _PreparePreProcessors;
  69605. private static _ProcessShaderConversion;
  69606. private static _ProcessIncludes;
  69607. }
  69608. }
  69609. declare module BABYLON {
  69610. /**
  69611. * @hidden
  69612. */
  69613. export interface IColor4Like {
  69614. r: float;
  69615. g: float;
  69616. b: float;
  69617. a: float;
  69618. }
  69619. /**
  69620. * @hidden
  69621. */
  69622. export interface IColor3Like {
  69623. r: float;
  69624. g: float;
  69625. b: float;
  69626. }
  69627. /**
  69628. * @hidden
  69629. */
  69630. export interface IVector4Like {
  69631. x: float;
  69632. y: float;
  69633. z: float;
  69634. w: float;
  69635. }
  69636. /**
  69637. * @hidden
  69638. */
  69639. export interface IVector3Like {
  69640. x: float;
  69641. y: float;
  69642. z: float;
  69643. }
  69644. /**
  69645. * @hidden
  69646. */
  69647. export interface IVector2Like {
  69648. x: float;
  69649. y: float;
  69650. }
  69651. /**
  69652. * @hidden
  69653. */
  69654. export interface IMatrixLike {
  69655. toArray(): DeepImmutable<Float32Array>;
  69656. updateFlag: int;
  69657. }
  69658. /**
  69659. * @hidden
  69660. */
  69661. export interface IViewportLike {
  69662. x: float;
  69663. y: float;
  69664. width: float;
  69665. height: float;
  69666. }
  69667. /**
  69668. * @hidden
  69669. */
  69670. export interface IPlaneLike {
  69671. normal: IVector3Like;
  69672. d: float;
  69673. normalize(): void;
  69674. }
  69675. }
  69676. declare module BABYLON {
  69677. /**
  69678. * Interface used to define common properties for effect fallbacks
  69679. */
  69680. export interface IEffectFallbacks {
  69681. /**
  69682. * Removes the defines that should be removed when falling back.
  69683. * @param currentDefines defines the current define statements for the shader.
  69684. * @param effect defines the current effect we try to compile
  69685. * @returns The resulting defines with defines of the current rank removed.
  69686. */
  69687. reduce(currentDefines: string, effect: Effect): string;
  69688. /**
  69689. * Removes the fallback from the bound mesh.
  69690. */
  69691. unBindMesh(): void;
  69692. /**
  69693. * Checks to see if more fallbacks are still availible.
  69694. */
  69695. hasMoreFallbacks: boolean;
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * Class used to evalaute queries containing `and` and `or` operators
  69701. */
  69702. export class AndOrNotEvaluator {
  69703. /**
  69704. * Evaluate a query
  69705. * @param query defines the query to evaluate
  69706. * @param evaluateCallback defines the callback used to filter result
  69707. * @returns true if the query matches
  69708. */
  69709. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69710. private static _HandleParenthesisContent;
  69711. private static _SimplifyNegation;
  69712. }
  69713. }
  69714. declare module BABYLON {
  69715. /**
  69716. * Class used to store custom tags
  69717. */
  69718. export class Tags {
  69719. /**
  69720. * Adds support for tags on the given object
  69721. * @param obj defines the object to use
  69722. */
  69723. static EnableFor(obj: any): void;
  69724. /**
  69725. * Removes tags support
  69726. * @param obj defines the object to use
  69727. */
  69728. static DisableFor(obj: any): void;
  69729. /**
  69730. * Gets a boolean indicating if the given object has tags
  69731. * @param obj defines the object to use
  69732. * @returns a boolean
  69733. */
  69734. static HasTags(obj: any): boolean;
  69735. /**
  69736. * Gets the tags available on a given object
  69737. * @param obj defines the object to use
  69738. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69739. * @returns the tags
  69740. */
  69741. static GetTags(obj: any, asString?: boolean): any;
  69742. /**
  69743. * Adds tags to an object
  69744. * @param obj defines the object to use
  69745. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69746. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69747. */
  69748. static AddTagsTo(obj: any, tagsString: string): void;
  69749. /**
  69750. * @hidden
  69751. */
  69752. static _AddTagTo(obj: any, tag: string): void;
  69753. /**
  69754. * Removes specific tags from a specific object
  69755. * @param obj defines the object to use
  69756. * @param tagsString defines the tags to remove
  69757. */
  69758. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69759. /**
  69760. * @hidden
  69761. */
  69762. static _RemoveTagFrom(obj: any, tag: string): void;
  69763. /**
  69764. * Defines if tags hosted on an object match a given query
  69765. * @param obj defines the object to use
  69766. * @param tagsQuery defines the tag query
  69767. * @returns a boolean
  69768. */
  69769. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69770. }
  69771. }
  69772. declare module BABYLON {
  69773. /**
  69774. * Scalar computation library
  69775. */
  69776. export class Scalar {
  69777. /**
  69778. * Two pi constants convenient for computation.
  69779. */
  69780. static TwoPi: number;
  69781. /**
  69782. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69783. * @param a number
  69784. * @param b number
  69785. * @param epsilon (default = 1.401298E-45)
  69786. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69787. */
  69788. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69789. /**
  69790. * Returns a string : the upper case translation of the number i to hexadecimal.
  69791. * @param i number
  69792. * @returns the upper case translation of the number i to hexadecimal.
  69793. */
  69794. static ToHex(i: number): string;
  69795. /**
  69796. * Returns -1 if value is negative and +1 is value is positive.
  69797. * @param value the value
  69798. * @returns the value itself if it's equal to zero.
  69799. */
  69800. static Sign(value: number): number;
  69801. /**
  69802. * Returns the value itself if it's between min and max.
  69803. * Returns min if the value is lower than min.
  69804. * Returns max if the value is greater than max.
  69805. * @param value the value to clmap
  69806. * @param min the min value to clamp to (default: 0)
  69807. * @param max the max value to clamp to (default: 1)
  69808. * @returns the clamped value
  69809. */
  69810. static Clamp(value: number, min?: number, max?: number): number;
  69811. /**
  69812. * the log2 of value.
  69813. * @param value the value to compute log2 of
  69814. * @returns the log2 of value.
  69815. */
  69816. static Log2(value: number): number;
  69817. /**
  69818. * Loops the value, so that it is never larger than length and never smaller than 0.
  69819. *
  69820. * This is similar to the modulo operator but it works with floating point numbers.
  69821. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69822. * With t = 5 and length = 2.5, the result would be 0.0.
  69823. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69824. * @param value the value
  69825. * @param length the length
  69826. * @returns the looped value
  69827. */
  69828. static Repeat(value: number, length: number): number;
  69829. /**
  69830. * Normalize the value between 0.0 and 1.0 using min and max values
  69831. * @param value value to normalize
  69832. * @param min max to normalize between
  69833. * @param max min to normalize between
  69834. * @returns the normalized value
  69835. */
  69836. static Normalize(value: number, min: number, max: number): number;
  69837. /**
  69838. * Denormalize the value from 0.0 and 1.0 using min and max values
  69839. * @param normalized value to denormalize
  69840. * @param min max to denormalize between
  69841. * @param max min to denormalize between
  69842. * @returns the denormalized value
  69843. */
  69844. static Denormalize(normalized: number, min: number, max: number): number;
  69845. /**
  69846. * Calculates the shortest difference between two given angles given in degrees.
  69847. * @param current current angle in degrees
  69848. * @param target target angle in degrees
  69849. * @returns the delta
  69850. */
  69851. static DeltaAngle(current: number, target: number): number;
  69852. /**
  69853. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69854. * @param tx value
  69855. * @param length length
  69856. * @returns The returned value will move back and forth between 0 and length
  69857. */
  69858. static PingPong(tx: number, length: number): number;
  69859. /**
  69860. * Interpolates between min and max with smoothing at the limits.
  69861. *
  69862. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69863. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69864. * @param from from
  69865. * @param to to
  69866. * @param tx value
  69867. * @returns the smooth stepped value
  69868. */
  69869. static SmoothStep(from: number, to: number, tx: number): number;
  69870. /**
  69871. * Moves a value current towards target.
  69872. *
  69873. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69874. * Negative values of maxDelta pushes the value away from target.
  69875. * @param current current value
  69876. * @param target target value
  69877. * @param maxDelta max distance to move
  69878. * @returns resulting value
  69879. */
  69880. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69881. /**
  69882. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69883. *
  69884. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69885. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69886. * @param current current value
  69887. * @param target target value
  69888. * @param maxDelta max distance to move
  69889. * @returns resulting angle
  69890. */
  69891. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69892. /**
  69893. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69894. * @param start start value
  69895. * @param end target value
  69896. * @param amount amount to lerp between
  69897. * @returns the lerped value
  69898. */
  69899. static Lerp(start: number, end: number, amount: number): number;
  69900. /**
  69901. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69902. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69903. * @param start start value
  69904. * @param end target value
  69905. * @param amount amount to lerp between
  69906. * @returns the lerped value
  69907. */
  69908. static LerpAngle(start: number, end: number, amount: number): number;
  69909. /**
  69910. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69911. * @param a start value
  69912. * @param b target value
  69913. * @param value value between a and b
  69914. * @returns the inverseLerp value
  69915. */
  69916. static InverseLerp(a: number, b: number, value: number): number;
  69917. /**
  69918. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69919. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69920. * @param value1 spline value
  69921. * @param tangent1 spline value
  69922. * @param value2 spline value
  69923. * @param tangent2 spline value
  69924. * @param amount input value
  69925. * @returns hermite result
  69926. */
  69927. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69928. /**
  69929. * Returns a random float number between and min and max values
  69930. * @param min min value of random
  69931. * @param max max value of random
  69932. * @returns random value
  69933. */
  69934. static RandomRange(min: number, max: number): number;
  69935. /**
  69936. * This function returns percentage of a number in a given range.
  69937. *
  69938. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69939. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69940. * @param number to convert to percentage
  69941. * @param min min range
  69942. * @param max max range
  69943. * @returns the percentage
  69944. */
  69945. static RangeToPercent(number: number, min: number, max: number): number;
  69946. /**
  69947. * This function returns number that corresponds to the percentage in a given range.
  69948. *
  69949. * PercentToRange(0.34,0,100) will return 34.
  69950. * @param percent to convert to number
  69951. * @param min min range
  69952. * @param max max range
  69953. * @returns the number
  69954. */
  69955. static PercentToRange(percent: number, min: number, max: number): number;
  69956. /**
  69957. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69958. * @param angle The angle to normalize in radian.
  69959. * @return The converted angle.
  69960. */
  69961. static NormalizeRadians(angle: number): number;
  69962. }
  69963. }
  69964. declare module BABYLON {
  69965. /**
  69966. * Constant used to convert a value to gamma space
  69967. * @ignorenaming
  69968. */
  69969. export const ToGammaSpace: number;
  69970. /**
  69971. * Constant used to convert a value to linear space
  69972. * @ignorenaming
  69973. */
  69974. export const ToLinearSpace = 2.2;
  69975. /**
  69976. * Constant used to define the minimal number value in Babylon.js
  69977. * @ignorenaming
  69978. */
  69979. let Epsilon: number;
  69980. }
  69981. declare module BABYLON {
  69982. /**
  69983. * Class used to represent a viewport on screen
  69984. */
  69985. export class Viewport {
  69986. /** viewport left coordinate */
  69987. x: number;
  69988. /** viewport top coordinate */
  69989. y: number;
  69990. /**viewport width */
  69991. width: number;
  69992. /** viewport height */
  69993. height: number;
  69994. /**
  69995. * Creates a Viewport object located at (x, y) and sized (width, height)
  69996. * @param x defines viewport left coordinate
  69997. * @param y defines viewport top coordinate
  69998. * @param width defines the viewport width
  69999. * @param height defines the viewport height
  70000. */
  70001. constructor(
  70002. /** viewport left coordinate */
  70003. x: number,
  70004. /** viewport top coordinate */
  70005. y: number,
  70006. /**viewport width */
  70007. width: number,
  70008. /** viewport height */
  70009. height: number);
  70010. /**
  70011. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70012. * @param renderWidth defines the rendering width
  70013. * @param renderHeight defines the rendering height
  70014. * @returns a new Viewport
  70015. */
  70016. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70017. /**
  70018. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70019. * @param renderWidth defines the rendering width
  70020. * @param renderHeight defines the rendering height
  70021. * @param ref defines the target viewport
  70022. * @returns the current viewport
  70023. */
  70024. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70025. /**
  70026. * Returns a new Viewport copied from the current one
  70027. * @returns a new Viewport
  70028. */
  70029. clone(): Viewport;
  70030. }
  70031. }
  70032. declare module BABYLON {
  70033. /**
  70034. * Class containing a set of static utilities functions for arrays.
  70035. */
  70036. export class ArrayTools {
  70037. /**
  70038. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70039. * @param size the number of element to construct and put in the array
  70040. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70041. * @returns a new array filled with new objects
  70042. */
  70043. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70044. }
  70045. }
  70046. declare module BABYLON {
  70047. /**
  70048. * Class representing a vector containing 2 coordinates
  70049. */
  70050. export class Vector2 {
  70051. /** defines the first coordinate */
  70052. x: number;
  70053. /** defines the second coordinate */
  70054. y: number;
  70055. /**
  70056. * Creates a new Vector2 from the given x and y coordinates
  70057. * @param x defines the first coordinate
  70058. * @param y defines the second coordinate
  70059. */
  70060. constructor(
  70061. /** defines the first coordinate */
  70062. x?: number,
  70063. /** defines the second coordinate */
  70064. y?: number);
  70065. /**
  70066. * Gets a string with the Vector2 coordinates
  70067. * @returns a string with the Vector2 coordinates
  70068. */
  70069. toString(): string;
  70070. /**
  70071. * Gets class name
  70072. * @returns the string "Vector2"
  70073. */
  70074. getClassName(): string;
  70075. /**
  70076. * Gets current vector hash code
  70077. * @returns the Vector2 hash code as a number
  70078. */
  70079. getHashCode(): number;
  70080. /**
  70081. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70082. * @param array defines the source array
  70083. * @param index defines the offset in source array
  70084. * @returns the current Vector2
  70085. */
  70086. toArray(array: FloatArray, index?: number): Vector2;
  70087. /**
  70088. * Copy the current vector to an array
  70089. * @returns a new array with 2 elements: the Vector2 coordinates.
  70090. */
  70091. asArray(): number[];
  70092. /**
  70093. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70094. * @param source defines the source Vector2
  70095. * @returns the current updated Vector2
  70096. */
  70097. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70098. /**
  70099. * Sets the Vector2 coordinates with the given floats
  70100. * @param x defines the first coordinate
  70101. * @param y defines the second coordinate
  70102. * @returns the current updated Vector2
  70103. */
  70104. copyFromFloats(x: number, y: number): Vector2;
  70105. /**
  70106. * Sets the Vector2 coordinates with the given floats
  70107. * @param x defines the first coordinate
  70108. * @param y defines the second coordinate
  70109. * @returns the current updated Vector2
  70110. */
  70111. set(x: number, y: number): Vector2;
  70112. /**
  70113. * Add another vector with the current one
  70114. * @param otherVector defines the other vector
  70115. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70116. */
  70117. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70118. /**
  70119. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70120. * @param otherVector defines the other vector
  70121. * @param result defines the target vector
  70122. * @returns the unmodified current Vector2
  70123. */
  70124. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70125. /**
  70126. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70127. * @param otherVector defines the other vector
  70128. * @returns the current updated Vector2
  70129. */
  70130. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70131. /**
  70132. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70133. * @param otherVector defines the other vector
  70134. * @returns a new Vector2
  70135. */
  70136. addVector3(otherVector: Vector3): Vector2;
  70137. /**
  70138. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70139. * @param otherVector defines the other vector
  70140. * @returns a new Vector2
  70141. */
  70142. subtract(otherVector: Vector2): Vector2;
  70143. /**
  70144. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70145. * @param otherVector defines the other vector
  70146. * @param result defines the target vector
  70147. * @returns the unmodified current Vector2
  70148. */
  70149. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70150. /**
  70151. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70152. * @param otherVector defines the other vector
  70153. * @returns the current updated Vector2
  70154. */
  70155. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70156. /**
  70157. * Multiplies in place the current Vector2 coordinates by the given ones
  70158. * @param otherVector defines the other vector
  70159. * @returns the current updated Vector2
  70160. */
  70161. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70162. /**
  70163. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70164. * @param otherVector defines the other vector
  70165. * @returns a new Vector2
  70166. */
  70167. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70168. /**
  70169. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70170. * @param otherVector defines the other vector
  70171. * @param result defines the target vector
  70172. * @returns the unmodified current Vector2
  70173. */
  70174. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70175. /**
  70176. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70177. * @param x defines the first coordinate
  70178. * @param y defines the second coordinate
  70179. * @returns a new Vector2
  70180. */
  70181. multiplyByFloats(x: number, y: number): Vector2;
  70182. /**
  70183. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70184. * @param otherVector defines the other vector
  70185. * @returns a new Vector2
  70186. */
  70187. divide(otherVector: Vector2): Vector2;
  70188. /**
  70189. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70190. * @param otherVector defines the other vector
  70191. * @param result defines the target vector
  70192. * @returns the unmodified current Vector2
  70193. */
  70194. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70195. /**
  70196. * Divides the current Vector2 coordinates by the given ones
  70197. * @param otherVector defines the other vector
  70198. * @returns the current updated Vector2
  70199. */
  70200. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70201. /**
  70202. * Gets a new Vector2 with current Vector2 negated coordinates
  70203. * @returns a new Vector2
  70204. */
  70205. negate(): Vector2;
  70206. /**
  70207. * Multiply the Vector2 coordinates by scale
  70208. * @param scale defines the scaling factor
  70209. * @returns the current updated Vector2
  70210. */
  70211. scaleInPlace(scale: number): Vector2;
  70212. /**
  70213. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70214. * @param scale defines the scaling factor
  70215. * @returns a new Vector2
  70216. */
  70217. scale(scale: number): Vector2;
  70218. /**
  70219. * Scale the current Vector2 values by a factor to a given Vector2
  70220. * @param scale defines the scale factor
  70221. * @param result defines the Vector2 object where to store the result
  70222. * @returns the unmodified current Vector2
  70223. */
  70224. scaleToRef(scale: number, result: Vector2): Vector2;
  70225. /**
  70226. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70227. * @param scale defines the scale factor
  70228. * @param result defines the Vector2 object where to store the result
  70229. * @returns the unmodified current Vector2
  70230. */
  70231. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70232. /**
  70233. * Gets a boolean if two vectors are equals
  70234. * @param otherVector defines the other vector
  70235. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70236. */
  70237. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70238. /**
  70239. * Gets a boolean if two vectors are equals (using an epsilon value)
  70240. * @param otherVector defines the other vector
  70241. * @param epsilon defines the minimal distance to consider equality
  70242. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70243. */
  70244. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70245. /**
  70246. * Gets a new Vector2 from current Vector2 floored values
  70247. * @returns a new Vector2
  70248. */
  70249. floor(): Vector2;
  70250. /**
  70251. * Gets a new Vector2 from current Vector2 floored values
  70252. * @returns a new Vector2
  70253. */
  70254. fract(): Vector2;
  70255. /**
  70256. * Gets the length of the vector
  70257. * @returns the vector length (float)
  70258. */
  70259. length(): number;
  70260. /**
  70261. * Gets the vector squared length
  70262. * @returns the vector squared length (float)
  70263. */
  70264. lengthSquared(): number;
  70265. /**
  70266. * Normalize the vector
  70267. * @returns the current updated Vector2
  70268. */
  70269. normalize(): Vector2;
  70270. /**
  70271. * Gets a new Vector2 copied from the Vector2
  70272. * @returns a new Vector2
  70273. */
  70274. clone(): Vector2;
  70275. /**
  70276. * Gets a new Vector2(0, 0)
  70277. * @returns a new Vector2
  70278. */
  70279. static Zero(): Vector2;
  70280. /**
  70281. * Gets a new Vector2(1, 1)
  70282. * @returns a new Vector2
  70283. */
  70284. static One(): Vector2;
  70285. /**
  70286. * Gets a new Vector2 set from the given index element of the given array
  70287. * @param array defines the data source
  70288. * @param offset defines the offset in the data source
  70289. * @returns a new Vector2
  70290. */
  70291. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70292. /**
  70293. * Sets "result" from the given index element of the given array
  70294. * @param array defines the data source
  70295. * @param offset defines the offset in the data source
  70296. * @param result defines the target vector
  70297. */
  70298. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70299. /**
  70300. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70301. * @param value1 defines 1st point of control
  70302. * @param value2 defines 2nd point of control
  70303. * @param value3 defines 3rd point of control
  70304. * @param value4 defines 4th point of control
  70305. * @param amount defines the interpolation factor
  70306. * @returns a new Vector2
  70307. */
  70308. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70309. /**
  70310. * 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".
  70311. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70312. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70313. * @param value defines the value to clamp
  70314. * @param min defines the lower limit
  70315. * @param max defines the upper limit
  70316. * @returns a new Vector2
  70317. */
  70318. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70319. /**
  70320. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70321. * @param value1 defines the 1st control point
  70322. * @param tangent1 defines the outgoing tangent
  70323. * @param value2 defines the 2nd control point
  70324. * @param tangent2 defines the incoming tangent
  70325. * @param amount defines the interpolation factor
  70326. * @returns a new Vector2
  70327. */
  70328. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70329. /**
  70330. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70331. * @param start defines the start vector
  70332. * @param end defines the end vector
  70333. * @param amount defines the interpolation factor
  70334. * @returns a new Vector2
  70335. */
  70336. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70337. /**
  70338. * Gets the dot product of the vector "left" and the vector "right"
  70339. * @param left defines first vector
  70340. * @param right defines second vector
  70341. * @returns the dot product (float)
  70342. */
  70343. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70344. /**
  70345. * Returns a new Vector2 equal to the normalized given vector
  70346. * @param vector defines the vector to normalize
  70347. * @returns a new Vector2
  70348. */
  70349. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70350. /**
  70351. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70352. * @param left defines 1st vector
  70353. * @param right defines 2nd vector
  70354. * @returns a new Vector2
  70355. */
  70356. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70357. /**
  70358. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70359. * @param left defines 1st vector
  70360. * @param right defines 2nd vector
  70361. * @returns a new Vector2
  70362. */
  70363. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70364. /**
  70365. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70366. * @param vector defines the vector to transform
  70367. * @param transformation defines the matrix to apply
  70368. * @returns a new Vector2
  70369. */
  70370. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70371. /**
  70372. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70373. * @param vector defines the vector to transform
  70374. * @param transformation defines the matrix to apply
  70375. * @param result defines the target vector
  70376. */
  70377. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70378. /**
  70379. * Determines if a given vector is included in a triangle
  70380. * @param p defines the vector to test
  70381. * @param p0 defines 1st triangle point
  70382. * @param p1 defines 2nd triangle point
  70383. * @param p2 defines 3rd triangle point
  70384. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70385. */
  70386. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70387. /**
  70388. * Gets the distance between the vectors "value1" and "value2"
  70389. * @param value1 defines first vector
  70390. * @param value2 defines second vector
  70391. * @returns the distance between vectors
  70392. */
  70393. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70394. /**
  70395. * Returns the squared distance between the vectors "value1" and "value2"
  70396. * @param value1 defines first vector
  70397. * @param value2 defines second vector
  70398. * @returns the squared distance between vectors
  70399. */
  70400. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70401. /**
  70402. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70403. * @param value1 defines first vector
  70404. * @param value2 defines second vector
  70405. * @returns a new Vector2
  70406. */
  70407. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70408. /**
  70409. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70410. * @param p defines the middle point
  70411. * @param segA defines one point of the segment
  70412. * @param segB defines the other point of the segment
  70413. * @returns the shortest distance
  70414. */
  70415. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70416. }
  70417. /**
  70418. * Classed used to store (x,y,z) vector representation
  70419. * A Vector3 is the main object used in 3D geometry
  70420. * It can represent etiher the coordinates of a point the space, either a direction
  70421. * Reminder: js uses a left handed forward facing system
  70422. */
  70423. export class Vector3 {
  70424. /**
  70425. * Defines the first coordinates (on X axis)
  70426. */
  70427. x: number;
  70428. /**
  70429. * Defines the second coordinates (on Y axis)
  70430. */
  70431. y: number;
  70432. /**
  70433. * Defines the third coordinates (on Z axis)
  70434. */
  70435. z: number;
  70436. private static _UpReadOnly;
  70437. private static _ZeroReadOnly;
  70438. /**
  70439. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70440. * @param x defines the first coordinates (on X axis)
  70441. * @param y defines the second coordinates (on Y axis)
  70442. * @param z defines the third coordinates (on Z axis)
  70443. */
  70444. constructor(
  70445. /**
  70446. * Defines the first coordinates (on X axis)
  70447. */
  70448. x?: number,
  70449. /**
  70450. * Defines the second coordinates (on Y axis)
  70451. */
  70452. y?: number,
  70453. /**
  70454. * Defines the third coordinates (on Z axis)
  70455. */
  70456. z?: number);
  70457. /**
  70458. * Creates a string representation of the Vector3
  70459. * @returns a string with the Vector3 coordinates.
  70460. */
  70461. toString(): string;
  70462. /**
  70463. * Gets the class name
  70464. * @returns the string "Vector3"
  70465. */
  70466. getClassName(): string;
  70467. /**
  70468. * Creates the Vector3 hash code
  70469. * @returns a number which tends to be unique between Vector3 instances
  70470. */
  70471. getHashCode(): number;
  70472. /**
  70473. * Creates an array containing three elements : the coordinates of the Vector3
  70474. * @returns a new array of numbers
  70475. */
  70476. asArray(): number[];
  70477. /**
  70478. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70479. * @param array defines the destination array
  70480. * @param index defines the offset in the destination array
  70481. * @returns the current Vector3
  70482. */
  70483. toArray(array: FloatArray, index?: number): Vector3;
  70484. /**
  70485. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70486. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70487. */
  70488. toQuaternion(): Quaternion;
  70489. /**
  70490. * Adds the given vector to the current Vector3
  70491. * @param otherVector defines the second operand
  70492. * @returns the current updated Vector3
  70493. */
  70494. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70495. /**
  70496. * Adds the given coordinates to the current Vector3
  70497. * @param x defines the x coordinate of the operand
  70498. * @param y defines the y coordinate of the operand
  70499. * @param z defines the z coordinate of the operand
  70500. * @returns the current updated Vector3
  70501. */
  70502. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70503. /**
  70504. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70505. * @param otherVector defines the second operand
  70506. * @returns the resulting Vector3
  70507. */
  70508. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70509. /**
  70510. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70511. * @param otherVector defines the second operand
  70512. * @param result defines the Vector3 object where to store the result
  70513. * @returns the current Vector3
  70514. */
  70515. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70516. /**
  70517. * Subtract the given vector from the current Vector3
  70518. * @param otherVector defines the second operand
  70519. * @returns the current updated Vector3
  70520. */
  70521. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70522. /**
  70523. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70524. * @param otherVector defines the second operand
  70525. * @returns the resulting Vector3
  70526. */
  70527. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70528. /**
  70529. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70530. * @param otherVector defines the second operand
  70531. * @param result defines the Vector3 object where to store the result
  70532. * @returns the current Vector3
  70533. */
  70534. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70535. /**
  70536. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70537. * @param x defines the x coordinate of the operand
  70538. * @param y defines the y coordinate of the operand
  70539. * @param z defines the z coordinate of the operand
  70540. * @returns the resulting Vector3
  70541. */
  70542. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70543. /**
  70544. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70545. * @param x defines the x coordinate of the operand
  70546. * @param y defines the y coordinate of the operand
  70547. * @param z defines the z coordinate of the operand
  70548. * @param result defines the Vector3 object where to store the result
  70549. * @returns the current Vector3
  70550. */
  70551. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70552. /**
  70553. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70554. * @returns a new Vector3
  70555. */
  70556. negate(): Vector3;
  70557. /**
  70558. * Multiplies the Vector3 coordinates by the float "scale"
  70559. * @param scale defines the multiplier factor
  70560. * @returns the current updated Vector3
  70561. */
  70562. scaleInPlace(scale: number): Vector3;
  70563. /**
  70564. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70565. * @param scale defines the multiplier factor
  70566. * @returns a new Vector3
  70567. */
  70568. scale(scale: number): Vector3;
  70569. /**
  70570. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70571. * @param scale defines the multiplier factor
  70572. * @param result defines the Vector3 object where to store the result
  70573. * @returns the current Vector3
  70574. */
  70575. scaleToRef(scale: number, result: Vector3): Vector3;
  70576. /**
  70577. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70578. * @param scale defines the scale factor
  70579. * @param result defines the Vector3 object where to store the result
  70580. * @returns the unmodified current Vector3
  70581. */
  70582. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70583. /**
  70584. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70585. * @param otherVector defines the second operand
  70586. * @returns true if both vectors are equals
  70587. */
  70588. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70589. /**
  70590. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70591. * @param otherVector defines the second operand
  70592. * @param epsilon defines the minimal distance to define values as equals
  70593. * @returns true if both vectors are distant less than epsilon
  70594. */
  70595. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70596. /**
  70597. * Returns true if the current Vector3 coordinates equals the given floats
  70598. * @param x defines the x coordinate of the operand
  70599. * @param y defines the y coordinate of the operand
  70600. * @param z defines the z coordinate of the operand
  70601. * @returns true if both vectors are equals
  70602. */
  70603. equalsToFloats(x: number, y: number, z: number): boolean;
  70604. /**
  70605. * Multiplies the current Vector3 coordinates by the given ones
  70606. * @param otherVector defines the second operand
  70607. * @returns the current updated Vector3
  70608. */
  70609. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70610. /**
  70611. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70612. * @param otherVector defines the second operand
  70613. * @returns the new Vector3
  70614. */
  70615. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70616. /**
  70617. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70618. * @param otherVector defines the second operand
  70619. * @param result defines the Vector3 object where to store the result
  70620. * @returns the current Vector3
  70621. */
  70622. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70623. /**
  70624. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70625. * @param x defines the x coordinate of the operand
  70626. * @param y defines the y coordinate of the operand
  70627. * @param z defines the z coordinate of the operand
  70628. * @returns the new Vector3
  70629. */
  70630. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70631. /**
  70632. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70633. * @param otherVector defines the second operand
  70634. * @returns the new Vector3
  70635. */
  70636. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70637. /**
  70638. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70639. * @param otherVector defines the second operand
  70640. * @param result defines the Vector3 object where to store the result
  70641. * @returns the current Vector3
  70642. */
  70643. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70644. /**
  70645. * Divides the current Vector3 coordinates by the given ones.
  70646. * @param otherVector defines the second operand
  70647. * @returns the current updated Vector3
  70648. */
  70649. divideInPlace(otherVector: Vector3): Vector3;
  70650. /**
  70651. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70652. * @param other defines the second operand
  70653. * @returns the current updated Vector3
  70654. */
  70655. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70656. /**
  70657. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70658. * @param other defines the second operand
  70659. * @returns the current updated Vector3
  70660. */
  70661. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70662. /**
  70663. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70664. * @param x defines the x coordinate of the operand
  70665. * @param y defines the y coordinate of the operand
  70666. * @param z defines the z coordinate of the operand
  70667. * @returns the current updated Vector3
  70668. */
  70669. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70670. /**
  70671. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70672. * @param x defines the x coordinate of the operand
  70673. * @param y defines the y coordinate of the operand
  70674. * @param z defines the z coordinate of the operand
  70675. * @returns the current updated Vector3
  70676. */
  70677. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70678. /**
  70679. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70680. * Check if is non uniform within a certain amount of decimal places to account for this
  70681. * @param epsilon the amount the values can differ
  70682. * @returns if the the vector is non uniform to a certain number of decimal places
  70683. */
  70684. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70685. /**
  70686. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70687. */
  70688. readonly isNonUniform: boolean;
  70689. /**
  70690. * Gets a new Vector3 from current Vector3 floored values
  70691. * @returns a new Vector3
  70692. */
  70693. floor(): Vector3;
  70694. /**
  70695. * Gets a new Vector3 from current Vector3 floored values
  70696. * @returns a new Vector3
  70697. */
  70698. fract(): Vector3;
  70699. /**
  70700. * Gets the length of the Vector3
  70701. * @returns the length of the Vector3
  70702. */
  70703. length(): number;
  70704. /**
  70705. * Gets the squared length of the Vector3
  70706. * @returns squared length of the Vector3
  70707. */
  70708. lengthSquared(): number;
  70709. /**
  70710. * Normalize the current Vector3.
  70711. * Please note that this is an in place operation.
  70712. * @returns the current updated Vector3
  70713. */
  70714. normalize(): Vector3;
  70715. /**
  70716. * Reorders the x y z properties of the vector in place
  70717. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70718. * @returns the current updated vector
  70719. */
  70720. reorderInPlace(order: string): this;
  70721. /**
  70722. * Rotates the vector around 0,0,0 by a quaternion
  70723. * @param quaternion the rotation quaternion
  70724. * @param result vector to store the result
  70725. * @returns the resulting vector
  70726. */
  70727. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70728. /**
  70729. * Rotates a vector around a given point
  70730. * @param quaternion the rotation quaternion
  70731. * @param point the point to rotate around
  70732. * @param result vector to store the result
  70733. * @returns the resulting vector
  70734. */
  70735. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70736. /**
  70737. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70738. * The cross product is then orthogonal to both current and "other"
  70739. * @param other defines the right operand
  70740. * @returns the cross product
  70741. */
  70742. cross(other: Vector3): Vector3;
  70743. /**
  70744. * Normalize the current Vector3 with the given input length.
  70745. * Please note that this is an in place operation.
  70746. * @param len the length of the vector
  70747. * @returns the current updated Vector3
  70748. */
  70749. normalizeFromLength(len: number): Vector3;
  70750. /**
  70751. * Normalize the current Vector3 to a new vector
  70752. * @returns the new Vector3
  70753. */
  70754. normalizeToNew(): Vector3;
  70755. /**
  70756. * Normalize the current Vector3 to the reference
  70757. * @param reference define the Vector3 to update
  70758. * @returns the updated Vector3
  70759. */
  70760. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70761. /**
  70762. * Creates a new Vector3 copied from the current Vector3
  70763. * @returns the new Vector3
  70764. */
  70765. clone(): Vector3;
  70766. /**
  70767. * Copies the given vector coordinates to the current Vector3 ones
  70768. * @param source defines the source Vector3
  70769. * @returns the current updated Vector3
  70770. */
  70771. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70772. /**
  70773. * Copies the given floats to the current Vector3 coordinates
  70774. * @param x defines the x coordinate of the operand
  70775. * @param y defines the y coordinate of the operand
  70776. * @param z defines the z coordinate of the operand
  70777. * @returns the current updated Vector3
  70778. */
  70779. copyFromFloats(x: number, y: number, z: number): Vector3;
  70780. /**
  70781. * Copies the given floats to the current Vector3 coordinates
  70782. * @param x defines the x coordinate of the operand
  70783. * @param y defines the y coordinate of the operand
  70784. * @param z defines the z coordinate of the operand
  70785. * @returns the current updated Vector3
  70786. */
  70787. set(x: number, y: number, z: number): Vector3;
  70788. /**
  70789. * Copies the given float to the current Vector3 coordinates
  70790. * @param v defines the x, y and z coordinates of the operand
  70791. * @returns the current updated Vector3
  70792. */
  70793. setAll(v: number): Vector3;
  70794. /**
  70795. * Get the clip factor between two vectors
  70796. * @param vector0 defines the first operand
  70797. * @param vector1 defines the second operand
  70798. * @param axis defines the axis to use
  70799. * @param size defines the size along the axis
  70800. * @returns the clip factor
  70801. */
  70802. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70803. /**
  70804. * Get angle between two vectors
  70805. * @param vector0 angle between vector0 and vector1
  70806. * @param vector1 angle between vector0 and vector1
  70807. * @param normal direction of the normal
  70808. * @return the angle between vector0 and vector1
  70809. */
  70810. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70811. /**
  70812. * Returns a new Vector3 set from the index "offset" of the given array
  70813. * @param array defines the source array
  70814. * @param offset defines the offset in the source array
  70815. * @returns the new Vector3
  70816. */
  70817. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70818. /**
  70819. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70820. * This function is deprecated. Use FromArray instead
  70821. * @param array defines the source array
  70822. * @param offset defines the offset in the source array
  70823. * @returns the new Vector3
  70824. */
  70825. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70826. /**
  70827. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70828. * @param array defines the source array
  70829. * @param offset defines the offset in the source array
  70830. * @param result defines the Vector3 where to store the result
  70831. */
  70832. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70833. /**
  70834. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70835. * This function is deprecated. Use FromArrayToRef instead.
  70836. * @param array defines the source array
  70837. * @param offset defines the offset in the source array
  70838. * @param result defines the Vector3 where to store the result
  70839. */
  70840. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70841. /**
  70842. * Sets the given vector "result" with the given floats.
  70843. * @param x defines the x coordinate of the source
  70844. * @param y defines the y coordinate of the source
  70845. * @param z defines the z coordinate of the source
  70846. * @param result defines the Vector3 where to store the result
  70847. */
  70848. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70849. /**
  70850. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70851. * @returns a new empty Vector3
  70852. */
  70853. static Zero(): Vector3;
  70854. /**
  70855. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70856. * @returns a new unit Vector3
  70857. */
  70858. static One(): Vector3;
  70859. /**
  70860. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70861. * @returns a new up Vector3
  70862. */
  70863. static Up(): Vector3;
  70864. /**
  70865. * Gets a up Vector3 that must not be updated
  70866. */
  70867. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70868. /**
  70869. * Gets a zero Vector3 that must not be updated
  70870. */
  70871. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70872. /**
  70873. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70874. * @returns a new down Vector3
  70875. */
  70876. static Down(): Vector3;
  70877. /**
  70878. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70879. * @returns a new forward Vector3
  70880. */
  70881. static Forward(): Vector3;
  70882. /**
  70883. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70884. * @returns a new forward Vector3
  70885. */
  70886. static Backward(): Vector3;
  70887. /**
  70888. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70889. * @returns a new right Vector3
  70890. */
  70891. static Right(): Vector3;
  70892. /**
  70893. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70894. * @returns a new left Vector3
  70895. */
  70896. static Left(): Vector3;
  70897. /**
  70898. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70899. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70900. * @param vector defines the Vector3 to transform
  70901. * @param transformation defines the transformation matrix
  70902. * @returns the transformed Vector3
  70903. */
  70904. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70905. /**
  70906. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70907. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70908. * @param vector defines the Vector3 to transform
  70909. * @param transformation defines the transformation matrix
  70910. * @param result defines the Vector3 where to store the result
  70911. */
  70912. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70913. /**
  70914. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70915. * This method computes tranformed coordinates only, not transformed direction vectors
  70916. * @param x define the x coordinate of the source vector
  70917. * @param y define the y coordinate of the source vector
  70918. * @param z define the z coordinate of the source vector
  70919. * @param transformation defines the transformation matrix
  70920. * @param result defines the Vector3 where to store the result
  70921. */
  70922. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70923. /**
  70924. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70925. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70926. * @param vector defines the Vector3 to transform
  70927. * @param transformation defines the transformation matrix
  70928. * @returns the new Vector3
  70929. */
  70930. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70931. /**
  70932. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70933. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70934. * @param vector defines the Vector3 to transform
  70935. * @param transformation defines the transformation matrix
  70936. * @param result defines the Vector3 where to store the result
  70937. */
  70938. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70939. /**
  70940. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70941. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70942. * @param x define the x coordinate of the source vector
  70943. * @param y define the y coordinate of the source vector
  70944. * @param z define the z coordinate of the source vector
  70945. * @param transformation defines the transformation matrix
  70946. * @param result defines the Vector3 where to store the result
  70947. */
  70948. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70949. /**
  70950. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70951. * @param value1 defines the first control point
  70952. * @param value2 defines the second control point
  70953. * @param value3 defines the third control point
  70954. * @param value4 defines the fourth control point
  70955. * @param amount defines the amount on the spline to use
  70956. * @returns the new Vector3
  70957. */
  70958. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70959. /**
  70960. * 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"
  70961. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70962. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70963. * @param value defines the current value
  70964. * @param min defines the lower range value
  70965. * @param max defines the upper range value
  70966. * @returns the new Vector3
  70967. */
  70968. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70969. /**
  70970. * 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"
  70971. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70972. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70973. * @param value defines the current value
  70974. * @param min defines the lower range value
  70975. * @param max defines the upper range value
  70976. * @param result defines the Vector3 where to store the result
  70977. */
  70978. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70979. /**
  70980. * Checks if a given vector is inside a specific range
  70981. * @param v defines the vector to test
  70982. * @param min defines the minimum range
  70983. * @param max defines the maximum range
  70984. */
  70985. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70986. /**
  70987. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70988. * @param value1 defines the first control point
  70989. * @param tangent1 defines the first tangent vector
  70990. * @param value2 defines the second control point
  70991. * @param tangent2 defines the second tangent vector
  70992. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70993. * @returns the new Vector3
  70994. */
  70995. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70996. /**
  70997. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70998. * @param start defines the start value
  70999. * @param end defines the end value
  71000. * @param amount max defines amount between both (between 0 and 1)
  71001. * @returns the new Vector3
  71002. */
  71003. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71004. /**
  71005. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71006. * @param start defines the start value
  71007. * @param end defines the end value
  71008. * @param amount max defines amount between both (between 0 and 1)
  71009. * @param result defines the Vector3 where to store the result
  71010. */
  71011. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71012. /**
  71013. * Returns the dot product (float) between the vectors "left" and "right"
  71014. * @param left defines the left operand
  71015. * @param right defines the right operand
  71016. * @returns the dot product
  71017. */
  71018. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71019. /**
  71020. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71021. * The cross product is then orthogonal to both "left" and "right"
  71022. * @param left defines the left operand
  71023. * @param right defines the right operand
  71024. * @returns the cross product
  71025. */
  71026. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71027. /**
  71028. * Sets the given vector "result" with the cross product of "left" and "right"
  71029. * The cross product is then orthogonal to both "left" and "right"
  71030. * @param left defines the left operand
  71031. * @param right defines the right operand
  71032. * @param result defines the Vector3 where to store the result
  71033. */
  71034. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71035. /**
  71036. * Returns a new Vector3 as the normalization of the given vector
  71037. * @param vector defines the Vector3 to normalize
  71038. * @returns the new Vector3
  71039. */
  71040. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71041. /**
  71042. * Sets the given vector "result" with the normalization of the given first vector
  71043. * @param vector defines the Vector3 to normalize
  71044. * @param result defines the Vector3 where to store the result
  71045. */
  71046. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71047. /**
  71048. * Project a Vector3 onto screen space
  71049. * @param vector defines the Vector3 to project
  71050. * @param world defines the world matrix to use
  71051. * @param transform defines the transform (view x projection) matrix to use
  71052. * @param viewport defines the screen viewport to use
  71053. * @returns the new Vector3
  71054. */
  71055. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71056. /** @hidden */
  71057. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71058. /**
  71059. * Unproject from screen space to object space
  71060. * @param source defines the screen space Vector3 to use
  71061. * @param viewportWidth defines the current width of the viewport
  71062. * @param viewportHeight defines the current height of the viewport
  71063. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71064. * @param transform defines the transform (view x projection) matrix to use
  71065. * @returns the new Vector3
  71066. */
  71067. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71068. /**
  71069. * Unproject from screen space to object space
  71070. * @param source defines the screen space Vector3 to use
  71071. * @param viewportWidth defines the current width of the viewport
  71072. * @param viewportHeight defines the current height of the viewport
  71073. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71074. * @param view defines the view matrix to use
  71075. * @param projection defines the projection matrix to use
  71076. * @returns the new Vector3
  71077. */
  71078. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71079. /**
  71080. * Unproject from screen space to object space
  71081. * @param source defines the screen space Vector3 to use
  71082. * @param viewportWidth defines the current width of the viewport
  71083. * @param viewportHeight defines the current height of the viewport
  71084. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71085. * @param view defines the view matrix to use
  71086. * @param projection defines the projection matrix to use
  71087. * @param result defines the Vector3 where to store the result
  71088. */
  71089. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71090. /**
  71091. * Unproject from screen space to object space
  71092. * @param sourceX defines the screen space x coordinate to use
  71093. * @param sourceY defines the screen space y coordinate to use
  71094. * @param sourceZ defines the screen space z coordinate to use
  71095. * @param viewportWidth defines the current width of the viewport
  71096. * @param viewportHeight defines the current height of the viewport
  71097. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71098. * @param view defines the view matrix to use
  71099. * @param projection defines the projection matrix to use
  71100. * @param result defines the Vector3 where to store the result
  71101. */
  71102. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71103. /**
  71104. * Gets the minimal coordinate values between two Vector3
  71105. * @param left defines the first operand
  71106. * @param right defines the second operand
  71107. * @returns the new Vector3
  71108. */
  71109. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71110. /**
  71111. * Gets the maximal coordinate values between two Vector3
  71112. * @param left defines the first operand
  71113. * @param right defines the second operand
  71114. * @returns the new Vector3
  71115. */
  71116. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71117. /**
  71118. * Returns the distance between the vectors "value1" and "value2"
  71119. * @param value1 defines the first operand
  71120. * @param value2 defines the second operand
  71121. * @returns the distance
  71122. */
  71123. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71124. /**
  71125. * Returns the squared distance between the vectors "value1" and "value2"
  71126. * @param value1 defines the first operand
  71127. * @param value2 defines the second operand
  71128. * @returns the squared distance
  71129. */
  71130. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71131. /**
  71132. * Returns a new Vector3 located at the center between "value1" and "value2"
  71133. * @param value1 defines the first operand
  71134. * @param value2 defines the second operand
  71135. * @returns the new Vector3
  71136. */
  71137. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71138. /**
  71139. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71140. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71141. * to something in order to rotate it from its local system to the given target system
  71142. * Note: axis1, axis2 and axis3 are normalized during this operation
  71143. * @param axis1 defines the first axis
  71144. * @param axis2 defines the second axis
  71145. * @param axis3 defines the third axis
  71146. * @returns a new Vector3
  71147. */
  71148. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71149. /**
  71150. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71151. * @param axis1 defines the first axis
  71152. * @param axis2 defines the second axis
  71153. * @param axis3 defines the third axis
  71154. * @param ref defines the Vector3 where to store the result
  71155. */
  71156. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71157. }
  71158. /**
  71159. * Vector4 class created for EulerAngle class conversion to Quaternion
  71160. */
  71161. export class Vector4 {
  71162. /** x value of the vector */
  71163. x: number;
  71164. /** y value of the vector */
  71165. y: number;
  71166. /** z value of the vector */
  71167. z: number;
  71168. /** w value of the vector */
  71169. w: number;
  71170. /**
  71171. * Creates a Vector4 object from the given floats.
  71172. * @param x x value of the vector
  71173. * @param y y value of the vector
  71174. * @param z z value of the vector
  71175. * @param w w value of the vector
  71176. */
  71177. constructor(
  71178. /** x value of the vector */
  71179. x: number,
  71180. /** y value of the vector */
  71181. y: number,
  71182. /** z value of the vector */
  71183. z: number,
  71184. /** w value of the vector */
  71185. w: number);
  71186. /**
  71187. * Returns the string with the Vector4 coordinates.
  71188. * @returns a string containing all the vector values
  71189. */
  71190. toString(): string;
  71191. /**
  71192. * Returns the string "Vector4".
  71193. * @returns "Vector4"
  71194. */
  71195. getClassName(): string;
  71196. /**
  71197. * Returns the Vector4 hash code.
  71198. * @returns a unique hash code
  71199. */
  71200. getHashCode(): number;
  71201. /**
  71202. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71203. * @returns the resulting array
  71204. */
  71205. asArray(): number[];
  71206. /**
  71207. * Populates the given array from the given index with the Vector4 coordinates.
  71208. * @param array array to populate
  71209. * @param index index of the array to start at (default: 0)
  71210. * @returns the Vector4.
  71211. */
  71212. toArray(array: FloatArray, index?: number): Vector4;
  71213. /**
  71214. * Adds the given vector to the current Vector4.
  71215. * @param otherVector the vector to add
  71216. * @returns the updated Vector4.
  71217. */
  71218. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71219. /**
  71220. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71221. * @param otherVector the vector to add
  71222. * @returns the resulting vector
  71223. */
  71224. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71225. /**
  71226. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71227. * @param otherVector the vector to add
  71228. * @param result the vector to store the result
  71229. * @returns the current Vector4.
  71230. */
  71231. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71232. /**
  71233. * Subtract in place the given vector from the current Vector4.
  71234. * @param otherVector the vector to subtract
  71235. * @returns the updated Vector4.
  71236. */
  71237. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71238. /**
  71239. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71240. * @param otherVector the vector to add
  71241. * @returns the new vector with the result
  71242. */
  71243. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71244. /**
  71245. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71246. * @param otherVector the vector to subtract
  71247. * @param result the vector to store the result
  71248. * @returns the current Vector4.
  71249. */
  71250. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71251. /**
  71252. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71253. */
  71254. /**
  71255. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71256. * @param x value to subtract
  71257. * @param y value to subtract
  71258. * @param z value to subtract
  71259. * @param w value to subtract
  71260. * @returns new vector containing the result
  71261. */
  71262. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71263. /**
  71264. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71265. * @param x value to subtract
  71266. * @param y value to subtract
  71267. * @param z value to subtract
  71268. * @param w value to subtract
  71269. * @param result the vector to store the result in
  71270. * @returns the current Vector4.
  71271. */
  71272. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71273. /**
  71274. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71275. * @returns a new vector with the negated values
  71276. */
  71277. negate(): Vector4;
  71278. /**
  71279. * Multiplies the current Vector4 coordinates by scale (float).
  71280. * @param scale the number to scale with
  71281. * @returns the updated Vector4.
  71282. */
  71283. scaleInPlace(scale: number): Vector4;
  71284. /**
  71285. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71286. * @param scale the number to scale with
  71287. * @returns a new vector with the result
  71288. */
  71289. scale(scale: number): Vector4;
  71290. /**
  71291. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71292. * @param scale the number to scale with
  71293. * @param result a vector to store the result in
  71294. * @returns the current Vector4.
  71295. */
  71296. scaleToRef(scale: number, result: Vector4): Vector4;
  71297. /**
  71298. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71299. * @param scale defines the scale factor
  71300. * @param result defines the Vector4 object where to store the result
  71301. * @returns the unmodified current Vector4
  71302. */
  71303. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71304. /**
  71305. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71306. * @param otherVector the vector to compare against
  71307. * @returns true if they are equal
  71308. */
  71309. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71310. /**
  71311. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71312. * @param otherVector vector to compare against
  71313. * @param epsilon (Default: very small number)
  71314. * @returns true if they are equal
  71315. */
  71316. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71317. /**
  71318. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71319. * @param x x value to compare against
  71320. * @param y y value to compare against
  71321. * @param z z value to compare against
  71322. * @param w w value to compare against
  71323. * @returns true if equal
  71324. */
  71325. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71326. /**
  71327. * Multiplies in place the current Vector4 by the given one.
  71328. * @param otherVector vector to multiple with
  71329. * @returns the updated Vector4.
  71330. */
  71331. multiplyInPlace(otherVector: Vector4): Vector4;
  71332. /**
  71333. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71334. * @param otherVector vector to multiple with
  71335. * @returns resulting new vector
  71336. */
  71337. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71338. /**
  71339. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71340. * @param otherVector vector to multiple with
  71341. * @param result vector to store the result
  71342. * @returns the current Vector4.
  71343. */
  71344. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71345. /**
  71346. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71347. * @param x x value multiply with
  71348. * @param y y value multiply with
  71349. * @param z z value multiply with
  71350. * @param w w value multiply with
  71351. * @returns resulting new vector
  71352. */
  71353. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71354. /**
  71355. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71356. * @param otherVector vector to devide with
  71357. * @returns resulting new vector
  71358. */
  71359. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71360. /**
  71361. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71362. * @param otherVector vector to devide with
  71363. * @param result vector to store the result
  71364. * @returns the current Vector4.
  71365. */
  71366. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71367. /**
  71368. * Divides the current Vector3 coordinates by the given ones.
  71369. * @param otherVector vector to devide with
  71370. * @returns the updated Vector3.
  71371. */
  71372. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71373. /**
  71374. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71375. * @param other defines the second operand
  71376. * @returns the current updated Vector4
  71377. */
  71378. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71379. /**
  71380. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71381. * @param other defines the second operand
  71382. * @returns the current updated Vector4
  71383. */
  71384. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71385. /**
  71386. * Gets a new Vector4 from current Vector4 floored values
  71387. * @returns a new Vector4
  71388. */
  71389. floor(): Vector4;
  71390. /**
  71391. * Gets a new Vector4 from current Vector3 floored values
  71392. * @returns a new Vector4
  71393. */
  71394. fract(): Vector4;
  71395. /**
  71396. * Returns the Vector4 length (float).
  71397. * @returns the length
  71398. */
  71399. length(): number;
  71400. /**
  71401. * Returns the Vector4 squared length (float).
  71402. * @returns the length squared
  71403. */
  71404. lengthSquared(): number;
  71405. /**
  71406. * Normalizes in place the Vector4.
  71407. * @returns the updated Vector4.
  71408. */
  71409. normalize(): Vector4;
  71410. /**
  71411. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71412. * @returns this converted to a new vector3
  71413. */
  71414. toVector3(): Vector3;
  71415. /**
  71416. * Returns a new Vector4 copied from the current one.
  71417. * @returns the new cloned vector
  71418. */
  71419. clone(): Vector4;
  71420. /**
  71421. * Updates the current Vector4 with the given one coordinates.
  71422. * @param source the source vector to copy from
  71423. * @returns the updated Vector4.
  71424. */
  71425. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71426. /**
  71427. * Updates the current Vector4 coordinates with the given floats.
  71428. * @param x float to copy from
  71429. * @param y float to copy from
  71430. * @param z float to copy from
  71431. * @param w float to copy from
  71432. * @returns the updated Vector4.
  71433. */
  71434. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71435. /**
  71436. * Updates the current Vector4 coordinates with the given floats.
  71437. * @param x float to set from
  71438. * @param y float to set from
  71439. * @param z float to set from
  71440. * @param w float to set from
  71441. * @returns the updated Vector4.
  71442. */
  71443. set(x: number, y: number, z: number, w: number): Vector4;
  71444. /**
  71445. * Copies the given float to the current Vector3 coordinates
  71446. * @param v defines the x, y, z and w coordinates of the operand
  71447. * @returns the current updated Vector3
  71448. */
  71449. setAll(v: number): Vector4;
  71450. /**
  71451. * Returns a new Vector4 set from the starting index of the given array.
  71452. * @param array the array to pull values from
  71453. * @param offset the offset into the array to start at
  71454. * @returns the new vector
  71455. */
  71456. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71457. /**
  71458. * Updates the given vector "result" from the starting index of the given array.
  71459. * @param array the array to pull values from
  71460. * @param offset the offset into the array to start at
  71461. * @param result the vector to store the result in
  71462. */
  71463. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71464. /**
  71465. * Updates the given vector "result" from the starting index of the given Float32Array.
  71466. * @param array the array to pull values from
  71467. * @param offset the offset into the array to start at
  71468. * @param result the vector to store the result in
  71469. */
  71470. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71471. /**
  71472. * Updates the given vector "result" coordinates from the given floats.
  71473. * @param x float to set from
  71474. * @param y float to set from
  71475. * @param z float to set from
  71476. * @param w float to set from
  71477. * @param result the vector to the floats in
  71478. */
  71479. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71480. /**
  71481. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71482. * @returns the new vector
  71483. */
  71484. static Zero(): Vector4;
  71485. /**
  71486. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71487. * @returns the new vector
  71488. */
  71489. static One(): Vector4;
  71490. /**
  71491. * Returns a new normalized Vector4 from the given one.
  71492. * @param vector the vector to normalize
  71493. * @returns the vector
  71494. */
  71495. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71496. /**
  71497. * Updates the given vector "result" from the normalization of the given one.
  71498. * @param vector the vector to normalize
  71499. * @param result the vector to store the result in
  71500. */
  71501. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71502. /**
  71503. * Returns a vector with the minimum values from the left and right vectors
  71504. * @param left left vector to minimize
  71505. * @param right right vector to minimize
  71506. * @returns a new vector with the minimum of the left and right vector values
  71507. */
  71508. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71509. /**
  71510. * Returns a vector with the maximum values from the left and right vectors
  71511. * @param left left vector to maximize
  71512. * @param right right vector to maximize
  71513. * @returns a new vector with the maximum of the left and right vector values
  71514. */
  71515. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71516. /**
  71517. * Returns the distance (float) between the vectors "value1" and "value2".
  71518. * @param value1 value to calulate the distance between
  71519. * @param value2 value to calulate the distance between
  71520. * @return the distance between the two vectors
  71521. */
  71522. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71523. /**
  71524. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71525. * @param value1 value to calulate the distance between
  71526. * @param value2 value to calulate the distance between
  71527. * @return the distance between the two vectors squared
  71528. */
  71529. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71530. /**
  71531. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71532. * @param value1 value to calulate the center between
  71533. * @param value2 value to calulate the center between
  71534. * @return the center between the two vectors
  71535. */
  71536. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71537. /**
  71538. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71539. * This methods computes transformed normalized direction vectors only.
  71540. * @param vector the vector to transform
  71541. * @param transformation the transformation matrix to apply
  71542. * @returns the new vector
  71543. */
  71544. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71545. /**
  71546. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71547. * This methods computes transformed normalized direction vectors only.
  71548. * @param vector the vector to transform
  71549. * @param transformation the transformation matrix to apply
  71550. * @param result the vector to store the result in
  71551. */
  71552. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71553. /**
  71554. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71555. * This methods computes transformed normalized direction vectors only.
  71556. * @param x value to transform
  71557. * @param y value to transform
  71558. * @param z value to transform
  71559. * @param w value to transform
  71560. * @param transformation the transformation matrix to apply
  71561. * @param result the vector to store the results in
  71562. */
  71563. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71564. /**
  71565. * Creates a new Vector4 from a Vector3
  71566. * @param source defines the source data
  71567. * @param w defines the 4th component (default is 0)
  71568. * @returns a new Vector4
  71569. */
  71570. static FromVector3(source: Vector3, w?: number): Vector4;
  71571. }
  71572. /**
  71573. * Class used to store quaternion data
  71574. * @see https://en.wikipedia.org/wiki/Quaternion
  71575. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71576. */
  71577. export class Quaternion {
  71578. /** defines the first component (0 by default) */
  71579. x: number;
  71580. /** defines the second component (0 by default) */
  71581. y: number;
  71582. /** defines the third component (0 by default) */
  71583. z: number;
  71584. /** defines the fourth component (1.0 by default) */
  71585. w: number;
  71586. /**
  71587. * Creates a new Quaternion from the given floats
  71588. * @param x defines the first component (0 by default)
  71589. * @param y defines the second component (0 by default)
  71590. * @param z defines the third component (0 by default)
  71591. * @param w defines the fourth component (1.0 by default)
  71592. */
  71593. constructor(
  71594. /** defines the first component (0 by default) */
  71595. x?: number,
  71596. /** defines the second component (0 by default) */
  71597. y?: number,
  71598. /** defines the third component (0 by default) */
  71599. z?: number,
  71600. /** defines the fourth component (1.0 by default) */
  71601. w?: number);
  71602. /**
  71603. * Gets a string representation for the current quaternion
  71604. * @returns a string with the Quaternion coordinates
  71605. */
  71606. toString(): string;
  71607. /**
  71608. * Gets the class name of the quaternion
  71609. * @returns the string "Quaternion"
  71610. */
  71611. getClassName(): string;
  71612. /**
  71613. * Gets a hash code for this quaternion
  71614. * @returns the quaternion hash code
  71615. */
  71616. getHashCode(): number;
  71617. /**
  71618. * Copy the quaternion to an array
  71619. * @returns a new array populated with 4 elements from the quaternion coordinates
  71620. */
  71621. asArray(): number[];
  71622. /**
  71623. * Check if two quaternions are equals
  71624. * @param otherQuaternion defines the second operand
  71625. * @return true if the current quaternion and the given one coordinates are strictly equals
  71626. */
  71627. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71628. /**
  71629. * Clone the current quaternion
  71630. * @returns a new quaternion copied from the current one
  71631. */
  71632. clone(): Quaternion;
  71633. /**
  71634. * Copy a quaternion to the current one
  71635. * @param other defines the other quaternion
  71636. * @returns the updated current quaternion
  71637. */
  71638. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71639. /**
  71640. * Updates the current quaternion with the given float coordinates
  71641. * @param x defines the x coordinate
  71642. * @param y defines the y coordinate
  71643. * @param z defines the z coordinate
  71644. * @param w defines the w coordinate
  71645. * @returns the updated current quaternion
  71646. */
  71647. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71648. /**
  71649. * Updates the current quaternion from the given float coordinates
  71650. * @param x defines the x coordinate
  71651. * @param y defines the y coordinate
  71652. * @param z defines the z coordinate
  71653. * @param w defines the w coordinate
  71654. * @returns the updated current quaternion
  71655. */
  71656. set(x: number, y: number, z: number, w: number): Quaternion;
  71657. /**
  71658. * Adds two quaternions
  71659. * @param other defines the second operand
  71660. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71661. */
  71662. add(other: DeepImmutable<Quaternion>): Quaternion;
  71663. /**
  71664. * Add a quaternion to the current one
  71665. * @param other defines the quaternion to add
  71666. * @returns the current quaternion
  71667. */
  71668. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71669. /**
  71670. * Subtract two quaternions
  71671. * @param other defines the second operand
  71672. * @returns a new quaternion as the subtraction result of the given one from the current one
  71673. */
  71674. subtract(other: Quaternion): Quaternion;
  71675. /**
  71676. * Multiplies the current quaternion by a scale factor
  71677. * @param value defines the scale factor
  71678. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71679. */
  71680. scale(value: number): Quaternion;
  71681. /**
  71682. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71683. * @param scale defines the scale factor
  71684. * @param result defines the Quaternion object where to store the result
  71685. * @returns the unmodified current quaternion
  71686. */
  71687. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71688. /**
  71689. * Multiplies in place the current quaternion by a scale factor
  71690. * @param value defines the scale factor
  71691. * @returns the current modified quaternion
  71692. */
  71693. scaleInPlace(value: number): Quaternion;
  71694. /**
  71695. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71696. * @param scale defines the scale factor
  71697. * @param result defines the Quaternion object where to store the result
  71698. * @returns the unmodified current quaternion
  71699. */
  71700. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71701. /**
  71702. * Multiplies two quaternions
  71703. * @param q1 defines the second operand
  71704. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71705. */
  71706. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71707. /**
  71708. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71709. * @param q1 defines the second operand
  71710. * @param result defines the target quaternion
  71711. * @returns the current quaternion
  71712. */
  71713. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71714. /**
  71715. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71716. * @param q1 defines the second operand
  71717. * @returns the currentupdated quaternion
  71718. */
  71719. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71720. /**
  71721. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71722. * @param ref defines the target quaternion
  71723. * @returns the current quaternion
  71724. */
  71725. conjugateToRef(ref: Quaternion): Quaternion;
  71726. /**
  71727. * Conjugates in place (1-q) the current quaternion
  71728. * @returns the current updated quaternion
  71729. */
  71730. conjugateInPlace(): Quaternion;
  71731. /**
  71732. * Conjugates in place (1-q) the current quaternion
  71733. * @returns a new quaternion
  71734. */
  71735. conjugate(): Quaternion;
  71736. /**
  71737. * Gets length of current quaternion
  71738. * @returns the quaternion length (float)
  71739. */
  71740. length(): number;
  71741. /**
  71742. * Normalize in place the current quaternion
  71743. * @returns the current updated quaternion
  71744. */
  71745. normalize(): Quaternion;
  71746. /**
  71747. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71748. * @param order is a reserved parameter and is ignore for now
  71749. * @returns a new Vector3 containing the Euler angles
  71750. */
  71751. toEulerAngles(order?: string): Vector3;
  71752. /**
  71753. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71754. * @param result defines the vector which will be filled with the Euler angles
  71755. * @param order is a reserved parameter and is ignore for now
  71756. * @returns the current unchanged quaternion
  71757. */
  71758. toEulerAnglesToRef(result: Vector3): Quaternion;
  71759. /**
  71760. * Updates the given rotation matrix with the current quaternion values
  71761. * @param result defines the target matrix
  71762. * @returns the current unchanged quaternion
  71763. */
  71764. toRotationMatrix(result: Matrix): Quaternion;
  71765. /**
  71766. * Updates the current quaternion from the given rotation matrix values
  71767. * @param matrix defines the source matrix
  71768. * @returns the current updated quaternion
  71769. */
  71770. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71771. /**
  71772. * Creates a new quaternion from a rotation matrix
  71773. * @param matrix defines the source matrix
  71774. * @returns a new quaternion created from the given rotation matrix values
  71775. */
  71776. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71777. /**
  71778. * Updates the given quaternion with the given rotation matrix values
  71779. * @param matrix defines the source matrix
  71780. * @param result defines the target quaternion
  71781. */
  71782. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71783. /**
  71784. * Returns the dot product (float) between the quaternions "left" and "right"
  71785. * @param left defines the left operand
  71786. * @param right defines the right operand
  71787. * @returns the dot product
  71788. */
  71789. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71790. /**
  71791. * Checks if the two quaternions are close to each other
  71792. * @param quat0 defines the first quaternion to check
  71793. * @param quat1 defines the second quaternion to check
  71794. * @returns true if the two quaternions are close to each other
  71795. */
  71796. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71797. /**
  71798. * Creates an empty quaternion
  71799. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71800. */
  71801. static Zero(): Quaternion;
  71802. /**
  71803. * Inverse a given quaternion
  71804. * @param q defines the source quaternion
  71805. * @returns a new quaternion as the inverted current quaternion
  71806. */
  71807. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71808. /**
  71809. * Inverse a given quaternion
  71810. * @param q defines the source quaternion
  71811. * @param result the quaternion the result will be stored in
  71812. * @returns the result quaternion
  71813. */
  71814. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71815. /**
  71816. * Creates an identity quaternion
  71817. * @returns the identity quaternion
  71818. */
  71819. static Identity(): Quaternion;
  71820. /**
  71821. * Gets a boolean indicating if the given quaternion is identity
  71822. * @param quaternion defines the quaternion to check
  71823. * @returns true if the quaternion is identity
  71824. */
  71825. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71826. /**
  71827. * Creates a quaternion from a rotation around an axis
  71828. * @param axis defines the axis to use
  71829. * @param angle defines the angle to use
  71830. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71831. */
  71832. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71833. /**
  71834. * Creates a rotation around an axis and stores it into the given quaternion
  71835. * @param axis defines the axis to use
  71836. * @param angle defines the angle to use
  71837. * @param result defines the target quaternion
  71838. * @returns the target quaternion
  71839. */
  71840. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71841. /**
  71842. * Creates a new quaternion from data stored into an array
  71843. * @param array defines the data source
  71844. * @param offset defines the offset in the source array where the data starts
  71845. * @returns a new quaternion
  71846. */
  71847. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71848. /**
  71849. * Create a quaternion from Euler rotation angles
  71850. * @param x Pitch
  71851. * @param y Yaw
  71852. * @param z Roll
  71853. * @returns the new Quaternion
  71854. */
  71855. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71856. /**
  71857. * Updates a quaternion from Euler rotation angles
  71858. * @param x Pitch
  71859. * @param y Yaw
  71860. * @param z Roll
  71861. * @param result the quaternion to store the result
  71862. * @returns the updated quaternion
  71863. */
  71864. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71865. /**
  71866. * Create a quaternion from Euler rotation vector
  71867. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71868. * @returns the new Quaternion
  71869. */
  71870. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71871. /**
  71872. * Updates a quaternion from Euler rotation vector
  71873. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71874. * @param result the quaternion to store the result
  71875. * @returns the updated quaternion
  71876. */
  71877. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71878. /**
  71879. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71880. * @param yaw defines the rotation around Y axis
  71881. * @param pitch defines the rotation around X axis
  71882. * @param roll defines the rotation around Z axis
  71883. * @returns the new quaternion
  71884. */
  71885. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71886. /**
  71887. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71888. * @param yaw defines the rotation around Y axis
  71889. * @param pitch defines the rotation around X axis
  71890. * @param roll defines the rotation around Z axis
  71891. * @param result defines the target quaternion
  71892. */
  71893. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71894. /**
  71895. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71896. * @param alpha defines the rotation around first axis
  71897. * @param beta defines the rotation around second axis
  71898. * @param gamma defines the rotation around third axis
  71899. * @returns the new quaternion
  71900. */
  71901. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71902. /**
  71903. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71904. * @param alpha defines the rotation around first axis
  71905. * @param beta defines the rotation around second axis
  71906. * @param gamma defines the rotation around third axis
  71907. * @param result defines the target quaternion
  71908. */
  71909. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71910. /**
  71911. * 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)
  71912. * @param axis1 defines the first axis
  71913. * @param axis2 defines the second axis
  71914. * @param axis3 defines the third axis
  71915. * @returns the new quaternion
  71916. */
  71917. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71918. /**
  71919. * 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
  71920. * @param axis1 defines the first axis
  71921. * @param axis2 defines the second axis
  71922. * @param axis3 defines the third axis
  71923. * @param ref defines the target quaternion
  71924. */
  71925. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71926. /**
  71927. * Interpolates between two quaternions
  71928. * @param left defines first quaternion
  71929. * @param right defines second quaternion
  71930. * @param amount defines the gradient to use
  71931. * @returns the new interpolated quaternion
  71932. */
  71933. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71934. /**
  71935. * Interpolates between two quaternions and stores it into a target quaternion
  71936. * @param left defines first quaternion
  71937. * @param right defines second quaternion
  71938. * @param amount defines the gradient to use
  71939. * @param result defines the target quaternion
  71940. */
  71941. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71942. /**
  71943. * Interpolate between two quaternions using Hermite interpolation
  71944. * @param value1 defines first quaternion
  71945. * @param tangent1 defines the incoming tangent
  71946. * @param value2 defines second quaternion
  71947. * @param tangent2 defines the outgoing tangent
  71948. * @param amount defines the target quaternion
  71949. * @returns the new interpolated quaternion
  71950. */
  71951. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71952. }
  71953. /**
  71954. * Class used to store matrix data (4x4)
  71955. */
  71956. export class Matrix {
  71957. private static _updateFlagSeed;
  71958. private static _identityReadOnly;
  71959. private _isIdentity;
  71960. private _isIdentityDirty;
  71961. private _isIdentity3x2;
  71962. private _isIdentity3x2Dirty;
  71963. /**
  71964. * Gets the update flag of the matrix which is an unique number for the matrix.
  71965. * It will be incremented every time the matrix data change.
  71966. * You can use it to speed the comparison between two versions of the same matrix.
  71967. */
  71968. updateFlag: number;
  71969. private readonly _m;
  71970. /**
  71971. * Gets the internal data of the matrix
  71972. */
  71973. readonly m: DeepImmutable<Float32Array>;
  71974. /** @hidden */
  71975. _markAsUpdated(): void;
  71976. /** @hidden */
  71977. private _updateIdentityStatus;
  71978. /**
  71979. * Creates an empty matrix (filled with zeros)
  71980. */
  71981. constructor();
  71982. /**
  71983. * Check if the current matrix is identity
  71984. * @returns true is the matrix is the identity matrix
  71985. */
  71986. isIdentity(): boolean;
  71987. /**
  71988. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71989. * @returns true is the matrix is the identity matrix
  71990. */
  71991. isIdentityAs3x2(): boolean;
  71992. /**
  71993. * Gets the determinant of the matrix
  71994. * @returns the matrix determinant
  71995. */
  71996. determinant(): number;
  71997. /**
  71998. * Returns the matrix as a Float32Array
  71999. * @returns the matrix underlying array
  72000. */
  72001. toArray(): DeepImmutable<Float32Array>;
  72002. /**
  72003. * Returns the matrix as a Float32Array
  72004. * @returns the matrix underlying array.
  72005. */
  72006. asArray(): DeepImmutable<Float32Array>;
  72007. /**
  72008. * Inverts the current matrix in place
  72009. * @returns the current inverted matrix
  72010. */
  72011. invert(): Matrix;
  72012. /**
  72013. * Sets all the matrix elements to zero
  72014. * @returns the current matrix
  72015. */
  72016. reset(): Matrix;
  72017. /**
  72018. * Adds the current matrix with a second one
  72019. * @param other defines the matrix to add
  72020. * @returns a new matrix as the addition of the current matrix and the given one
  72021. */
  72022. add(other: DeepImmutable<Matrix>): Matrix;
  72023. /**
  72024. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72025. * @param other defines the matrix to add
  72026. * @param result defines the target matrix
  72027. * @returns the current matrix
  72028. */
  72029. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72030. /**
  72031. * Adds in place the given matrix to the current matrix
  72032. * @param other defines the second operand
  72033. * @returns the current updated matrix
  72034. */
  72035. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72036. /**
  72037. * Sets the given matrix to the current inverted Matrix
  72038. * @param other defines the target matrix
  72039. * @returns the unmodified current matrix
  72040. */
  72041. invertToRef(other: Matrix): Matrix;
  72042. /**
  72043. * add a value at the specified position in the current Matrix
  72044. * @param index the index of the value within the matrix. between 0 and 15.
  72045. * @param value the value to be added
  72046. * @returns the current updated matrix
  72047. */
  72048. addAtIndex(index: number, value: number): Matrix;
  72049. /**
  72050. * mutiply the specified position in the current Matrix by a value
  72051. * @param index the index of the value within the matrix. between 0 and 15.
  72052. * @param value the value to be added
  72053. * @returns the current updated matrix
  72054. */
  72055. multiplyAtIndex(index: number, value: number): Matrix;
  72056. /**
  72057. * Inserts the translation vector (using 3 floats) in the current matrix
  72058. * @param x defines the 1st component of the translation
  72059. * @param y defines the 2nd component of the translation
  72060. * @param z defines the 3rd component of the translation
  72061. * @returns the current updated matrix
  72062. */
  72063. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72064. /**
  72065. * Adds the translation vector (using 3 floats) in the current matrix
  72066. * @param x defines the 1st component of the translation
  72067. * @param y defines the 2nd component of the translation
  72068. * @param z defines the 3rd component of the translation
  72069. * @returns the current updated matrix
  72070. */
  72071. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72072. /**
  72073. * Inserts the translation vector in the current matrix
  72074. * @param vector3 defines the translation to insert
  72075. * @returns the current updated matrix
  72076. */
  72077. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72078. /**
  72079. * Gets the translation value of the current matrix
  72080. * @returns a new Vector3 as the extracted translation from the matrix
  72081. */
  72082. getTranslation(): Vector3;
  72083. /**
  72084. * Fill a Vector3 with the extracted translation from the matrix
  72085. * @param result defines the Vector3 where to store the translation
  72086. * @returns the current matrix
  72087. */
  72088. getTranslationToRef(result: Vector3): Matrix;
  72089. /**
  72090. * Remove rotation and scaling part from the matrix
  72091. * @returns the updated matrix
  72092. */
  72093. removeRotationAndScaling(): Matrix;
  72094. /**
  72095. * Multiply two matrices
  72096. * @param other defines the second operand
  72097. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72098. */
  72099. multiply(other: DeepImmutable<Matrix>): Matrix;
  72100. /**
  72101. * Copy the current matrix from the given one
  72102. * @param other defines the source matrix
  72103. * @returns the current updated matrix
  72104. */
  72105. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72106. /**
  72107. * Populates the given array from the starting index with the current matrix values
  72108. * @param array defines the target array
  72109. * @param offset defines the offset in the target array where to start storing values
  72110. * @returns the current matrix
  72111. */
  72112. copyToArray(array: Float32Array, offset?: number): Matrix;
  72113. /**
  72114. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72115. * @param other defines the second operand
  72116. * @param result defines the matrix where to store the multiplication
  72117. * @returns the current matrix
  72118. */
  72119. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72120. /**
  72121. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72122. * @param other defines the second operand
  72123. * @param result defines the array where to store the multiplication
  72124. * @param offset defines the offset in the target array where to start storing values
  72125. * @returns the current matrix
  72126. */
  72127. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72128. /**
  72129. * Check equality between this matrix and a second one
  72130. * @param value defines the second matrix to compare
  72131. * @returns true is the current matrix and the given one values are strictly equal
  72132. */
  72133. equals(value: DeepImmutable<Matrix>): boolean;
  72134. /**
  72135. * Clone the current matrix
  72136. * @returns a new matrix from the current matrix
  72137. */
  72138. clone(): Matrix;
  72139. /**
  72140. * Returns the name of the current matrix class
  72141. * @returns the string "Matrix"
  72142. */
  72143. getClassName(): string;
  72144. /**
  72145. * Gets the hash code of the current matrix
  72146. * @returns the hash code
  72147. */
  72148. getHashCode(): number;
  72149. /**
  72150. * Decomposes the current Matrix into a translation, rotation and scaling components
  72151. * @param scale defines the scale vector3 given as a reference to update
  72152. * @param rotation defines the rotation quaternion given as a reference to update
  72153. * @param translation defines the translation vector3 given as a reference to update
  72154. * @returns true if operation was successful
  72155. */
  72156. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72157. /**
  72158. * Gets specific row of the matrix
  72159. * @param index defines the number of the row to get
  72160. * @returns the index-th row of the current matrix as a new Vector4
  72161. */
  72162. getRow(index: number): Nullable<Vector4>;
  72163. /**
  72164. * Sets the index-th row of the current matrix to the vector4 values
  72165. * @param index defines the number of the row to set
  72166. * @param row defines the target vector4
  72167. * @returns the updated current matrix
  72168. */
  72169. setRow(index: number, row: Vector4): Matrix;
  72170. /**
  72171. * Compute the transpose of the matrix
  72172. * @returns the new transposed matrix
  72173. */
  72174. transpose(): Matrix;
  72175. /**
  72176. * Compute the transpose of the matrix and store it in a given matrix
  72177. * @param result defines the target matrix
  72178. * @returns the current matrix
  72179. */
  72180. transposeToRef(result: Matrix): Matrix;
  72181. /**
  72182. * Sets the index-th row of the current matrix with the given 4 x float values
  72183. * @param index defines the row index
  72184. * @param x defines the x component to set
  72185. * @param y defines the y component to set
  72186. * @param z defines the z component to set
  72187. * @param w defines the w component to set
  72188. * @returns the updated current matrix
  72189. */
  72190. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72191. /**
  72192. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72193. * @param scale defines the scale factor
  72194. * @returns a new matrix
  72195. */
  72196. scale(scale: number): Matrix;
  72197. /**
  72198. * Scale the current matrix values by a factor to a given result matrix
  72199. * @param scale defines the scale factor
  72200. * @param result defines the matrix to store the result
  72201. * @returns the current matrix
  72202. */
  72203. scaleToRef(scale: number, result: Matrix): Matrix;
  72204. /**
  72205. * Scale the current matrix values by a factor and add the result to a given matrix
  72206. * @param scale defines the scale factor
  72207. * @param result defines the Matrix to store the result
  72208. * @returns the current matrix
  72209. */
  72210. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72211. /**
  72212. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72213. * @param ref matrix to store the result
  72214. */
  72215. toNormalMatrix(ref: Matrix): void;
  72216. /**
  72217. * Gets only rotation part of the current matrix
  72218. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72219. */
  72220. getRotationMatrix(): Matrix;
  72221. /**
  72222. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72223. * @param result defines the target matrix to store data to
  72224. * @returns the current matrix
  72225. */
  72226. getRotationMatrixToRef(result: Matrix): Matrix;
  72227. /**
  72228. * Toggles model matrix from being right handed to left handed in place and vice versa
  72229. */
  72230. toggleModelMatrixHandInPlace(): void;
  72231. /**
  72232. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72233. */
  72234. toggleProjectionMatrixHandInPlace(): void;
  72235. /**
  72236. * Creates a matrix from an array
  72237. * @param array defines the source array
  72238. * @param offset defines an offset in the source array
  72239. * @returns a new Matrix set from the starting index of the given array
  72240. */
  72241. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72242. /**
  72243. * Copy the content of an array into a given matrix
  72244. * @param array defines the source array
  72245. * @param offset defines an offset in the source array
  72246. * @param result defines the target matrix
  72247. */
  72248. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72249. /**
  72250. * Stores an array into a matrix after having multiplied each component by a given factor
  72251. * @param array defines the source array
  72252. * @param offset defines the offset in the source array
  72253. * @param scale defines the scaling factor
  72254. * @param result defines the target matrix
  72255. */
  72256. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72257. /**
  72258. * Gets an identity matrix that must not be updated
  72259. */
  72260. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72261. /**
  72262. * Stores a list of values (16) inside a given matrix
  72263. * @param initialM11 defines 1st value of 1st row
  72264. * @param initialM12 defines 2nd value of 1st row
  72265. * @param initialM13 defines 3rd value of 1st row
  72266. * @param initialM14 defines 4th value of 1st row
  72267. * @param initialM21 defines 1st value of 2nd row
  72268. * @param initialM22 defines 2nd value of 2nd row
  72269. * @param initialM23 defines 3rd value of 2nd row
  72270. * @param initialM24 defines 4th value of 2nd row
  72271. * @param initialM31 defines 1st value of 3rd row
  72272. * @param initialM32 defines 2nd value of 3rd row
  72273. * @param initialM33 defines 3rd value of 3rd row
  72274. * @param initialM34 defines 4th value of 3rd row
  72275. * @param initialM41 defines 1st value of 4th row
  72276. * @param initialM42 defines 2nd value of 4th row
  72277. * @param initialM43 defines 3rd value of 4th row
  72278. * @param initialM44 defines 4th value of 4th row
  72279. * @param result defines the target matrix
  72280. */
  72281. 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;
  72282. /**
  72283. * Creates new matrix from a list of values (16)
  72284. * @param initialM11 defines 1st value of 1st row
  72285. * @param initialM12 defines 2nd value of 1st row
  72286. * @param initialM13 defines 3rd value of 1st row
  72287. * @param initialM14 defines 4th value of 1st row
  72288. * @param initialM21 defines 1st value of 2nd row
  72289. * @param initialM22 defines 2nd value of 2nd row
  72290. * @param initialM23 defines 3rd value of 2nd row
  72291. * @param initialM24 defines 4th value of 2nd row
  72292. * @param initialM31 defines 1st value of 3rd row
  72293. * @param initialM32 defines 2nd value of 3rd row
  72294. * @param initialM33 defines 3rd value of 3rd row
  72295. * @param initialM34 defines 4th value of 3rd row
  72296. * @param initialM41 defines 1st value of 4th row
  72297. * @param initialM42 defines 2nd value of 4th row
  72298. * @param initialM43 defines 3rd value of 4th row
  72299. * @param initialM44 defines 4th value of 4th row
  72300. * @returns the new matrix
  72301. */
  72302. 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;
  72303. /**
  72304. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72305. * @param scale defines the scale vector3
  72306. * @param rotation defines the rotation quaternion
  72307. * @param translation defines the translation vector3
  72308. * @returns a new matrix
  72309. */
  72310. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72311. /**
  72312. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72313. * @param scale defines the scale vector3
  72314. * @param rotation defines the rotation quaternion
  72315. * @param translation defines the translation vector3
  72316. * @param result defines the target matrix
  72317. */
  72318. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72319. /**
  72320. * Creates a new identity matrix
  72321. * @returns a new identity matrix
  72322. */
  72323. static Identity(): Matrix;
  72324. /**
  72325. * Creates a new identity matrix and stores the result in a given matrix
  72326. * @param result defines the target matrix
  72327. */
  72328. static IdentityToRef(result: Matrix): void;
  72329. /**
  72330. * Creates a new zero matrix
  72331. * @returns a new zero matrix
  72332. */
  72333. static Zero(): Matrix;
  72334. /**
  72335. * Creates a new rotation matrix for "angle" radians around the X axis
  72336. * @param angle defines the angle (in radians) to use
  72337. * @return the new matrix
  72338. */
  72339. static RotationX(angle: number): Matrix;
  72340. /**
  72341. * Creates a new matrix as the invert of a given matrix
  72342. * @param source defines the source matrix
  72343. * @returns the new matrix
  72344. */
  72345. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72346. /**
  72347. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72348. * @param angle defines the angle (in radians) to use
  72349. * @param result defines the target matrix
  72350. */
  72351. static RotationXToRef(angle: number, result: Matrix): void;
  72352. /**
  72353. * Creates a new rotation matrix for "angle" radians around the Y axis
  72354. * @param angle defines the angle (in radians) to use
  72355. * @return the new matrix
  72356. */
  72357. static RotationY(angle: number): Matrix;
  72358. /**
  72359. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72360. * @param angle defines the angle (in radians) to use
  72361. * @param result defines the target matrix
  72362. */
  72363. static RotationYToRef(angle: number, result: Matrix): void;
  72364. /**
  72365. * Creates a new rotation matrix for "angle" radians around the Z axis
  72366. * @param angle defines the angle (in radians) to use
  72367. * @return the new matrix
  72368. */
  72369. static RotationZ(angle: number): Matrix;
  72370. /**
  72371. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72372. * @param angle defines the angle (in radians) to use
  72373. * @param result defines the target matrix
  72374. */
  72375. static RotationZToRef(angle: number, result: Matrix): void;
  72376. /**
  72377. * Creates a new rotation matrix for "angle" radians around the given axis
  72378. * @param axis defines the axis to use
  72379. * @param angle defines the angle (in radians) to use
  72380. * @return the new matrix
  72381. */
  72382. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72383. /**
  72384. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72385. * @param axis defines the axis to use
  72386. * @param angle defines the angle (in radians) to use
  72387. * @param result defines the target matrix
  72388. */
  72389. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72390. /**
  72391. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72392. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72393. * @param from defines the vector to align
  72394. * @param to defines the vector to align to
  72395. * @param result defines the target matrix
  72396. */
  72397. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72398. /**
  72399. * Creates a rotation matrix
  72400. * @param yaw defines the yaw angle in radians (Y axis)
  72401. * @param pitch defines the pitch angle in radians (X axis)
  72402. * @param roll defines the roll angle in radians (X axis)
  72403. * @returns the new rotation matrix
  72404. */
  72405. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72406. /**
  72407. * Creates a rotation matrix and stores it in a given matrix
  72408. * @param yaw defines the yaw angle in radians (Y axis)
  72409. * @param pitch defines the pitch angle in radians (X axis)
  72410. * @param roll defines the roll angle in radians (X axis)
  72411. * @param result defines the target matrix
  72412. */
  72413. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72414. /**
  72415. * Creates a scaling matrix
  72416. * @param x defines the scale factor on X axis
  72417. * @param y defines the scale factor on Y axis
  72418. * @param z defines the scale factor on Z axis
  72419. * @returns the new matrix
  72420. */
  72421. static Scaling(x: number, y: number, z: number): Matrix;
  72422. /**
  72423. * Creates a scaling matrix and stores it in a given matrix
  72424. * @param x defines the scale factor on X axis
  72425. * @param y defines the scale factor on Y axis
  72426. * @param z defines the scale factor on Z axis
  72427. * @param result defines the target matrix
  72428. */
  72429. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72430. /**
  72431. * Creates a translation matrix
  72432. * @param x defines the translation on X axis
  72433. * @param y defines the translation on Y axis
  72434. * @param z defines the translationon Z axis
  72435. * @returns the new matrix
  72436. */
  72437. static Translation(x: number, y: number, z: number): Matrix;
  72438. /**
  72439. * Creates a translation matrix and stores it in a given matrix
  72440. * @param x defines the translation on X axis
  72441. * @param y defines the translation on Y axis
  72442. * @param z defines the translationon Z axis
  72443. * @param result defines the target matrix
  72444. */
  72445. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72446. /**
  72447. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72448. * @param startValue defines the start value
  72449. * @param endValue defines the end value
  72450. * @param gradient defines the gradient factor
  72451. * @returns the new matrix
  72452. */
  72453. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72454. /**
  72455. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72456. * @param startValue defines the start value
  72457. * @param endValue defines the end value
  72458. * @param gradient defines the gradient factor
  72459. * @param result defines the Matrix object where to store data
  72460. */
  72461. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72462. /**
  72463. * Builds a new matrix whose values are computed by:
  72464. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72465. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72466. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72467. * @param startValue defines the first matrix
  72468. * @param endValue defines the second matrix
  72469. * @param gradient defines the gradient between the two matrices
  72470. * @returns the new matrix
  72471. */
  72472. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72473. /**
  72474. * Update a matrix to values which are computed by:
  72475. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72476. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72477. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72478. * @param startValue defines the first matrix
  72479. * @param endValue defines the second matrix
  72480. * @param gradient defines the gradient between the two matrices
  72481. * @param result defines the target matrix
  72482. */
  72483. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72484. /**
  72485. * 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"
  72486. * This function works in left handed mode
  72487. * @param eye defines the final position of the entity
  72488. * @param target defines where the entity should look at
  72489. * @param up defines the up vector for the entity
  72490. * @returns the new matrix
  72491. */
  72492. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72493. /**
  72494. * 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".
  72495. * This function works in left handed mode
  72496. * @param eye defines the final position of the entity
  72497. * @param target defines where the entity should look at
  72498. * @param up defines the up vector for the entity
  72499. * @param result defines the target matrix
  72500. */
  72501. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72502. /**
  72503. * 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"
  72504. * This function works in right handed mode
  72505. * @param eye defines the final position of the entity
  72506. * @param target defines where the entity should look at
  72507. * @param up defines the up vector for the entity
  72508. * @returns the new matrix
  72509. */
  72510. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72511. /**
  72512. * 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".
  72513. * This function works in right handed mode
  72514. * @param eye defines the final position of the entity
  72515. * @param target defines where the entity should look at
  72516. * @param up defines the up vector for the entity
  72517. * @param result defines the target matrix
  72518. */
  72519. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72520. /**
  72521. * Create a left-handed orthographic projection matrix
  72522. * @param width defines the viewport width
  72523. * @param height defines the viewport height
  72524. * @param znear defines the near clip plane
  72525. * @param zfar defines the far clip plane
  72526. * @returns a new matrix as a left-handed orthographic projection matrix
  72527. */
  72528. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72529. /**
  72530. * Store a left-handed orthographic projection to a given matrix
  72531. * @param width defines the viewport width
  72532. * @param height defines the viewport height
  72533. * @param znear defines the near clip plane
  72534. * @param zfar defines the far clip plane
  72535. * @param result defines the target matrix
  72536. */
  72537. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72538. /**
  72539. * Create a left-handed orthographic projection matrix
  72540. * @param left defines the viewport left coordinate
  72541. * @param right defines the viewport right coordinate
  72542. * @param bottom defines the viewport bottom coordinate
  72543. * @param top defines the viewport top coordinate
  72544. * @param znear defines the near clip plane
  72545. * @param zfar defines the far clip plane
  72546. * @returns a new matrix as a left-handed orthographic projection matrix
  72547. */
  72548. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72549. /**
  72550. * Stores a left-handed orthographic projection into a given matrix
  72551. * @param left defines the viewport left coordinate
  72552. * @param right defines the viewport right coordinate
  72553. * @param bottom defines the viewport bottom coordinate
  72554. * @param top defines the viewport top coordinate
  72555. * @param znear defines the near clip plane
  72556. * @param zfar defines the far clip plane
  72557. * @param result defines the target matrix
  72558. */
  72559. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72560. /**
  72561. * Creates a right-handed orthographic projection matrix
  72562. * @param left defines the viewport left coordinate
  72563. * @param right defines the viewport right coordinate
  72564. * @param bottom defines the viewport bottom coordinate
  72565. * @param top defines the viewport top coordinate
  72566. * @param znear defines the near clip plane
  72567. * @param zfar defines the far clip plane
  72568. * @returns a new matrix as a right-handed orthographic projection matrix
  72569. */
  72570. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72571. /**
  72572. * Stores a right-handed orthographic projection into a given matrix
  72573. * @param left defines the viewport left coordinate
  72574. * @param right defines the viewport right coordinate
  72575. * @param bottom defines the viewport bottom coordinate
  72576. * @param top defines the viewport top coordinate
  72577. * @param znear defines the near clip plane
  72578. * @param zfar defines the far clip plane
  72579. * @param result defines the target matrix
  72580. */
  72581. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72582. /**
  72583. * Creates a left-handed perspective projection matrix
  72584. * @param width defines the viewport width
  72585. * @param height defines the viewport height
  72586. * @param znear defines the near clip plane
  72587. * @param zfar defines the far clip plane
  72588. * @returns a new matrix as a left-handed perspective projection matrix
  72589. */
  72590. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72591. /**
  72592. * Creates a left-handed perspective projection matrix
  72593. * @param fov defines the horizontal field of view
  72594. * @param aspect defines the aspect ratio
  72595. * @param znear defines the near clip plane
  72596. * @param zfar defines the far clip plane
  72597. * @returns a new matrix as a left-handed perspective projection matrix
  72598. */
  72599. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72600. /**
  72601. * Stores a left-handed perspective projection into a given matrix
  72602. * @param fov defines the horizontal field of view
  72603. * @param aspect defines the aspect ratio
  72604. * @param znear defines the near clip plane
  72605. * @param zfar defines the far clip plane
  72606. * @param result defines the target matrix
  72607. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72608. */
  72609. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72610. /**
  72611. * Creates a right-handed perspective projection matrix
  72612. * @param fov defines the horizontal field of view
  72613. * @param aspect defines the aspect ratio
  72614. * @param znear defines the near clip plane
  72615. * @param zfar defines the far clip plane
  72616. * @returns a new matrix as a right-handed perspective projection matrix
  72617. */
  72618. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72619. /**
  72620. * Stores a right-handed perspective projection into a given matrix
  72621. * @param fov defines the horizontal field of view
  72622. * @param aspect defines the aspect ratio
  72623. * @param znear defines the near clip plane
  72624. * @param zfar defines the far clip plane
  72625. * @param result defines the target matrix
  72626. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72627. */
  72628. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72629. /**
  72630. * Stores a perspective projection for WebVR info a given matrix
  72631. * @param fov defines the field of view
  72632. * @param znear defines the near clip plane
  72633. * @param zfar defines the far clip plane
  72634. * @param result defines the target matrix
  72635. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72636. */
  72637. static PerspectiveFovWebVRToRef(fov: {
  72638. upDegrees: number;
  72639. downDegrees: number;
  72640. leftDegrees: number;
  72641. rightDegrees: number;
  72642. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72643. /**
  72644. * Computes a complete transformation matrix
  72645. * @param viewport defines the viewport to use
  72646. * @param world defines the world matrix
  72647. * @param view defines the view matrix
  72648. * @param projection defines the projection matrix
  72649. * @param zmin defines the near clip plane
  72650. * @param zmax defines the far clip plane
  72651. * @returns the transformation matrix
  72652. */
  72653. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72654. /**
  72655. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72656. * @param matrix defines the matrix to use
  72657. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72658. */
  72659. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72660. /**
  72661. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72662. * @param matrix defines the matrix to use
  72663. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72664. */
  72665. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72666. /**
  72667. * Compute the transpose of a given matrix
  72668. * @param matrix defines the matrix to transpose
  72669. * @returns the new matrix
  72670. */
  72671. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72672. /**
  72673. * Compute the transpose of a matrix and store it in a target matrix
  72674. * @param matrix defines the matrix to transpose
  72675. * @param result defines the target matrix
  72676. */
  72677. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72678. /**
  72679. * Computes a reflection matrix from a plane
  72680. * @param plane defines the reflection plane
  72681. * @returns a new matrix
  72682. */
  72683. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72684. /**
  72685. * Computes a reflection matrix from a plane
  72686. * @param plane defines the reflection plane
  72687. * @param result defines the target matrix
  72688. */
  72689. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72690. /**
  72691. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72692. * @param xaxis defines the value of the 1st axis
  72693. * @param yaxis defines the value of the 2nd axis
  72694. * @param zaxis defines the value of the 3rd axis
  72695. * @param result defines the target matrix
  72696. */
  72697. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72698. /**
  72699. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72700. * @param quat defines the quaternion to use
  72701. * @param result defines the target matrix
  72702. */
  72703. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72704. }
  72705. /**
  72706. * @hidden
  72707. */
  72708. export class TmpVectors {
  72709. static Vector2: Vector2[];
  72710. static Vector3: Vector3[];
  72711. static Vector4: Vector4[];
  72712. static Quaternion: Quaternion[];
  72713. static Matrix: Matrix[];
  72714. }
  72715. }
  72716. declare module BABYLON {
  72717. /**
  72718. * Defines potential orientation for back face culling
  72719. */
  72720. export enum Orientation {
  72721. /**
  72722. * Clockwise
  72723. */
  72724. CW = 0,
  72725. /** Counter clockwise */
  72726. CCW = 1
  72727. }
  72728. /** Class used to represent a Bezier curve */
  72729. export class BezierCurve {
  72730. /**
  72731. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72732. * @param t defines the time
  72733. * @param x1 defines the left coordinate on X axis
  72734. * @param y1 defines the left coordinate on Y axis
  72735. * @param x2 defines the right coordinate on X axis
  72736. * @param y2 defines the right coordinate on Y axis
  72737. * @returns the interpolated value
  72738. */
  72739. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72740. }
  72741. /**
  72742. * Defines angle representation
  72743. */
  72744. export class Angle {
  72745. private _radians;
  72746. /**
  72747. * Creates an Angle object of "radians" radians (float).
  72748. * @param radians the angle in radians
  72749. */
  72750. constructor(radians: number);
  72751. /**
  72752. * Get value in degrees
  72753. * @returns the Angle value in degrees (float)
  72754. */
  72755. degrees(): number;
  72756. /**
  72757. * Get value in radians
  72758. * @returns the Angle value in radians (float)
  72759. */
  72760. radians(): number;
  72761. /**
  72762. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72763. * @param a defines first vector
  72764. * @param b defines second vector
  72765. * @returns a new Angle
  72766. */
  72767. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72768. /**
  72769. * Gets a new Angle object from the given float in radians
  72770. * @param radians defines the angle value in radians
  72771. * @returns a new Angle
  72772. */
  72773. static FromRadians(radians: number): Angle;
  72774. /**
  72775. * Gets a new Angle object from the given float in degrees
  72776. * @param degrees defines the angle value in degrees
  72777. * @returns a new Angle
  72778. */
  72779. static FromDegrees(degrees: number): Angle;
  72780. }
  72781. /**
  72782. * This represents an arc in a 2d space.
  72783. */
  72784. export class Arc2 {
  72785. /** Defines the start point of the arc */
  72786. startPoint: Vector2;
  72787. /** Defines the mid point of the arc */
  72788. midPoint: Vector2;
  72789. /** Defines the end point of the arc */
  72790. endPoint: Vector2;
  72791. /**
  72792. * Defines the center point of the arc.
  72793. */
  72794. centerPoint: Vector2;
  72795. /**
  72796. * Defines the radius of the arc.
  72797. */
  72798. radius: number;
  72799. /**
  72800. * Defines the angle of the arc (from mid point to end point).
  72801. */
  72802. angle: Angle;
  72803. /**
  72804. * Defines the start angle of the arc (from start point to middle point).
  72805. */
  72806. startAngle: Angle;
  72807. /**
  72808. * Defines the orientation of the arc (clock wise/counter clock wise).
  72809. */
  72810. orientation: Orientation;
  72811. /**
  72812. * Creates an Arc object from the three given points : start, middle and end.
  72813. * @param startPoint Defines the start point of the arc
  72814. * @param midPoint Defines the midlle point of the arc
  72815. * @param endPoint Defines the end point of the arc
  72816. */
  72817. constructor(
  72818. /** Defines the start point of the arc */
  72819. startPoint: Vector2,
  72820. /** Defines the mid point of the arc */
  72821. midPoint: Vector2,
  72822. /** Defines the end point of the arc */
  72823. endPoint: Vector2);
  72824. }
  72825. /**
  72826. * Represents a 2D path made up of multiple 2D points
  72827. */
  72828. export class Path2 {
  72829. private _points;
  72830. private _length;
  72831. /**
  72832. * If the path start and end point are the same
  72833. */
  72834. closed: boolean;
  72835. /**
  72836. * Creates a Path2 object from the starting 2D coordinates x and y.
  72837. * @param x the starting points x value
  72838. * @param y the starting points y value
  72839. */
  72840. constructor(x: number, y: number);
  72841. /**
  72842. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72843. * @param x the added points x value
  72844. * @param y the added points y value
  72845. * @returns the updated Path2.
  72846. */
  72847. addLineTo(x: number, y: number): Path2;
  72848. /**
  72849. * 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.
  72850. * @param midX middle point x value
  72851. * @param midY middle point y value
  72852. * @param endX end point x value
  72853. * @param endY end point y value
  72854. * @param numberOfSegments (default: 36)
  72855. * @returns the updated Path2.
  72856. */
  72857. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72858. /**
  72859. * Closes the Path2.
  72860. * @returns the Path2.
  72861. */
  72862. close(): Path2;
  72863. /**
  72864. * Gets the sum of the distance between each sequential point in the path
  72865. * @returns the Path2 total length (float).
  72866. */
  72867. length(): number;
  72868. /**
  72869. * Gets the points which construct the path
  72870. * @returns the Path2 internal array of points.
  72871. */
  72872. getPoints(): Vector2[];
  72873. /**
  72874. * Retreives the point at the distance aways from the starting point
  72875. * @param normalizedLengthPosition the length along the path to retreive the point from
  72876. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72877. */
  72878. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72879. /**
  72880. * Creates a new path starting from an x and y position
  72881. * @param x starting x value
  72882. * @param y starting y value
  72883. * @returns a new Path2 starting at the coordinates (x, y).
  72884. */
  72885. static StartingAt(x: number, y: number): Path2;
  72886. }
  72887. /**
  72888. * Represents a 3D path made up of multiple 3D points
  72889. */
  72890. export class Path3D {
  72891. /**
  72892. * an array of Vector3, the curve axis of the Path3D
  72893. */
  72894. path: Vector3[];
  72895. private _curve;
  72896. private _distances;
  72897. private _tangents;
  72898. private _normals;
  72899. private _binormals;
  72900. private _raw;
  72901. private _alignTangentsWithPath;
  72902. private readonly _pointAtData;
  72903. /**
  72904. * new Path3D(path, normal, raw)
  72905. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72906. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72907. * @param path an array of Vector3, the curve axis of the Path3D
  72908. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72909. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72910. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  72911. */
  72912. constructor(
  72913. /**
  72914. * an array of Vector3, the curve axis of the Path3D
  72915. */
  72916. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  72917. /**
  72918. * Returns the Path3D array of successive Vector3 designing its curve.
  72919. * @returns the Path3D array of successive Vector3 designing its curve.
  72920. */
  72921. getCurve(): Vector3[];
  72922. /**
  72923. * Returns the Path3D array of successive Vector3 designing its curve.
  72924. * @returns the Path3D array of successive Vector3 designing its curve.
  72925. */
  72926. getPoints(): Vector3[];
  72927. /**
  72928. * @returns the computed length (float) of the path.
  72929. */
  72930. length(): number;
  72931. /**
  72932. * Returns an array populated with tangent vectors on each Path3D curve point.
  72933. * @returns an array populated with tangent vectors on each Path3D curve point.
  72934. */
  72935. getTangents(): Vector3[];
  72936. /**
  72937. * Returns an array populated with normal vectors on each Path3D curve point.
  72938. * @returns an array populated with normal vectors on each Path3D curve point.
  72939. */
  72940. getNormals(): Vector3[];
  72941. /**
  72942. * Returns an array populated with binormal vectors on each Path3D curve point.
  72943. * @returns an array populated with binormal vectors on each Path3D curve point.
  72944. */
  72945. getBinormals(): Vector3[];
  72946. /**
  72947. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72948. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72949. */
  72950. getDistances(): number[];
  72951. /**
  72952. * Returns an interpolated point along this path
  72953. * @param position the position of the point along this path, from 0.0 to 1.0
  72954. * @returns a new Vector3 as the point
  72955. */
  72956. getPointAt(position: number): Vector3;
  72957. /**
  72958. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  72959. * @param position the position of the point along this path, from 0.0 to 1.0
  72960. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  72961. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  72962. */
  72963. getTangentAt(position: number, interpolated?: boolean): Vector3;
  72964. /**
  72965. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  72966. * @param position the position of the point along this path, from 0.0 to 1.0
  72967. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  72968. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  72969. */
  72970. getNormalAt(position: number, interpolated?: boolean): Vector3;
  72971. /**
  72972. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  72973. * @param position the position of the point along this path, from 0.0 to 1.0
  72974. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  72975. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  72976. */
  72977. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  72978. /**
  72979. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  72980. * @param position the position of the point along this path, from 0.0 to 1.0
  72981. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  72982. */
  72983. getDistanceAt(position: number): number;
  72984. /**
  72985. * Returns the array index of the previous point of an interpolated point along this path
  72986. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  72987. * @returns the array index
  72988. */
  72989. getPreviousPointIndexAt(position: number): number;
  72990. /**
  72991. * 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)
  72992. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  72993. * @returns the sub position
  72994. */
  72995. getSubPositionAt(position: number): number;
  72996. /**
  72997. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  72998. * @param target the vector of which to get the closest position to
  72999. * @returns the position of the closest virtual point on this path to the target vector
  73000. */
  73001. getClosestPositionTo(target: Vector3): number;
  73002. /**
  73003. * Returns a sub path (slice) of this path
  73004. * @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
  73005. * @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
  73006. * @returns a sub path (slice) of this path
  73007. */
  73008. slice(start?: number, end?: number): Path3D;
  73009. /**
  73010. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73011. * @param path path which all values are copied into the curves points
  73012. * @param firstNormal which should be projected onto the curve
  73013. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73014. * @returns the same object updated.
  73015. */
  73016. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73017. private _compute;
  73018. private _getFirstNonNullVector;
  73019. private _getLastNonNullVector;
  73020. private _normalVector;
  73021. /**
  73022. * Updates the point at data for an interpolated point along this curve
  73023. * @param position the position of the point along this curve, from 0.0 to 1.0
  73024. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73025. * @returns the (updated) point at data
  73026. */
  73027. private _updatePointAtData;
  73028. /**
  73029. * Updates the point at data from the specified parameters
  73030. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73031. * @param point the interpolated point
  73032. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73033. */
  73034. private _setPointAtData;
  73035. /**
  73036. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73037. */
  73038. private _updateInterpolationMatrix;
  73039. }
  73040. /**
  73041. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73042. * A Curve3 is designed from a series of successive Vector3.
  73043. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73044. */
  73045. export class Curve3 {
  73046. private _points;
  73047. private _length;
  73048. /**
  73049. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73050. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73051. * @param v1 (Vector3) the control point
  73052. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73053. * @param nbPoints (integer) the wanted number of points in the curve
  73054. * @returns the created Curve3
  73055. */
  73056. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73057. /**
  73058. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73059. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73060. * @param v1 (Vector3) the first control point
  73061. * @param v2 (Vector3) the second control point
  73062. * @param v3 (Vector3) the end point of the Cubic Bezier
  73063. * @param nbPoints (integer) the wanted number of points in the curve
  73064. * @returns the created Curve3
  73065. */
  73066. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73067. /**
  73068. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73069. * @param p1 (Vector3) the origin point of the Hermite Spline
  73070. * @param t1 (Vector3) the tangent vector at the origin point
  73071. * @param p2 (Vector3) the end point of the Hermite Spline
  73072. * @param t2 (Vector3) the tangent vector at the end point
  73073. * @param nbPoints (integer) the wanted number of points in the curve
  73074. * @returns the created Curve3
  73075. */
  73076. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73077. /**
  73078. * Returns a Curve3 object along a CatmullRom Spline curve :
  73079. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73080. * @param nbPoints (integer) the wanted number of points between each curve control points
  73081. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73082. * @returns the created Curve3
  73083. */
  73084. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73085. /**
  73086. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73087. * A Curve3 is designed from a series of successive Vector3.
  73088. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73089. * @param points points which make up the curve
  73090. */
  73091. constructor(points: Vector3[]);
  73092. /**
  73093. * @returns the Curve3 stored array of successive Vector3
  73094. */
  73095. getPoints(): Vector3[];
  73096. /**
  73097. * @returns the computed length (float) of the curve.
  73098. */
  73099. length(): number;
  73100. /**
  73101. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73102. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73103. * curveA and curveB keep unchanged.
  73104. * @param curve the curve to continue from this curve
  73105. * @returns the newly constructed curve
  73106. */
  73107. continue(curve: DeepImmutable<Curve3>): Curve3;
  73108. private _computeLength;
  73109. }
  73110. }
  73111. declare module BABYLON {
  73112. /**
  73113. * This represents the main contract an easing function should follow.
  73114. * Easing functions are used throughout the animation system.
  73115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73116. */
  73117. export interface IEasingFunction {
  73118. /**
  73119. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73120. * of the easing function.
  73121. * The link below provides some of the most common examples of easing functions.
  73122. * @see https://easings.net/
  73123. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73124. * @returns the corresponding value on the curve defined by the easing function
  73125. */
  73126. ease(gradient: number): number;
  73127. }
  73128. /**
  73129. * Base class used for every default easing function.
  73130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73131. */
  73132. export class EasingFunction implements IEasingFunction {
  73133. /**
  73134. * Interpolation follows the mathematical formula associated with the easing function.
  73135. */
  73136. static readonly EASINGMODE_EASEIN: number;
  73137. /**
  73138. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73139. */
  73140. static readonly EASINGMODE_EASEOUT: number;
  73141. /**
  73142. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73143. */
  73144. static readonly EASINGMODE_EASEINOUT: number;
  73145. private _easingMode;
  73146. /**
  73147. * Sets the easing mode of the current function.
  73148. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73149. */
  73150. setEasingMode(easingMode: number): void;
  73151. /**
  73152. * Gets the current easing mode.
  73153. * @returns the easing mode
  73154. */
  73155. getEasingMode(): number;
  73156. /**
  73157. * @hidden
  73158. */
  73159. easeInCore(gradient: number): number;
  73160. /**
  73161. * Given an input gradient between 0 and 1, this returns the corresponding value
  73162. * of the easing function.
  73163. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73164. * @returns the corresponding value on the curve defined by the easing function
  73165. */
  73166. ease(gradient: number): number;
  73167. }
  73168. /**
  73169. * Easing function with a circle shape (see link below).
  73170. * @see https://easings.net/#easeInCirc
  73171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73172. */
  73173. export class CircleEase extends EasingFunction implements IEasingFunction {
  73174. /** @hidden */
  73175. easeInCore(gradient: number): number;
  73176. }
  73177. /**
  73178. * Easing function with a ease back shape (see link below).
  73179. * @see https://easings.net/#easeInBack
  73180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73181. */
  73182. export class BackEase extends EasingFunction implements IEasingFunction {
  73183. /** Defines the amplitude of the function */
  73184. amplitude: number;
  73185. /**
  73186. * Instantiates a back ease easing
  73187. * @see https://easings.net/#easeInBack
  73188. * @param amplitude Defines the amplitude of the function
  73189. */
  73190. constructor(
  73191. /** Defines the amplitude of the function */
  73192. amplitude?: number);
  73193. /** @hidden */
  73194. easeInCore(gradient: number): number;
  73195. }
  73196. /**
  73197. * Easing function with a bouncing shape (see link below).
  73198. * @see https://easings.net/#easeInBounce
  73199. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73200. */
  73201. export class BounceEase extends EasingFunction implements IEasingFunction {
  73202. /** Defines the number of bounces */
  73203. bounces: number;
  73204. /** Defines the amplitude of the bounce */
  73205. bounciness: number;
  73206. /**
  73207. * Instantiates a bounce easing
  73208. * @see https://easings.net/#easeInBounce
  73209. * @param bounces Defines the number of bounces
  73210. * @param bounciness Defines the amplitude of the bounce
  73211. */
  73212. constructor(
  73213. /** Defines the number of bounces */
  73214. bounces?: number,
  73215. /** Defines the amplitude of the bounce */
  73216. bounciness?: number);
  73217. /** @hidden */
  73218. easeInCore(gradient: number): number;
  73219. }
  73220. /**
  73221. * Easing function with a power of 3 shape (see link below).
  73222. * @see https://easings.net/#easeInCubic
  73223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73224. */
  73225. export class CubicEase extends EasingFunction implements IEasingFunction {
  73226. /** @hidden */
  73227. easeInCore(gradient: number): number;
  73228. }
  73229. /**
  73230. * Easing function with an elastic shape (see link below).
  73231. * @see https://easings.net/#easeInElastic
  73232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73233. */
  73234. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73235. /** Defines the number of oscillations*/
  73236. oscillations: number;
  73237. /** Defines the amplitude of the oscillations*/
  73238. springiness: number;
  73239. /**
  73240. * Instantiates an elastic easing function
  73241. * @see https://easings.net/#easeInElastic
  73242. * @param oscillations Defines the number of oscillations
  73243. * @param springiness Defines the amplitude of the oscillations
  73244. */
  73245. constructor(
  73246. /** Defines the number of oscillations*/
  73247. oscillations?: number,
  73248. /** Defines the amplitude of the oscillations*/
  73249. springiness?: number);
  73250. /** @hidden */
  73251. easeInCore(gradient: number): number;
  73252. }
  73253. /**
  73254. * Easing function with an exponential shape (see link below).
  73255. * @see https://easings.net/#easeInExpo
  73256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73257. */
  73258. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73259. /** Defines the exponent of the function */
  73260. exponent: number;
  73261. /**
  73262. * Instantiates an exponential easing function
  73263. * @see https://easings.net/#easeInExpo
  73264. * @param exponent Defines the exponent of the function
  73265. */
  73266. constructor(
  73267. /** Defines the exponent of the function */
  73268. exponent?: number);
  73269. /** @hidden */
  73270. easeInCore(gradient: number): number;
  73271. }
  73272. /**
  73273. * Easing function with a power shape (see link below).
  73274. * @see https://easings.net/#easeInQuad
  73275. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73276. */
  73277. export class PowerEase extends EasingFunction implements IEasingFunction {
  73278. /** Defines the power of the function */
  73279. power: number;
  73280. /**
  73281. * Instantiates an power base easing function
  73282. * @see https://easings.net/#easeInQuad
  73283. * @param power Defines the power of the function
  73284. */
  73285. constructor(
  73286. /** Defines the power of the function */
  73287. power?: number);
  73288. /** @hidden */
  73289. easeInCore(gradient: number): number;
  73290. }
  73291. /**
  73292. * Easing function with a power of 2 shape (see link below).
  73293. * @see https://easings.net/#easeInQuad
  73294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73295. */
  73296. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73297. /** @hidden */
  73298. easeInCore(gradient: number): number;
  73299. }
  73300. /**
  73301. * Easing function with a power of 4 shape (see link below).
  73302. * @see https://easings.net/#easeInQuart
  73303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73304. */
  73305. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73306. /** @hidden */
  73307. easeInCore(gradient: number): number;
  73308. }
  73309. /**
  73310. * Easing function with a power of 5 shape (see link below).
  73311. * @see https://easings.net/#easeInQuint
  73312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73313. */
  73314. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73315. /** @hidden */
  73316. easeInCore(gradient: number): number;
  73317. }
  73318. /**
  73319. * Easing function with a sin shape (see link below).
  73320. * @see https://easings.net/#easeInSine
  73321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73322. */
  73323. export class SineEase extends EasingFunction implements IEasingFunction {
  73324. /** @hidden */
  73325. easeInCore(gradient: number): number;
  73326. }
  73327. /**
  73328. * Easing function with a bezier shape (see link below).
  73329. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73330. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73331. */
  73332. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73333. /** Defines the x component of the start tangent in the bezier curve */
  73334. x1: number;
  73335. /** Defines the y component of the start tangent in the bezier curve */
  73336. y1: number;
  73337. /** Defines the x component of the end tangent in the bezier curve */
  73338. x2: number;
  73339. /** Defines the y component of the end tangent in the bezier curve */
  73340. y2: number;
  73341. /**
  73342. * Instantiates a bezier function
  73343. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73344. * @param x1 Defines the x component of the start tangent in the bezier curve
  73345. * @param y1 Defines the y component of the start tangent in the bezier curve
  73346. * @param x2 Defines the x component of the end tangent in the bezier curve
  73347. * @param y2 Defines the y component of the end tangent in the bezier curve
  73348. */
  73349. constructor(
  73350. /** Defines the x component of the start tangent in the bezier curve */
  73351. x1?: number,
  73352. /** Defines the y component of the start tangent in the bezier curve */
  73353. y1?: number,
  73354. /** Defines the x component of the end tangent in the bezier curve */
  73355. x2?: number,
  73356. /** Defines the y component of the end tangent in the bezier curve */
  73357. y2?: number);
  73358. /** @hidden */
  73359. easeInCore(gradient: number): number;
  73360. }
  73361. }
  73362. declare module BABYLON {
  73363. /**
  73364. * Class used to hold a RBG color
  73365. */
  73366. export class Color3 {
  73367. /**
  73368. * Defines the red component (between 0 and 1, default is 0)
  73369. */
  73370. r: number;
  73371. /**
  73372. * Defines the green component (between 0 and 1, default is 0)
  73373. */
  73374. g: number;
  73375. /**
  73376. * Defines the blue component (between 0 and 1, default is 0)
  73377. */
  73378. b: number;
  73379. /**
  73380. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73381. * @param r defines the red component (between 0 and 1, default is 0)
  73382. * @param g defines the green component (between 0 and 1, default is 0)
  73383. * @param b defines the blue component (between 0 and 1, default is 0)
  73384. */
  73385. constructor(
  73386. /**
  73387. * Defines the red component (between 0 and 1, default is 0)
  73388. */
  73389. r?: number,
  73390. /**
  73391. * Defines the green component (between 0 and 1, default is 0)
  73392. */
  73393. g?: number,
  73394. /**
  73395. * Defines the blue component (between 0 and 1, default is 0)
  73396. */
  73397. b?: number);
  73398. /**
  73399. * Creates a string with the Color3 current values
  73400. * @returns the string representation of the Color3 object
  73401. */
  73402. toString(): string;
  73403. /**
  73404. * Returns the string "Color3"
  73405. * @returns "Color3"
  73406. */
  73407. getClassName(): string;
  73408. /**
  73409. * Compute the Color3 hash code
  73410. * @returns an unique number that can be used to hash Color3 objects
  73411. */
  73412. getHashCode(): number;
  73413. /**
  73414. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73415. * @param array defines the array where to store the r,g,b components
  73416. * @param index defines an optional index in the target array to define where to start storing values
  73417. * @returns the current Color3 object
  73418. */
  73419. toArray(array: FloatArray, index?: number): Color3;
  73420. /**
  73421. * Returns a new Color4 object from the current Color3 and the given alpha
  73422. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73423. * @returns a new Color4 object
  73424. */
  73425. toColor4(alpha?: number): Color4;
  73426. /**
  73427. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73428. * @returns the new array
  73429. */
  73430. asArray(): number[];
  73431. /**
  73432. * Returns the luminance value
  73433. * @returns a float value
  73434. */
  73435. toLuminance(): number;
  73436. /**
  73437. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73438. * @param otherColor defines the second operand
  73439. * @returns the new Color3 object
  73440. */
  73441. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73442. /**
  73443. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73444. * @param otherColor defines the second operand
  73445. * @param result defines the Color3 object where to store the result
  73446. * @returns the current Color3
  73447. */
  73448. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73449. /**
  73450. * Determines equality between Color3 objects
  73451. * @param otherColor defines the second operand
  73452. * @returns true if the rgb values are equal to the given ones
  73453. */
  73454. equals(otherColor: DeepImmutable<Color3>): boolean;
  73455. /**
  73456. * Determines equality between the current Color3 object and a set of r,b,g values
  73457. * @param r defines the red component to check
  73458. * @param g defines the green component to check
  73459. * @param b defines the blue component to check
  73460. * @returns true if the rgb values are equal to the given ones
  73461. */
  73462. equalsFloats(r: number, g: number, b: number): boolean;
  73463. /**
  73464. * Multiplies in place each rgb value by scale
  73465. * @param scale defines the scaling factor
  73466. * @returns the updated Color3
  73467. */
  73468. scale(scale: number): Color3;
  73469. /**
  73470. * Multiplies the rgb values by scale and stores the result into "result"
  73471. * @param scale defines the scaling factor
  73472. * @param result defines the Color3 object where to store the result
  73473. * @returns the unmodified current Color3
  73474. */
  73475. scaleToRef(scale: number, result: Color3): Color3;
  73476. /**
  73477. * Scale the current Color3 values by a factor and add the result to a given Color3
  73478. * @param scale defines the scale factor
  73479. * @param result defines color to store the result into
  73480. * @returns the unmodified current Color3
  73481. */
  73482. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73483. /**
  73484. * Clamps the rgb values by the min and max values and stores the result into "result"
  73485. * @param min defines minimum clamping value (default is 0)
  73486. * @param max defines maximum clamping value (default is 1)
  73487. * @param result defines color to store the result into
  73488. * @returns the original Color3
  73489. */
  73490. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73491. /**
  73492. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73493. * @param otherColor defines the second operand
  73494. * @returns the new Color3
  73495. */
  73496. add(otherColor: DeepImmutable<Color3>): Color3;
  73497. /**
  73498. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73499. * @param otherColor defines the second operand
  73500. * @param result defines Color3 object to store the result into
  73501. * @returns the unmodified current Color3
  73502. */
  73503. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73504. /**
  73505. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73506. * @param otherColor defines the second operand
  73507. * @returns the new Color3
  73508. */
  73509. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73510. /**
  73511. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73512. * @param otherColor defines the second operand
  73513. * @param result defines Color3 object to store the result into
  73514. * @returns the unmodified current Color3
  73515. */
  73516. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73517. /**
  73518. * Copy the current object
  73519. * @returns a new Color3 copied the current one
  73520. */
  73521. clone(): Color3;
  73522. /**
  73523. * Copies the rgb values from the source in the current Color3
  73524. * @param source defines the source Color3 object
  73525. * @returns the updated Color3 object
  73526. */
  73527. copyFrom(source: DeepImmutable<Color3>): Color3;
  73528. /**
  73529. * Updates the Color3 rgb values from the given floats
  73530. * @param r defines the red component to read from
  73531. * @param g defines the green component to read from
  73532. * @param b defines the blue component to read from
  73533. * @returns the current Color3 object
  73534. */
  73535. copyFromFloats(r: number, g: number, b: number): Color3;
  73536. /**
  73537. * Updates the Color3 rgb values from the given floats
  73538. * @param r defines the red component to read from
  73539. * @param g defines the green component to read from
  73540. * @param b defines the blue component to read from
  73541. * @returns the current Color3 object
  73542. */
  73543. set(r: number, g: number, b: number): Color3;
  73544. /**
  73545. * Compute the Color3 hexadecimal code as a string
  73546. * @returns a string containing the hexadecimal representation of the Color3 object
  73547. */
  73548. toHexString(): string;
  73549. /**
  73550. * Computes a new Color3 converted from the current one to linear space
  73551. * @returns a new Color3 object
  73552. */
  73553. toLinearSpace(): Color3;
  73554. /**
  73555. * Converts current color in rgb space to HSV values
  73556. * @returns a new color3 representing the HSV values
  73557. */
  73558. toHSV(): Color3;
  73559. /**
  73560. * Converts current color in rgb space to HSV values
  73561. * @param result defines the Color3 where to store the HSV values
  73562. */
  73563. toHSVToRef(result: Color3): void;
  73564. /**
  73565. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73566. * @param convertedColor defines the Color3 object where to store the linear space version
  73567. * @returns the unmodified Color3
  73568. */
  73569. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73570. /**
  73571. * Computes a new Color3 converted from the current one to gamma space
  73572. * @returns a new Color3 object
  73573. */
  73574. toGammaSpace(): Color3;
  73575. /**
  73576. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73577. * @param convertedColor defines the Color3 object where to store the gamma space version
  73578. * @returns the unmodified Color3
  73579. */
  73580. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73581. private static _BlackReadOnly;
  73582. /**
  73583. * Convert Hue, saturation and value to a Color3 (RGB)
  73584. * @param hue defines the hue
  73585. * @param saturation defines the saturation
  73586. * @param value defines the value
  73587. * @param result defines the Color3 where to store the RGB values
  73588. */
  73589. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73590. /**
  73591. * Creates a new Color3 from the string containing valid hexadecimal values
  73592. * @param hex defines a string containing valid hexadecimal values
  73593. * @returns a new Color3 object
  73594. */
  73595. static FromHexString(hex: string): Color3;
  73596. /**
  73597. * Creates a new Color3 from the starting index of the given array
  73598. * @param array defines the source array
  73599. * @param offset defines an offset in the source array
  73600. * @returns a new Color3 object
  73601. */
  73602. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73603. /**
  73604. * Creates a new Color3 from integer values (< 256)
  73605. * @param r defines the red component to read from (value between 0 and 255)
  73606. * @param g defines the green component to read from (value between 0 and 255)
  73607. * @param b defines the blue component to read from (value between 0 and 255)
  73608. * @returns a new Color3 object
  73609. */
  73610. static FromInts(r: number, g: number, b: number): Color3;
  73611. /**
  73612. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73613. * @param start defines the start Color3 value
  73614. * @param end defines the end Color3 value
  73615. * @param amount defines the gradient value between start and end
  73616. * @returns a new Color3 object
  73617. */
  73618. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73619. /**
  73620. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73621. * @param left defines the start value
  73622. * @param right defines the end value
  73623. * @param amount defines the gradient factor
  73624. * @param result defines the Color3 object where to store the result
  73625. */
  73626. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73627. /**
  73628. * Returns a Color3 value containing a red color
  73629. * @returns a new Color3 object
  73630. */
  73631. static Red(): Color3;
  73632. /**
  73633. * Returns a Color3 value containing a green color
  73634. * @returns a new Color3 object
  73635. */
  73636. static Green(): Color3;
  73637. /**
  73638. * Returns a Color3 value containing a blue color
  73639. * @returns a new Color3 object
  73640. */
  73641. static Blue(): Color3;
  73642. /**
  73643. * Returns a Color3 value containing a black color
  73644. * @returns a new Color3 object
  73645. */
  73646. static Black(): Color3;
  73647. /**
  73648. * Gets a Color3 value containing a black color that must not be updated
  73649. */
  73650. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73651. /**
  73652. * Returns a Color3 value containing a white color
  73653. * @returns a new Color3 object
  73654. */
  73655. static White(): Color3;
  73656. /**
  73657. * Returns a Color3 value containing a purple color
  73658. * @returns a new Color3 object
  73659. */
  73660. static Purple(): Color3;
  73661. /**
  73662. * Returns a Color3 value containing a magenta color
  73663. * @returns a new Color3 object
  73664. */
  73665. static Magenta(): Color3;
  73666. /**
  73667. * Returns a Color3 value containing a yellow color
  73668. * @returns a new Color3 object
  73669. */
  73670. static Yellow(): Color3;
  73671. /**
  73672. * Returns a Color3 value containing a gray color
  73673. * @returns a new Color3 object
  73674. */
  73675. static Gray(): Color3;
  73676. /**
  73677. * Returns a Color3 value containing a teal color
  73678. * @returns a new Color3 object
  73679. */
  73680. static Teal(): Color3;
  73681. /**
  73682. * Returns a Color3 value containing a random color
  73683. * @returns a new Color3 object
  73684. */
  73685. static Random(): Color3;
  73686. }
  73687. /**
  73688. * Class used to hold a RBGA color
  73689. */
  73690. export class Color4 {
  73691. /**
  73692. * Defines the red component (between 0 and 1, default is 0)
  73693. */
  73694. r: number;
  73695. /**
  73696. * Defines the green component (between 0 and 1, default is 0)
  73697. */
  73698. g: number;
  73699. /**
  73700. * Defines the blue component (between 0 and 1, default is 0)
  73701. */
  73702. b: number;
  73703. /**
  73704. * Defines the alpha component (between 0 and 1, default is 1)
  73705. */
  73706. a: number;
  73707. /**
  73708. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73709. * @param r defines the red component (between 0 and 1, default is 0)
  73710. * @param g defines the green component (between 0 and 1, default is 0)
  73711. * @param b defines the blue component (between 0 and 1, default is 0)
  73712. * @param a defines the alpha component (between 0 and 1, default is 1)
  73713. */
  73714. constructor(
  73715. /**
  73716. * Defines the red component (between 0 and 1, default is 0)
  73717. */
  73718. r?: number,
  73719. /**
  73720. * Defines the green component (between 0 and 1, default is 0)
  73721. */
  73722. g?: number,
  73723. /**
  73724. * Defines the blue component (between 0 and 1, default is 0)
  73725. */
  73726. b?: number,
  73727. /**
  73728. * Defines the alpha component (between 0 and 1, default is 1)
  73729. */
  73730. a?: number);
  73731. /**
  73732. * Adds in place the given Color4 values to the current Color4 object
  73733. * @param right defines the second operand
  73734. * @returns the current updated Color4 object
  73735. */
  73736. addInPlace(right: DeepImmutable<Color4>): Color4;
  73737. /**
  73738. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73739. * @returns the new array
  73740. */
  73741. asArray(): number[];
  73742. /**
  73743. * Stores from the starting index in the given array the Color4 successive values
  73744. * @param array defines the array where to store the r,g,b components
  73745. * @param index defines an optional index in the target array to define where to start storing values
  73746. * @returns the current Color4 object
  73747. */
  73748. toArray(array: number[], index?: number): Color4;
  73749. /**
  73750. * Determines equality between Color4 objects
  73751. * @param otherColor defines the second operand
  73752. * @returns true if the rgba values are equal to the given ones
  73753. */
  73754. equals(otherColor: DeepImmutable<Color4>): boolean;
  73755. /**
  73756. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73757. * @param right defines the second operand
  73758. * @returns a new Color4 object
  73759. */
  73760. add(right: DeepImmutable<Color4>): Color4;
  73761. /**
  73762. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73763. * @param right defines the second operand
  73764. * @returns a new Color4 object
  73765. */
  73766. subtract(right: DeepImmutable<Color4>): Color4;
  73767. /**
  73768. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73769. * @param right defines the second operand
  73770. * @param result defines the Color4 object where to store the result
  73771. * @returns the current Color4 object
  73772. */
  73773. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73774. /**
  73775. * Creates a new Color4 with the current Color4 values multiplied by scale
  73776. * @param scale defines the scaling factor to apply
  73777. * @returns a new Color4 object
  73778. */
  73779. scale(scale: number): Color4;
  73780. /**
  73781. * Multiplies the current Color4 values by scale and stores the result in "result"
  73782. * @param scale defines the scaling factor to apply
  73783. * @param result defines the Color4 object where to store the result
  73784. * @returns the current unmodified Color4
  73785. */
  73786. scaleToRef(scale: number, result: Color4): Color4;
  73787. /**
  73788. * Scale the current Color4 values by a factor and add the result to a given Color4
  73789. * @param scale defines the scale factor
  73790. * @param result defines the Color4 object where to store the result
  73791. * @returns the unmodified current Color4
  73792. */
  73793. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73794. /**
  73795. * Clamps the rgb values by the min and max values and stores the result into "result"
  73796. * @param min defines minimum clamping value (default is 0)
  73797. * @param max defines maximum clamping value (default is 1)
  73798. * @param result defines color to store the result into.
  73799. * @returns the cuurent Color4
  73800. */
  73801. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73802. /**
  73803. * Multipy an Color4 value by another and return a new Color4 object
  73804. * @param color defines the Color4 value to multiply by
  73805. * @returns a new Color4 object
  73806. */
  73807. multiply(color: Color4): Color4;
  73808. /**
  73809. * Multipy a Color4 value by another and push the result in a reference value
  73810. * @param color defines the Color4 value to multiply by
  73811. * @param result defines the Color4 to fill the result in
  73812. * @returns the result Color4
  73813. */
  73814. multiplyToRef(color: Color4, result: Color4): Color4;
  73815. /**
  73816. * Creates a string with the Color4 current values
  73817. * @returns the string representation of the Color4 object
  73818. */
  73819. toString(): string;
  73820. /**
  73821. * Returns the string "Color4"
  73822. * @returns "Color4"
  73823. */
  73824. getClassName(): string;
  73825. /**
  73826. * Compute the Color4 hash code
  73827. * @returns an unique number that can be used to hash Color4 objects
  73828. */
  73829. getHashCode(): number;
  73830. /**
  73831. * Creates a new Color4 copied from the current one
  73832. * @returns a new Color4 object
  73833. */
  73834. clone(): Color4;
  73835. /**
  73836. * Copies the given Color4 values into the current one
  73837. * @param source defines the source Color4 object
  73838. * @returns the current updated Color4 object
  73839. */
  73840. copyFrom(source: Color4): Color4;
  73841. /**
  73842. * Copies the given float values into the current one
  73843. * @param r defines the red component to read from
  73844. * @param g defines the green component to read from
  73845. * @param b defines the blue component to read from
  73846. * @param a defines the alpha component to read from
  73847. * @returns the current updated Color4 object
  73848. */
  73849. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73850. /**
  73851. * Copies the given float values into the current one
  73852. * @param r defines the red component to read from
  73853. * @param g defines the green component to read from
  73854. * @param b defines the blue component to read from
  73855. * @param a defines the alpha component to read from
  73856. * @returns the current updated Color4 object
  73857. */
  73858. set(r: number, g: number, b: number, a: number): Color4;
  73859. /**
  73860. * Compute the Color4 hexadecimal code as a string
  73861. * @returns a string containing the hexadecimal representation of the Color4 object
  73862. */
  73863. toHexString(): string;
  73864. /**
  73865. * Computes a new Color4 converted from the current one to linear space
  73866. * @returns a new Color4 object
  73867. */
  73868. toLinearSpace(): Color4;
  73869. /**
  73870. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73871. * @param convertedColor defines the Color4 object where to store the linear space version
  73872. * @returns the unmodified Color4
  73873. */
  73874. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73875. /**
  73876. * Computes a new Color4 converted from the current one to gamma space
  73877. * @returns a new Color4 object
  73878. */
  73879. toGammaSpace(): Color4;
  73880. /**
  73881. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73882. * @param convertedColor defines the Color4 object where to store the gamma space version
  73883. * @returns the unmodified Color4
  73884. */
  73885. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73886. /**
  73887. * Creates a new Color4 from the string containing valid hexadecimal values
  73888. * @param hex defines a string containing valid hexadecimal values
  73889. * @returns a new Color4 object
  73890. */
  73891. static FromHexString(hex: string): Color4;
  73892. /**
  73893. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73894. * @param left defines the start value
  73895. * @param right defines the end value
  73896. * @param amount defines the gradient factor
  73897. * @returns a new Color4 object
  73898. */
  73899. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73900. /**
  73901. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73902. * @param left defines the start value
  73903. * @param right defines the end value
  73904. * @param amount defines the gradient factor
  73905. * @param result defines the Color4 object where to store data
  73906. */
  73907. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73908. /**
  73909. * Creates a new Color4 from a Color3 and an alpha value
  73910. * @param color3 defines the source Color3 to read from
  73911. * @param alpha defines the alpha component (1.0 by default)
  73912. * @returns a new Color4 object
  73913. */
  73914. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73915. /**
  73916. * Creates a new Color4 from the starting index element of the given array
  73917. * @param array defines the source array to read from
  73918. * @param offset defines the offset in the source array
  73919. * @returns a new Color4 object
  73920. */
  73921. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73922. /**
  73923. * Creates a new Color3 from integer values (< 256)
  73924. * @param r defines the red component to read from (value between 0 and 255)
  73925. * @param g defines the green component to read from (value between 0 and 255)
  73926. * @param b defines the blue component to read from (value between 0 and 255)
  73927. * @param a defines the alpha component to read from (value between 0 and 255)
  73928. * @returns a new Color3 object
  73929. */
  73930. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73931. /**
  73932. * Check the content of a given array and convert it to an array containing RGBA data
  73933. * If the original array was already containing count * 4 values then it is returned directly
  73934. * @param colors defines the array to check
  73935. * @param count defines the number of RGBA data to expect
  73936. * @returns an array containing count * 4 values (RGBA)
  73937. */
  73938. static CheckColors4(colors: number[], count: number): number[];
  73939. }
  73940. /**
  73941. * @hidden
  73942. */
  73943. export class TmpColors {
  73944. static Color3: Color3[];
  73945. static Color4: Color4[];
  73946. }
  73947. }
  73948. declare module BABYLON {
  73949. /**
  73950. * Defines an interface which represents an animation key frame
  73951. */
  73952. export interface IAnimationKey {
  73953. /**
  73954. * Frame of the key frame
  73955. */
  73956. frame: number;
  73957. /**
  73958. * Value at the specifies key frame
  73959. */
  73960. value: any;
  73961. /**
  73962. * The input tangent for the cubic hermite spline
  73963. */
  73964. inTangent?: any;
  73965. /**
  73966. * The output tangent for the cubic hermite spline
  73967. */
  73968. outTangent?: any;
  73969. /**
  73970. * The animation interpolation type
  73971. */
  73972. interpolation?: AnimationKeyInterpolation;
  73973. }
  73974. /**
  73975. * Enum for the animation key frame interpolation type
  73976. */
  73977. export enum AnimationKeyInterpolation {
  73978. /**
  73979. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73980. */
  73981. STEP = 1
  73982. }
  73983. }
  73984. declare module BABYLON {
  73985. /**
  73986. * Represents the range of an animation
  73987. */
  73988. export class AnimationRange {
  73989. /**The name of the animation range**/
  73990. name: string;
  73991. /**The starting frame of the animation */
  73992. from: number;
  73993. /**The ending frame of the animation*/
  73994. to: number;
  73995. /**
  73996. * Initializes the range of an animation
  73997. * @param name The name of the animation range
  73998. * @param from The starting frame of the animation
  73999. * @param to The ending frame of the animation
  74000. */
  74001. constructor(
  74002. /**The name of the animation range**/
  74003. name: string,
  74004. /**The starting frame of the animation */
  74005. from: number,
  74006. /**The ending frame of the animation*/
  74007. to: number);
  74008. /**
  74009. * Makes a copy of the animation range
  74010. * @returns A copy of the animation range
  74011. */
  74012. clone(): AnimationRange;
  74013. }
  74014. }
  74015. declare module BABYLON {
  74016. /**
  74017. * Composed of a frame, and an action function
  74018. */
  74019. export class AnimationEvent {
  74020. /** The frame for which the event is triggered **/
  74021. frame: number;
  74022. /** The event to perform when triggered **/
  74023. action: (currentFrame: number) => void;
  74024. /** Specifies if the event should be triggered only once**/
  74025. onlyOnce?: boolean | undefined;
  74026. /**
  74027. * Specifies if the animation event is done
  74028. */
  74029. isDone: boolean;
  74030. /**
  74031. * Initializes the animation event
  74032. * @param frame The frame for which the event is triggered
  74033. * @param action The event to perform when triggered
  74034. * @param onlyOnce Specifies if the event should be triggered only once
  74035. */
  74036. constructor(
  74037. /** The frame for which the event is triggered **/
  74038. frame: number,
  74039. /** The event to perform when triggered **/
  74040. action: (currentFrame: number) => void,
  74041. /** Specifies if the event should be triggered only once**/
  74042. onlyOnce?: boolean | undefined);
  74043. /** @hidden */
  74044. _clone(): AnimationEvent;
  74045. }
  74046. }
  74047. declare module BABYLON {
  74048. /**
  74049. * Interface used to define a behavior
  74050. */
  74051. export interface Behavior<T> {
  74052. /** gets or sets behavior's name */
  74053. name: string;
  74054. /**
  74055. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74056. */
  74057. init(): void;
  74058. /**
  74059. * Called when the behavior is attached to a target
  74060. * @param target defines the target where the behavior is attached to
  74061. */
  74062. attach(target: T): void;
  74063. /**
  74064. * Called when the behavior is detached from its target
  74065. */
  74066. detach(): void;
  74067. }
  74068. /**
  74069. * Interface implemented by classes supporting behaviors
  74070. */
  74071. export interface IBehaviorAware<T> {
  74072. /**
  74073. * Attach a behavior
  74074. * @param behavior defines the behavior to attach
  74075. * @returns the current host
  74076. */
  74077. addBehavior(behavior: Behavior<T>): T;
  74078. /**
  74079. * Remove a behavior from the current object
  74080. * @param behavior defines the behavior to detach
  74081. * @returns the current host
  74082. */
  74083. removeBehavior(behavior: Behavior<T>): T;
  74084. /**
  74085. * Gets a behavior using its name to search
  74086. * @param name defines the name to search
  74087. * @returns the behavior or null if not found
  74088. */
  74089. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74090. }
  74091. }
  74092. declare module BABYLON {
  74093. /**
  74094. * Defines an array and its length.
  74095. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74096. */
  74097. export interface ISmartArrayLike<T> {
  74098. /**
  74099. * The data of the array.
  74100. */
  74101. data: Array<T>;
  74102. /**
  74103. * The active length of the array.
  74104. */
  74105. length: number;
  74106. }
  74107. /**
  74108. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74109. */
  74110. export class SmartArray<T> implements ISmartArrayLike<T> {
  74111. /**
  74112. * The full set of data from the array.
  74113. */
  74114. data: Array<T>;
  74115. /**
  74116. * The active length of the array.
  74117. */
  74118. length: number;
  74119. protected _id: number;
  74120. /**
  74121. * Instantiates a Smart Array.
  74122. * @param capacity defines the default capacity of the array.
  74123. */
  74124. constructor(capacity: number);
  74125. /**
  74126. * Pushes a value at the end of the active data.
  74127. * @param value defines the object to push in the array.
  74128. */
  74129. push(value: T): void;
  74130. /**
  74131. * Iterates over the active data and apply the lambda to them.
  74132. * @param func defines the action to apply on each value.
  74133. */
  74134. forEach(func: (content: T) => void): void;
  74135. /**
  74136. * Sorts the full sets of data.
  74137. * @param compareFn defines the comparison function to apply.
  74138. */
  74139. sort(compareFn: (a: T, b: T) => number): void;
  74140. /**
  74141. * Resets the active data to an empty array.
  74142. */
  74143. reset(): void;
  74144. /**
  74145. * Releases all the data from the array as well as the array.
  74146. */
  74147. dispose(): void;
  74148. /**
  74149. * Concats the active data with a given array.
  74150. * @param array defines the data to concatenate with.
  74151. */
  74152. concat(array: any): void;
  74153. /**
  74154. * Returns the position of a value in the active data.
  74155. * @param value defines the value to find the index for
  74156. * @returns the index if found in the active data otherwise -1
  74157. */
  74158. indexOf(value: T): number;
  74159. /**
  74160. * Returns whether an element is part of the active data.
  74161. * @param value defines the value to look for
  74162. * @returns true if found in the active data otherwise false
  74163. */
  74164. contains(value: T): boolean;
  74165. private static _GlobalId;
  74166. }
  74167. /**
  74168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74169. * The data in this array can only be present once
  74170. */
  74171. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74172. private _duplicateId;
  74173. /**
  74174. * Pushes a value at the end of the active data.
  74175. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74176. * @param value defines the object to push in the array.
  74177. */
  74178. push(value: T): void;
  74179. /**
  74180. * Pushes a value at the end of the active data.
  74181. * If the data is already present, it won t be added again
  74182. * @param value defines the object to push in the array.
  74183. * @returns true if added false if it was already present
  74184. */
  74185. pushNoDuplicate(value: T): boolean;
  74186. /**
  74187. * Resets the active data to an empty array.
  74188. */
  74189. reset(): void;
  74190. /**
  74191. * Concats the active data with a given array.
  74192. * This ensures no dupplicate will be present in the result.
  74193. * @param array defines the data to concatenate with.
  74194. */
  74195. concatWithNoDuplicate(array: any): void;
  74196. }
  74197. }
  74198. declare module BABYLON {
  74199. /**
  74200. * @ignore
  74201. * This is a list of all the different input types that are available in the application.
  74202. * Fo instance: ArcRotateCameraGamepadInput...
  74203. */
  74204. export var CameraInputTypes: {};
  74205. /**
  74206. * This is the contract to implement in order to create a new input class.
  74207. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74208. */
  74209. export interface ICameraInput<TCamera extends Camera> {
  74210. /**
  74211. * Defines the camera the input is attached to.
  74212. */
  74213. camera: Nullable<TCamera>;
  74214. /**
  74215. * Gets the class name of the current intput.
  74216. * @returns the class name
  74217. */
  74218. getClassName(): string;
  74219. /**
  74220. * Get the friendly name associated with the input class.
  74221. * @returns the input friendly name
  74222. */
  74223. getSimpleName(): string;
  74224. /**
  74225. * Attach the input controls to a specific dom element to get the input from.
  74226. * @param element Defines the element the controls should be listened from
  74227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74228. */
  74229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74230. /**
  74231. * Detach the current controls from the specified dom element.
  74232. * @param element Defines the element to stop listening the inputs from
  74233. */
  74234. detachControl(element: Nullable<HTMLElement>): void;
  74235. /**
  74236. * Update the current camera state depending on the inputs that have been used this frame.
  74237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74238. */
  74239. checkInputs?: () => void;
  74240. }
  74241. /**
  74242. * Represents a map of input types to input instance or input index to input instance.
  74243. */
  74244. export interface CameraInputsMap<TCamera extends Camera> {
  74245. /**
  74246. * Accessor to the input by input type.
  74247. */
  74248. [name: string]: ICameraInput<TCamera>;
  74249. /**
  74250. * Accessor to the input by input index.
  74251. */
  74252. [idx: number]: ICameraInput<TCamera>;
  74253. }
  74254. /**
  74255. * This represents the input manager used within a camera.
  74256. * It helps dealing with all the different kind of input attached to a camera.
  74257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74258. */
  74259. export class CameraInputsManager<TCamera extends Camera> {
  74260. /**
  74261. * Defines the list of inputs attahed to the camera.
  74262. */
  74263. attached: CameraInputsMap<TCamera>;
  74264. /**
  74265. * Defines the dom element the camera is collecting inputs from.
  74266. * This is null if the controls have not been attached.
  74267. */
  74268. attachedElement: Nullable<HTMLElement>;
  74269. /**
  74270. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74271. */
  74272. noPreventDefault: boolean;
  74273. /**
  74274. * Defined the camera the input manager belongs to.
  74275. */
  74276. camera: TCamera;
  74277. /**
  74278. * Update the current camera state depending on the inputs that have been used this frame.
  74279. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74280. */
  74281. checkInputs: () => void;
  74282. /**
  74283. * Instantiate a new Camera Input Manager.
  74284. * @param camera Defines the camera the input manager blongs to
  74285. */
  74286. constructor(camera: TCamera);
  74287. /**
  74288. * Add an input method to a camera
  74289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74290. * @param input camera input method
  74291. */
  74292. add(input: ICameraInput<TCamera>): void;
  74293. /**
  74294. * Remove a specific input method from a camera
  74295. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74296. * @param inputToRemove camera input method
  74297. */
  74298. remove(inputToRemove: ICameraInput<TCamera>): void;
  74299. /**
  74300. * Remove a specific input type from a camera
  74301. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74302. * @param inputType the type of the input to remove
  74303. */
  74304. removeByType(inputType: string): void;
  74305. private _addCheckInputs;
  74306. /**
  74307. * Attach the input controls to the currently attached dom element to listen the events from.
  74308. * @param input Defines the input to attach
  74309. */
  74310. attachInput(input: ICameraInput<TCamera>): void;
  74311. /**
  74312. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74313. * @param element Defines the dom element to collect the events from
  74314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74315. */
  74316. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74317. /**
  74318. * Detach the current manager inputs controls from a specific dom element.
  74319. * @param element Defines the dom element to collect the events from
  74320. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74321. */
  74322. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74323. /**
  74324. * Rebuild the dynamic inputCheck function from the current list of
  74325. * defined inputs in the manager.
  74326. */
  74327. rebuildInputCheck(): void;
  74328. /**
  74329. * Remove all attached input methods from a camera
  74330. */
  74331. clear(): void;
  74332. /**
  74333. * Serialize the current input manager attached to a camera.
  74334. * This ensures than once parsed,
  74335. * the input associated to the camera will be identical to the current ones
  74336. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74337. */
  74338. serialize(serializedCamera: any): void;
  74339. /**
  74340. * Parses an input manager serialized JSON to restore the previous list of inputs
  74341. * and states associated to a camera.
  74342. * @param parsedCamera Defines the JSON to parse
  74343. */
  74344. parse(parsedCamera: any): void;
  74345. }
  74346. }
  74347. declare module BABYLON {
  74348. /**
  74349. * Class used to store data that will be store in GPU memory
  74350. */
  74351. export class Buffer {
  74352. private _engine;
  74353. private _buffer;
  74354. /** @hidden */
  74355. _data: Nullable<DataArray>;
  74356. private _updatable;
  74357. private _instanced;
  74358. private _divisor;
  74359. /**
  74360. * Gets the byte stride.
  74361. */
  74362. readonly byteStride: number;
  74363. /**
  74364. * Constructor
  74365. * @param engine the engine
  74366. * @param data the data to use for this buffer
  74367. * @param updatable whether the data is updatable
  74368. * @param stride the stride (optional)
  74369. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74370. * @param instanced whether the buffer is instanced (optional)
  74371. * @param useBytes set to true if the stride in in bytes (optional)
  74372. * @param divisor sets an optional divisor for instances (1 by default)
  74373. */
  74374. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74375. /**
  74376. * Create a new VertexBuffer based on the current buffer
  74377. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74378. * @param offset defines offset in the buffer (0 by default)
  74379. * @param size defines the size in floats of attributes (position is 3 for instance)
  74380. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74381. * @param instanced defines if the vertex buffer contains indexed data
  74382. * @param useBytes defines if the offset and stride are in bytes *
  74383. * @param divisor sets an optional divisor for instances (1 by default)
  74384. * @returns the new vertex buffer
  74385. */
  74386. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74387. /**
  74388. * Gets a boolean indicating if the Buffer is updatable?
  74389. * @returns true if the buffer is updatable
  74390. */
  74391. isUpdatable(): boolean;
  74392. /**
  74393. * Gets current buffer's data
  74394. * @returns a DataArray or null
  74395. */
  74396. getData(): Nullable<DataArray>;
  74397. /**
  74398. * Gets underlying native buffer
  74399. * @returns underlying native buffer
  74400. */
  74401. getBuffer(): Nullable<DataBuffer>;
  74402. /**
  74403. * Gets the stride in float32 units (i.e. byte stride / 4).
  74404. * May not be an integer if the byte stride is not divisible by 4.
  74405. * DEPRECATED. Use byteStride instead.
  74406. * @returns the stride in float32 units
  74407. */
  74408. getStrideSize(): number;
  74409. /**
  74410. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74411. * @param data defines the data to store
  74412. */
  74413. create(data?: Nullable<DataArray>): void;
  74414. /** @hidden */
  74415. _rebuild(): void;
  74416. /**
  74417. * Update current buffer data
  74418. * @param data defines the data to store
  74419. */
  74420. update(data: DataArray): void;
  74421. /**
  74422. * Updates the data directly.
  74423. * @param data the new data
  74424. * @param offset the new offset
  74425. * @param vertexCount the vertex count (optional)
  74426. * @param useBytes set to true if the offset is in bytes
  74427. */
  74428. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74429. /**
  74430. * Release all resources
  74431. */
  74432. dispose(): void;
  74433. }
  74434. /**
  74435. * Specialized buffer used to store vertex data
  74436. */
  74437. export class VertexBuffer {
  74438. /** @hidden */
  74439. _buffer: Buffer;
  74440. private _kind;
  74441. private _size;
  74442. private _ownsBuffer;
  74443. private _instanced;
  74444. private _instanceDivisor;
  74445. /**
  74446. * The byte type.
  74447. */
  74448. static readonly BYTE: number;
  74449. /**
  74450. * The unsigned byte type.
  74451. */
  74452. static readonly UNSIGNED_BYTE: number;
  74453. /**
  74454. * The short type.
  74455. */
  74456. static readonly SHORT: number;
  74457. /**
  74458. * The unsigned short type.
  74459. */
  74460. static readonly UNSIGNED_SHORT: number;
  74461. /**
  74462. * The integer type.
  74463. */
  74464. static readonly INT: number;
  74465. /**
  74466. * The unsigned integer type.
  74467. */
  74468. static readonly UNSIGNED_INT: number;
  74469. /**
  74470. * The float type.
  74471. */
  74472. static readonly FLOAT: number;
  74473. /**
  74474. * Gets or sets the instance divisor when in instanced mode
  74475. */
  74476. instanceDivisor: number;
  74477. /**
  74478. * Gets the byte stride.
  74479. */
  74480. readonly byteStride: number;
  74481. /**
  74482. * Gets the byte offset.
  74483. */
  74484. readonly byteOffset: number;
  74485. /**
  74486. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74487. */
  74488. readonly normalized: boolean;
  74489. /**
  74490. * Gets the data type of each component in the array.
  74491. */
  74492. readonly type: number;
  74493. /**
  74494. * Constructor
  74495. * @param engine the engine
  74496. * @param data the data to use for this vertex buffer
  74497. * @param kind the vertex buffer kind
  74498. * @param updatable whether the data is updatable
  74499. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74500. * @param stride the stride (optional)
  74501. * @param instanced whether the buffer is instanced (optional)
  74502. * @param offset the offset of the data (optional)
  74503. * @param size the number of components (optional)
  74504. * @param type the type of the component (optional)
  74505. * @param normalized whether the data contains normalized data (optional)
  74506. * @param useBytes set to true if stride and offset are in bytes (optional)
  74507. * @param divisor defines the instance divisor to use (1 by default)
  74508. */
  74509. 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);
  74510. /** @hidden */
  74511. _rebuild(): void;
  74512. /**
  74513. * Returns the kind of the VertexBuffer (string)
  74514. * @returns a string
  74515. */
  74516. getKind(): string;
  74517. /**
  74518. * Gets a boolean indicating if the VertexBuffer is updatable?
  74519. * @returns true if the buffer is updatable
  74520. */
  74521. isUpdatable(): boolean;
  74522. /**
  74523. * Gets current buffer's data
  74524. * @returns a DataArray or null
  74525. */
  74526. getData(): Nullable<DataArray>;
  74527. /**
  74528. * Gets underlying native buffer
  74529. * @returns underlying native buffer
  74530. */
  74531. getBuffer(): Nullable<DataBuffer>;
  74532. /**
  74533. * Gets the stride in float32 units (i.e. byte stride / 4).
  74534. * May not be an integer if the byte stride is not divisible by 4.
  74535. * DEPRECATED. Use byteStride instead.
  74536. * @returns the stride in float32 units
  74537. */
  74538. getStrideSize(): number;
  74539. /**
  74540. * Returns the offset as a multiple of the type byte length.
  74541. * DEPRECATED. Use byteOffset instead.
  74542. * @returns the offset in bytes
  74543. */
  74544. getOffset(): number;
  74545. /**
  74546. * Returns the number of components per vertex attribute (integer)
  74547. * @returns the size in float
  74548. */
  74549. getSize(): number;
  74550. /**
  74551. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74552. * @returns true if this buffer is instanced
  74553. */
  74554. getIsInstanced(): boolean;
  74555. /**
  74556. * Returns the instancing divisor, zero for non-instanced (integer).
  74557. * @returns a number
  74558. */
  74559. getInstanceDivisor(): number;
  74560. /**
  74561. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74562. * @param data defines the data to store
  74563. */
  74564. create(data?: DataArray): void;
  74565. /**
  74566. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74567. * This function will create a new buffer if the current one is not updatable
  74568. * @param data defines the data to store
  74569. */
  74570. update(data: DataArray): void;
  74571. /**
  74572. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74573. * Returns the directly updated WebGLBuffer.
  74574. * @param data the new data
  74575. * @param offset the new offset
  74576. * @param useBytes set to true if the offset is in bytes
  74577. */
  74578. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74579. /**
  74580. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74581. */
  74582. dispose(): void;
  74583. /**
  74584. * Enumerates each value of this vertex buffer as numbers.
  74585. * @param count the number of values to enumerate
  74586. * @param callback the callback function called for each value
  74587. */
  74588. forEach(count: number, callback: (value: number, index: number) => void): void;
  74589. /**
  74590. * Positions
  74591. */
  74592. static readonly PositionKind: string;
  74593. /**
  74594. * Normals
  74595. */
  74596. static readonly NormalKind: string;
  74597. /**
  74598. * Tangents
  74599. */
  74600. static readonly TangentKind: string;
  74601. /**
  74602. * Texture coordinates
  74603. */
  74604. static readonly UVKind: string;
  74605. /**
  74606. * Texture coordinates 2
  74607. */
  74608. static readonly UV2Kind: string;
  74609. /**
  74610. * Texture coordinates 3
  74611. */
  74612. static readonly UV3Kind: string;
  74613. /**
  74614. * Texture coordinates 4
  74615. */
  74616. static readonly UV4Kind: string;
  74617. /**
  74618. * Texture coordinates 5
  74619. */
  74620. static readonly UV5Kind: string;
  74621. /**
  74622. * Texture coordinates 6
  74623. */
  74624. static readonly UV6Kind: string;
  74625. /**
  74626. * Colors
  74627. */
  74628. static readonly ColorKind: string;
  74629. /**
  74630. * Matrix indices (for bones)
  74631. */
  74632. static readonly MatricesIndicesKind: string;
  74633. /**
  74634. * Matrix weights (for bones)
  74635. */
  74636. static readonly MatricesWeightsKind: string;
  74637. /**
  74638. * Additional matrix indices (for bones)
  74639. */
  74640. static readonly MatricesIndicesExtraKind: string;
  74641. /**
  74642. * Additional matrix weights (for bones)
  74643. */
  74644. static readonly MatricesWeightsExtraKind: string;
  74645. /**
  74646. * Deduces the stride given a kind.
  74647. * @param kind The kind string to deduce
  74648. * @returns The deduced stride
  74649. */
  74650. static DeduceStride(kind: string): number;
  74651. /**
  74652. * Gets the byte length of the given type.
  74653. * @param type the type
  74654. * @returns the number of bytes
  74655. */
  74656. static GetTypeByteLength(type: number): number;
  74657. /**
  74658. * Enumerates each value of the given parameters as numbers.
  74659. * @param data the data to enumerate
  74660. * @param byteOffset the byte offset of the data
  74661. * @param byteStride the byte stride of the data
  74662. * @param componentCount the number of components per element
  74663. * @param componentType the type of the component
  74664. * @param count the number of values to enumerate
  74665. * @param normalized whether the data is normalized
  74666. * @param callback the callback function called for each value
  74667. */
  74668. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74669. private static _GetFloatValue;
  74670. }
  74671. }
  74672. declare module BABYLON {
  74673. /**
  74674. * @hidden
  74675. */
  74676. export class IntersectionInfo {
  74677. bu: Nullable<number>;
  74678. bv: Nullable<number>;
  74679. distance: number;
  74680. faceId: number;
  74681. subMeshId: number;
  74682. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74683. }
  74684. }
  74685. declare module BABYLON {
  74686. /**
  74687. * Represens a plane by the equation ax + by + cz + d = 0
  74688. */
  74689. export class Plane {
  74690. private static _TmpMatrix;
  74691. /**
  74692. * Normal of the plane (a,b,c)
  74693. */
  74694. normal: Vector3;
  74695. /**
  74696. * d component of the plane
  74697. */
  74698. d: number;
  74699. /**
  74700. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74701. * @param a a component of the plane
  74702. * @param b b component of the plane
  74703. * @param c c component of the plane
  74704. * @param d d component of the plane
  74705. */
  74706. constructor(a: number, b: number, c: number, d: number);
  74707. /**
  74708. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74709. */
  74710. asArray(): number[];
  74711. /**
  74712. * @returns a new plane copied from the current Plane.
  74713. */
  74714. clone(): Plane;
  74715. /**
  74716. * @returns the string "Plane".
  74717. */
  74718. getClassName(): string;
  74719. /**
  74720. * @returns the Plane hash code.
  74721. */
  74722. getHashCode(): number;
  74723. /**
  74724. * Normalize the current Plane in place.
  74725. * @returns the updated Plane.
  74726. */
  74727. normalize(): Plane;
  74728. /**
  74729. * Applies a transformation the plane and returns the result
  74730. * @param transformation the transformation matrix to be applied to the plane
  74731. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74732. */
  74733. transform(transformation: DeepImmutable<Matrix>): Plane;
  74734. /**
  74735. * Calcualtte the dot product between the point and the plane normal
  74736. * @param point point to calculate the dot product with
  74737. * @returns the dot product (float) of the point coordinates and the plane normal.
  74738. */
  74739. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74740. /**
  74741. * Updates the current Plane from the plane defined by the three given points.
  74742. * @param point1 one of the points used to contruct the plane
  74743. * @param point2 one of the points used to contruct the plane
  74744. * @param point3 one of the points used to contruct the plane
  74745. * @returns the updated Plane.
  74746. */
  74747. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74748. /**
  74749. * Checks if the plane is facing a given direction
  74750. * @param direction the direction to check if the plane is facing
  74751. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74752. * @returns True is the vector "direction" is the same side than the plane normal.
  74753. */
  74754. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74755. /**
  74756. * Calculates the distance to a point
  74757. * @param point point to calculate distance to
  74758. * @returns the signed distance (float) from the given point to the Plane.
  74759. */
  74760. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74761. /**
  74762. * Creates a plane from an array
  74763. * @param array the array to create a plane from
  74764. * @returns a new Plane from the given array.
  74765. */
  74766. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74767. /**
  74768. * Creates a plane from three points
  74769. * @param point1 point used to create the plane
  74770. * @param point2 point used to create the plane
  74771. * @param point3 point used to create the plane
  74772. * @returns a new Plane defined by the three given points.
  74773. */
  74774. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74775. /**
  74776. * Creates a plane from an origin point and a normal
  74777. * @param origin origin of the plane to be constructed
  74778. * @param normal normal of the plane to be constructed
  74779. * @returns a new Plane the normal vector to this plane at the given origin point.
  74780. * Note : the vector "normal" is updated because normalized.
  74781. */
  74782. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74783. /**
  74784. * Calculates the distance from a plane and a point
  74785. * @param origin origin of the plane to be constructed
  74786. * @param normal normal of the plane to be constructed
  74787. * @param point point to calculate distance to
  74788. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74789. */
  74790. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74791. }
  74792. }
  74793. declare module BABYLON {
  74794. /**
  74795. * Class used to store bounding sphere information
  74796. */
  74797. export class BoundingSphere {
  74798. /**
  74799. * Gets the center of the bounding sphere in local space
  74800. */
  74801. readonly center: Vector3;
  74802. /**
  74803. * Radius of the bounding sphere in local space
  74804. */
  74805. radius: number;
  74806. /**
  74807. * Gets the center of the bounding sphere in world space
  74808. */
  74809. readonly centerWorld: Vector3;
  74810. /**
  74811. * Radius of the bounding sphere in world space
  74812. */
  74813. radiusWorld: number;
  74814. /**
  74815. * Gets the minimum vector in local space
  74816. */
  74817. readonly minimum: Vector3;
  74818. /**
  74819. * Gets the maximum vector in local space
  74820. */
  74821. readonly maximum: Vector3;
  74822. private _worldMatrix;
  74823. private static readonly TmpVector3;
  74824. /**
  74825. * Creates a new bounding sphere
  74826. * @param min defines the minimum vector (in local space)
  74827. * @param max defines the maximum vector (in local space)
  74828. * @param worldMatrix defines the new world matrix
  74829. */
  74830. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74831. /**
  74832. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74833. * @param min defines the new minimum vector (in local space)
  74834. * @param max defines the new maximum vector (in local space)
  74835. * @param worldMatrix defines the new world matrix
  74836. */
  74837. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74838. /**
  74839. * Scale the current bounding sphere by applying a scale factor
  74840. * @param factor defines the scale factor to apply
  74841. * @returns the current bounding box
  74842. */
  74843. scale(factor: number): BoundingSphere;
  74844. /**
  74845. * Gets the world matrix of the bounding box
  74846. * @returns a matrix
  74847. */
  74848. getWorldMatrix(): DeepImmutable<Matrix>;
  74849. /** @hidden */
  74850. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74851. /**
  74852. * Tests if the bounding sphere is intersecting the frustum planes
  74853. * @param frustumPlanes defines the frustum planes to test
  74854. * @returns true if there is an intersection
  74855. */
  74856. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74857. /**
  74858. * Tests if the bounding sphere center is in between the frustum planes.
  74859. * Used for optimistic fast inclusion.
  74860. * @param frustumPlanes defines the frustum planes to test
  74861. * @returns true if the sphere center is in between the frustum planes
  74862. */
  74863. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74864. /**
  74865. * Tests if a point is inside the bounding sphere
  74866. * @param point defines the point to test
  74867. * @returns true if the point is inside the bounding sphere
  74868. */
  74869. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74870. /**
  74871. * Checks if two sphere intersct
  74872. * @param sphere0 sphere 0
  74873. * @param sphere1 sphere 1
  74874. * @returns true if the speres intersect
  74875. */
  74876. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74877. }
  74878. }
  74879. declare module BABYLON {
  74880. /**
  74881. * Class used to store bounding box information
  74882. */
  74883. export class BoundingBox implements ICullable {
  74884. /**
  74885. * Gets the 8 vectors representing the bounding box in local space
  74886. */
  74887. readonly vectors: Vector3[];
  74888. /**
  74889. * Gets the center of the bounding box in local space
  74890. */
  74891. readonly center: Vector3;
  74892. /**
  74893. * Gets the center of the bounding box in world space
  74894. */
  74895. readonly centerWorld: Vector3;
  74896. /**
  74897. * Gets the extend size in local space
  74898. */
  74899. readonly extendSize: Vector3;
  74900. /**
  74901. * Gets the extend size in world space
  74902. */
  74903. readonly extendSizeWorld: Vector3;
  74904. /**
  74905. * Gets the OBB (object bounding box) directions
  74906. */
  74907. readonly directions: Vector3[];
  74908. /**
  74909. * Gets the 8 vectors representing the bounding box in world space
  74910. */
  74911. readonly vectorsWorld: Vector3[];
  74912. /**
  74913. * Gets the minimum vector in world space
  74914. */
  74915. readonly minimumWorld: Vector3;
  74916. /**
  74917. * Gets the maximum vector in world space
  74918. */
  74919. readonly maximumWorld: Vector3;
  74920. /**
  74921. * Gets the minimum vector in local space
  74922. */
  74923. readonly minimum: Vector3;
  74924. /**
  74925. * Gets the maximum vector in local space
  74926. */
  74927. readonly maximum: Vector3;
  74928. private _worldMatrix;
  74929. private static readonly TmpVector3;
  74930. /**
  74931. * @hidden
  74932. */
  74933. _tag: number;
  74934. /**
  74935. * Creates a new bounding box
  74936. * @param min defines the minimum vector (in local space)
  74937. * @param max defines the maximum vector (in local space)
  74938. * @param worldMatrix defines the new world matrix
  74939. */
  74940. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74941. /**
  74942. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74943. * @param min defines the new minimum vector (in local space)
  74944. * @param max defines the new maximum vector (in local space)
  74945. * @param worldMatrix defines the new world matrix
  74946. */
  74947. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74948. /**
  74949. * Scale the current bounding box by applying a scale factor
  74950. * @param factor defines the scale factor to apply
  74951. * @returns the current bounding box
  74952. */
  74953. scale(factor: number): BoundingBox;
  74954. /**
  74955. * Gets the world matrix of the bounding box
  74956. * @returns a matrix
  74957. */
  74958. getWorldMatrix(): DeepImmutable<Matrix>;
  74959. /** @hidden */
  74960. _update(world: DeepImmutable<Matrix>): void;
  74961. /**
  74962. * Tests if the bounding box is intersecting the frustum planes
  74963. * @param frustumPlanes defines the frustum planes to test
  74964. * @returns true if there is an intersection
  74965. */
  74966. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74967. /**
  74968. * Tests if the bounding box is entirely inside the frustum planes
  74969. * @param frustumPlanes defines the frustum planes to test
  74970. * @returns true if there is an inclusion
  74971. */
  74972. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74973. /**
  74974. * Tests if a point is inside the bounding box
  74975. * @param point defines the point to test
  74976. * @returns true if the point is inside the bounding box
  74977. */
  74978. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74979. /**
  74980. * Tests if the bounding box intersects with a bounding sphere
  74981. * @param sphere defines the sphere to test
  74982. * @returns true if there is an intersection
  74983. */
  74984. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74985. /**
  74986. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74987. * @param min defines the min vector to use
  74988. * @param max defines the max vector to use
  74989. * @returns true if there is an intersection
  74990. */
  74991. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74992. /**
  74993. * Tests if two bounding boxes are intersections
  74994. * @param box0 defines the first box to test
  74995. * @param box1 defines the second box to test
  74996. * @returns true if there is an intersection
  74997. */
  74998. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74999. /**
  75000. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75001. * @param minPoint defines the minimum vector of the bounding box
  75002. * @param maxPoint defines the maximum vector of the bounding box
  75003. * @param sphereCenter defines the sphere center
  75004. * @param sphereRadius defines the sphere radius
  75005. * @returns true if there is an intersection
  75006. */
  75007. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75008. /**
  75009. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75010. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75011. * @param frustumPlanes defines the frustum planes to test
  75012. * @return true if there is an inclusion
  75013. */
  75014. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75015. /**
  75016. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75017. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75018. * @param frustumPlanes defines the frustum planes to test
  75019. * @return true if there is an intersection
  75020. */
  75021. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75022. }
  75023. }
  75024. declare module BABYLON {
  75025. /** @hidden */
  75026. export class Collider {
  75027. /** Define if a collision was found */
  75028. collisionFound: boolean;
  75029. /**
  75030. * Define last intersection point in local space
  75031. */
  75032. intersectionPoint: Vector3;
  75033. /**
  75034. * Define last collided mesh
  75035. */
  75036. collidedMesh: Nullable<AbstractMesh>;
  75037. private _collisionPoint;
  75038. private _planeIntersectionPoint;
  75039. private _tempVector;
  75040. private _tempVector2;
  75041. private _tempVector3;
  75042. private _tempVector4;
  75043. private _edge;
  75044. private _baseToVertex;
  75045. private _destinationPoint;
  75046. private _slidePlaneNormal;
  75047. private _displacementVector;
  75048. /** @hidden */
  75049. _radius: Vector3;
  75050. /** @hidden */
  75051. _retry: number;
  75052. private _velocity;
  75053. private _basePoint;
  75054. private _epsilon;
  75055. /** @hidden */
  75056. _velocityWorldLength: number;
  75057. /** @hidden */
  75058. _basePointWorld: Vector3;
  75059. private _velocityWorld;
  75060. private _normalizedVelocity;
  75061. /** @hidden */
  75062. _initialVelocity: Vector3;
  75063. /** @hidden */
  75064. _initialPosition: Vector3;
  75065. private _nearestDistance;
  75066. private _collisionMask;
  75067. collisionMask: number;
  75068. /**
  75069. * Gets the plane normal used to compute the sliding response (in local space)
  75070. */
  75071. readonly slidePlaneNormal: Vector3;
  75072. /** @hidden */
  75073. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75074. /** @hidden */
  75075. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75076. /** @hidden */
  75077. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75078. /** @hidden */
  75079. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75080. /** @hidden */
  75081. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75082. /** @hidden */
  75083. _getResponse(pos: Vector3, vel: Vector3): void;
  75084. }
  75085. }
  75086. declare module BABYLON {
  75087. /**
  75088. * Interface for cullable objects
  75089. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75090. */
  75091. export interface ICullable {
  75092. /**
  75093. * Checks if the object or part of the object is in the frustum
  75094. * @param frustumPlanes Camera near/planes
  75095. * @returns true if the object is in frustum otherwise false
  75096. */
  75097. isInFrustum(frustumPlanes: Plane[]): boolean;
  75098. /**
  75099. * Checks if a cullable object (mesh...) is in the camera frustum
  75100. * Unlike isInFrustum this cheks the full bounding box
  75101. * @param frustumPlanes Camera near/planes
  75102. * @returns true if the object is in frustum otherwise false
  75103. */
  75104. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75105. }
  75106. /**
  75107. * Info for a bounding data of a mesh
  75108. */
  75109. export class BoundingInfo implements ICullable {
  75110. /**
  75111. * Bounding box for the mesh
  75112. */
  75113. readonly boundingBox: BoundingBox;
  75114. /**
  75115. * Bounding sphere for the mesh
  75116. */
  75117. readonly boundingSphere: BoundingSphere;
  75118. private _isLocked;
  75119. private static readonly TmpVector3;
  75120. /**
  75121. * Constructs bounding info
  75122. * @param minimum min vector of the bounding box/sphere
  75123. * @param maximum max vector of the bounding box/sphere
  75124. * @param worldMatrix defines the new world matrix
  75125. */
  75126. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75127. /**
  75128. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75129. * @param min defines the new minimum vector (in local space)
  75130. * @param max defines the new maximum vector (in local space)
  75131. * @param worldMatrix defines the new world matrix
  75132. */
  75133. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75134. /**
  75135. * min vector of the bounding box/sphere
  75136. */
  75137. readonly minimum: Vector3;
  75138. /**
  75139. * max vector of the bounding box/sphere
  75140. */
  75141. readonly maximum: Vector3;
  75142. /**
  75143. * If the info is locked and won't be updated to avoid perf overhead
  75144. */
  75145. isLocked: boolean;
  75146. /**
  75147. * Updates the bounding sphere and box
  75148. * @param world world matrix to be used to update
  75149. */
  75150. update(world: DeepImmutable<Matrix>): void;
  75151. /**
  75152. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75153. * @param center New center of the bounding info
  75154. * @param extend New extend of the bounding info
  75155. * @returns the current bounding info
  75156. */
  75157. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75158. /**
  75159. * Scale the current bounding info by applying a scale factor
  75160. * @param factor defines the scale factor to apply
  75161. * @returns the current bounding info
  75162. */
  75163. scale(factor: number): BoundingInfo;
  75164. /**
  75165. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75166. * @param frustumPlanes defines the frustum to test
  75167. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75168. * @returns true if the bounding info is in the frustum planes
  75169. */
  75170. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75171. /**
  75172. * Gets the world distance between the min and max points of the bounding box
  75173. */
  75174. readonly diagonalLength: number;
  75175. /**
  75176. * Checks if a cullable object (mesh...) is in the camera frustum
  75177. * Unlike isInFrustum this cheks the full bounding box
  75178. * @param frustumPlanes Camera near/planes
  75179. * @returns true if the object is in frustum otherwise false
  75180. */
  75181. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75182. /** @hidden */
  75183. _checkCollision(collider: Collider): boolean;
  75184. /**
  75185. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75186. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75187. * @param point the point to check intersection with
  75188. * @returns if the point intersects
  75189. */
  75190. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75191. /**
  75192. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75193. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75194. * @param boundingInfo the bounding info to check intersection with
  75195. * @param precise if the intersection should be done using OBB
  75196. * @returns if the bounding info intersects
  75197. */
  75198. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75199. }
  75200. }
  75201. declare module BABYLON {
  75202. /**
  75203. * Extracts minimum and maximum values from a list of indexed positions
  75204. * @param positions defines the positions to use
  75205. * @param indices defines the indices to the positions
  75206. * @param indexStart defines the start index
  75207. * @param indexCount defines the end index
  75208. * @param bias defines bias value to add to the result
  75209. * @return minimum and maximum values
  75210. */
  75211. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75212. minimum: Vector3;
  75213. maximum: Vector3;
  75214. };
  75215. /**
  75216. * Extracts minimum and maximum values from a list of positions
  75217. * @param positions defines the positions to use
  75218. * @param start defines the start index in the positions array
  75219. * @param count defines the number of positions to handle
  75220. * @param bias defines bias value to add to the result
  75221. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75222. * @return minimum and maximum values
  75223. */
  75224. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75225. minimum: Vector3;
  75226. maximum: Vector3;
  75227. };
  75228. }
  75229. declare module BABYLON {
  75230. /** @hidden */
  75231. export class WebGLDataBuffer extends DataBuffer {
  75232. private _buffer;
  75233. constructor(resource: WebGLBuffer);
  75234. readonly underlyingResource: any;
  75235. }
  75236. }
  75237. declare module BABYLON {
  75238. /** @hidden */
  75239. export class WebGLPipelineContext implements IPipelineContext {
  75240. engine: ThinEngine;
  75241. program: Nullable<WebGLProgram>;
  75242. context?: WebGLRenderingContext;
  75243. vertexShader?: WebGLShader;
  75244. fragmentShader?: WebGLShader;
  75245. isParallelCompiled: boolean;
  75246. onCompiled?: () => void;
  75247. transformFeedback?: WebGLTransformFeedback | null;
  75248. readonly isAsync: boolean;
  75249. readonly isReady: boolean;
  75250. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75251. }
  75252. }
  75253. declare module BABYLON {
  75254. interface ThinEngine {
  75255. /**
  75256. * Create an uniform buffer
  75257. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75258. * @param elements defines the content of the uniform buffer
  75259. * @returns the webGL uniform buffer
  75260. */
  75261. createUniformBuffer(elements: FloatArray): DataBuffer;
  75262. /**
  75263. * Create a dynamic uniform buffer
  75264. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75265. * @param elements defines the content of the uniform buffer
  75266. * @returns the webGL uniform buffer
  75267. */
  75268. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75269. /**
  75270. * Update an existing uniform buffer
  75271. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75272. * @param uniformBuffer defines the target uniform buffer
  75273. * @param elements defines the content to update
  75274. * @param offset defines the offset in the uniform buffer where update should start
  75275. * @param count defines the size of the data to update
  75276. */
  75277. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75278. /**
  75279. * Bind an uniform buffer to the current webGL context
  75280. * @param buffer defines the buffer to bind
  75281. */
  75282. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75283. /**
  75284. * Bind a buffer to the current webGL context at a given location
  75285. * @param buffer defines the buffer to bind
  75286. * @param location defines the index where to bind the buffer
  75287. */
  75288. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75289. /**
  75290. * Bind a specific block at a given index in a specific shader program
  75291. * @param pipelineContext defines the pipeline context to use
  75292. * @param blockName defines the block name
  75293. * @param index defines the index where to bind the block
  75294. */
  75295. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75296. }
  75297. }
  75298. declare module BABYLON {
  75299. /**
  75300. * Uniform buffer objects.
  75301. *
  75302. * Handles blocks of uniform on the GPU.
  75303. *
  75304. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75305. *
  75306. * For more information, please refer to :
  75307. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75308. */
  75309. export class UniformBuffer {
  75310. private _engine;
  75311. private _buffer;
  75312. private _data;
  75313. private _bufferData;
  75314. private _dynamic?;
  75315. private _uniformLocations;
  75316. private _uniformSizes;
  75317. private _uniformLocationPointer;
  75318. private _needSync;
  75319. private _noUBO;
  75320. private _currentEffect;
  75321. /** @hidden */
  75322. _alreadyBound: boolean;
  75323. private static _MAX_UNIFORM_SIZE;
  75324. private static _tempBuffer;
  75325. /**
  75326. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75327. * This is dynamic to allow compat with webgl 1 and 2.
  75328. * You will need to pass the name of the uniform as well as the value.
  75329. */
  75330. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75331. /**
  75332. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75333. * This is dynamic to allow compat with webgl 1 and 2.
  75334. * You will need to pass the name of the uniform as well as the value.
  75335. */
  75336. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75337. /**
  75338. * Lambda to Update a single float in a uniform buffer.
  75339. * This is dynamic to allow compat with webgl 1 and 2.
  75340. * You will need to pass the name of the uniform as well as the value.
  75341. */
  75342. updateFloat: (name: string, x: number) => void;
  75343. /**
  75344. * Lambda to Update a vec2 of float in a uniform buffer.
  75345. * This is dynamic to allow compat with webgl 1 and 2.
  75346. * You will need to pass the name of the uniform as well as the value.
  75347. */
  75348. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75349. /**
  75350. * Lambda to Update a vec3 of float in a uniform buffer.
  75351. * This is dynamic to allow compat with webgl 1 and 2.
  75352. * You will need to pass the name of the uniform as well as the value.
  75353. */
  75354. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75355. /**
  75356. * Lambda to Update a vec4 of float in a uniform buffer.
  75357. * This is dynamic to allow compat with webgl 1 and 2.
  75358. * You will need to pass the name of the uniform as well as the value.
  75359. */
  75360. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75361. /**
  75362. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75363. * This is dynamic to allow compat with webgl 1 and 2.
  75364. * You will need to pass the name of the uniform as well as the value.
  75365. */
  75366. updateMatrix: (name: string, mat: Matrix) => void;
  75367. /**
  75368. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75369. * This is dynamic to allow compat with webgl 1 and 2.
  75370. * You will need to pass the name of the uniform as well as the value.
  75371. */
  75372. updateVector3: (name: string, vector: Vector3) => void;
  75373. /**
  75374. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75375. * This is dynamic to allow compat with webgl 1 and 2.
  75376. * You will need to pass the name of the uniform as well as the value.
  75377. */
  75378. updateVector4: (name: string, vector: Vector4) => void;
  75379. /**
  75380. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75381. * This is dynamic to allow compat with webgl 1 and 2.
  75382. * You will need to pass the name of the uniform as well as the value.
  75383. */
  75384. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75385. /**
  75386. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75387. * This is dynamic to allow compat with webgl 1 and 2.
  75388. * You will need to pass the name of the uniform as well as the value.
  75389. */
  75390. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75391. /**
  75392. * Instantiates a new Uniform buffer objects.
  75393. *
  75394. * Handles blocks of uniform on the GPU.
  75395. *
  75396. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75397. *
  75398. * For more information, please refer to :
  75399. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75400. * @param engine Define the engine the buffer is associated with
  75401. * @param data Define the data contained in the buffer
  75402. * @param dynamic Define if the buffer is updatable
  75403. */
  75404. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75405. /**
  75406. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75407. * or just falling back on setUniformXXX calls.
  75408. */
  75409. readonly useUbo: boolean;
  75410. /**
  75411. * Indicates if the WebGL underlying uniform buffer is in sync
  75412. * with the javascript cache data.
  75413. */
  75414. readonly isSync: boolean;
  75415. /**
  75416. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75417. * Also, a dynamic UniformBuffer will disable cache verification and always
  75418. * update the underlying WebGL uniform buffer to the GPU.
  75419. * @returns if Dynamic, otherwise false
  75420. */
  75421. isDynamic(): boolean;
  75422. /**
  75423. * The data cache on JS side.
  75424. * @returns the underlying data as a float array
  75425. */
  75426. getData(): Float32Array;
  75427. /**
  75428. * The underlying WebGL Uniform buffer.
  75429. * @returns the webgl buffer
  75430. */
  75431. getBuffer(): Nullable<DataBuffer>;
  75432. /**
  75433. * std140 layout specifies how to align data within an UBO structure.
  75434. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75435. * for specs.
  75436. */
  75437. private _fillAlignment;
  75438. /**
  75439. * Adds an uniform in the buffer.
  75440. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75441. * for the layout to be correct !
  75442. * @param name Name of the uniform, as used in the uniform block in the shader.
  75443. * @param size Data size, or data directly.
  75444. */
  75445. addUniform(name: string, size: number | number[]): void;
  75446. /**
  75447. * Adds a Matrix 4x4 to the uniform buffer.
  75448. * @param name Name of the uniform, as used in the uniform block in the shader.
  75449. * @param mat A 4x4 matrix.
  75450. */
  75451. addMatrix(name: string, mat: Matrix): void;
  75452. /**
  75453. * Adds a vec2 to the uniform buffer.
  75454. * @param name Name of the uniform, as used in the uniform block in the shader.
  75455. * @param x Define the x component value of the vec2
  75456. * @param y Define the y component value of the vec2
  75457. */
  75458. addFloat2(name: string, x: number, y: number): void;
  75459. /**
  75460. * Adds a vec3 to the uniform buffer.
  75461. * @param name Name of the uniform, as used in the uniform block in the shader.
  75462. * @param x Define the x component value of the vec3
  75463. * @param y Define the y component value of the vec3
  75464. * @param z Define the z component value of the vec3
  75465. */
  75466. addFloat3(name: string, x: number, y: number, z: number): void;
  75467. /**
  75468. * Adds a vec3 to the uniform buffer.
  75469. * @param name Name of the uniform, as used in the uniform block in the shader.
  75470. * @param color Define the vec3 from a Color
  75471. */
  75472. addColor3(name: string, color: Color3): void;
  75473. /**
  75474. * Adds a vec4 to the uniform buffer.
  75475. * @param name Name of the uniform, as used in the uniform block in the shader.
  75476. * @param color Define the rgb components from a Color
  75477. * @param alpha Define the a component of the vec4
  75478. */
  75479. addColor4(name: string, color: Color3, alpha: number): void;
  75480. /**
  75481. * Adds a vec3 to the uniform buffer.
  75482. * @param name Name of the uniform, as used in the uniform block in the shader.
  75483. * @param vector Define the vec3 components from a Vector
  75484. */
  75485. addVector3(name: string, vector: Vector3): void;
  75486. /**
  75487. * Adds a Matrix 3x3 to the uniform buffer.
  75488. * @param name Name of the uniform, as used in the uniform block in the shader.
  75489. */
  75490. addMatrix3x3(name: string): void;
  75491. /**
  75492. * Adds a Matrix 2x2 to the uniform buffer.
  75493. * @param name Name of the uniform, as used in the uniform block in the shader.
  75494. */
  75495. addMatrix2x2(name: string): void;
  75496. /**
  75497. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75498. */
  75499. create(): void;
  75500. /** @hidden */
  75501. _rebuild(): void;
  75502. /**
  75503. * Updates the WebGL Uniform Buffer on the GPU.
  75504. * If the `dynamic` flag is set to true, no cache comparison is done.
  75505. * Otherwise, the buffer will be updated only if the cache differs.
  75506. */
  75507. update(): void;
  75508. /**
  75509. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75510. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75511. * @param data Define the flattened data
  75512. * @param size Define the size of the data.
  75513. */
  75514. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75515. private _valueCache;
  75516. private _cacheMatrix;
  75517. private _updateMatrix3x3ForUniform;
  75518. private _updateMatrix3x3ForEffect;
  75519. private _updateMatrix2x2ForEffect;
  75520. private _updateMatrix2x2ForUniform;
  75521. private _updateFloatForEffect;
  75522. private _updateFloatForUniform;
  75523. private _updateFloat2ForEffect;
  75524. private _updateFloat2ForUniform;
  75525. private _updateFloat3ForEffect;
  75526. private _updateFloat3ForUniform;
  75527. private _updateFloat4ForEffect;
  75528. private _updateFloat4ForUniform;
  75529. private _updateMatrixForEffect;
  75530. private _updateMatrixForUniform;
  75531. private _updateVector3ForEffect;
  75532. private _updateVector3ForUniform;
  75533. private _updateVector4ForEffect;
  75534. private _updateVector4ForUniform;
  75535. private _updateColor3ForEffect;
  75536. private _updateColor3ForUniform;
  75537. private _updateColor4ForEffect;
  75538. private _updateColor4ForUniform;
  75539. /**
  75540. * Sets a sampler uniform on the effect.
  75541. * @param name Define the name of the sampler.
  75542. * @param texture Define the texture to set in the sampler
  75543. */
  75544. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75545. /**
  75546. * Directly updates the value of the uniform in the cache AND on the GPU.
  75547. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75548. * @param data Define the flattened data
  75549. */
  75550. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75551. /**
  75552. * Binds this uniform buffer to an effect.
  75553. * @param effect Define the effect to bind the buffer to
  75554. * @param name Name of the uniform block in the shader.
  75555. */
  75556. bindToEffect(effect: Effect, name: string): void;
  75557. /**
  75558. * Disposes the uniform buffer.
  75559. */
  75560. dispose(): void;
  75561. }
  75562. }
  75563. declare module BABYLON {
  75564. /**
  75565. * Enum that determines the text-wrapping mode to use.
  75566. */
  75567. export enum InspectableType {
  75568. /**
  75569. * Checkbox for booleans
  75570. */
  75571. Checkbox = 0,
  75572. /**
  75573. * Sliders for numbers
  75574. */
  75575. Slider = 1,
  75576. /**
  75577. * Vector3
  75578. */
  75579. Vector3 = 2,
  75580. /**
  75581. * Quaternions
  75582. */
  75583. Quaternion = 3,
  75584. /**
  75585. * Color3
  75586. */
  75587. Color3 = 4,
  75588. /**
  75589. * String
  75590. */
  75591. String = 5
  75592. }
  75593. /**
  75594. * Interface used to define custom inspectable properties.
  75595. * This interface is used by the inspector to display custom property grids
  75596. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75597. */
  75598. export interface IInspectable {
  75599. /**
  75600. * Gets the label to display
  75601. */
  75602. label: string;
  75603. /**
  75604. * Gets the name of the property to edit
  75605. */
  75606. propertyName: string;
  75607. /**
  75608. * Gets the type of the editor to use
  75609. */
  75610. type: InspectableType;
  75611. /**
  75612. * Gets the minimum value of the property when using in "slider" mode
  75613. */
  75614. min?: number;
  75615. /**
  75616. * Gets the maximum value of the property when using in "slider" mode
  75617. */
  75618. max?: number;
  75619. /**
  75620. * Gets the setp to use when using in "slider" mode
  75621. */
  75622. step?: number;
  75623. }
  75624. }
  75625. declare module BABYLON {
  75626. /**
  75627. * Class used to provide helper for timing
  75628. */
  75629. export class TimingTools {
  75630. /**
  75631. * Polyfill for setImmediate
  75632. * @param action defines the action to execute after the current execution block
  75633. */
  75634. static SetImmediate(action: () => void): void;
  75635. }
  75636. }
  75637. declare module BABYLON {
  75638. /**
  75639. * Class used to enable instatition of objects by class name
  75640. */
  75641. export class InstantiationTools {
  75642. /**
  75643. * Use this object to register external classes like custom textures or material
  75644. * to allow the laoders to instantiate them
  75645. */
  75646. static RegisteredExternalClasses: {
  75647. [key: string]: Object;
  75648. };
  75649. /**
  75650. * Tries to instantiate a new object from a given class name
  75651. * @param className defines the class name to instantiate
  75652. * @returns the new object or null if the system was not able to do the instantiation
  75653. */
  75654. static Instantiate(className: string): any;
  75655. }
  75656. }
  75657. declare module BABYLON {
  75658. /**
  75659. * Define options used to create a depth texture
  75660. */
  75661. export class DepthTextureCreationOptions {
  75662. /** Specifies whether or not a stencil should be allocated in the texture */
  75663. generateStencil?: boolean;
  75664. /** Specifies whether or not bilinear filtering is enable on the texture */
  75665. bilinearFiltering?: boolean;
  75666. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75667. comparisonFunction?: number;
  75668. /** Specifies if the created texture is a cube texture */
  75669. isCube?: boolean;
  75670. }
  75671. }
  75672. declare module BABYLON {
  75673. interface ThinEngine {
  75674. /**
  75675. * Creates a depth stencil cube texture.
  75676. * This is only available in WebGL 2.
  75677. * @param size The size of face edge in the cube texture.
  75678. * @param options The options defining the cube texture.
  75679. * @returns The cube texture
  75680. */
  75681. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75682. /**
  75683. * Creates a cube texture
  75684. * @param rootUrl defines the url where the files to load is located
  75685. * @param scene defines the current scene
  75686. * @param files defines the list of files to load (1 per face)
  75687. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75688. * @param onLoad defines an optional callback raised when the texture is loaded
  75689. * @param onError defines an optional callback raised if there is an issue to load the texture
  75690. * @param format defines the format of the data
  75691. * @param forcedExtension defines the extension to use to pick the right loader
  75692. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75693. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75694. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75695. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75696. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75697. * @returns the cube texture as an InternalTexture
  75698. */
  75699. 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;
  75700. /**
  75701. * Creates a cube texture
  75702. * @param rootUrl defines the url where the files to load is located
  75703. * @param scene defines the current scene
  75704. * @param files defines the list of files to load (1 per face)
  75705. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75706. * @param onLoad defines an optional callback raised when the texture is loaded
  75707. * @param onError defines an optional callback raised if there is an issue to load the texture
  75708. * @param format defines the format of the data
  75709. * @param forcedExtension defines the extension to use to pick the right loader
  75710. * @returns the cube texture as an InternalTexture
  75711. */
  75712. 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;
  75713. /**
  75714. * Creates a cube texture
  75715. * @param rootUrl defines the url where the files to load is located
  75716. * @param scene defines the current scene
  75717. * @param files defines the list of files to load (1 per face)
  75718. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75719. * @param onLoad defines an optional callback raised when the texture is loaded
  75720. * @param onError defines an optional callback raised if there is an issue to load the texture
  75721. * @param format defines the format of the data
  75722. * @param forcedExtension defines the extension to use to pick the right loader
  75723. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75724. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75725. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75726. * @returns the cube texture as an InternalTexture
  75727. */
  75728. 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;
  75729. /** @hidden */
  75730. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75731. /** @hidden */
  75732. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75733. /** @hidden */
  75734. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75735. /** @hidden */
  75736. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75737. /**
  75738. * @hidden
  75739. */
  75740. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75741. }
  75742. }
  75743. declare module BABYLON {
  75744. /**
  75745. * Class for creating a cube texture
  75746. */
  75747. export class CubeTexture extends BaseTexture {
  75748. private _delayedOnLoad;
  75749. /**
  75750. * The url of the texture
  75751. */
  75752. url: string;
  75753. /**
  75754. * Gets or sets the center of the bounding box associated with the cube texture.
  75755. * It must define where the camera used to render the texture was set
  75756. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75757. */
  75758. boundingBoxPosition: Vector3;
  75759. private _boundingBoxSize;
  75760. /**
  75761. * Gets or sets the size of the bounding box associated with the cube texture
  75762. * When defined, the cubemap will switch to local mode
  75763. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75764. * @example https://www.babylonjs-playground.com/#RNASML
  75765. */
  75766. /**
  75767. * Returns the bounding box size
  75768. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75769. */
  75770. boundingBoxSize: Vector3;
  75771. protected _rotationY: number;
  75772. /**
  75773. * Sets texture matrix rotation angle around Y axis in radians.
  75774. */
  75775. /**
  75776. * Gets texture matrix rotation angle around Y axis radians.
  75777. */
  75778. rotationY: number;
  75779. /**
  75780. * Are mip maps generated for this texture or not.
  75781. */
  75782. readonly noMipmap: boolean;
  75783. private _noMipmap;
  75784. private _files;
  75785. protected _forcedExtension: Nullable<string>;
  75786. private _extensions;
  75787. private _textureMatrix;
  75788. private _format;
  75789. private _createPolynomials;
  75790. /** @hidden */
  75791. _prefiltered: boolean;
  75792. /**
  75793. * Creates a cube texture from an array of image urls
  75794. * @param files defines an array of image urls
  75795. * @param scene defines the hosting scene
  75796. * @param noMipmap specifies if mip maps are not used
  75797. * @returns a cube texture
  75798. */
  75799. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75800. /**
  75801. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75802. * @param url defines the url of the prefiltered texture
  75803. * @param scene defines the scene the texture is attached to
  75804. * @param forcedExtension defines the extension of the file if different from the url
  75805. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75806. * @return the prefiltered texture
  75807. */
  75808. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75809. /**
  75810. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75811. * as prefiltered data.
  75812. * @param rootUrl defines the url of the texture or the root name of the six images
  75813. * @param scene defines the scene the texture is attached to
  75814. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75815. * @param noMipmap defines if mipmaps should be created or not
  75816. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75817. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75818. * @param onError defines a callback triggered in case of error during load
  75819. * @param format defines the internal format to use for the texture once loaded
  75820. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75821. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75822. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75823. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75824. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75825. * @return the cube texture
  75826. */
  75827. 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);
  75828. /**
  75829. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75830. */
  75831. readonly isPrefiltered: boolean;
  75832. /**
  75833. * Get the current class name of the texture useful for serialization or dynamic coding.
  75834. * @returns "CubeTexture"
  75835. */
  75836. getClassName(): string;
  75837. /**
  75838. * Update the url (and optional buffer) of this texture if url was null during construction.
  75839. * @param url the url of the texture
  75840. * @param forcedExtension defines the extension to use
  75841. * @param onLoad callback called when the texture is loaded (defaults to null)
  75842. */
  75843. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75844. /**
  75845. * Delays loading of the cube texture
  75846. * @param forcedExtension defines the extension to use
  75847. */
  75848. delayLoad(forcedExtension?: string): void;
  75849. /**
  75850. * Returns the reflection texture matrix
  75851. * @returns the reflection texture matrix
  75852. */
  75853. getReflectionTextureMatrix(): Matrix;
  75854. /**
  75855. * Sets the reflection texture matrix
  75856. * @param value Reflection texture matrix
  75857. */
  75858. setReflectionTextureMatrix(value: Matrix): void;
  75859. /**
  75860. * Parses text to create a cube texture
  75861. * @param parsedTexture define the serialized text to read from
  75862. * @param scene defines the hosting scene
  75863. * @param rootUrl defines the root url of the cube texture
  75864. * @returns a cube texture
  75865. */
  75866. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75867. /**
  75868. * Makes a clone, or deep copy, of the cube texture
  75869. * @returns a new cube texture
  75870. */
  75871. clone(): CubeTexture;
  75872. }
  75873. }
  75874. declare module BABYLON {
  75875. /**
  75876. * Manages the defines for the Material
  75877. */
  75878. export class MaterialDefines {
  75879. /** @hidden */
  75880. protected _keys: string[];
  75881. private _isDirty;
  75882. /** @hidden */
  75883. _renderId: number;
  75884. /** @hidden */
  75885. _areLightsDirty: boolean;
  75886. /** @hidden */
  75887. _areLightsDisposed: boolean;
  75888. /** @hidden */
  75889. _areAttributesDirty: boolean;
  75890. /** @hidden */
  75891. _areTexturesDirty: boolean;
  75892. /** @hidden */
  75893. _areFresnelDirty: boolean;
  75894. /** @hidden */
  75895. _areMiscDirty: boolean;
  75896. /** @hidden */
  75897. _areImageProcessingDirty: boolean;
  75898. /** @hidden */
  75899. _normals: boolean;
  75900. /** @hidden */
  75901. _uvs: boolean;
  75902. /** @hidden */
  75903. _needNormals: boolean;
  75904. /** @hidden */
  75905. _needUVs: boolean;
  75906. [id: string]: any;
  75907. /**
  75908. * Specifies if the material needs to be re-calculated
  75909. */
  75910. readonly isDirty: boolean;
  75911. /**
  75912. * Marks the material to indicate that it has been re-calculated
  75913. */
  75914. markAsProcessed(): void;
  75915. /**
  75916. * Marks the material to indicate that it needs to be re-calculated
  75917. */
  75918. markAsUnprocessed(): void;
  75919. /**
  75920. * Marks the material to indicate all of its defines need to be re-calculated
  75921. */
  75922. markAllAsDirty(): void;
  75923. /**
  75924. * Marks the material to indicate that image processing needs to be re-calculated
  75925. */
  75926. markAsImageProcessingDirty(): void;
  75927. /**
  75928. * Marks the material to indicate the lights need to be re-calculated
  75929. * @param disposed Defines whether the light is dirty due to dispose or not
  75930. */
  75931. markAsLightDirty(disposed?: boolean): void;
  75932. /**
  75933. * Marks the attribute state as changed
  75934. */
  75935. markAsAttributesDirty(): void;
  75936. /**
  75937. * Marks the texture state as changed
  75938. */
  75939. markAsTexturesDirty(): void;
  75940. /**
  75941. * Marks the fresnel state as changed
  75942. */
  75943. markAsFresnelDirty(): void;
  75944. /**
  75945. * Marks the misc state as changed
  75946. */
  75947. markAsMiscDirty(): void;
  75948. /**
  75949. * Rebuilds the material defines
  75950. */
  75951. rebuild(): void;
  75952. /**
  75953. * Specifies if two material defines are equal
  75954. * @param other - A material define instance to compare to
  75955. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75956. */
  75957. isEqual(other: MaterialDefines): boolean;
  75958. /**
  75959. * Clones this instance's defines to another instance
  75960. * @param other - material defines to clone values to
  75961. */
  75962. cloneTo(other: MaterialDefines): void;
  75963. /**
  75964. * Resets the material define values
  75965. */
  75966. reset(): void;
  75967. /**
  75968. * Converts the material define values to a string
  75969. * @returns - String of material define information
  75970. */
  75971. toString(): string;
  75972. }
  75973. }
  75974. declare module BABYLON {
  75975. /**
  75976. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75977. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75978. * 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;
  75979. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75980. */
  75981. export class ColorCurves {
  75982. private _dirty;
  75983. private _tempColor;
  75984. private _globalCurve;
  75985. private _highlightsCurve;
  75986. private _midtonesCurve;
  75987. private _shadowsCurve;
  75988. private _positiveCurve;
  75989. private _negativeCurve;
  75990. private _globalHue;
  75991. private _globalDensity;
  75992. private _globalSaturation;
  75993. private _globalExposure;
  75994. /**
  75995. * Gets the global Hue value.
  75996. * 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).
  75997. */
  75998. /**
  75999. * Sets the global Hue value.
  76000. * 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).
  76001. */
  76002. globalHue: number;
  76003. /**
  76004. * Gets the global Density value.
  76005. * 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.
  76006. * Values less than zero provide a filter of opposite hue.
  76007. */
  76008. /**
  76009. * Sets the global Density value.
  76010. * 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.
  76011. * Values less than zero provide a filter of opposite hue.
  76012. */
  76013. globalDensity: number;
  76014. /**
  76015. * Gets the global Saturation value.
  76016. * 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.
  76017. */
  76018. /**
  76019. * Sets the global Saturation value.
  76020. * 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.
  76021. */
  76022. globalSaturation: number;
  76023. /**
  76024. * Gets the global Exposure value.
  76025. * 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.
  76026. */
  76027. /**
  76028. * Sets the global Exposure value.
  76029. * 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.
  76030. */
  76031. globalExposure: number;
  76032. private _highlightsHue;
  76033. private _highlightsDensity;
  76034. private _highlightsSaturation;
  76035. private _highlightsExposure;
  76036. /**
  76037. * Gets the highlights Hue value.
  76038. * 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).
  76039. */
  76040. /**
  76041. * Sets the highlights Hue value.
  76042. * 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).
  76043. */
  76044. highlightsHue: number;
  76045. /**
  76046. * Gets the highlights Density value.
  76047. * 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.
  76048. * Values less than zero provide a filter of opposite hue.
  76049. */
  76050. /**
  76051. * Sets the highlights Density value.
  76052. * 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.
  76053. * Values less than zero provide a filter of opposite hue.
  76054. */
  76055. highlightsDensity: number;
  76056. /**
  76057. * Gets the highlights Saturation value.
  76058. * 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.
  76059. */
  76060. /**
  76061. * Sets the highlights Saturation value.
  76062. * 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.
  76063. */
  76064. highlightsSaturation: number;
  76065. /**
  76066. * Gets the highlights Exposure value.
  76067. * 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.
  76068. */
  76069. /**
  76070. * Sets the highlights Exposure value.
  76071. * 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.
  76072. */
  76073. highlightsExposure: number;
  76074. private _midtonesHue;
  76075. private _midtonesDensity;
  76076. private _midtonesSaturation;
  76077. private _midtonesExposure;
  76078. /**
  76079. * Gets the midtones Hue value.
  76080. * 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).
  76081. */
  76082. /**
  76083. * Sets the midtones Hue value.
  76084. * 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).
  76085. */
  76086. midtonesHue: number;
  76087. /**
  76088. * Gets the midtones Density value.
  76089. * 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.
  76090. * Values less than zero provide a filter of opposite hue.
  76091. */
  76092. /**
  76093. * Sets the midtones Density value.
  76094. * 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.
  76095. * Values less than zero provide a filter of opposite hue.
  76096. */
  76097. midtonesDensity: number;
  76098. /**
  76099. * Gets the midtones Saturation value.
  76100. * 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.
  76101. */
  76102. /**
  76103. * Sets the midtones Saturation value.
  76104. * 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.
  76105. */
  76106. midtonesSaturation: number;
  76107. /**
  76108. * Gets the midtones Exposure value.
  76109. * 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.
  76110. */
  76111. /**
  76112. * Sets the midtones Exposure value.
  76113. * 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.
  76114. */
  76115. midtonesExposure: number;
  76116. private _shadowsHue;
  76117. private _shadowsDensity;
  76118. private _shadowsSaturation;
  76119. private _shadowsExposure;
  76120. /**
  76121. * Gets the shadows Hue value.
  76122. * 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).
  76123. */
  76124. /**
  76125. * Sets the shadows Hue value.
  76126. * 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).
  76127. */
  76128. shadowsHue: number;
  76129. /**
  76130. * Gets the shadows Density value.
  76131. * 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.
  76132. * Values less than zero provide a filter of opposite hue.
  76133. */
  76134. /**
  76135. * Sets the shadows Density value.
  76136. * 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.
  76137. * Values less than zero provide a filter of opposite hue.
  76138. */
  76139. shadowsDensity: number;
  76140. /**
  76141. * Gets the shadows Saturation value.
  76142. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  76143. */
  76144. /**
  76145. * Sets the shadows Saturation value.
  76146. * 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.
  76147. */
  76148. shadowsSaturation: number;
  76149. /**
  76150. * Gets the shadows Exposure value.
  76151. * 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.
  76152. */
  76153. /**
  76154. * Sets the shadows Exposure value.
  76155. * 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.
  76156. */
  76157. shadowsExposure: number;
  76158. /**
  76159. * Returns the class name
  76160. * @returns The class name
  76161. */
  76162. getClassName(): string;
  76163. /**
  76164. * Binds the color curves to the shader.
  76165. * @param colorCurves The color curve to bind
  76166. * @param effect The effect to bind to
  76167. * @param positiveUniform The positive uniform shader parameter
  76168. * @param neutralUniform The neutral uniform shader parameter
  76169. * @param negativeUniform The negative uniform shader parameter
  76170. */
  76171. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76172. /**
  76173. * Prepare the list of uniforms associated with the ColorCurves effects.
  76174. * @param uniformsList The list of uniforms used in the effect
  76175. */
  76176. static PrepareUniforms(uniformsList: string[]): void;
  76177. /**
  76178. * Returns color grading data based on a hue, density, saturation and exposure value.
  76179. * @param filterHue The hue of the color filter.
  76180. * @param filterDensity The density of the color filter.
  76181. * @param saturation The saturation.
  76182. * @param exposure The exposure.
  76183. * @param result The result data container.
  76184. */
  76185. private getColorGradingDataToRef;
  76186. /**
  76187. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76188. * @param value The input slider value in range [-100,100].
  76189. * @returns Adjusted value.
  76190. */
  76191. private static applyColorGradingSliderNonlinear;
  76192. /**
  76193. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76194. * @param hue The hue (H) input.
  76195. * @param saturation The saturation (S) input.
  76196. * @param brightness The brightness (B) input.
  76197. * @result An RGBA color represented as Vector4.
  76198. */
  76199. private static fromHSBToRef;
  76200. /**
  76201. * Returns a value clamped between min and max
  76202. * @param value The value to clamp
  76203. * @param min The minimum of value
  76204. * @param max The maximum of value
  76205. * @returns The clamped value.
  76206. */
  76207. private static clamp;
  76208. /**
  76209. * Clones the current color curve instance.
  76210. * @return The cloned curves
  76211. */
  76212. clone(): ColorCurves;
  76213. /**
  76214. * Serializes the current color curve instance to a json representation.
  76215. * @return a JSON representation
  76216. */
  76217. serialize(): any;
  76218. /**
  76219. * Parses the color curve from a json representation.
  76220. * @param source the JSON source to parse
  76221. * @return The parsed curves
  76222. */
  76223. static Parse(source: any): ColorCurves;
  76224. }
  76225. }
  76226. declare module BABYLON {
  76227. /**
  76228. * Interface to follow in your material defines to integrate easily the
  76229. * Image proccessing functions.
  76230. * @hidden
  76231. */
  76232. export interface IImageProcessingConfigurationDefines {
  76233. IMAGEPROCESSING: boolean;
  76234. VIGNETTE: boolean;
  76235. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76236. VIGNETTEBLENDMODEOPAQUE: boolean;
  76237. TONEMAPPING: boolean;
  76238. TONEMAPPING_ACES: boolean;
  76239. CONTRAST: boolean;
  76240. EXPOSURE: boolean;
  76241. COLORCURVES: boolean;
  76242. COLORGRADING: boolean;
  76243. COLORGRADING3D: boolean;
  76244. SAMPLER3DGREENDEPTH: boolean;
  76245. SAMPLER3DBGRMAP: boolean;
  76246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76247. }
  76248. /**
  76249. * @hidden
  76250. */
  76251. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76252. IMAGEPROCESSING: boolean;
  76253. VIGNETTE: boolean;
  76254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76255. VIGNETTEBLENDMODEOPAQUE: boolean;
  76256. TONEMAPPING: boolean;
  76257. TONEMAPPING_ACES: boolean;
  76258. CONTRAST: boolean;
  76259. COLORCURVES: boolean;
  76260. COLORGRADING: boolean;
  76261. COLORGRADING3D: boolean;
  76262. SAMPLER3DGREENDEPTH: boolean;
  76263. SAMPLER3DBGRMAP: boolean;
  76264. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76265. EXPOSURE: boolean;
  76266. constructor();
  76267. }
  76268. /**
  76269. * This groups together the common properties used for image processing either in direct forward pass
  76270. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76271. * or not.
  76272. */
  76273. export class ImageProcessingConfiguration {
  76274. /**
  76275. * Default tone mapping applied in BabylonJS.
  76276. */
  76277. static readonly TONEMAPPING_STANDARD: number;
  76278. /**
  76279. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76280. * to other engines rendering to increase portability.
  76281. */
  76282. static readonly TONEMAPPING_ACES: number;
  76283. /**
  76284. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76285. */
  76286. colorCurves: Nullable<ColorCurves>;
  76287. private _colorCurvesEnabled;
  76288. /**
  76289. * Gets wether the color curves effect is enabled.
  76290. */
  76291. /**
  76292. * Sets wether the color curves effect is enabled.
  76293. */
  76294. colorCurvesEnabled: boolean;
  76295. private _colorGradingTexture;
  76296. /**
  76297. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76298. */
  76299. /**
  76300. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76301. */
  76302. colorGradingTexture: Nullable<BaseTexture>;
  76303. private _colorGradingEnabled;
  76304. /**
  76305. * Gets wether the color grading effect is enabled.
  76306. */
  76307. /**
  76308. * Sets wether the color grading effect is enabled.
  76309. */
  76310. colorGradingEnabled: boolean;
  76311. private _colorGradingWithGreenDepth;
  76312. /**
  76313. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76314. */
  76315. /**
  76316. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76317. */
  76318. colorGradingWithGreenDepth: boolean;
  76319. private _colorGradingBGR;
  76320. /**
  76321. * Gets wether the color grading texture contains BGR values.
  76322. */
  76323. /**
  76324. * Sets wether the color grading texture contains BGR values.
  76325. */
  76326. colorGradingBGR: boolean;
  76327. /** @hidden */
  76328. _exposure: number;
  76329. /**
  76330. * Gets the Exposure used in the effect.
  76331. */
  76332. /**
  76333. * Sets the Exposure used in the effect.
  76334. */
  76335. exposure: number;
  76336. private _toneMappingEnabled;
  76337. /**
  76338. * Gets wether the tone mapping effect is enabled.
  76339. */
  76340. /**
  76341. * Sets wether the tone mapping effect is enabled.
  76342. */
  76343. toneMappingEnabled: boolean;
  76344. private _toneMappingType;
  76345. /**
  76346. * Gets the type of tone mapping effect.
  76347. */
  76348. /**
  76349. * Sets the type of tone mapping effect used in BabylonJS.
  76350. */
  76351. toneMappingType: number;
  76352. protected _contrast: number;
  76353. /**
  76354. * Gets the contrast used in the effect.
  76355. */
  76356. /**
  76357. * Sets the contrast used in the effect.
  76358. */
  76359. contrast: number;
  76360. /**
  76361. * Vignette stretch size.
  76362. */
  76363. vignetteStretch: number;
  76364. /**
  76365. * Vignette centre X Offset.
  76366. */
  76367. vignetteCentreX: number;
  76368. /**
  76369. * Vignette centre Y Offset.
  76370. */
  76371. vignetteCentreY: number;
  76372. /**
  76373. * Vignette weight or intensity of the vignette effect.
  76374. */
  76375. vignetteWeight: number;
  76376. /**
  76377. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76378. * if vignetteEnabled is set to true.
  76379. */
  76380. vignetteColor: Color4;
  76381. /**
  76382. * Camera field of view used by the Vignette effect.
  76383. */
  76384. vignetteCameraFov: number;
  76385. private _vignetteBlendMode;
  76386. /**
  76387. * Gets the vignette blend mode allowing different kind of effect.
  76388. */
  76389. /**
  76390. * Sets the vignette blend mode allowing different kind of effect.
  76391. */
  76392. vignetteBlendMode: number;
  76393. private _vignetteEnabled;
  76394. /**
  76395. * Gets wether the vignette effect is enabled.
  76396. */
  76397. /**
  76398. * Sets wether the vignette effect is enabled.
  76399. */
  76400. vignetteEnabled: boolean;
  76401. private _applyByPostProcess;
  76402. /**
  76403. * Gets wether the image processing is applied through a post process or not.
  76404. */
  76405. /**
  76406. * Sets wether the image processing is applied through a post process or not.
  76407. */
  76408. applyByPostProcess: boolean;
  76409. private _isEnabled;
  76410. /**
  76411. * Gets wether the image processing is enabled or not.
  76412. */
  76413. /**
  76414. * Sets wether the image processing is enabled or not.
  76415. */
  76416. isEnabled: boolean;
  76417. /**
  76418. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76419. */
  76420. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76421. /**
  76422. * Method called each time the image processing information changes requires to recompile the effect.
  76423. */
  76424. protected _updateParameters(): void;
  76425. /**
  76426. * Gets the current class name.
  76427. * @return "ImageProcessingConfiguration"
  76428. */
  76429. getClassName(): string;
  76430. /**
  76431. * Prepare the list of uniforms associated with the Image Processing effects.
  76432. * @param uniforms The list of uniforms used in the effect
  76433. * @param defines the list of defines currently in use
  76434. */
  76435. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76436. /**
  76437. * Prepare the list of samplers associated with the Image Processing effects.
  76438. * @param samplersList The list of uniforms used in the effect
  76439. * @param defines the list of defines currently in use
  76440. */
  76441. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76442. /**
  76443. * Prepare the list of defines associated to the shader.
  76444. * @param defines the list of defines to complete
  76445. * @param forPostProcess Define if we are currently in post process mode or not
  76446. */
  76447. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76448. /**
  76449. * Returns true if all the image processing information are ready.
  76450. * @returns True if ready, otherwise, false
  76451. */
  76452. isReady(): boolean;
  76453. /**
  76454. * Binds the image processing to the shader.
  76455. * @param effect The effect to bind to
  76456. * @param overrideAspectRatio Override the aspect ratio of the effect
  76457. */
  76458. bind(effect: Effect, overrideAspectRatio?: number): void;
  76459. /**
  76460. * Clones the current image processing instance.
  76461. * @return The cloned image processing
  76462. */
  76463. clone(): ImageProcessingConfiguration;
  76464. /**
  76465. * Serializes the current image processing instance to a json representation.
  76466. * @return a JSON representation
  76467. */
  76468. serialize(): any;
  76469. /**
  76470. * Parses the image processing from a json representation.
  76471. * @param source the JSON source to parse
  76472. * @return The parsed image processing
  76473. */
  76474. static Parse(source: any): ImageProcessingConfiguration;
  76475. private static _VIGNETTEMODE_MULTIPLY;
  76476. private static _VIGNETTEMODE_OPAQUE;
  76477. /**
  76478. * Used to apply the vignette as a mix with the pixel color.
  76479. */
  76480. static readonly VIGNETTEMODE_MULTIPLY: number;
  76481. /**
  76482. * Used to apply the vignette as a replacement of the pixel color.
  76483. */
  76484. static readonly VIGNETTEMODE_OPAQUE: number;
  76485. }
  76486. }
  76487. declare module BABYLON {
  76488. /** @hidden */
  76489. export var postprocessVertexShader: {
  76490. name: string;
  76491. shader: string;
  76492. };
  76493. }
  76494. declare module BABYLON {
  76495. interface ThinEngine {
  76496. /**
  76497. * Creates a new render target texture
  76498. * @param size defines the size of the texture
  76499. * @param options defines the options used to create the texture
  76500. * @returns a new render target texture stored in an InternalTexture
  76501. */
  76502. createRenderTargetTexture(size: number | {
  76503. width: number;
  76504. height: number;
  76505. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76506. /**
  76507. * Creates a depth stencil texture.
  76508. * This is only available in WebGL 2 or with the depth texture extension available.
  76509. * @param size The size of face edge in the texture.
  76510. * @param options The options defining the texture.
  76511. * @returns The texture
  76512. */
  76513. createDepthStencilTexture(size: number | {
  76514. width: number;
  76515. height: number;
  76516. }, options: DepthTextureCreationOptions): InternalTexture;
  76517. /** @hidden */
  76518. _createDepthStencilTexture(size: number | {
  76519. width: number;
  76520. height: number;
  76521. }, options: DepthTextureCreationOptions): InternalTexture;
  76522. }
  76523. }
  76524. declare module BABYLON {
  76525. /** Defines supported spaces */
  76526. export enum Space {
  76527. /** Local (object) space */
  76528. LOCAL = 0,
  76529. /** World space */
  76530. WORLD = 1,
  76531. /** Bone space */
  76532. BONE = 2
  76533. }
  76534. /** Defines the 3 main axes */
  76535. export class Axis {
  76536. /** X axis */
  76537. static X: Vector3;
  76538. /** Y axis */
  76539. static Y: Vector3;
  76540. /** Z axis */
  76541. static Z: Vector3;
  76542. }
  76543. }
  76544. declare module BABYLON {
  76545. /**
  76546. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76547. * This is the base of the follow, arc rotate cameras and Free camera
  76548. * @see http://doc.babylonjs.com/features/cameras
  76549. */
  76550. export class TargetCamera extends Camera {
  76551. private static _RigCamTransformMatrix;
  76552. private static _TargetTransformMatrix;
  76553. private static _TargetFocalPoint;
  76554. /**
  76555. * Define the current direction the camera is moving to
  76556. */
  76557. cameraDirection: Vector3;
  76558. /**
  76559. * Define the current rotation the camera is rotating to
  76560. */
  76561. cameraRotation: Vector2;
  76562. /**
  76563. * When set, the up vector of the camera will be updated by the rotation of the camera
  76564. */
  76565. updateUpVectorFromRotation: boolean;
  76566. private _tmpQuaternion;
  76567. /**
  76568. * Define the current rotation of the camera
  76569. */
  76570. rotation: Vector3;
  76571. /**
  76572. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76573. */
  76574. rotationQuaternion: Quaternion;
  76575. /**
  76576. * Define the current speed of the camera
  76577. */
  76578. speed: number;
  76579. /**
  76580. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76581. * around all axis.
  76582. */
  76583. noRotationConstraint: boolean;
  76584. /**
  76585. * Define the current target of the camera as an object or a position.
  76586. */
  76587. lockedTarget: any;
  76588. /** @hidden */
  76589. _currentTarget: Vector3;
  76590. /** @hidden */
  76591. _initialFocalDistance: number;
  76592. /** @hidden */
  76593. _viewMatrix: Matrix;
  76594. /** @hidden */
  76595. _camMatrix: Matrix;
  76596. /** @hidden */
  76597. _cameraTransformMatrix: Matrix;
  76598. /** @hidden */
  76599. _cameraRotationMatrix: Matrix;
  76600. /** @hidden */
  76601. _referencePoint: Vector3;
  76602. /** @hidden */
  76603. _transformedReferencePoint: Vector3;
  76604. protected _globalCurrentTarget: Vector3;
  76605. protected _globalCurrentUpVector: Vector3;
  76606. /** @hidden */
  76607. _reset: () => void;
  76608. private _defaultUp;
  76609. /**
  76610. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76611. * This is the base of the follow, arc rotate cameras and Free camera
  76612. * @see http://doc.babylonjs.com/features/cameras
  76613. * @param name Defines the name of the camera in the scene
  76614. * @param position Defines the start position of the camera in the scene
  76615. * @param scene Defines the scene the camera belongs to
  76616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76617. */
  76618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76619. /**
  76620. * Gets the position in front of the camera at a given distance.
  76621. * @param distance The distance from the camera we want the position to be
  76622. * @returns the position
  76623. */
  76624. getFrontPosition(distance: number): Vector3;
  76625. /** @hidden */
  76626. _getLockedTargetPosition(): Nullable<Vector3>;
  76627. private _storedPosition;
  76628. private _storedRotation;
  76629. private _storedRotationQuaternion;
  76630. /**
  76631. * Store current camera state of the camera (fov, position, rotation, etc..)
  76632. * @returns the camera
  76633. */
  76634. storeState(): Camera;
  76635. /**
  76636. * Restored camera state. You must call storeState() first
  76637. * @returns whether it was successful or not
  76638. * @hidden
  76639. */
  76640. _restoreStateValues(): boolean;
  76641. /** @hidden */
  76642. _initCache(): void;
  76643. /** @hidden */
  76644. _updateCache(ignoreParentClass?: boolean): void;
  76645. /** @hidden */
  76646. _isSynchronizedViewMatrix(): boolean;
  76647. /** @hidden */
  76648. _computeLocalCameraSpeed(): number;
  76649. /**
  76650. * Defines the target the camera should look at.
  76651. * @param target Defines the new target as a Vector or a mesh
  76652. */
  76653. setTarget(target: Vector3): void;
  76654. /**
  76655. * Return the current target position of the camera. This value is expressed in local space.
  76656. * @returns the target position
  76657. */
  76658. getTarget(): Vector3;
  76659. /** @hidden */
  76660. _decideIfNeedsToMove(): boolean;
  76661. /** @hidden */
  76662. _updatePosition(): void;
  76663. /** @hidden */
  76664. _checkInputs(): void;
  76665. protected _updateCameraRotationMatrix(): void;
  76666. /**
  76667. * 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)
  76668. * @returns the current camera
  76669. */
  76670. private _rotateUpVectorWithCameraRotationMatrix;
  76671. private _cachedRotationZ;
  76672. private _cachedQuaternionRotationZ;
  76673. /** @hidden */
  76674. _getViewMatrix(): Matrix;
  76675. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76676. /**
  76677. * @hidden
  76678. */
  76679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76680. /**
  76681. * @hidden
  76682. */
  76683. _updateRigCameras(): void;
  76684. private _getRigCamPositionAndTarget;
  76685. /**
  76686. * Gets the current object class name.
  76687. * @return the class name
  76688. */
  76689. getClassName(): string;
  76690. }
  76691. }
  76692. declare module BABYLON {
  76693. /**
  76694. * Gather the list of keyboard event types as constants.
  76695. */
  76696. export class KeyboardEventTypes {
  76697. /**
  76698. * The keydown event is fired when a key becomes active (pressed).
  76699. */
  76700. static readonly KEYDOWN: number;
  76701. /**
  76702. * The keyup event is fired when a key has been released.
  76703. */
  76704. static readonly KEYUP: number;
  76705. }
  76706. /**
  76707. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76708. */
  76709. export class KeyboardInfo {
  76710. /**
  76711. * Defines the type of event (KeyboardEventTypes)
  76712. */
  76713. type: number;
  76714. /**
  76715. * Defines the related dom event
  76716. */
  76717. event: KeyboardEvent;
  76718. /**
  76719. * Instantiates a new keyboard info.
  76720. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76721. * @param type Defines the type of event (KeyboardEventTypes)
  76722. * @param event Defines the related dom event
  76723. */
  76724. constructor(
  76725. /**
  76726. * Defines the type of event (KeyboardEventTypes)
  76727. */
  76728. type: number,
  76729. /**
  76730. * Defines the related dom event
  76731. */
  76732. event: KeyboardEvent);
  76733. }
  76734. /**
  76735. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76736. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76737. */
  76738. export class KeyboardInfoPre extends KeyboardInfo {
  76739. /**
  76740. * Defines the type of event (KeyboardEventTypes)
  76741. */
  76742. type: number;
  76743. /**
  76744. * Defines the related dom event
  76745. */
  76746. event: KeyboardEvent;
  76747. /**
  76748. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76749. */
  76750. skipOnPointerObservable: boolean;
  76751. /**
  76752. * Instantiates a new keyboard pre info.
  76753. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76754. * @param type Defines the type of event (KeyboardEventTypes)
  76755. * @param event Defines the related dom event
  76756. */
  76757. constructor(
  76758. /**
  76759. * Defines the type of event (KeyboardEventTypes)
  76760. */
  76761. type: number,
  76762. /**
  76763. * Defines the related dom event
  76764. */
  76765. event: KeyboardEvent);
  76766. }
  76767. }
  76768. declare module BABYLON {
  76769. /**
  76770. * Manage the keyboard inputs to control the movement of a free camera.
  76771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76772. */
  76773. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76774. /**
  76775. * Defines the camera the input is attached to.
  76776. */
  76777. camera: FreeCamera;
  76778. /**
  76779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76780. */
  76781. keysUp: number[];
  76782. /**
  76783. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76784. */
  76785. keysDown: number[];
  76786. /**
  76787. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76788. */
  76789. keysLeft: number[];
  76790. /**
  76791. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76792. */
  76793. keysRight: number[];
  76794. private _keys;
  76795. private _onCanvasBlurObserver;
  76796. private _onKeyboardObserver;
  76797. private _engine;
  76798. private _scene;
  76799. /**
  76800. * Attach the input controls to a specific dom element to get the input from.
  76801. * @param element Defines the element the controls should be listened from
  76802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76803. */
  76804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76805. /**
  76806. * Detach the current controls from the specified dom element.
  76807. * @param element Defines the element to stop listening the inputs from
  76808. */
  76809. detachControl(element: Nullable<HTMLElement>): void;
  76810. /**
  76811. * Update the current camera state depending on the inputs that have been used this frame.
  76812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76813. */
  76814. checkInputs(): void;
  76815. /**
  76816. * Gets the class name of the current intput.
  76817. * @returns the class name
  76818. */
  76819. getClassName(): string;
  76820. /** @hidden */
  76821. _onLostFocus(): void;
  76822. /**
  76823. * Get the friendly name associated with the input class.
  76824. * @returns the input friendly name
  76825. */
  76826. getSimpleName(): string;
  76827. }
  76828. }
  76829. declare module BABYLON {
  76830. /**
  76831. * Interface describing all the common properties and methods a shadow light needs to implement.
  76832. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76833. * as well as binding the different shadow properties to the effects.
  76834. */
  76835. export interface IShadowLight extends Light {
  76836. /**
  76837. * The light id in the scene (used in scene.findLighById for instance)
  76838. */
  76839. id: string;
  76840. /**
  76841. * The position the shdow will be casted from.
  76842. */
  76843. position: Vector3;
  76844. /**
  76845. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76846. */
  76847. direction: Vector3;
  76848. /**
  76849. * The transformed position. Position of the light in world space taking parenting in account.
  76850. */
  76851. transformedPosition: Vector3;
  76852. /**
  76853. * The transformed direction. Direction of the light in world space taking parenting in account.
  76854. */
  76855. transformedDirection: Vector3;
  76856. /**
  76857. * The friendly name of the light in the scene.
  76858. */
  76859. name: string;
  76860. /**
  76861. * Defines the shadow projection clipping minimum z value.
  76862. */
  76863. shadowMinZ: number;
  76864. /**
  76865. * Defines the shadow projection clipping maximum z value.
  76866. */
  76867. shadowMaxZ: number;
  76868. /**
  76869. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76870. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76871. */
  76872. computeTransformedInformation(): boolean;
  76873. /**
  76874. * Gets the scene the light belongs to.
  76875. * @returns The scene
  76876. */
  76877. getScene(): Scene;
  76878. /**
  76879. * Callback defining a custom Projection Matrix Builder.
  76880. * This can be used to override the default projection matrix computation.
  76881. */
  76882. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76883. /**
  76884. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76885. * @param matrix The materix to updated with the projection information
  76886. * @param viewMatrix The transform matrix of the light
  76887. * @param renderList The list of mesh to render in the map
  76888. * @returns The current light
  76889. */
  76890. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76891. /**
  76892. * Gets the current depth scale used in ESM.
  76893. * @returns The scale
  76894. */
  76895. getDepthScale(): number;
  76896. /**
  76897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76898. * @returns true if a cube texture needs to be use
  76899. */
  76900. needCube(): boolean;
  76901. /**
  76902. * Detects if the projection matrix requires to be recomputed this frame.
  76903. * @returns true if it requires to be recomputed otherwise, false.
  76904. */
  76905. needProjectionMatrixCompute(): boolean;
  76906. /**
  76907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76908. */
  76909. forceProjectionMatrixCompute(): void;
  76910. /**
  76911. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76912. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76913. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76914. */
  76915. getShadowDirection(faceIndex?: number): Vector3;
  76916. /**
  76917. * Gets the minZ used for shadow according to both the scene and the light.
  76918. * @param activeCamera The camera we are returning the min for
  76919. * @returns the depth min z
  76920. */
  76921. getDepthMinZ(activeCamera: Camera): number;
  76922. /**
  76923. * Gets the maxZ used for shadow according to both the scene and the light.
  76924. * @param activeCamera The camera we are returning the max for
  76925. * @returns the depth max z
  76926. */
  76927. getDepthMaxZ(activeCamera: Camera): number;
  76928. }
  76929. /**
  76930. * Base implementation IShadowLight
  76931. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76932. */
  76933. export abstract class ShadowLight extends Light implements IShadowLight {
  76934. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76935. protected _position: Vector3;
  76936. protected _setPosition(value: Vector3): void;
  76937. /**
  76938. * Sets the position the shadow will be casted from. Also use as the light position for both
  76939. * point and spot lights.
  76940. */
  76941. /**
  76942. * Sets the position the shadow will be casted from. Also use as the light position for both
  76943. * point and spot lights.
  76944. */
  76945. position: Vector3;
  76946. protected _direction: Vector3;
  76947. protected _setDirection(value: Vector3): void;
  76948. /**
  76949. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76950. * Also use as the light direction on spot and directional lights.
  76951. */
  76952. /**
  76953. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76954. * Also use as the light direction on spot and directional lights.
  76955. */
  76956. direction: Vector3;
  76957. private _shadowMinZ;
  76958. /**
  76959. * Gets the shadow projection clipping minimum z value.
  76960. */
  76961. /**
  76962. * Sets the shadow projection clipping minimum z value.
  76963. */
  76964. shadowMinZ: number;
  76965. private _shadowMaxZ;
  76966. /**
  76967. * Sets the shadow projection clipping maximum z value.
  76968. */
  76969. /**
  76970. * Gets the shadow projection clipping maximum z value.
  76971. */
  76972. shadowMaxZ: number;
  76973. /**
  76974. * Callback defining a custom Projection Matrix Builder.
  76975. * This can be used to override the default projection matrix computation.
  76976. */
  76977. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76978. /**
  76979. * The transformed position. Position of the light in world space taking parenting in account.
  76980. */
  76981. transformedPosition: Vector3;
  76982. /**
  76983. * The transformed direction. Direction of the light in world space taking parenting in account.
  76984. */
  76985. transformedDirection: Vector3;
  76986. private _needProjectionMatrixCompute;
  76987. /**
  76988. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76989. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76990. */
  76991. computeTransformedInformation(): boolean;
  76992. /**
  76993. * Return the depth scale used for the shadow map.
  76994. * @returns the depth scale.
  76995. */
  76996. getDepthScale(): number;
  76997. /**
  76998. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76999. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77000. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77001. */
  77002. getShadowDirection(faceIndex?: number): Vector3;
  77003. /**
  77004. * Returns the ShadowLight absolute position in the World.
  77005. * @returns the position vector in world space
  77006. */
  77007. getAbsolutePosition(): Vector3;
  77008. /**
  77009. * Sets the ShadowLight direction toward the passed target.
  77010. * @param target The point to target in local space
  77011. * @returns the updated ShadowLight direction
  77012. */
  77013. setDirectionToTarget(target: Vector3): Vector3;
  77014. /**
  77015. * Returns the light rotation in euler definition.
  77016. * @returns the x y z rotation in local space.
  77017. */
  77018. getRotation(): Vector3;
  77019. /**
  77020. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77021. * @returns true if a cube texture needs to be use
  77022. */
  77023. needCube(): boolean;
  77024. /**
  77025. * Detects if the projection matrix requires to be recomputed this frame.
  77026. * @returns true if it requires to be recomputed otherwise, false.
  77027. */
  77028. needProjectionMatrixCompute(): boolean;
  77029. /**
  77030. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77031. */
  77032. forceProjectionMatrixCompute(): void;
  77033. /** @hidden */
  77034. _initCache(): void;
  77035. /** @hidden */
  77036. _isSynchronized(): boolean;
  77037. /**
  77038. * Computes the world matrix of the node
  77039. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77040. * @returns the world matrix
  77041. */
  77042. computeWorldMatrix(force?: boolean): Matrix;
  77043. /**
  77044. * Gets the minZ used for shadow according to both the scene and the light.
  77045. * @param activeCamera The camera we are returning the min for
  77046. * @returns the depth min z
  77047. */
  77048. getDepthMinZ(activeCamera: Camera): number;
  77049. /**
  77050. * Gets the maxZ used for shadow according to both the scene and the light.
  77051. * @param activeCamera The camera we are returning the max for
  77052. * @returns the depth max z
  77053. */
  77054. getDepthMaxZ(activeCamera: Camera): number;
  77055. /**
  77056. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77057. * @param matrix The materix to updated with the projection information
  77058. * @param viewMatrix The transform matrix of the light
  77059. * @param renderList The list of mesh to render in the map
  77060. * @returns The current light
  77061. */
  77062. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77063. }
  77064. }
  77065. declare module BABYLON {
  77066. /**
  77067. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77068. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77069. */
  77070. export class EffectFallbacks implements IEffectFallbacks {
  77071. private _defines;
  77072. private _currentRank;
  77073. private _maxRank;
  77074. private _mesh;
  77075. /**
  77076. * Removes the fallback from the bound mesh.
  77077. */
  77078. unBindMesh(): void;
  77079. /**
  77080. * Adds a fallback on the specified property.
  77081. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77082. * @param define The name of the define in the shader
  77083. */
  77084. addFallback(rank: number, define: string): void;
  77085. /**
  77086. * Sets the mesh to use CPU skinning when needing to fallback.
  77087. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77088. * @param mesh The mesh to use the fallbacks.
  77089. */
  77090. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77091. /**
  77092. * Checks to see if more fallbacks are still availible.
  77093. */
  77094. readonly hasMoreFallbacks: boolean;
  77095. /**
  77096. * Removes the defines that should be removed when falling back.
  77097. * @param currentDefines defines the current define statements for the shader.
  77098. * @param effect defines the current effect we try to compile
  77099. * @returns The resulting defines with defines of the current rank removed.
  77100. */
  77101. reduce(currentDefines: string, effect: Effect): string;
  77102. }
  77103. }
  77104. declare module BABYLON {
  77105. /**
  77106. * "Static Class" containing the most commonly used helper while dealing with material for
  77107. * rendering purpose.
  77108. *
  77109. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77110. *
  77111. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77112. */
  77113. export class MaterialHelper {
  77114. /**
  77115. * Bind the current view position to an effect.
  77116. * @param effect The effect to be bound
  77117. * @param scene The scene the eyes position is used from
  77118. */
  77119. static BindEyePosition(effect: Effect, scene: Scene): void;
  77120. /**
  77121. * Helps preparing the defines values about the UVs in used in the effect.
  77122. * UVs are shared as much as we can accross channels in the shaders.
  77123. * @param texture The texture we are preparing the UVs for
  77124. * @param defines The defines to update
  77125. * @param key The channel key "diffuse", "specular"... used in the shader
  77126. */
  77127. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77128. /**
  77129. * Binds a texture matrix value to its corrsponding uniform
  77130. * @param texture The texture to bind the matrix for
  77131. * @param uniformBuffer The uniform buffer receivin the data
  77132. * @param key The channel key "diffuse", "specular"... used in the shader
  77133. */
  77134. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77135. /**
  77136. * Gets the current status of the fog (should it be enabled?)
  77137. * @param mesh defines the mesh to evaluate for fog support
  77138. * @param scene defines the hosting scene
  77139. * @returns true if fog must be enabled
  77140. */
  77141. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77142. /**
  77143. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77144. * @param mesh defines the current mesh
  77145. * @param scene defines the current scene
  77146. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77147. * @param pointsCloud defines if point cloud rendering has to be turned on
  77148. * @param fogEnabled defines if fog has to be turned on
  77149. * @param alphaTest defines if alpha testing has to be turned on
  77150. * @param defines defines the current list of defines
  77151. */
  77152. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77153. /**
  77154. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77155. * @param scene defines the current scene
  77156. * @param engine defines the current engine
  77157. * @param defines specifies the list of active defines
  77158. * @param useInstances defines if instances have to be turned on
  77159. * @param useClipPlane defines if clip plane have to be turned on
  77160. */
  77161. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77162. /**
  77163. * Prepares the defines for bones
  77164. * @param mesh The mesh containing the geometry data we will draw
  77165. * @param defines The defines to update
  77166. */
  77167. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77168. /**
  77169. * Prepares the defines for morph targets
  77170. * @param mesh The mesh containing the geometry data we will draw
  77171. * @param defines The defines to update
  77172. */
  77173. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77174. /**
  77175. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77176. * @param mesh The mesh containing the geometry data we will draw
  77177. * @param defines The defines to update
  77178. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77179. * @param useBones Precise whether bones should be used or not (override mesh info)
  77180. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77181. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77182. * @returns false if defines are considered not dirty and have not been checked
  77183. */
  77184. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77185. /**
  77186. * Prepares the defines related to multiview
  77187. * @param scene The scene we are intending to draw
  77188. * @param defines The defines to update
  77189. */
  77190. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77191. /**
  77192. * Prepares the defines related to the light information passed in parameter
  77193. * @param scene The scene we are intending to draw
  77194. * @param mesh The mesh the effect is compiling for
  77195. * @param light The light the effect is compiling for
  77196. * @param lightIndex The index of the light
  77197. * @param defines The defines to update
  77198. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77199. * @param state Defines the current state regarding what is needed (normals, etc...)
  77200. */
  77201. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77202. needNormals: boolean;
  77203. needRebuild: boolean;
  77204. shadowEnabled: boolean;
  77205. specularEnabled: boolean;
  77206. lightmapMode: boolean;
  77207. }): void;
  77208. /**
  77209. * Prepares the defines related to the light information passed in parameter
  77210. * @param scene The scene we are intending to draw
  77211. * @param mesh The mesh the effect is compiling for
  77212. * @param defines The defines to update
  77213. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77214. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77215. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77216. * @returns true if normals will be required for the rest of the effect
  77217. */
  77218. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77219. /**
  77220. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77221. * @param lightIndex defines the light index
  77222. * @param uniformsList The uniform list
  77223. * @param samplersList The sampler list
  77224. * @param projectedLightTexture defines if projected texture must be used
  77225. * @param uniformBuffersList defines an optional list of uniform buffers
  77226. */
  77227. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77228. /**
  77229. * Prepares the uniforms and samplers list to be used in the effect
  77230. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77231. * @param samplersList The sampler list
  77232. * @param defines The defines helping in the list generation
  77233. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77234. */
  77235. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77236. /**
  77237. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77238. * @param defines The defines to update while falling back
  77239. * @param fallbacks The authorized effect fallbacks
  77240. * @param maxSimultaneousLights The maximum number of lights allowed
  77241. * @param rank the current rank of the Effect
  77242. * @returns The newly affected rank
  77243. */
  77244. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77245. private static _TmpMorphInfluencers;
  77246. /**
  77247. * Prepares the list of attributes required for morph targets according to the effect defines.
  77248. * @param attribs The current list of supported attribs
  77249. * @param mesh The mesh to prepare the morph targets attributes for
  77250. * @param influencers The number of influencers
  77251. */
  77252. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77253. /**
  77254. * Prepares the list of attributes required for morph targets according to the effect defines.
  77255. * @param attribs The current list of supported attribs
  77256. * @param mesh The mesh to prepare the morph targets attributes for
  77257. * @param defines The current Defines of the effect
  77258. */
  77259. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77260. /**
  77261. * Prepares the list of attributes required for bones according to the effect defines.
  77262. * @param attribs The current list of supported attribs
  77263. * @param mesh The mesh to prepare the bones attributes for
  77264. * @param defines The current Defines of the effect
  77265. * @param fallbacks The current efffect fallback strategy
  77266. */
  77267. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77268. /**
  77269. * Check and prepare the list of attributes required for instances according to the effect defines.
  77270. * @param attribs The current list of supported attribs
  77271. * @param defines The current MaterialDefines of the effect
  77272. */
  77273. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77274. /**
  77275. * Add the list of attributes required for instances to the attribs array.
  77276. * @param attribs The current list of supported attribs
  77277. */
  77278. static PushAttributesForInstances(attribs: string[]): void;
  77279. /**
  77280. * Binds the light information to the effect.
  77281. * @param light The light containing the generator
  77282. * @param effect The effect we are binding the data to
  77283. * @param lightIndex The light index in the effect used to render
  77284. */
  77285. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77286. /**
  77287. * Binds the lights information from the scene to the effect for the given mesh.
  77288. * @param light Light to bind
  77289. * @param lightIndex Light index
  77290. * @param scene The scene where the light belongs to
  77291. * @param effect The effect we are binding the data to
  77292. * @param useSpecular Defines if specular is supported
  77293. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77294. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77295. */
  77296. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77297. /**
  77298. * Binds the lights information from the scene to the effect for the given mesh.
  77299. * @param scene The scene the lights belongs to
  77300. * @param mesh The mesh we are binding the information to render
  77301. * @param effect The effect we are binding the data to
  77302. * @param defines The generated defines for the effect
  77303. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77304. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77305. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77306. */
  77307. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77308. private static _tempFogColor;
  77309. /**
  77310. * Binds the fog information from the scene to the effect for the given mesh.
  77311. * @param scene The scene the lights belongs to
  77312. * @param mesh The mesh we are binding the information to render
  77313. * @param effect The effect we are binding the data to
  77314. * @param linearSpace Defines if the fog effect is applied in linear space
  77315. */
  77316. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77317. /**
  77318. * Binds the bones information from the mesh to the effect.
  77319. * @param mesh The mesh we are binding the information to render
  77320. * @param effect The effect we are binding the data to
  77321. */
  77322. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77323. /**
  77324. * Binds the morph targets information from the mesh to the effect.
  77325. * @param abstractMesh The mesh we are binding the information to render
  77326. * @param effect The effect we are binding the data to
  77327. */
  77328. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77329. /**
  77330. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77331. * @param defines The generated defines used in the effect
  77332. * @param effect The effect we are binding the data to
  77333. * @param scene The scene we are willing to render with logarithmic scale for
  77334. */
  77335. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77336. /**
  77337. * Binds the clip plane information from the scene to the effect.
  77338. * @param scene The scene the clip plane information are extracted from
  77339. * @param effect The effect we are binding the data to
  77340. */
  77341. static BindClipPlane(effect: Effect, scene: Scene): void;
  77342. }
  77343. }
  77344. declare module BABYLON {
  77345. /** @hidden */
  77346. export var packingFunctions: {
  77347. name: string;
  77348. shader: string;
  77349. };
  77350. }
  77351. declare module BABYLON {
  77352. /** @hidden */
  77353. export var shadowMapPixelShader: {
  77354. name: string;
  77355. shader: string;
  77356. };
  77357. }
  77358. declare module BABYLON {
  77359. /** @hidden */
  77360. export var bonesDeclaration: {
  77361. name: string;
  77362. shader: string;
  77363. };
  77364. }
  77365. declare module BABYLON {
  77366. /** @hidden */
  77367. export var morphTargetsVertexGlobalDeclaration: {
  77368. name: string;
  77369. shader: string;
  77370. };
  77371. }
  77372. declare module BABYLON {
  77373. /** @hidden */
  77374. export var morphTargetsVertexDeclaration: {
  77375. name: string;
  77376. shader: string;
  77377. };
  77378. }
  77379. declare module BABYLON {
  77380. /** @hidden */
  77381. export var instancesDeclaration: {
  77382. name: string;
  77383. shader: string;
  77384. };
  77385. }
  77386. declare module BABYLON {
  77387. /** @hidden */
  77388. export var helperFunctions: {
  77389. name: string;
  77390. shader: string;
  77391. };
  77392. }
  77393. declare module BABYLON {
  77394. /** @hidden */
  77395. export var morphTargetsVertex: {
  77396. name: string;
  77397. shader: string;
  77398. };
  77399. }
  77400. declare module BABYLON {
  77401. /** @hidden */
  77402. export var instancesVertex: {
  77403. name: string;
  77404. shader: string;
  77405. };
  77406. }
  77407. declare module BABYLON {
  77408. /** @hidden */
  77409. export var bonesVertex: {
  77410. name: string;
  77411. shader: string;
  77412. };
  77413. }
  77414. declare module BABYLON {
  77415. /** @hidden */
  77416. export var shadowMapVertexShader: {
  77417. name: string;
  77418. shader: string;
  77419. };
  77420. }
  77421. declare module BABYLON {
  77422. /** @hidden */
  77423. export var depthBoxBlurPixelShader: {
  77424. name: string;
  77425. shader: string;
  77426. };
  77427. }
  77428. declare module BABYLON {
  77429. /**
  77430. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77431. */
  77432. export interface ICustomShaderOptions {
  77433. /**
  77434. * Gets or sets the custom shader name to use
  77435. */
  77436. shaderName: string;
  77437. /**
  77438. * The list of attribute names used in the shader
  77439. */
  77440. attributes?: string[];
  77441. /**
  77442. * The list of unifrom names used in the shader
  77443. */
  77444. uniforms?: string[];
  77445. /**
  77446. * The list of sampler names used in the shader
  77447. */
  77448. samplers?: string[];
  77449. /**
  77450. * The list of defines used in the shader
  77451. */
  77452. defines?: string[];
  77453. }
  77454. /**
  77455. * Interface to implement to create a shadow generator compatible with BJS.
  77456. */
  77457. export interface IShadowGenerator {
  77458. /**
  77459. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77460. * @returns The render target texture if present otherwise, null
  77461. */
  77462. getShadowMap(): Nullable<RenderTargetTexture>;
  77463. /**
  77464. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77465. * @returns The render target texture if the shadow map is present otherwise, null
  77466. */
  77467. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77468. /**
  77469. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77470. * @param subMesh The submesh we want to render in the shadow map
  77471. * @param useInstances Defines wether will draw in the map using instances
  77472. * @returns true if ready otherwise, false
  77473. */
  77474. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77475. /**
  77476. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77477. * @param defines Defines of the material we want to update
  77478. * @param lightIndex Index of the light in the enabled light list of the material
  77479. */
  77480. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77481. /**
  77482. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77483. * defined in the generator but impacting the effect).
  77484. * It implies the unifroms available on the materials are the standard BJS ones.
  77485. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77486. * @param effect The effect we are binfing the information for
  77487. */
  77488. bindShadowLight(lightIndex: string, effect: Effect): void;
  77489. /**
  77490. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77491. * (eq to shadow prjection matrix * light transform matrix)
  77492. * @returns The transform matrix used to create the shadow map
  77493. */
  77494. getTransformMatrix(): Matrix;
  77495. /**
  77496. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77497. * Cube and 2D textures for instance.
  77498. */
  77499. recreateShadowMap(): void;
  77500. /**
  77501. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77502. * @param onCompiled Callback triggered at the and of the effects compilation
  77503. * @param options Sets of optional options forcing the compilation with different modes
  77504. */
  77505. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77506. useInstances: boolean;
  77507. }>): void;
  77508. /**
  77509. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77510. * @param options Sets of optional options forcing the compilation with different modes
  77511. * @returns A promise that resolves when the compilation completes
  77512. */
  77513. forceCompilationAsync(options?: Partial<{
  77514. useInstances: boolean;
  77515. }>): Promise<void>;
  77516. /**
  77517. * Serializes the shadow generator setup to a json object.
  77518. * @returns The serialized JSON object
  77519. */
  77520. serialize(): any;
  77521. /**
  77522. * Disposes the Shadow map and related Textures and effects.
  77523. */
  77524. dispose(): void;
  77525. }
  77526. /**
  77527. * Default implementation IShadowGenerator.
  77528. * This is the main object responsible of generating shadows in the framework.
  77529. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77530. */
  77531. export class ShadowGenerator implements IShadowGenerator {
  77532. /**
  77533. * Shadow generator mode None: no filtering applied.
  77534. */
  77535. static readonly FILTER_NONE: number;
  77536. /**
  77537. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77538. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77539. */
  77540. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77541. /**
  77542. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77543. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77544. */
  77545. static readonly FILTER_POISSONSAMPLING: number;
  77546. /**
  77547. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77548. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77549. */
  77550. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77551. /**
  77552. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77553. * edge artifacts on steep falloff.
  77554. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77555. */
  77556. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77557. /**
  77558. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77559. * edge artifacts on steep falloff.
  77560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77561. */
  77562. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77563. /**
  77564. * Shadow generator mode PCF: Percentage Closer Filtering
  77565. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77566. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77567. */
  77568. static readonly FILTER_PCF: number;
  77569. /**
  77570. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77571. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77572. * Contact Hardening
  77573. */
  77574. static readonly FILTER_PCSS: number;
  77575. /**
  77576. * Reserved for PCF and PCSS
  77577. * Highest Quality.
  77578. *
  77579. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77580. *
  77581. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77582. */
  77583. static readonly QUALITY_HIGH: number;
  77584. /**
  77585. * Reserved for PCF and PCSS
  77586. * Good tradeoff for quality/perf cross devices
  77587. *
  77588. * Execute PCF on a 3*3 kernel.
  77589. *
  77590. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77591. */
  77592. static readonly QUALITY_MEDIUM: number;
  77593. /**
  77594. * Reserved for PCF and PCSS
  77595. * The lowest quality but the fastest.
  77596. *
  77597. * Execute PCF on a 1*1 kernel.
  77598. *
  77599. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77600. */
  77601. static readonly QUALITY_LOW: number;
  77602. /** Gets or sets the custom shader name to use */
  77603. customShaderOptions: ICustomShaderOptions;
  77604. /**
  77605. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77606. */
  77607. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77608. /**
  77609. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77610. */
  77611. onAfterShadowMapRenderObservable: Observable<Effect>;
  77612. /**
  77613. * Observable triggered before a mesh is rendered in the shadow map.
  77614. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77615. */
  77616. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77617. /**
  77618. * Observable triggered after a mesh is rendered in the shadow map.
  77619. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77620. */
  77621. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77622. private _bias;
  77623. /**
  77624. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77625. */
  77626. /**
  77627. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77628. */
  77629. bias: number;
  77630. private _normalBias;
  77631. /**
  77632. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77633. */
  77634. /**
  77635. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77636. */
  77637. normalBias: number;
  77638. private _blurBoxOffset;
  77639. /**
  77640. * Gets the blur box offset: offset applied during the blur pass.
  77641. * Only useful if useKernelBlur = false
  77642. */
  77643. /**
  77644. * Sets the blur box offset: offset applied during the blur pass.
  77645. * Only useful if useKernelBlur = false
  77646. */
  77647. blurBoxOffset: number;
  77648. private _blurScale;
  77649. /**
  77650. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77651. * 2 means half of the size.
  77652. */
  77653. /**
  77654. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77655. * 2 means half of the size.
  77656. */
  77657. blurScale: number;
  77658. private _blurKernel;
  77659. /**
  77660. * Gets the blur kernel: kernel size of the blur pass.
  77661. * Only useful if useKernelBlur = true
  77662. */
  77663. /**
  77664. * Sets the blur kernel: kernel size of the blur pass.
  77665. * Only useful if useKernelBlur = true
  77666. */
  77667. blurKernel: number;
  77668. private _useKernelBlur;
  77669. /**
  77670. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77671. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77672. */
  77673. /**
  77674. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77675. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77676. */
  77677. useKernelBlur: boolean;
  77678. private _depthScale;
  77679. /**
  77680. * Gets the depth scale used in ESM mode.
  77681. */
  77682. /**
  77683. * Sets the depth scale used in ESM mode.
  77684. * This can override the scale stored on the light.
  77685. */
  77686. depthScale: number;
  77687. private _filter;
  77688. /**
  77689. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77690. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77691. */
  77692. /**
  77693. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77694. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77695. */
  77696. filter: number;
  77697. /**
  77698. * Gets if the current filter is set to Poisson Sampling.
  77699. */
  77700. /**
  77701. * Sets the current filter to Poisson Sampling.
  77702. */
  77703. usePoissonSampling: boolean;
  77704. /**
  77705. * Gets if the current filter is set to ESM.
  77706. */
  77707. /**
  77708. * Sets the current filter is to ESM.
  77709. */
  77710. useExponentialShadowMap: boolean;
  77711. /**
  77712. * Gets if the current filter is set to filtered ESM.
  77713. */
  77714. /**
  77715. * Gets if the current filter is set to filtered ESM.
  77716. */
  77717. useBlurExponentialShadowMap: boolean;
  77718. /**
  77719. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77720. * exponential to prevent steep falloff artifacts).
  77721. */
  77722. /**
  77723. * Sets the current filter to "close ESM" (using the inverse of the
  77724. * exponential to prevent steep falloff artifacts).
  77725. */
  77726. useCloseExponentialShadowMap: boolean;
  77727. /**
  77728. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77729. * exponential to prevent steep falloff artifacts).
  77730. */
  77731. /**
  77732. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77733. * exponential to prevent steep falloff artifacts).
  77734. */
  77735. useBlurCloseExponentialShadowMap: boolean;
  77736. /**
  77737. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77738. */
  77739. /**
  77740. * Sets the current filter to "PCF" (percentage closer filtering).
  77741. */
  77742. usePercentageCloserFiltering: boolean;
  77743. private _filteringQuality;
  77744. /**
  77745. * Gets the PCF or PCSS Quality.
  77746. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77747. */
  77748. /**
  77749. * Sets the PCF or PCSS Quality.
  77750. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77751. */
  77752. filteringQuality: number;
  77753. /**
  77754. * Gets if the current filter is set to "PCSS" (contact hardening).
  77755. */
  77756. /**
  77757. * Sets the current filter to "PCSS" (contact hardening).
  77758. */
  77759. useContactHardeningShadow: boolean;
  77760. private _contactHardeningLightSizeUVRatio;
  77761. /**
  77762. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77763. * Using a ratio helps keeping shape stability independently of the map size.
  77764. *
  77765. * It does not account for the light projection as it was having too much
  77766. * instability during the light setup or during light position changes.
  77767. *
  77768. * Only valid if useContactHardeningShadow is true.
  77769. */
  77770. /**
  77771. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77772. * Using a ratio helps keeping shape stability independently of the map size.
  77773. *
  77774. * It does not account for the light projection as it was having too much
  77775. * instability during the light setup or during light position changes.
  77776. *
  77777. * Only valid if useContactHardeningShadow is true.
  77778. */
  77779. contactHardeningLightSizeUVRatio: number;
  77780. private _darkness;
  77781. /** Gets or sets the actual darkness of a shadow */
  77782. darkness: number;
  77783. /**
  77784. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77785. * 0 means strongest and 1 would means no shadow.
  77786. * @returns the darkness.
  77787. */
  77788. getDarkness(): number;
  77789. /**
  77790. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77791. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77792. * @returns the shadow generator allowing fluent coding.
  77793. */
  77794. setDarkness(darkness: number): ShadowGenerator;
  77795. private _transparencyShadow;
  77796. /** Gets or sets the ability to have transparent shadow */
  77797. transparencyShadow: boolean;
  77798. /**
  77799. * Sets the ability to have transparent shadow (boolean).
  77800. * @param transparent True if transparent else False
  77801. * @returns the shadow generator allowing fluent coding
  77802. */
  77803. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77804. private _shadowMap;
  77805. private _shadowMap2;
  77806. /**
  77807. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77808. * @returns The render target texture if present otherwise, null
  77809. */
  77810. getShadowMap(): Nullable<RenderTargetTexture>;
  77811. /**
  77812. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77813. * @returns The render target texture if the shadow map is present otherwise, null
  77814. */
  77815. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77816. /**
  77817. * Gets the class name of that object
  77818. * @returns "ShadowGenerator"
  77819. */
  77820. getClassName(): string;
  77821. /**
  77822. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77823. * @param mesh Mesh to add
  77824. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77825. * @returns the Shadow Generator itself
  77826. */
  77827. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77828. /**
  77829. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77830. * @param mesh Mesh to remove
  77831. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77832. * @returns the Shadow Generator itself
  77833. */
  77834. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77835. /**
  77836. * Controls the extent to which the shadows fade out at the edge of the frustum
  77837. * Used only by directionals and spots
  77838. */
  77839. frustumEdgeFalloff: number;
  77840. private _light;
  77841. /**
  77842. * Returns the associated light object.
  77843. * @returns the light generating the shadow
  77844. */
  77845. getLight(): IShadowLight;
  77846. /**
  77847. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77848. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77849. * It might on the other hand introduce peter panning.
  77850. */
  77851. forceBackFacesOnly: boolean;
  77852. private _scene;
  77853. private _lightDirection;
  77854. private _effect;
  77855. private _viewMatrix;
  77856. private _projectionMatrix;
  77857. private _transformMatrix;
  77858. private _cachedPosition;
  77859. private _cachedDirection;
  77860. private _cachedDefines;
  77861. private _currentRenderID;
  77862. private _boxBlurPostprocess;
  77863. private _kernelBlurXPostprocess;
  77864. private _kernelBlurYPostprocess;
  77865. private _blurPostProcesses;
  77866. private _mapSize;
  77867. private _currentFaceIndex;
  77868. private _currentFaceIndexCache;
  77869. private _textureType;
  77870. private _defaultTextureMatrix;
  77871. private _storedUniqueId;
  77872. /** @hidden */
  77873. static _SceneComponentInitialization: (scene: Scene) => void;
  77874. /**
  77875. * Creates a ShadowGenerator object.
  77876. * A ShadowGenerator is the required tool to use the shadows.
  77877. * Each light casting shadows needs to use its own ShadowGenerator.
  77878. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77879. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77880. * @param light The light object generating the shadows.
  77881. * @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.
  77882. */
  77883. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77884. private _initializeGenerator;
  77885. private _initializeShadowMap;
  77886. private _initializeBlurRTTAndPostProcesses;
  77887. private _renderForShadowMap;
  77888. private _renderSubMeshForShadowMap;
  77889. private _applyFilterValues;
  77890. /**
  77891. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77892. * @param onCompiled Callback triggered at the and of the effects compilation
  77893. * @param options Sets of optional options forcing the compilation with different modes
  77894. */
  77895. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77896. useInstances: boolean;
  77897. }>): void;
  77898. /**
  77899. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77900. * @param options Sets of optional options forcing the compilation with different modes
  77901. * @returns A promise that resolves when the compilation completes
  77902. */
  77903. forceCompilationAsync(options?: Partial<{
  77904. useInstances: boolean;
  77905. }>): Promise<void>;
  77906. /**
  77907. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77908. * @param subMesh The submesh we want to render in the shadow map
  77909. * @param useInstances Defines wether will draw in the map using instances
  77910. * @returns true if ready otherwise, false
  77911. */
  77912. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77913. /**
  77914. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77915. * @param defines Defines of the material we want to update
  77916. * @param lightIndex Index of the light in the enabled light list of the material
  77917. */
  77918. prepareDefines(defines: any, lightIndex: number): void;
  77919. /**
  77920. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77921. * defined in the generator but impacting the effect).
  77922. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77923. * @param effect The effect we are binfing the information for
  77924. */
  77925. bindShadowLight(lightIndex: string, effect: Effect): void;
  77926. /**
  77927. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77928. * (eq to shadow prjection matrix * light transform matrix)
  77929. * @returns The transform matrix used to create the shadow map
  77930. */
  77931. getTransformMatrix(): Matrix;
  77932. /**
  77933. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77934. * Cube and 2D textures for instance.
  77935. */
  77936. recreateShadowMap(): void;
  77937. private _disposeBlurPostProcesses;
  77938. private _disposeRTTandPostProcesses;
  77939. /**
  77940. * Disposes the ShadowGenerator.
  77941. * Returns nothing.
  77942. */
  77943. dispose(): void;
  77944. /**
  77945. * Serializes the shadow generator setup to a json object.
  77946. * @returns The serialized JSON object
  77947. */
  77948. serialize(): any;
  77949. /**
  77950. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77951. * @param parsedShadowGenerator The JSON object to parse
  77952. * @param scene The scene to create the shadow map for
  77953. * @returns The parsed shadow generator
  77954. */
  77955. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77956. }
  77957. }
  77958. declare module BABYLON {
  77959. /**
  77960. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77961. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77962. * 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.
  77963. */
  77964. export abstract class Light extends Node {
  77965. /**
  77966. * Falloff Default: light is falling off following the material specification:
  77967. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77968. */
  77969. static readonly FALLOFF_DEFAULT: number;
  77970. /**
  77971. * Falloff Physical: light is falling off following the inverse squared distance law.
  77972. */
  77973. static readonly FALLOFF_PHYSICAL: number;
  77974. /**
  77975. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77976. * to enhance interoperability with other engines.
  77977. */
  77978. static readonly FALLOFF_GLTF: number;
  77979. /**
  77980. * Falloff Standard: light is falling off like in the standard material
  77981. * to enhance interoperability with other materials.
  77982. */
  77983. static readonly FALLOFF_STANDARD: number;
  77984. /**
  77985. * If every light affecting the material is in this lightmapMode,
  77986. * material.lightmapTexture adds or multiplies
  77987. * (depends on material.useLightmapAsShadowmap)
  77988. * after every other light calculations.
  77989. */
  77990. static readonly LIGHTMAP_DEFAULT: number;
  77991. /**
  77992. * material.lightmapTexture as only diffuse lighting from this light
  77993. * adds only specular lighting from this light
  77994. * adds dynamic shadows
  77995. */
  77996. static readonly LIGHTMAP_SPECULAR: number;
  77997. /**
  77998. * material.lightmapTexture as only lighting
  77999. * no light calculation from this light
  78000. * only adds dynamic shadows from this light
  78001. */
  78002. static readonly LIGHTMAP_SHADOWSONLY: number;
  78003. /**
  78004. * Each light type uses the default quantity according to its type:
  78005. * point/spot lights use luminous intensity
  78006. * directional lights use illuminance
  78007. */
  78008. static readonly INTENSITYMODE_AUTOMATIC: number;
  78009. /**
  78010. * lumen (lm)
  78011. */
  78012. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78013. /**
  78014. * candela (lm/sr)
  78015. */
  78016. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78017. /**
  78018. * lux (lm/m^2)
  78019. */
  78020. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78021. /**
  78022. * nit (cd/m^2)
  78023. */
  78024. static readonly INTENSITYMODE_LUMINANCE: number;
  78025. /**
  78026. * Light type const id of the point light.
  78027. */
  78028. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78029. /**
  78030. * Light type const id of the directional light.
  78031. */
  78032. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78033. /**
  78034. * Light type const id of the spot light.
  78035. */
  78036. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78037. /**
  78038. * Light type const id of the hemispheric light.
  78039. */
  78040. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78041. /**
  78042. * Diffuse gives the basic color to an object.
  78043. */
  78044. diffuse: Color3;
  78045. /**
  78046. * Specular produces a highlight color on an object.
  78047. * Note: This is note affecting PBR materials.
  78048. */
  78049. specular: Color3;
  78050. /**
  78051. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78052. * falling off base on range or angle.
  78053. * This can be set to any values in Light.FALLOFF_x.
  78054. *
  78055. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78056. * other types of materials.
  78057. */
  78058. falloffType: number;
  78059. /**
  78060. * Strength of the light.
  78061. * Note: By default it is define in the framework own unit.
  78062. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78063. */
  78064. intensity: number;
  78065. private _range;
  78066. protected _inverseSquaredRange: number;
  78067. /**
  78068. * Defines how far from the source the light is impacting in scene units.
  78069. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78070. */
  78071. /**
  78072. * Defines how far from the source the light is impacting in scene units.
  78073. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78074. */
  78075. range: number;
  78076. /**
  78077. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78078. * of light.
  78079. */
  78080. private _photometricScale;
  78081. private _intensityMode;
  78082. /**
  78083. * Gets the photometric scale used to interpret the intensity.
  78084. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78085. */
  78086. /**
  78087. * Sets the photometric scale used to interpret the intensity.
  78088. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78089. */
  78090. intensityMode: number;
  78091. private _radius;
  78092. /**
  78093. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78094. */
  78095. /**
  78096. * sets the light radius used by PBR Materials to simulate soft area lights.
  78097. */
  78098. radius: number;
  78099. private _renderPriority;
  78100. /**
  78101. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78102. * exceeding the number allowed of the materials.
  78103. */
  78104. renderPriority: number;
  78105. private _shadowEnabled;
  78106. /**
  78107. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78108. * the current shadow generator.
  78109. */
  78110. /**
  78111. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78112. * the current shadow generator.
  78113. */
  78114. shadowEnabled: boolean;
  78115. private _includedOnlyMeshes;
  78116. /**
  78117. * Gets the only meshes impacted by this light.
  78118. */
  78119. /**
  78120. * Sets the only meshes impacted by this light.
  78121. */
  78122. includedOnlyMeshes: AbstractMesh[];
  78123. private _excludedMeshes;
  78124. /**
  78125. * Gets the meshes not impacted by this light.
  78126. */
  78127. /**
  78128. * Sets the meshes not impacted by this light.
  78129. */
  78130. excludedMeshes: AbstractMesh[];
  78131. private _excludeWithLayerMask;
  78132. /**
  78133. * Gets the layer id use to find what meshes are not impacted by the light.
  78134. * Inactive if 0
  78135. */
  78136. /**
  78137. * Sets the layer id use to find what meshes are not impacted by the light.
  78138. * Inactive if 0
  78139. */
  78140. excludeWithLayerMask: number;
  78141. private _includeOnlyWithLayerMask;
  78142. /**
  78143. * Gets the layer id use to find what meshes are impacted by the light.
  78144. * Inactive if 0
  78145. */
  78146. /**
  78147. * Sets the layer id use to find what meshes are impacted by the light.
  78148. * Inactive if 0
  78149. */
  78150. includeOnlyWithLayerMask: number;
  78151. private _lightmapMode;
  78152. /**
  78153. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78154. */
  78155. /**
  78156. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78157. */
  78158. lightmapMode: number;
  78159. /**
  78160. * Shadow generator associted to the light.
  78161. * @hidden Internal use only.
  78162. */
  78163. _shadowGenerator: Nullable<IShadowGenerator>;
  78164. /**
  78165. * @hidden Internal use only.
  78166. */
  78167. _excludedMeshesIds: string[];
  78168. /**
  78169. * @hidden Internal use only.
  78170. */
  78171. _includedOnlyMeshesIds: string[];
  78172. /**
  78173. * The current light unifom buffer.
  78174. * @hidden Internal use only.
  78175. */
  78176. _uniformBuffer: UniformBuffer;
  78177. /** @hidden */
  78178. _renderId: number;
  78179. /**
  78180. * Creates a Light object in the scene.
  78181. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78182. * @param name The firendly name of the light
  78183. * @param scene The scene the light belongs too
  78184. */
  78185. constructor(name: string, scene: Scene);
  78186. protected abstract _buildUniformLayout(): void;
  78187. /**
  78188. * Sets the passed Effect "effect" with the Light information.
  78189. * @param effect The effect to update
  78190. * @param lightIndex The index of the light in the effect to update
  78191. * @returns The light
  78192. */
  78193. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78194. /**
  78195. * Sets the passed Effect "effect" with the Light information.
  78196. * @param effect The effect to update
  78197. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78198. * @returns The light
  78199. */
  78200. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78201. /**
  78202. * Returns the string "Light".
  78203. * @returns the class name
  78204. */
  78205. getClassName(): string;
  78206. /** @hidden */
  78207. readonly _isLight: boolean;
  78208. /**
  78209. * Converts the light information to a readable string for debug purpose.
  78210. * @param fullDetails Supports for multiple levels of logging within scene loading
  78211. * @returns the human readable light info
  78212. */
  78213. toString(fullDetails?: boolean): string;
  78214. /** @hidden */
  78215. protected _syncParentEnabledState(): void;
  78216. /**
  78217. * Set the enabled state of this node.
  78218. * @param value - the new enabled state
  78219. */
  78220. setEnabled(value: boolean): void;
  78221. /**
  78222. * Returns the Light associated shadow generator if any.
  78223. * @return the associated shadow generator.
  78224. */
  78225. getShadowGenerator(): Nullable<IShadowGenerator>;
  78226. /**
  78227. * Returns a Vector3, the absolute light position in the World.
  78228. * @returns the world space position of the light
  78229. */
  78230. getAbsolutePosition(): Vector3;
  78231. /**
  78232. * Specifies if the light will affect the passed mesh.
  78233. * @param mesh The mesh to test against the light
  78234. * @return true the mesh is affected otherwise, false.
  78235. */
  78236. canAffectMesh(mesh: AbstractMesh): boolean;
  78237. /**
  78238. * Sort function to order lights for rendering.
  78239. * @param a First Light object to compare to second.
  78240. * @param b Second Light object to compare first.
  78241. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78242. */
  78243. static CompareLightsPriority(a: Light, b: Light): number;
  78244. /**
  78245. * Releases resources associated with this node.
  78246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78248. */
  78249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78250. /**
  78251. * Returns the light type ID (integer).
  78252. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78253. */
  78254. getTypeID(): number;
  78255. /**
  78256. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78257. * @returns the scaled intensity in intensity mode unit
  78258. */
  78259. getScaledIntensity(): number;
  78260. /**
  78261. * Returns a new Light object, named "name", from the current one.
  78262. * @param name The name of the cloned light
  78263. * @returns the new created light
  78264. */
  78265. clone(name: string): Nullable<Light>;
  78266. /**
  78267. * Serializes the current light into a Serialization object.
  78268. * @returns the serialized object.
  78269. */
  78270. serialize(): any;
  78271. /**
  78272. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78273. * This new light is named "name" and added to the passed scene.
  78274. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78275. * @param name The friendly name of the light
  78276. * @param scene The scene the new light will belong to
  78277. * @returns the constructor function
  78278. */
  78279. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78280. /**
  78281. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78282. * @param parsedLight The JSON representation of the light
  78283. * @param scene The scene to create the parsed light in
  78284. * @returns the created light after parsing
  78285. */
  78286. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78287. private _hookArrayForExcluded;
  78288. private _hookArrayForIncludedOnly;
  78289. private _resyncMeshes;
  78290. /**
  78291. * Forces the meshes to update their light related information in their rendering used effects
  78292. * @hidden Internal Use Only
  78293. */
  78294. _markMeshesAsLightDirty(): void;
  78295. /**
  78296. * Recomputes the cached photometric scale if needed.
  78297. */
  78298. private _computePhotometricScale;
  78299. /**
  78300. * Returns the Photometric Scale according to the light type and intensity mode.
  78301. */
  78302. private _getPhotometricScale;
  78303. /**
  78304. * Reorder the light in the scene according to their defined priority.
  78305. * @hidden Internal Use Only
  78306. */
  78307. _reorderLightsInScene(): void;
  78308. /**
  78309. * Prepares the list of defines specific to the light type.
  78310. * @param defines the list of defines
  78311. * @param lightIndex defines the index of the light for the effect
  78312. */
  78313. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78314. }
  78315. }
  78316. declare module BABYLON {
  78317. /**
  78318. * Interface used to define Action
  78319. */
  78320. export interface IAction {
  78321. /**
  78322. * Trigger for the action
  78323. */
  78324. trigger: number;
  78325. /** Options of the trigger */
  78326. triggerOptions: any;
  78327. /**
  78328. * Gets the trigger parameters
  78329. * @returns the trigger parameters
  78330. */
  78331. getTriggerParameter(): any;
  78332. /**
  78333. * Internal only - executes current action event
  78334. * @hidden
  78335. */
  78336. _executeCurrent(evt?: ActionEvent): void;
  78337. /**
  78338. * Serialize placeholder for child classes
  78339. * @param parent of child
  78340. * @returns the serialized object
  78341. */
  78342. serialize(parent: any): any;
  78343. /**
  78344. * Internal only
  78345. * @hidden
  78346. */
  78347. _prepare(): void;
  78348. /**
  78349. * Internal only - manager for action
  78350. * @hidden
  78351. */
  78352. _actionManager: AbstractActionManager;
  78353. /**
  78354. * Adds action to chain of actions, may be a DoNothingAction
  78355. * @param action defines the next action to execute
  78356. * @returns The action passed in
  78357. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78358. */
  78359. then(action: IAction): IAction;
  78360. }
  78361. /**
  78362. * The action to be carried out following a trigger
  78363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78364. */
  78365. export class Action implements IAction {
  78366. /** the trigger, with or without parameters, for the action */
  78367. triggerOptions: any;
  78368. /**
  78369. * Trigger for the action
  78370. */
  78371. trigger: number;
  78372. /**
  78373. * Internal only - manager for action
  78374. * @hidden
  78375. */
  78376. _actionManager: ActionManager;
  78377. private _nextActiveAction;
  78378. private _child;
  78379. private _condition?;
  78380. private _triggerParameter;
  78381. /**
  78382. * An event triggered prior to action being executed.
  78383. */
  78384. onBeforeExecuteObservable: Observable<Action>;
  78385. /**
  78386. * Creates a new Action
  78387. * @param triggerOptions the trigger, with or without parameters, for the action
  78388. * @param condition an optional determinant of action
  78389. */
  78390. constructor(
  78391. /** the trigger, with or without parameters, for the action */
  78392. triggerOptions: any, condition?: Condition);
  78393. /**
  78394. * Internal only
  78395. * @hidden
  78396. */
  78397. _prepare(): void;
  78398. /**
  78399. * Gets the trigger parameters
  78400. * @returns the trigger parameters
  78401. */
  78402. getTriggerParameter(): any;
  78403. /**
  78404. * Internal only - executes current action event
  78405. * @hidden
  78406. */
  78407. _executeCurrent(evt?: ActionEvent): void;
  78408. /**
  78409. * Execute placeholder for child classes
  78410. * @param evt optional action event
  78411. */
  78412. execute(evt?: ActionEvent): void;
  78413. /**
  78414. * Skips to next active action
  78415. */
  78416. skipToNextActiveAction(): void;
  78417. /**
  78418. * Adds action to chain of actions, may be a DoNothingAction
  78419. * @param action defines the next action to execute
  78420. * @returns The action passed in
  78421. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78422. */
  78423. then(action: Action): Action;
  78424. /**
  78425. * Internal only
  78426. * @hidden
  78427. */
  78428. _getProperty(propertyPath: string): string;
  78429. /**
  78430. * Internal only
  78431. * @hidden
  78432. */
  78433. _getEffectiveTarget(target: any, propertyPath: string): any;
  78434. /**
  78435. * Serialize placeholder for child classes
  78436. * @param parent of child
  78437. * @returns the serialized object
  78438. */
  78439. serialize(parent: any): any;
  78440. /**
  78441. * Internal only called by serialize
  78442. * @hidden
  78443. */
  78444. protected _serialize(serializedAction: any, parent?: any): any;
  78445. /**
  78446. * Internal only
  78447. * @hidden
  78448. */
  78449. static _SerializeValueAsString: (value: any) => string;
  78450. /**
  78451. * Internal only
  78452. * @hidden
  78453. */
  78454. static _GetTargetProperty: (target: Node | Scene) => {
  78455. name: string;
  78456. targetType: string;
  78457. value: string;
  78458. };
  78459. }
  78460. }
  78461. declare module BABYLON {
  78462. /**
  78463. * A Condition applied to an Action
  78464. */
  78465. export class Condition {
  78466. /**
  78467. * Internal only - manager for action
  78468. * @hidden
  78469. */
  78470. _actionManager: ActionManager;
  78471. /**
  78472. * Internal only
  78473. * @hidden
  78474. */
  78475. _evaluationId: number;
  78476. /**
  78477. * Internal only
  78478. * @hidden
  78479. */
  78480. _currentResult: boolean;
  78481. /**
  78482. * Creates a new Condition
  78483. * @param actionManager the manager of the action the condition is applied to
  78484. */
  78485. constructor(actionManager: ActionManager);
  78486. /**
  78487. * Check if the current condition is valid
  78488. * @returns a boolean
  78489. */
  78490. isValid(): boolean;
  78491. /**
  78492. * Internal only
  78493. * @hidden
  78494. */
  78495. _getProperty(propertyPath: string): string;
  78496. /**
  78497. * Internal only
  78498. * @hidden
  78499. */
  78500. _getEffectiveTarget(target: any, propertyPath: string): any;
  78501. /**
  78502. * Serialize placeholder for child classes
  78503. * @returns the serialized object
  78504. */
  78505. serialize(): any;
  78506. /**
  78507. * Internal only
  78508. * @hidden
  78509. */
  78510. protected _serialize(serializedCondition: any): any;
  78511. }
  78512. /**
  78513. * Defines specific conditional operators as extensions of Condition
  78514. */
  78515. export class ValueCondition extends Condition {
  78516. /** path to specify the property of the target the conditional operator uses */
  78517. propertyPath: string;
  78518. /** the value compared by the conditional operator against the current value of the property */
  78519. value: any;
  78520. /** the conditional operator, default ValueCondition.IsEqual */
  78521. operator: number;
  78522. /**
  78523. * Internal only
  78524. * @hidden
  78525. */
  78526. private static _IsEqual;
  78527. /**
  78528. * Internal only
  78529. * @hidden
  78530. */
  78531. private static _IsDifferent;
  78532. /**
  78533. * Internal only
  78534. * @hidden
  78535. */
  78536. private static _IsGreater;
  78537. /**
  78538. * Internal only
  78539. * @hidden
  78540. */
  78541. private static _IsLesser;
  78542. /**
  78543. * returns the number for IsEqual
  78544. */
  78545. static readonly IsEqual: number;
  78546. /**
  78547. * Returns the number for IsDifferent
  78548. */
  78549. static readonly IsDifferent: number;
  78550. /**
  78551. * Returns the number for IsGreater
  78552. */
  78553. static readonly IsGreater: number;
  78554. /**
  78555. * Returns the number for IsLesser
  78556. */
  78557. static readonly IsLesser: number;
  78558. /**
  78559. * Internal only The action manager for the condition
  78560. * @hidden
  78561. */
  78562. _actionManager: ActionManager;
  78563. /**
  78564. * Internal only
  78565. * @hidden
  78566. */
  78567. private _target;
  78568. /**
  78569. * Internal only
  78570. * @hidden
  78571. */
  78572. private _effectiveTarget;
  78573. /**
  78574. * Internal only
  78575. * @hidden
  78576. */
  78577. private _property;
  78578. /**
  78579. * Creates a new ValueCondition
  78580. * @param actionManager manager for the action the condition applies to
  78581. * @param target for the action
  78582. * @param propertyPath path to specify the property of the target the conditional operator uses
  78583. * @param value the value compared by the conditional operator against the current value of the property
  78584. * @param operator the conditional operator, default ValueCondition.IsEqual
  78585. */
  78586. constructor(actionManager: ActionManager, target: any,
  78587. /** path to specify the property of the target the conditional operator uses */
  78588. propertyPath: string,
  78589. /** the value compared by the conditional operator against the current value of the property */
  78590. value: any,
  78591. /** the conditional operator, default ValueCondition.IsEqual */
  78592. operator?: number);
  78593. /**
  78594. * Compares the given value with the property value for the specified conditional operator
  78595. * @returns the result of the comparison
  78596. */
  78597. isValid(): boolean;
  78598. /**
  78599. * Serialize the ValueCondition into a JSON compatible object
  78600. * @returns serialization object
  78601. */
  78602. serialize(): any;
  78603. /**
  78604. * Gets the name of the conditional operator for the ValueCondition
  78605. * @param operator the conditional operator
  78606. * @returns the name
  78607. */
  78608. static GetOperatorName(operator: number): string;
  78609. }
  78610. /**
  78611. * Defines a predicate condition as an extension of Condition
  78612. */
  78613. export class PredicateCondition extends Condition {
  78614. /** defines the predicate function used to validate the condition */
  78615. predicate: () => boolean;
  78616. /**
  78617. * Internal only - manager for action
  78618. * @hidden
  78619. */
  78620. _actionManager: ActionManager;
  78621. /**
  78622. * Creates a new PredicateCondition
  78623. * @param actionManager manager for the action the condition applies to
  78624. * @param predicate defines the predicate function used to validate the condition
  78625. */
  78626. constructor(actionManager: ActionManager,
  78627. /** defines the predicate function used to validate the condition */
  78628. predicate: () => boolean);
  78629. /**
  78630. * @returns the validity of the predicate condition
  78631. */
  78632. isValid(): boolean;
  78633. }
  78634. /**
  78635. * Defines a state condition as an extension of Condition
  78636. */
  78637. export class StateCondition extends Condition {
  78638. /** Value to compare with target state */
  78639. value: string;
  78640. /**
  78641. * Internal only - manager for action
  78642. * @hidden
  78643. */
  78644. _actionManager: ActionManager;
  78645. /**
  78646. * Internal only
  78647. * @hidden
  78648. */
  78649. private _target;
  78650. /**
  78651. * Creates a new StateCondition
  78652. * @param actionManager manager for the action the condition applies to
  78653. * @param target of the condition
  78654. * @param value to compare with target state
  78655. */
  78656. constructor(actionManager: ActionManager, target: any,
  78657. /** Value to compare with target state */
  78658. value: string);
  78659. /**
  78660. * Gets a boolean indicating if the current condition is met
  78661. * @returns the validity of the state
  78662. */
  78663. isValid(): boolean;
  78664. /**
  78665. * Serialize the StateCondition into a JSON compatible object
  78666. * @returns serialization object
  78667. */
  78668. serialize(): any;
  78669. }
  78670. }
  78671. declare module BABYLON {
  78672. /**
  78673. * This defines an action responsible to toggle a boolean once triggered.
  78674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78675. */
  78676. export class SwitchBooleanAction extends Action {
  78677. /**
  78678. * The path to the boolean property in the target object
  78679. */
  78680. propertyPath: string;
  78681. private _target;
  78682. private _effectiveTarget;
  78683. private _property;
  78684. /**
  78685. * Instantiate the action
  78686. * @param triggerOptions defines the trigger options
  78687. * @param target defines the object containing the boolean
  78688. * @param propertyPath defines the path to the boolean property in the target object
  78689. * @param condition defines the trigger related conditions
  78690. */
  78691. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78692. /** @hidden */
  78693. _prepare(): void;
  78694. /**
  78695. * Execute the action toggle the boolean value.
  78696. */
  78697. execute(): void;
  78698. /**
  78699. * Serializes the actions and its related information.
  78700. * @param parent defines the object to serialize in
  78701. * @returns the serialized object
  78702. */
  78703. serialize(parent: any): any;
  78704. }
  78705. /**
  78706. * This defines an action responsible to set a the state field of the target
  78707. * to a desired value once triggered.
  78708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78709. */
  78710. export class SetStateAction extends Action {
  78711. /**
  78712. * The value to store in the state field.
  78713. */
  78714. value: string;
  78715. private _target;
  78716. /**
  78717. * Instantiate the action
  78718. * @param triggerOptions defines the trigger options
  78719. * @param target defines the object containing the state property
  78720. * @param value defines the value to store in the state field
  78721. * @param condition defines the trigger related conditions
  78722. */
  78723. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78724. /**
  78725. * Execute the action and store the value on the target state property.
  78726. */
  78727. execute(): void;
  78728. /**
  78729. * Serializes the actions and its related information.
  78730. * @param parent defines the object to serialize in
  78731. * @returns the serialized object
  78732. */
  78733. serialize(parent: any): any;
  78734. }
  78735. /**
  78736. * This defines an action responsible to set a property of the target
  78737. * to a desired value once triggered.
  78738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78739. */
  78740. export class SetValueAction extends Action {
  78741. /**
  78742. * The path of the property to set in the target.
  78743. */
  78744. propertyPath: string;
  78745. /**
  78746. * The value to set in the property
  78747. */
  78748. value: any;
  78749. private _target;
  78750. private _effectiveTarget;
  78751. private _property;
  78752. /**
  78753. * Instantiate the action
  78754. * @param triggerOptions defines the trigger options
  78755. * @param target defines the object containing the property
  78756. * @param propertyPath defines the path of the property to set in the target
  78757. * @param value defines the value to set in the property
  78758. * @param condition defines the trigger related conditions
  78759. */
  78760. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78761. /** @hidden */
  78762. _prepare(): void;
  78763. /**
  78764. * Execute the action and set the targetted property to the desired value.
  78765. */
  78766. execute(): void;
  78767. /**
  78768. * Serializes the actions and its related information.
  78769. * @param parent defines the object to serialize in
  78770. * @returns the serialized object
  78771. */
  78772. serialize(parent: any): any;
  78773. }
  78774. /**
  78775. * This defines an action responsible to increment the target value
  78776. * to a desired value once triggered.
  78777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78778. */
  78779. export class IncrementValueAction extends Action {
  78780. /**
  78781. * The path of the property to increment in the target.
  78782. */
  78783. propertyPath: string;
  78784. /**
  78785. * The value we should increment the property by.
  78786. */
  78787. value: any;
  78788. private _target;
  78789. private _effectiveTarget;
  78790. private _property;
  78791. /**
  78792. * Instantiate the action
  78793. * @param triggerOptions defines the trigger options
  78794. * @param target defines the object containing the property
  78795. * @param propertyPath defines the path of the property to increment in the target
  78796. * @param value defines the value value we should increment the property by
  78797. * @param condition defines the trigger related conditions
  78798. */
  78799. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78800. /** @hidden */
  78801. _prepare(): void;
  78802. /**
  78803. * Execute the action and increment the target of the value amount.
  78804. */
  78805. execute(): void;
  78806. /**
  78807. * Serializes the actions and its related information.
  78808. * @param parent defines the object to serialize in
  78809. * @returns the serialized object
  78810. */
  78811. serialize(parent: any): any;
  78812. }
  78813. /**
  78814. * This defines an action responsible to start an animation once triggered.
  78815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78816. */
  78817. export class PlayAnimationAction extends Action {
  78818. /**
  78819. * Where the animation should start (animation frame)
  78820. */
  78821. from: number;
  78822. /**
  78823. * Where the animation should stop (animation frame)
  78824. */
  78825. to: number;
  78826. /**
  78827. * Define if the animation should loop or stop after the first play.
  78828. */
  78829. loop?: boolean;
  78830. private _target;
  78831. /**
  78832. * Instantiate the action
  78833. * @param triggerOptions defines the trigger options
  78834. * @param target defines the target animation or animation name
  78835. * @param from defines from where the animation should start (animation frame)
  78836. * @param end defines where the animation should stop (animation frame)
  78837. * @param loop defines if the animation should loop or stop after the first play
  78838. * @param condition defines the trigger related conditions
  78839. */
  78840. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78841. /** @hidden */
  78842. _prepare(): void;
  78843. /**
  78844. * Execute the action and play the animation.
  78845. */
  78846. execute(): void;
  78847. /**
  78848. * Serializes the actions and its related information.
  78849. * @param parent defines the object to serialize in
  78850. * @returns the serialized object
  78851. */
  78852. serialize(parent: any): any;
  78853. }
  78854. /**
  78855. * This defines an action responsible to stop an animation once triggered.
  78856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78857. */
  78858. export class StopAnimationAction extends Action {
  78859. private _target;
  78860. /**
  78861. * Instantiate the action
  78862. * @param triggerOptions defines the trigger options
  78863. * @param target defines the target animation or animation name
  78864. * @param condition defines the trigger related conditions
  78865. */
  78866. constructor(triggerOptions: any, target: any, condition?: Condition);
  78867. /** @hidden */
  78868. _prepare(): void;
  78869. /**
  78870. * Execute the action and stop the animation.
  78871. */
  78872. execute(): void;
  78873. /**
  78874. * Serializes the actions and its related information.
  78875. * @param parent defines the object to serialize in
  78876. * @returns the serialized object
  78877. */
  78878. serialize(parent: any): any;
  78879. }
  78880. /**
  78881. * This defines an action responsible that does nothing once triggered.
  78882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78883. */
  78884. export class DoNothingAction extends Action {
  78885. /**
  78886. * Instantiate the action
  78887. * @param triggerOptions defines the trigger options
  78888. * @param condition defines the trigger related conditions
  78889. */
  78890. constructor(triggerOptions?: any, condition?: Condition);
  78891. /**
  78892. * Execute the action and do nothing.
  78893. */
  78894. execute(): void;
  78895. /**
  78896. * Serializes the actions and its related information.
  78897. * @param parent defines the object to serialize in
  78898. * @returns the serialized object
  78899. */
  78900. serialize(parent: any): any;
  78901. }
  78902. /**
  78903. * This defines an action responsible to trigger several actions once triggered.
  78904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78905. */
  78906. export class CombineAction extends Action {
  78907. /**
  78908. * The list of aggregated animations to run.
  78909. */
  78910. children: Action[];
  78911. /**
  78912. * Instantiate the action
  78913. * @param triggerOptions defines the trigger options
  78914. * @param children defines the list of aggregated animations to run
  78915. * @param condition defines the trigger related conditions
  78916. */
  78917. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78918. /** @hidden */
  78919. _prepare(): void;
  78920. /**
  78921. * Execute the action and executes all the aggregated actions.
  78922. */
  78923. execute(evt: ActionEvent): void;
  78924. /**
  78925. * Serializes the actions and its related information.
  78926. * @param parent defines the object to serialize in
  78927. * @returns the serialized object
  78928. */
  78929. serialize(parent: any): any;
  78930. }
  78931. /**
  78932. * This defines an action responsible to run code (external event) once triggered.
  78933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78934. */
  78935. export class ExecuteCodeAction extends Action {
  78936. /**
  78937. * The callback function to run.
  78938. */
  78939. func: (evt: ActionEvent) => void;
  78940. /**
  78941. * Instantiate the action
  78942. * @param triggerOptions defines the trigger options
  78943. * @param func defines the callback function to run
  78944. * @param condition defines the trigger related conditions
  78945. */
  78946. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78947. /**
  78948. * Execute the action and run the attached code.
  78949. */
  78950. execute(evt: ActionEvent): void;
  78951. }
  78952. /**
  78953. * This defines an action responsible to set the parent property of the target once triggered.
  78954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78955. */
  78956. export class SetParentAction extends Action {
  78957. private _parent;
  78958. private _target;
  78959. /**
  78960. * Instantiate the action
  78961. * @param triggerOptions defines the trigger options
  78962. * @param target defines the target containing the parent property
  78963. * @param parent defines from where the animation should start (animation frame)
  78964. * @param condition defines the trigger related conditions
  78965. */
  78966. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78967. /** @hidden */
  78968. _prepare(): void;
  78969. /**
  78970. * Execute the action and set the parent property.
  78971. */
  78972. execute(): void;
  78973. /**
  78974. * Serializes the actions and its related information.
  78975. * @param parent defines the object to serialize in
  78976. * @returns the serialized object
  78977. */
  78978. serialize(parent: any): any;
  78979. }
  78980. }
  78981. declare module BABYLON {
  78982. /**
  78983. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78984. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78986. */
  78987. export class ActionManager extends AbstractActionManager {
  78988. /**
  78989. * Nothing
  78990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78991. */
  78992. static readonly NothingTrigger: number;
  78993. /**
  78994. * On pick
  78995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78996. */
  78997. static readonly OnPickTrigger: number;
  78998. /**
  78999. * On left pick
  79000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79001. */
  79002. static readonly OnLeftPickTrigger: number;
  79003. /**
  79004. * On right pick
  79005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79006. */
  79007. static readonly OnRightPickTrigger: number;
  79008. /**
  79009. * On center pick
  79010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79011. */
  79012. static readonly OnCenterPickTrigger: number;
  79013. /**
  79014. * On pick down
  79015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79016. */
  79017. static readonly OnPickDownTrigger: number;
  79018. /**
  79019. * On double pick
  79020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79021. */
  79022. static readonly OnDoublePickTrigger: number;
  79023. /**
  79024. * On pick up
  79025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79026. */
  79027. static readonly OnPickUpTrigger: number;
  79028. /**
  79029. * On pick out.
  79030. * This trigger will only be raised if you also declared a OnPickDown
  79031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79032. */
  79033. static readonly OnPickOutTrigger: number;
  79034. /**
  79035. * On long press
  79036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79037. */
  79038. static readonly OnLongPressTrigger: number;
  79039. /**
  79040. * On pointer over
  79041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79042. */
  79043. static readonly OnPointerOverTrigger: number;
  79044. /**
  79045. * On pointer out
  79046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79047. */
  79048. static readonly OnPointerOutTrigger: number;
  79049. /**
  79050. * On every frame
  79051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79052. */
  79053. static readonly OnEveryFrameTrigger: number;
  79054. /**
  79055. * On intersection enter
  79056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79057. */
  79058. static readonly OnIntersectionEnterTrigger: number;
  79059. /**
  79060. * On intersection exit
  79061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79062. */
  79063. static readonly OnIntersectionExitTrigger: number;
  79064. /**
  79065. * On key down
  79066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79067. */
  79068. static readonly OnKeyDownTrigger: number;
  79069. /**
  79070. * On key up
  79071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79072. */
  79073. static readonly OnKeyUpTrigger: number;
  79074. private _scene;
  79075. /**
  79076. * Creates a new action manager
  79077. * @param scene defines the hosting scene
  79078. */
  79079. constructor(scene: Scene);
  79080. /**
  79081. * Releases all associated resources
  79082. */
  79083. dispose(): void;
  79084. /**
  79085. * Gets hosting scene
  79086. * @returns the hosting scene
  79087. */
  79088. getScene(): Scene;
  79089. /**
  79090. * Does this action manager handles actions of any of the given triggers
  79091. * @param triggers defines the triggers to be tested
  79092. * @return a boolean indicating whether one (or more) of the triggers is handled
  79093. */
  79094. hasSpecificTriggers(triggers: number[]): boolean;
  79095. /**
  79096. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79097. * speed.
  79098. * @param triggerA defines the trigger to be tested
  79099. * @param triggerB defines the trigger to be tested
  79100. * @return a boolean indicating whether one (or more) of the triggers is handled
  79101. */
  79102. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79103. /**
  79104. * Does this action manager handles actions of a given trigger
  79105. * @param trigger defines the trigger to be tested
  79106. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79107. * @return whether the trigger is handled
  79108. */
  79109. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79110. /**
  79111. * Does this action manager has pointer triggers
  79112. */
  79113. readonly hasPointerTriggers: boolean;
  79114. /**
  79115. * Does this action manager has pick triggers
  79116. */
  79117. readonly hasPickTriggers: boolean;
  79118. /**
  79119. * Registers an action to this action manager
  79120. * @param action defines the action to be registered
  79121. * @return the action amended (prepared) after registration
  79122. */
  79123. registerAction(action: IAction): Nullable<IAction>;
  79124. /**
  79125. * Unregisters an action to this action manager
  79126. * @param action defines the action to be unregistered
  79127. * @return a boolean indicating whether the action has been unregistered
  79128. */
  79129. unregisterAction(action: IAction): Boolean;
  79130. /**
  79131. * Process a specific trigger
  79132. * @param trigger defines the trigger to process
  79133. * @param evt defines the event details to be processed
  79134. */
  79135. processTrigger(trigger: number, evt?: IActionEvent): void;
  79136. /** @hidden */
  79137. _getEffectiveTarget(target: any, propertyPath: string): any;
  79138. /** @hidden */
  79139. _getProperty(propertyPath: string): string;
  79140. /**
  79141. * Serialize this manager to a JSON object
  79142. * @param name defines the property name to store this manager
  79143. * @returns a JSON representation of this manager
  79144. */
  79145. serialize(name: string): any;
  79146. /**
  79147. * Creates a new ActionManager from a JSON data
  79148. * @param parsedActions defines the JSON data to read from
  79149. * @param object defines the hosting mesh
  79150. * @param scene defines the hosting scene
  79151. */
  79152. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79153. /**
  79154. * Get a trigger name by index
  79155. * @param trigger defines the trigger index
  79156. * @returns a trigger name
  79157. */
  79158. static GetTriggerName(trigger: number): string;
  79159. }
  79160. }
  79161. declare module BABYLON {
  79162. /**
  79163. * Class representing a ray with position and direction
  79164. */
  79165. export class Ray {
  79166. /** origin point */
  79167. origin: Vector3;
  79168. /** direction */
  79169. direction: Vector3;
  79170. /** length of the ray */
  79171. length: number;
  79172. private static readonly TmpVector3;
  79173. private _tmpRay;
  79174. /**
  79175. * Creates a new ray
  79176. * @param origin origin point
  79177. * @param direction direction
  79178. * @param length length of the ray
  79179. */
  79180. constructor(
  79181. /** origin point */
  79182. origin: Vector3,
  79183. /** direction */
  79184. direction: Vector3,
  79185. /** length of the ray */
  79186. length?: number);
  79187. /**
  79188. * Checks if the ray intersects a box
  79189. * @param minimum bound of the box
  79190. * @param maximum bound of the box
  79191. * @param intersectionTreshold extra extend to be added to the box in all direction
  79192. * @returns if the box was hit
  79193. */
  79194. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79195. /**
  79196. * Checks if the ray intersects a box
  79197. * @param box the bounding box to check
  79198. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79199. * @returns if the box was hit
  79200. */
  79201. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79202. /**
  79203. * If the ray hits a sphere
  79204. * @param sphere the bounding sphere to check
  79205. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79206. * @returns true if it hits the sphere
  79207. */
  79208. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79209. /**
  79210. * If the ray hits a triange
  79211. * @param vertex0 triangle vertex
  79212. * @param vertex1 triangle vertex
  79213. * @param vertex2 triangle vertex
  79214. * @returns intersection information if hit
  79215. */
  79216. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79217. /**
  79218. * Checks if ray intersects a plane
  79219. * @param plane the plane to check
  79220. * @returns the distance away it was hit
  79221. */
  79222. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79223. /**
  79224. * Calculate the intercept of a ray on a given axis
  79225. * @param axis to check 'x' | 'y' | 'z'
  79226. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79227. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79228. */
  79229. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79230. /**
  79231. * Checks if ray intersects a mesh
  79232. * @param mesh the mesh to check
  79233. * @param fastCheck if only the bounding box should checked
  79234. * @returns picking info of the intersecton
  79235. */
  79236. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79237. /**
  79238. * Checks if ray intersects a mesh
  79239. * @param meshes the meshes to check
  79240. * @param fastCheck if only the bounding box should checked
  79241. * @param results array to store result in
  79242. * @returns Array of picking infos
  79243. */
  79244. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79245. private _comparePickingInfo;
  79246. private static smallnum;
  79247. private static rayl;
  79248. /**
  79249. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79250. * @param sega the first point of the segment to test the intersection against
  79251. * @param segb the second point of the segment to test the intersection against
  79252. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79253. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79254. */
  79255. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79256. /**
  79257. * Update the ray from viewport position
  79258. * @param x position
  79259. * @param y y position
  79260. * @param viewportWidth viewport width
  79261. * @param viewportHeight viewport height
  79262. * @param world world matrix
  79263. * @param view view matrix
  79264. * @param projection projection matrix
  79265. * @returns this ray updated
  79266. */
  79267. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79268. /**
  79269. * Creates a ray with origin and direction of 0,0,0
  79270. * @returns the new ray
  79271. */
  79272. static Zero(): Ray;
  79273. /**
  79274. * Creates a new ray from screen space and viewport
  79275. * @param x position
  79276. * @param y y position
  79277. * @param viewportWidth viewport width
  79278. * @param viewportHeight viewport height
  79279. * @param world world matrix
  79280. * @param view view matrix
  79281. * @param projection projection matrix
  79282. * @returns new ray
  79283. */
  79284. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79285. /**
  79286. * 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
  79287. * transformed to the given world matrix.
  79288. * @param origin The origin point
  79289. * @param end The end point
  79290. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79291. * @returns the new ray
  79292. */
  79293. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79294. /**
  79295. * Transforms a ray by a matrix
  79296. * @param ray ray to transform
  79297. * @param matrix matrix to apply
  79298. * @returns the resulting new ray
  79299. */
  79300. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79301. /**
  79302. * Transforms a ray by a matrix
  79303. * @param ray ray to transform
  79304. * @param matrix matrix to apply
  79305. * @param result ray to store result in
  79306. */
  79307. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79308. /**
  79309. * Unproject a ray from screen space to object space
  79310. * @param sourceX defines the screen space x coordinate to use
  79311. * @param sourceY defines the screen space y coordinate to use
  79312. * @param viewportWidth defines the current width of the viewport
  79313. * @param viewportHeight defines the current height of the viewport
  79314. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79315. * @param view defines the view matrix to use
  79316. * @param projection defines the projection matrix to use
  79317. */
  79318. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79319. }
  79320. /**
  79321. * Type used to define predicate used to select faces when a mesh intersection is detected
  79322. */
  79323. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79324. interface Scene {
  79325. /** @hidden */
  79326. _tempPickingRay: Nullable<Ray>;
  79327. /** @hidden */
  79328. _cachedRayForTransform: Ray;
  79329. /** @hidden */
  79330. _pickWithRayInverseMatrix: Matrix;
  79331. /** @hidden */
  79332. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79333. /** @hidden */
  79334. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79335. }
  79336. }
  79337. declare module BABYLON {
  79338. /**
  79339. * Groups all the scene component constants in one place to ease maintenance.
  79340. * @hidden
  79341. */
  79342. export class SceneComponentConstants {
  79343. static readonly NAME_EFFECTLAYER: string;
  79344. static readonly NAME_LAYER: string;
  79345. static readonly NAME_LENSFLARESYSTEM: string;
  79346. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79347. static readonly NAME_PARTICLESYSTEM: string;
  79348. static readonly NAME_GAMEPAD: string;
  79349. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79350. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79351. static readonly NAME_DEPTHRENDERER: string;
  79352. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79353. static readonly NAME_SPRITE: string;
  79354. static readonly NAME_OUTLINERENDERER: string;
  79355. static readonly NAME_PROCEDURALTEXTURE: string;
  79356. static readonly NAME_SHADOWGENERATOR: string;
  79357. static readonly NAME_OCTREE: string;
  79358. static readonly NAME_PHYSICSENGINE: string;
  79359. static readonly NAME_AUDIO: string;
  79360. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79361. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79362. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79363. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79364. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79365. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79366. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79367. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79368. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79369. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79370. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79371. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79372. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79373. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79374. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79375. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79376. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79377. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79378. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79379. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79380. static readonly STEP_AFTERRENDER_AUDIO: number;
  79381. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79382. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79383. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79384. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79385. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79386. static readonly STEP_POINTERMOVE_SPRITE: number;
  79387. static readonly STEP_POINTERDOWN_SPRITE: number;
  79388. static readonly STEP_POINTERUP_SPRITE: number;
  79389. }
  79390. /**
  79391. * This represents a scene component.
  79392. *
  79393. * This is used to decouple the dependency the scene is having on the different workloads like
  79394. * layers, post processes...
  79395. */
  79396. export interface ISceneComponent {
  79397. /**
  79398. * The name of the component. Each component must have a unique name.
  79399. */
  79400. name: string;
  79401. /**
  79402. * The scene the component belongs to.
  79403. */
  79404. scene: Scene;
  79405. /**
  79406. * Register the component to one instance of a scene.
  79407. */
  79408. register(): void;
  79409. /**
  79410. * Rebuilds the elements related to this component in case of
  79411. * context lost for instance.
  79412. */
  79413. rebuild(): void;
  79414. /**
  79415. * Disposes the component and the associated ressources.
  79416. */
  79417. dispose(): void;
  79418. }
  79419. /**
  79420. * This represents a SERIALIZABLE scene component.
  79421. *
  79422. * This extends Scene Component to add Serialization methods on top.
  79423. */
  79424. export interface ISceneSerializableComponent extends ISceneComponent {
  79425. /**
  79426. * Adds all the elements from the container to the scene
  79427. * @param container the container holding the elements
  79428. */
  79429. addFromContainer(container: AbstractScene): void;
  79430. /**
  79431. * Removes all the elements in the container from the scene
  79432. * @param container contains the elements to remove
  79433. * @param dispose if the removed element should be disposed (default: false)
  79434. */
  79435. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79436. /**
  79437. * Serializes the component data to the specified json object
  79438. * @param serializationObject The object to serialize to
  79439. */
  79440. serialize(serializationObject: any): void;
  79441. }
  79442. /**
  79443. * Strong typing of a Mesh related stage step action
  79444. */
  79445. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79446. /**
  79447. * Strong typing of a Evaluate Sub Mesh related stage step action
  79448. */
  79449. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79450. /**
  79451. * Strong typing of a Active Mesh related stage step action
  79452. */
  79453. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79454. /**
  79455. * Strong typing of a Camera related stage step action
  79456. */
  79457. export type CameraStageAction = (camera: Camera) => void;
  79458. /**
  79459. * Strong typing of a Camera Frame buffer related stage step action
  79460. */
  79461. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79462. /**
  79463. * Strong typing of a Render Target related stage step action
  79464. */
  79465. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79466. /**
  79467. * Strong typing of a RenderingGroup related stage step action
  79468. */
  79469. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79470. /**
  79471. * Strong typing of a Mesh Render related stage step action
  79472. */
  79473. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79474. /**
  79475. * Strong typing of a simple stage step action
  79476. */
  79477. export type SimpleStageAction = () => void;
  79478. /**
  79479. * Strong typing of a render target action.
  79480. */
  79481. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79482. /**
  79483. * Strong typing of a pointer move action.
  79484. */
  79485. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79486. /**
  79487. * Strong typing of a pointer up/down action.
  79488. */
  79489. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79490. /**
  79491. * Representation of a stage in the scene (Basically a list of ordered steps)
  79492. * @hidden
  79493. */
  79494. export class Stage<T extends Function> extends Array<{
  79495. index: number;
  79496. component: ISceneComponent;
  79497. action: T;
  79498. }> {
  79499. /**
  79500. * Hide ctor from the rest of the world.
  79501. * @param items The items to add.
  79502. */
  79503. private constructor();
  79504. /**
  79505. * Creates a new Stage.
  79506. * @returns A new instance of a Stage
  79507. */
  79508. static Create<T extends Function>(): Stage<T>;
  79509. /**
  79510. * Registers a step in an ordered way in the targeted stage.
  79511. * @param index Defines the position to register the step in
  79512. * @param component Defines the component attached to the step
  79513. * @param action Defines the action to launch during the step
  79514. */
  79515. registerStep(index: number, component: ISceneComponent, action: T): void;
  79516. /**
  79517. * Clears all the steps from the stage.
  79518. */
  79519. clear(): void;
  79520. }
  79521. }
  79522. declare module BABYLON {
  79523. interface Scene {
  79524. /** @hidden */
  79525. _pointerOverSprite: Nullable<Sprite>;
  79526. /** @hidden */
  79527. _pickedDownSprite: Nullable<Sprite>;
  79528. /** @hidden */
  79529. _tempSpritePickingRay: Nullable<Ray>;
  79530. /**
  79531. * All of the sprite managers added to this scene
  79532. * @see http://doc.babylonjs.com/babylon101/sprites
  79533. */
  79534. spriteManagers: Array<ISpriteManager>;
  79535. /**
  79536. * An event triggered when sprites rendering is about to start
  79537. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79538. */
  79539. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79540. /**
  79541. * An event triggered when sprites rendering is done
  79542. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79543. */
  79544. onAfterSpritesRenderingObservable: Observable<Scene>;
  79545. /** @hidden */
  79546. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79547. /** Launch a ray to try to pick a sprite in the scene
  79548. * @param x position on screen
  79549. * @param y position on screen
  79550. * @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
  79551. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79552. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79553. * @returns a PickingInfo
  79554. */
  79555. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79556. /** Use the given ray to pick a sprite in the scene
  79557. * @param ray The ray (in world space) to use to pick meshes
  79558. * @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
  79559. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79560. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79561. * @returns a PickingInfo
  79562. */
  79563. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79564. /** @hidden */
  79565. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79566. /** Launch a ray to try to pick sprites in the scene
  79567. * @param x position on screen
  79568. * @param y position on screen
  79569. * @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
  79570. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79571. * @returns a PickingInfo array
  79572. */
  79573. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79574. /** Use the given ray to pick sprites in the scene
  79575. * @param ray The ray (in world space) to use to pick meshes
  79576. * @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
  79577. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79578. * @returns a PickingInfo array
  79579. */
  79580. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79581. /**
  79582. * Force the sprite under the pointer
  79583. * @param sprite defines the sprite to use
  79584. */
  79585. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79586. /**
  79587. * Gets the sprite under the pointer
  79588. * @returns a Sprite or null if no sprite is under the pointer
  79589. */
  79590. getPointerOverSprite(): Nullable<Sprite>;
  79591. }
  79592. /**
  79593. * Defines the sprite scene component responsible to manage sprites
  79594. * in a given scene.
  79595. */
  79596. export class SpriteSceneComponent implements ISceneComponent {
  79597. /**
  79598. * The component name helpfull to identify the component in the list of scene components.
  79599. */
  79600. readonly name: string;
  79601. /**
  79602. * The scene the component belongs to.
  79603. */
  79604. scene: Scene;
  79605. /** @hidden */
  79606. private _spritePredicate;
  79607. /**
  79608. * Creates a new instance of the component for the given scene
  79609. * @param scene Defines the scene to register the component in
  79610. */
  79611. constructor(scene: Scene);
  79612. /**
  79613. * Registers the component in a given scene
  79614. */
  79615. register(): void;
  79616. /**
  79617. * Rebuilds the elements related to this component in case of
  79618. * context lost for instance.
  79619. */
  79620. rebuild(): void;
  79621. /**
  79622. * Disposes the component and the associated ressources.
  79623. */
  79624. dispose(): void;
  79625. private _pickSpriteButKeepRay;
  79626. private _pointerMove;
  79627. private _pointerDown;
  79628. private _pointerUp;
  79629. }
  79630. }
  79631. declare module BABYLON {
  79632. /** @hidden */
  79633. export var fogFragmentDeclaration: {
  79634. name: string;
  79635. shader: string;
  79636. };
  79637. }
  79638. declare module BABYLON {
  79639. /** @hidden */
  79640. export var fogFragment: {
  79641. name: string;
  79642. shader: string;
  79643. };
  79644. }
  79645. declare module BABYLON {
  79646. /** @hidden */
  79647. export var spritesPixelShader: {
  79648. name: string;
  79649. shader: string;
  79650. };
  79651. }
  79652. declare module BABYLON {
  79653. /** @hidden */
  79654. export var fogVertexDeclaration: {
  79655. name: string;
  79656. shader: string;
  79657. };
  79658. }
  79659. declare module BABYLON {
  79660. /** @hidden */
  79661. export var spritesVertexShader: {
  79662. name: string;
  79663. shader: string;
  79664. };
  79665. }
  79666. declare module BABYLON {
  79667. /**
  79668. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79669. */
  79670. export interface ISpriteManager extends IDisposable {
  79671. /**
  79672. * Restricts the camera to viewing objects with the same layerMask.
  79673. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79674. */
  79675. layerMask: number;
  79676. /**
  79677. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79678. */
  79679. isPickable: boolean;
  79680. /**
  79681. * Specifies the rendering group id for this mesh (0 by default)
  79682. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79683. */
  79684. renderingGroupId: number;
  79685. /**
  79686. * Defines the list of sprites managed by the manager.
  79687. */
  79688. sprites: Array<Sprite>;
  79689. /**
  79690. * Tests the intersection of a sprite with a specific ray.
  79691. * @param ray The ray we are sending to test the collision
  79692. * @param camera The camera space we are sending rays in
  79693. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79694. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79695. * @returns picking info or null.
  79696. */
  79697. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79698. /**
  79699. * Intersects the sprites with a ray
  79700. * @param ray defines the ray to intersect with
  79701. * @param camera defines the current active camera
  79702. * @param predicate defines a predicate used to select candidate sprites
  79703. * @returns null if no hit or a PickingInfo array
  79704. */
  79705. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79706. /**
  79707. * Renders the list of sprites on screen.
  79708. */
  79709. render(): void;
  79710. }
  79711. /**
  79712. * Class used to manage multiple sprites on the same spritesheet
  79713. * @see http://doc.babylonjs.com/babylon101/sprites
  79714. */
  79715. export class SpriteManager implements ISpriteManager {
  79716. /** defines the manager's name */
  79717. name: string;
  79718. /** Gets the list of sprites */
  79719. sprites: Sprite[];
  79720. /** Gets or sets the rendering group id (0 by default) */
  79721. renderingGroupId: number;
  79722. /** Gets or sets camera layer mask */
  79723. layerMask: number;
  79724. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79725. fogEnabled: boolean;
  79726. /** Gets or sets a boolean indicating if the sprites are pickable */
  79727. isPickable: boolean;
  79728. /** Defines the default width of a cell in the spritesheet */
  79729. cellWidth: number;
  79730. /** Defines the default height of a cell in the spritesheet */
  79731. cellHeight: number;
  79732. /** Associative array from JSON sprite data file */
  79733. private _cellData;
  79734. /** Array of sprite names from JSON sprite data file */
  79735. private _spriteMap;
  79736. /** True when packed cell data from JSON file is ready*/
  79737. private _packedAndReady;
  79738. /**
  79739. * An event triggered when the manager is disposed.
  79740. */
  79741. onDisposeObservable: Observable<SpriteManager>;
  79742. private _onDisposeObserver;
  79743. /**
  79744. * Callback called when the manager is disposed
  79745. */
  79746. onDispose: () => void;
  79747. private _capacity;
  79748. private _fromPacked;
  79749. private _spriteTexture;
  79750. private _epsilon;
  79751. private _scene;
  79752. private _vertexData;
  79753. private _buffer;
  79754. private _vertexBuffers;
  79755. private _indexBuffer;
  79756. private _effectBase;
  79757. private _effectFog;
  79758. /**
  79759. * Gets or sets the spritesheet texture
  79760. */
  79761. texture: Texture;
  79762. /**
  79763. * Creates a new sprite manager
  79764. * @param name defines the manager's name
  79765. * @param imgUrl defines the sprite sheet url
  79766. * @param capacity defines the maximum allowed number of sprites
  79767. * @param cellSize defines the size of a sprite cell
  79768. * @param scene defines the hosting scene
  79769. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79770. * @param samplingMode defines the smapling mode to use with spritesheet
  79771. * @param fromPacked set to false; do not alter
  79772. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79773. */
  79774. constructor(
  79775. /** defines the manager's name */
  79776. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79777. private _makePacked;
  79778. private _appendSpriteVertex;
  79779. /**
  79780. * Intersects the sprites with a ray
  79781. * @param ray defines the ray to intersect with
  79782. * @param camera defines the current active camera
  79783. * @param predicate defines a predicate used to select candidate sprites
  79784. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79785. * @returns null if no hit or a PickingInfo
  79786. */
  79787. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79788. /**
  79789. * Intersects the sprites with a ray
  79790. * @param ray defines the ray to intersect with
  79791. * @param camera defines the current active camera
  79792. * @param predicate defines a predicate used to select candidate sprites
  79793. * @returns null if no hit or a PickingInfo array
  79794. */
  79795. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79796. /**
  79797. * Render all child sprites
  79798. */
  79799. render(): void;
  79800. /**
  79801. * Release associated resources
  79802. */
  79803. dispose(): void;
  79804. }
  79805. }
  79806. declare module BABYLON {
  79807. /**
  79808. * Class used to represent a sprite
  79809. * @see http://doc.babylonjs.com/babylon101/sprites
  79810. */
  79811. export class Sprite {
  79812. /** defines the name */
  79813. name: string;
  79814. /** Gets or sets the current world position */
  79815. position: Vector3;
  79816. /** Gets or sets the main color */
  79817. color: Color4;
  79818. /** Gets or sets the width */
  79819. width: number;
  79820. /** Gets or sets the height */
  79821. height: number;
  79822. /** Gets or sets rotation angle */
  79823. angle: number;
  79824. /** Gets or sets the cell index in the sprite sheet */
  79825. cellIndex: number;
  79826. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79827. cellRef: string;
  79828. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79829. invertU: number;
  79830. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79831. invertV: number;
  79832. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79833. disposeWhenFinishedAnimating: boolean;
  79834. /** Gets the list of attached animations */
  79835. animations: Animation[];
  79836. /** Gets or sets a boolean indicating if the sprite can be picked */
  79837. isPickable: boolean;
  79838. /**
  79839. * Gets or sets the associated action manager
  79840. */
  79841. actionManager: Nullable<ActionManager>;
  79842. private _animationStarted;
  79843. private _loopAnimation;
  79844. private _fromIndex;
  79845. private _toIndex;
  79846. private _delay;
  79847. private _direction;
  79848. private _manager;
  79849. private _time;
  79850. private _onAnimationEnd;
  79851. /**
  79852. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79853. */
  79854. isVisible: boolean;
  79855. /**
  79856. * Gets or sets the sprite size
  79857. */
  79858. size: number;
  79859. /**
  79860. * Creates a new Sprite
  79861. * @param name defines the name
  79862. * @param manager defines the manager
  79863. */
  79864. constructor(
  79865. /** defines the name */
  79866. name: string, manager: ISpriteManager);
  79867. /**
  79868. * Starts an animation
  79869. * @param from defines the initial key
  79870. * @param to defines the end key
  79871. * @param loop defines if the animation must loop
  79872. * @param delay defines the start delay (in ms)
  79873. * @param onAnimationEnd defines a callback to call when animation ends
  79874. */
  79875. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79876. /** Stops current animation (if any) */
  79877. stopAnimation(): void;
  79878. /** @hidden */
  79879. _animate(deltaTime: number): void;
  79880. /** Release associated resources */
  79881. dispose(): void;
  79882. }
  79883. }
  79884. declare module BABYLON {
  79885. /**
  79886. * Information about the result of picking within a scene
  79887. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79888. */
  79889. export class PickingInfo {
  79890. /** @hidden */
  79891. _pickingUnavailable: boolean;
  79892. /**
  79893. * If the pick collided with an object
  79894. */
  79895. hit: boolean;
  79896. /**
  79897. * Distance away where the pick collided
  79898. */
  79899. distance: number;
  79900. /**
  79901. * The location of pick collision
  79902. */
  79903. pickedPoint: Nullable<Vector3>;
  79904. /**
  79905. * The mesh corresponding the the pick collision
  79906. */
  79907. pickedMesh: Nullable<AbstractMesh>;
  79908. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79909. bu: number;
  79910. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79911. bv: number;
  79912. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79913. faceId: number;
  79914. /** Id of the the submesh that was picked */
  79915. subMeshId: number;
  79916. /** If a sprite was picked, this will be the sprite the pick collided with */
  79917. pickedSprite: Nullable<Sprite>;
  79918. /**
  79919. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79920. */
  79921. originMesh: Nullable<AbstractMesh>;
  79922. /**
  79923. * The ray that was used to perform the picking.
  79924. */
  79925. ray: Nullable<Ray>;
  79926. /**
  79927. * Gets the normal correspodning to the face the pick collided with
  79928. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79929. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79930. * @returns The normal correspodning to the face the pick collided with
  79931. */
  79932. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79933. /**
  79934. * Gets the texture coordinates of where the pick occured
  79935. * @returns the vector containing the coordnates of the texture
  79936. */
  79937. getTextureCoordinates(): Nullable<Vector2>;
  79938. }
  79939. }
  79940. declare module BABYLON {
  79941. /**
  79942. * Gather the list of pointer event types as constants.
  79943. */
  79944. export class PointerEventTypes {
  79945. /**
  79946. * 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.
  79947. */
  79948. static readonly POINTERDOWN: number;
  79949. /**
  79950. * The pointerup event is fired when a pointer is no longer active.
  79951. */
  79952. static readonly POINTERUP: number;
  79953. /**
  79954. * The pointermove event is fired when a pointer changes coordinates.
  79955. */
  79956. static readonly POINTERMOVE: number;
  79957. /**
  79958. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79959. */
  79960. static readonly POINTERWHEEL: number;
  79961. /**
  79962. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79963. */
  79964. static readonly POINTERPICK: number;
  79965. /**
  79966. * The pointertap event is fired when a the object has been touched and released without drag.
  79967. */
  79968. static readonly POINTERTAP: number;
  79969. /**
  79970. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79971. */
  79972. static readonly POINTERDOUBLETAP: number;
  79973. }
  79974. /**
  79975. * Base class of pointer info types.
  79976. */
  79977. export class PointerInfoBase {
  79978. /**
  79979. * Defines the type of event (PointerEventTypes)
  79980. */
  79981. type: number;
  79982. /**
  79983. * Defines the related dom event
  79984. */
  79985. event: PointerEvent | MouseWheelEvent;
  79986. /**
  79987. * Instantiates the base class of pointers info.
  79988. * @param type Defines the type of event (PointerEventTypes)
  79989. * @param event Defines the related dom event
  79990. */
  79991. constructor(
  79992. /**
  79993. * Defines the type of event (PointerEventTypes)
  79994. */
  79995. type: number,
  79996. /**
  79997. * Defines the related dom event
  79998. */
  79999. event: PointerEvent | MouseWheelEvent);
  80000. }
  80001. /**
  80002. * This class is used to store pointer related info for the onPrePointerObservable event.
  80003. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80004. */
  80005. export class PointerInfoPre extends PointerInfoBase {
  80006. /**
  80007. * Ray from a pointer if availible (eg. 6dof controller)
  80008. */
  80009. ray: Nullable<Ray>;
  80010. /**
  80011. * Defines the local position of the pointer on the canvas.
  80012. */
  80013. localPosition: Vector2;
  80014. /**
  80015. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80016. */
  80017. skipOnPointerObservable: boolean;
  80018. /**
  80019. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80020. * @param type Defines the type of event (PointerEventTypes)
  80021. * @param event Defines the related dom event
  80022. * @param localX Defines the local x coordinates of the pointer when the event occured
  80023. * @param localY Defines the local y coordinates of the pointer when the event occured
  80024. */
  80025. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80026. }
  80027. /**
  80028. * This type contains all the data related to a pointer event in Babylon.js.
  80029. * 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.
  80030. */
  80031. export class PointerInfo extends PointerInfoBase {
  80032. /**
  80033. * Defines the picking info associated to the info (if any)\
  80034. */
  80035. pickInfo: Nullable<PickingInfo>;
  80036. /**
  80037. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80038. * @param type Defines the type of event (PointerEventTypes)
  80039. * @param event Defines the related dom event
  80040. * @param pickInfo Defines the picking info associated to the info (if any)\
  80041. */
  80042. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80043. /**
  80044. * Defines the picking info associated to the info (if any)\
  80045. */
  80046. pickInfo: Nullable<PickingInfo>);
  80047. }
  80048. /**
  80049. * Data relating to a touch event on the screen.
  80050. */
  80051. export interface PointerTouch {
  80052. /**
  80053. * X coordinate of touch.
  80054. */
  80055. x: number;
  80056. /**
  80057. * Y coordinate of touch.
  80058. */
  80059. y: number;
  80060. /**
  80061. * Id of touch. Unique for each finger.
  80062. */
  80063. pointerId: number;
  80064. /**
  80065. * Event type passed from DOM.
  80066. */
  80067. type: any;
  80068. }
  80069. }
  80070. declare module BABYLON {
  80071. /**
  80072. * Manage the mouse inputs to control the movement of a free camera.
  80073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80074. */
  80075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80076. /**
  80077. * Define if touch is enabled in the mouse input
  80078. */
  80079. touchEnabled: boolean;
  80080. /**
  80081. * Defines the camera the input is attached to.
  80082. */
  80083. camera: FreeCamera;
  80084. /**
  80085. * Defines the buttons associated with the input to handle camera move.
  80086. */
  80087. buttons: number[];
  80088. /**
  80089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80090. */
  80091. angularSensibility: number;
  80092. private _pointerInput;
  80093. private _onMouseMove;
  80094. private _observer;
  80095. private previousPosition;
  80096. /**
  80097. * Observable for when a pointer move event occurs containing the move offset
  80098. */
  80099. onPointerMovedObservable: Observable<{
  80100. offsetX: number;
  80101. offsetY: number;
  80102. }>;
  80103. /**
  80104. * @hidden
  80105. * If the camera should be rotated automatically based on pointer movement
  80106. */
  80107. _allowCameraRotation: boolean;
  80108. /**
  80109. * Manage the mouse inputs to control the movement of a free camera.
  80110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80111. * @param touchEnabled Defines if touch is enabled or not
  80112. */
  80113. constructor(
  80114. /**
  80115. * Define if touch is enabled in the mouse input
  80116. */
  80117. touchEnabled?: boolean);
  80118. /**
  80119. * Attach the input controls to a specific dom element to get the input from.
  80120. * @param element Defines the element the controls should be listened from
  80121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80122. */
  80123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80124. /**
  80125. * Called on JS contextmenu event.
  80126. * Override this method to provide functionality.
  80127. */
  80128. protected onContextMenu(evt: PointerEvent): void;
  80129. /**
  80130. * Detach the current controls from the specified dom element.
  80131. * @param element Defines the element to stop listening the inputs from
  80132. */
  80133. detachControl(element: Nullable<HTMLElement>): void;
  80134. /**
  80135. * Gets the class name of the current intput.
  80136. * @returns the class name
  80137. */
  80138. getClassName(): string;
  80139. /**
  80140. * Get the friendly name associated with the input class.
  80141. * @returns the input friendly name
  80142. */
  80143. getSimpleName(): string;
  80144. }
  80145. }
  80146. declare module BABYLON {
  80147. /**
  80148. * Manage the touch inputs to control the movement of a free camera.
  80149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80150. */
  80151. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80152. /**
  80153. * Defines the camera the input is attached to.
  80154. */
  80155. camera: FreeCamera;
  80156. /**
  80157. * Defines the touch sensibility for rotation.
  80158. * The higher the faster.
  80159. */
  80160. touchAngularSensibility: number;
  80161. /**
  80162. * Defines the touch sensibility for move.
  80163. * The higher the faster.
  80164. */
  80165. touchMoveSensibility: number;
  80166. private _offsetX;
  80167. private _offsetY;
  80168. private _pointerPressed;
  80169. private _pointerInput;
  80170. private _observer;
  80171. private _onLostFocus;
  80172. /**
  80173. * Attach the input controls to a specific dom element to get the input from.
  80174. * @param element Defines the element the controls should be listened from
  80175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80176. */
  80177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80178. /**
  80179. * Detach the current controls from the specified dom element.
  80180. * @param element Defines the element to stop listening the inputs from
  80181. */
  80182. detachControl(element: Nullable<HTMLElement>): void;
  80183. /**
  80184. * Update the current camera state depending on the inputs that have been used this frame.
  80185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80186. */
  80187. checkInputs(): void;
  80188. /**
  80189. * Gets the class name of the current intput.
  80190. * @returns the class name
  80191. */
  80192. getClassName(): string;
  80193. /**
  80194. * Get the friendly name associated with the input class.
  80195. * @returns the input friendly name
  80196. */
  80197. getSimpleName(): string;
  80198. }
  80199. }
  80200. declare module BABYLON {
  80201. /**
  80202. * Default Inputs manager for the FreeCamera.
  80203. * It groups all the default supported inputs for ease of use.
  80204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80205. */
  80206. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80207. /**
  80208. * @hidden
  80209. */
  80210. _mouseInput: Nullable<FreeCameraMouseInput>;
  80211. /**
  80212. * Instantiates a new FreeCameraInputsManager.
  80213. * @param camera Defines the camera the inputs belong to
  80214. */
  80215. constructor(camera: FreeCamera);
  80216. /**
  80217. * Add keyboard input support to the input manager.
  80218. * @returns the current input manager
  80219. */
  80220. addKeyboard(): FreeCameraInputsManager;
  80221. /**
  80222. * Add mouse input support to the input manager.
  80223. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80224. * @returns the current input manager
  80225. */
  80226. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80227. /**
  80228. * Removes the mouse input support from the manager
  80229. * @returns the current input manager
  80230. */
  80231. removeMouse(): FreeCameraInputsManager;
  80232. /**
  80233. * Add touch input support to the input manager.
  80234. * @returns the current input manager
  80235. */
  80236. addTouch(): FreeCameraInputsManager;
  80237. /**
  80238. * Remove all attached input methods from a camera
  80239. */
  80240. clear(): void;
  80241. }
  80242. }
  80243. declare module BABYLON {
  80244. /**
  80245. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80246. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80247. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80248. */
  80249. export class FreeCamera extends TargetCamera {
  80250. /**
  80251. * Define the collision ellipsoid of the camera.
  80252. * This is helpful to simulate a camera body like the player body around the camera
  80253. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80254. */
  80255. ellipsoid: Vector3;
  80256. /**
  80257. * Define an offset for the position of the ellipsoid around the camera.
  80258. * This can be helpful to determine the center of the body near the gravity center of the body
  80259. * instead of its head.
  80260. */
  80261. ellipsoidOffset: Vector3;
  80262. /**
  80263. * Enable or disable collisions of the camera with the rest of the scene objects.
  80264. */
  80265. checkCollisions: boolean;
  80266. /**
  80267. * Enable or disable gravity on the camera.
  80268. */
  80269. applyGravity: boolean;
  80270. /**
  80271. * Define the input manager associated to the camera.
  80272. */
  80273. inputs: FreeCameraInputsManager;
  80274. /**
  80275. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80276. * Higher values reduce sensitivity.
  80277. */
  80278. /**
  80279. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80280. * Higher values reduce sensitivity.
  80281. */
  80282. angularSensibility: number;
  80283. /**
  80284. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80285. */
  80286. keysUp: number[];
  80287. /**
  80288. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80289. */
  80290. keysDown: number[];
  80291. /**
  80292. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80293. */
  80294. keysLeft: number[];
  80295. /**
  80296. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80297. */
  80298. keysRight: number[];
  80299. /**
  80300. * Event raised when the camera collide with a mesh in the scene.
  80301. */
  80302. onCollide: (collidedMesh: AbstractMesh) => void;
  80303. private _collider;
  80304. private _needMoveForGravity;
  80305. private _oldPosition;
  80306. private _diffPosition;
  80307. private _newPosition;
  80308. /** @hidden */
  80309. _localDirection: Vector3;
  80310. /** @hidden */
  80311. _transformedDirection: Vector3;
  80312. /**
  80313. * Instantiates a Free Camera.
  80314. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80315. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80316. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80317. * @param name Define the name of the camera in the scene
  80318. * @param position Define the start position of the camera in the scene
  80319. * @param scene Define the scene the camera belongs to
  80320. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80321. */
  80322. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80323. /**
  80324. * Attached controls to the current camera.
  80325. * @param element Defines the element the controls should be listened from
  80326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80327. */
  80328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80329. /**
  80330. * Detach the current controls from the camera.
  80331. * The camera will stop reacting to inputs.
  80332. * @param element Defines the element to stop listening the inputs from
  80333. */
  80334. detachControl(element: HTMLElement): void;
  80335. private _collisionMask;
  80336. /**
  80337. * Define a collision mask to limit the list of object the camera can collide with
  80338. */
  80339. collisionMask: number;
  80340. /** @hidden */
  80341. _collideWithWorld(displacement: Vector3): void;
  80342. private _onCollisionPositionChange;
  80343. /** @hidden */
  80344. _checkInputs(): void;
  80345. /** @hidden */
  80346. _decideIfNeedsToMove(): boolean;
  80347. /** @hidden */
  80348. _updatePosition(): void;
  80349. /**
  80350. * Destroy the camera and release the current resources hold by it.
  80351. */
  80352. dispose(): void;
  80353. /**
  80354. * Gets the current object class name.
  80355. * @return the class name
  80356. */
  80357. getClassName(): string;
  80358. }
  80359. }
  80360. declare module BABYLON {
  80361. /**
  80362. * Represents a gamepad control stick position
  80363. */
  80364. export class StickValues {
  80365. /**
  80366. * The x component of the control stick
  80367. */
  80368. x: number;
  80369. /**
  80370. * The y component of the control stick
  80371. */
  80372. y: number;
  80373. /**
  80374. * Initializes the gamepad x and y control stick values
  80375. * @param x The x component of the gamepad control stick value
  80376. * @param y The y component of the gamepad control stick value
  80377. */
  80378. constructor(
  80379. /**
  80380. * The x component of the control stick
  80381. */
  80382. x: number,
  80383. /**
  80384. * The y component of the control stick
  80385. */
  80386. y: number);
  80387. }
  80388. /**
  80389. * An interface which manages callbacks for gamepad button changes
  80390. */
  80391. export interface GamepadButtonChanges {
  80392. /**
  80393. * Called when a gamepad has been changed
  80394. */
  80395. changed: boolean;
  80396. /**
  80397. * Called when a gamepad press event has been triggered
  80398. */
  80399. pressChanged: boolean;
  80400. /**
  80401. * Called when a touch event has been triggered
  80402. */
  80403. touchChanged: boolean;
  80404. /**
  80405. * Called when a value has changed
  80406. */
  80407. valueChanged: boolean;
  80408. }
  80409. /**
  80410. * Represents a gamepad
  80411. */
  80412. export class Gamepad {
  80413. /**
  80414. * The id of the gamepad
  80415. */
  80416. id: string;
  80417. /**
  80418. * The index of the gamepad
  80419. */
  80420. index: number;
  80421. /**
  80422. * The browser gamepad
  80423. */
  80424. browserGamepad: any;
  80425. /**
  80426. * Specifies what type of gamepad this represents
  80427. */
  80428. type: number;
  80429. private _leftStick;
  80430. private _rightStick;
  80431. /** @hidden */
  80432. _isConnected: boolean;
  80433. private _leftStickAxisX;
  80434. private _leftStickAxisY;
  80435. private _rightStickAxisX;
  80436. private _rightStickAxisY;
  80437. /**
  80438. * Triggered when the left control stick has been changed
  80439. */
  80440. private _onleftstickchanged;
  80441. /**
  80442. * Triggered when the right control stick has been changed
  80443. */
  80444. private _onrightstickchanged;
  80445. /**
  80446. * Represents a gamepad controller
  80447. */
  80448. static GAMEPAD: number;
  80449. /**
  80450. * Represents a generic controller
  80451. */
  80452. static GENERIC: number;
  80453. /**
  80454. * Represents an XBox controller
  80455. */
  80456. static XBOX: number;
  80457. /**
  80458. * Represents a pose-enabled controller
  80459. */
  80460. static POSE_ENABLED: number;
  80461. /**
  80462. * Represents an Dual Shock controller
  80463. */
  80464. static DUALSHOCK: number;
  80465. /**
  80466. * Specifies whether the left control stick should be Y-inverted
  80467. */
  80468. protected _invertLeftStickY: boolean;
  80469. /**
  80470. * Specifies if the gamepad has been connected
  80471. */
  80472. readonly isConnected: boolean;
  80473. /**
  80474. * Initializes the gamepad
  80475. * @param id The id of the gamepad
  80476. * @param index The index of the gamepad
  80477. * @param browserGamepad The browser gamepad
  80478. * @param leftStickX The x component of the left joystick
  80479. * @param leftStickY The y component of the left joystick
  80480. * @param rightStickX The x component of the right joystick
  80481. * @param rightStickY The y component of the right joystick
  80482. */
  80483. constructor(
  80484. /**
  80485. * The id of the gamepad
  80486. */
  80487. id: string,
  80488. /**
  80489. * The index of the gamepad
  80490. */
  80491. index: number,
  80492. /**
  80493. * The browser gamepad
  80494. */
  80495. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80496. /**
  80497. * Callback triggered when the left joystick has changed
  80498. * @param callback
  80499. */
  80500. onleftstickchanged(callback: (values: StickValues) => void): void;
  80501. /**
  80502. * Callback triggered when the right joystick has changed
  80503. * @param callback
  80504. */
  80505. onrightstickchanged(callback: (values: StickValues) => void): void;
  80506. /**
  80507. * Gets the left joystick
  80508. */
  80509. /**
  80510. * Sets the left joystick values
  80511. */
  80512. leftStick: StickValues;
  80513. /**
  80514. * Gets the right joystick
  80515. */
  80516. /**
  80517. * Sets the right joystick value
  80518. */
  80519. rightStick: StickValues;
  80520. /**
  80521. * Updates the gamepad joystick positions
  80522. */
  80523. update(): void;
  80524. /**
  80525. * Disposes the gamepad
  80526. */
  80527. dispose(): void;
  80528. }
  80529. /**
  80530. * Represents a generic gamepad
  80531. */
  80532. export class GenericPad extends Gamepad {
  80533. private _buttons;
  80534. private _onbuttondown;
  80535. private _onbuttonup;
  80536. /**
  80537. * Observable triggered when a button has been pressed
  80538. */
  80539. onButtonDownObservable: Observable<number>;
  80540. /**
  80541. * Observable triggered when a button has been released
  80542. */
  80543. onButtonUpObservable: Observable<number>;
  80544. /**
  80545. * Callback triggered when a button has been pressed
  80546. * @param callback Called when a button has been pressed
  80547. */
  80548. onbuttondown(callback: (buttonPressed: number) => void): void;
  80549. /**
  80550. * Callback triggered when a button has been released
  80551. * @param callback Called when a button has been released
  80552. */
  80553. onbuttonup(callback: (buttonReleased: number) => void): void;
  80554. /**
  80555. * Initializes the generic gamepad
  80556. * @param id The id of the generic gamepad
  80557. * @param index The index of the generic gamepad
  80558. * @param browserGamepad The browser gamepad
  80559. */
  80560. constructor(id: string, index: number, browserGamepad: any);
  80561. private _setButtonValue;
  80562. /**
  80563. * Updates the generic gamepad
  80564. */
  80565. update(): void;
  80566. /**
  80567. * Disposes the generic gamepad
  80568. */
  80569. dispose(): void;
  80570. }
  80571. }
  80572. declare module BABYLON {
  80573. interface Engine {
  80574. /**
  80575. * Creates a raw texture
  80576. * @param data defines the data to store in the texture
  80577. * @param width defines the width of the texture
  80578. * @param height defines the height of the texture
  80579. * @param format defines the format of the data
  80580. * @param generateMipMaps defines if the engine should generate the mip levels
  80581. * @param invertY defines if data must be stored with Y axis inverted
  80582. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80583. * @param compression defines the compression used (null by default)
  80584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80585. * @returns the raw texture inside an InternalTexture
  80586. */
  80587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80588. /**
  80589. * Update a raw texture
  80590. * @param texture defines the texture to update
  80591. * @param data defines the data to store in the texture
  80592. * @param format defines the format of the data
  80593. * @param invertY defines if data must be stored with Y axis inverted
  80594. */
  80595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80596. /**
  80597. * Update a raw texture
  80598. * @param texture defines the texture to update
  80599. * @param data defines the data to store in the texture
  80600. * @param format defines the format of the data
  80601. * @param invertY defines if data must be stored with Y axis inverted
  80602. * @param compression defines the compression used (null by default)
  80603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80604. */
  80605. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80606. /**
  80607. * Creates a new raw cube texture
  80608. * @param data defines the array of data to use to create each face
  80609. * @param size defines the size of the textures
  80610. * @param format defines the format of the data
  80611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80612. * @param generateMipMaps defines if the engine should generate the mip levels
  80613. * @param invertY defines if data must be stored with Y axis inverted
  80614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80615. * @param compression defines the compression used (null by default)
  80616. * @returns the cube texture as an InternalTexture
  80617. */
  80618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80619. /**
  80620. * Update a raw cube texture
  80621. * @param texture defines the texture to udpdate
  80622. * @param data defines the data to store
  80623. * @param format defines the data format
  80624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80625. * @param invertY defines if data must be stored with Y axis inverted
  80626. */
  80627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80628. /**
  80629. * Update a raw cube texture
  80630. * @param texture defines the texture to udpdate
  80631. * @param data defines the data to store
  80632. * @param format defines the data format
  80633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80634. * @param invertY defines if data must be stored with Y axis inverted
  80635. * @param compression defines the compression used (null by default)
  80636. */
  80637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80638. /**
  80639. * Update a raw cube texture
  80640. * @param texture defines the texture to udpdate
  80641. * @param data defines the data to store
  80642. * @param format defines the data format
  80643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80644. * @param invertY defines if data must be stored with Y axis inverted
  80645. * @param compression defines the compression used (null by default)
  80646. * @param level defines which level of the texture to update
  80647. */
  80648. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80649. /**
  80650. * Creates a new raw cube texture from a specified url
  80651. * @param url defines the url where the data is located
  80652. * @param scene defines the current scene
  80653. * @param size defines the size of the textures
  80654. * @param format defines the format of the data
  80655. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80656. * @param noMipmap defines if the engine should avoid generating the mip levels
  80657. * @param callback defines a callback used to extract texture data from loaded data
  80658. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80659. * @param onLoad defines a callback called when texture is loaded
  80660. * @param onError defines a callback called if there is an error
  80661. * @returns the cube texture as an InternalTexture
  80662. */
  80663. 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;
  80664. /**
  80665. * Creates a new raw cube texture from a specified url
  80666. * @param url defines the url where the data is located
  80667. * @param scene defines the current scene
  80668. * @param size defines the size of the textures
  80669. * @param format defines the format of the data
  80670. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80671. * @param noMipmap defines if the engine should avoid generating the mip levels
  80672. * @param callback defines a callback used to extract texture data from loaded data
  80673. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80674. * @param onLoad defines a callback called when texture is loaded
  80675. * @param onError defines a callback called if there is an error
  80676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80677. * @param invertY defines if data must be stored with Y axis inverted
  80678. * @returns the cube texture as an InternalTexture
  80679. */
  80680. 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;
  80681. /**
  80682. * Creates a new raw 3D texture
  80683. * @param data defines the data used to create the texture
  80684. * @param width defines the width of the texture
  80685. * @param height defines the height of the texture
  80686. * @param depth defines the depth of the texture
  80687. * @param format defines the format of the texture
  80688. * @param generateMipMaps defines if the engine must generate mip levels
  80689. * @param invertY defines if data must be stored with Y axis inverted
  80690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80691. * @param compression defines the compressed used (can be null)
  80692. * @param textureType defines the compressed used (can be null)
  80693. * @returns a new raw 3D texture (stored in an InternalTexture)
  80694. */
  80695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80696. /**
  80697. * Update a raw 3D texture
  80698. * @param texture defines the texture to update
  80699. * @param data defines the data to store
  80700. * @param format defines the data format
  80701. * @param invertY defines if data must be stored with Y axis inverted
  80702. */
  80703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80704. /**
  80705. * Update a raw 3D texture
  80706. * @param texture defines the texture to update
  80707. * @param data defines the data to store
  80708. * @param format defines the data format
  80709. * @param invertY defines if data must be stored with Y axis inverted
  80710. * @param compression defines the used compression (can be null)
  80711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80712. */
  80713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80714. /**
  80715. * Creates a new raw 2D array texture
  80716. * @param data defines the data used to create the texture
  80717. * @param width defines the width of the texture
  80718. * @param height defines the height of the texture
  80719. * @param depth defines the number of layers of the texture
  80720. * @param format defines the format of the texture
  80721. * @param generateMipMaps defines if the engine must generate mip levels
  80722. * @param invertY defines if data must be stored with Y axis inverted
  80723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80724. * @param compression defines the compressed used (can be null)
  80725. * @param textureType defines the compressed used (can be null)
  80726. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80727. */
  80728. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80729. /**
  80730. * Update a raw 2D array texture
  80731. * @param texture defines the texture to update
  80732. * @param data defines the data to store
  80733. * @param format defines the data format
  80734. * @param invertY defines if data must be stored with Y axis inverted
  80735. */
  80736. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80737. /**
  80738. * Update a raw 2D array texture
  80739. * @param texture defines the texture to update
  80740. * @param data defines the data to store
  80741. * @param format defines the data format
  80742. * @param invertY defines if data must be stored with Y axis inverted
  80743. * @param compression defines the used compression (can be null)
  80744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80745. */
  80746. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80747. }
  80748. }
  80749. declare module BABYLON {
  80750. /**
  80751. * Raw texture can help creating a texture directly from an array of data.
  80752. * This can be super useful if you either get the data from an uncompressed source or
  80753. * if you wish to create your texture pixel by pixel.
  80754. */
  80755. export class RawTexture extends Texture {
  80756. /**
  80757. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80758. */
  80759. format: number;
  80760. private _engine;
  80761. /**
  80762. * Instantiates a new RawTexture.
  80763. * Raw texture can help creating a texture directly from an array of data.
  80764. * This can be super useful if you either get the data from an uncompressed source or
  80765. * if you wish to create your texture pixel by pixel.
  80766. * @param data define the array of data to use to create the texture
  80767. * @param width define the width of the texture
  80768. * @param height define the height of the texture
  80769. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80770. * @param scene define the scene the texture belongs to
  80771. * @param generateMipMaps define whether mip maps should be generated or not
  80772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80774. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80775. */
  80776. constructor(data: ArrayBufferView, width: number, height: number,
  80777. /**
  80778. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80779. */
  80780. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80781. /**
  80782. * Updates the texture underlying data.
  80783. * @param data Define the new data of the texture
  80784. */
  80785. update(data: ArrayBufferView): void;
  80786. /**
  80787. * Creates a luminance texture from some data.
  80788. * @param data Define the texture data
  80789. * @param width Define the width of the texture
  80790. * @param height Define the height of the texture
  80791. * @param scene Define the scene the texture belongs to
  80792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80795. * @returns the luminance texture
  80796. */
  80797. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80798. /**
  80799. * Creates a luminance alpha texture from some data.
  80800. * @param data Define the texture data
  80801. * @param width Define the width of the texture
  80802. * @param height Define the height of the texture
  80803. * @param scene Define the scene the texture belongs to
  80804. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80807. * @returns the luminance alpha texture
  80808. */
  80809. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80810. /**
  80811. * Creates an alpha texture from some data.
  80812. * @param data Define the texture data
  80813. * @param width Define the width of the texture
  80814. * @param height Define the height of the texture
  80815. * @param scene Define the scene the texture belongs to
  80816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80819. * @returns the alpha texture
  80820. */
  80821. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80822. /**
  80823. * Creates a RGB texture from some data.
  80824. * @param data Define the texture data
  80825. * @param width Define the width of the texture
  80826. * @param height Define the height of the texture
  80827. * @param scene Define the scene the texture belongs to
  80828. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80829. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80830. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80831. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80832. * @returns the RGB alpha texture
  80833. */
  80834. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80835. /**
  80836. * Creates a RGBA texture from some data.
  80837. * @param data Define the texture data
  80838. * @param width Define the width of the texture
  80839. * @param height Define the height of the texture
  80840. * @param scene Define the scene the texture belongs to
  80841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80844. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80845. * @returns the RGBA texture
  80846. */
  80847. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80848. /**
  80849. * Creates a R texture from some data.
  80850. * @param data Define the texture data
  80851. * @param width Define the width of the texture
  80852. * @param height Define the height of the texture
  80853. * @param scene Define the scene the texture belongs to
  80854. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80858. * @returns the R texture
  80859. */
  80860. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80861. }
  80862. }
  80863. declare module BABYLON {
  80864. /**
  80865. * Interface for the size containing width and height
  80866. */
  80867. export interface ISize {
  80868. /**
  80869. * Width
  80870. */
  80871. width: number;
  80872. /**
  80873. * Heighht
  80874. */
  80875. height: number;
  80876. }
  80877. /**
  80878. * Size containing widht and height
  80879. */
  80880. export class Size implements ISize {
  80881. /**
  80882. * Width
  80883. */
  80884. width: number;
  80885. /**
  80886. * Height
  80887. */
  80888. height: number;
  80889. /**
  80890. * Creates a Size object from the given width and height (floats).
  80891. * @param width width of the new size
  80892. * @param height height of the new size
  80893. */
  80894. constructor(width: number, height: number);
  80895. /**
  80896. * Returns a string with the Size width and height
  80897. * @returns a string with the Size width and height
  80898. */
  80899. toString(): string;
  80900. /**
  80901. * "Size"
  80902. * @returns the string "Size"
  80903. */
  80904. getClassName(): string;
  80905. /**
  80906. * Returns the Size hash code.
  80907. * @returns a hash code for a unique width and height
  80908. */
  80909. getHashCode(): number;
  80910. /**
  80911. * Updates the current size from the given one.
  80912. * @param src the given size
  80913. */
  80914. copyFrom(src: Size): void;
  80915. /**
  80916. * Updates in place the current Size from the given floats.
  80917. * @param width width of the new size
  80918. * @param height height of the new size
  80919. * @returns the updated Size.
  80920. */
  80921. copyFromFloats(width: number, height: number): Size;
  80922. /**
  80923. * Updates in place the current Size from the given floats.
  80924. * @param width width to set
  80925. * @param height height to set
  80926. * @returns the updated Size.
  80927. */
  80928. set(width: number, height: number): Size;
  80929. /**
  80930. * Multiplies the width and height by numbers
  80931. * @param w factor to multiple the width by
  80932. * @param h factor to multiple the height by
  80933. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80934. */
  80935. multiplyByFloats(w: number, h: number): Size;
  80936. /**
  80937. * Clones the size
  80938. * @returns a new Size copied from the given one.
  80939. */
  80940. clone(): Size;
  80941. /**
  80942. * True if the current Size and the given one width and height are strictly equal.
  80943. * @param other the other size to compare against
  80944. * @returns True if the current Size and the given one width and height are strictly equal.
  80945. */
  80946. equals(other: Size): boolean;
  80947. /**
  80948. * The surface of the Size : width * height (float).
  80949. */
  80950. readonly surface: number;
  80951. /**
  80952. * Create a new size of zero
  80953. * @returns a new Size set to (0.0, 0.0)
  80954. */
  80955. static Zero(): Size;
  80956. /**
  80957. * Sums the width and height of two sizes
  80958. * @param otherSize size to add to this size
  80959. * @returns a new Size set as the addition result of the current Size and the given one.
  80960. */
  80961. add(otherSize: Size): Size;
  80962. /**
  80963. * Subtracts the width and height of two
  80964. * @param otherSize size to subtract to this size
  80965. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80966. */
  80967. subtract(otherSize: Size): Size;
  80968. /**
  80969. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80970. * @param start starting size to lerp between
  80971. * @param end end size to lerp between
  80972. * @param amount amount to lerp between the start and end values
  80973. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80974. */
  80975. static Lerp(start: Size, end: Size, amount: number): Size;
  80976. }
  80977. }
  80978. declare module BABYLON {
  80979. /**
  80980. * Defines a runtime animation
  80981. */
  80982. export class RuntimeAnimation {
  80983. private _events;
  80984. /**
  80985. * The current frame of the runtime animation
  80986. */
  80987. private _currentFrame;
  80988. /**
  80989. * The animation used by the runtime animation
  80990. */
  80991. private _animation;
  80992. /**
  80993. * The target of the runtime animation
  80994. */
  80995. private _target;
  80996. /**
  80997. * The initiating animatable
  80998. */
  80999. private _host;
  81000. /**
  81001. * The original value of the runtime animation
  81002. */
  81003. private _originalValue;
  81004. /**
  81005. * The original blend value of the runtime animation
  81006. */
  81007. private _originalBlendValue;
  81008. /**
  81009. * The offsets cache of the runtime animation
  81010. */
  81011. private _offsetsCache;
  81012. /**
  81013. * The high limits cache of the runtime animation
  81014. */
  81015. private _highLimitsCache;
  81016. /**
  81017. * Specifies if the runtime animation has been stopped
  81018. */
  81019. private _stopped;
  81020. /**
  81021. * The blending factor of the runtime animation
  81022. */
  81023. private _blendingFactor;
  81024. /**
  81025. * The BabylonJS scene
  81026. */
  81027. private _scene;
  81028. /**
  81029. * The current value of the runtime animation
  81030. */
  81031. private _currentValue;
  81032. /** @hidden */
  81033. _animationState: _IAnimationState;
  81034. /**
  81035. * The active target of the runtime animation
  81036. */
  81037. private _activeTargets;
  81038. private _currentActiveTarget;
  81039. private _directTarget;
  81040. /**
  81041. * The target path of the runtime animation
  81042. */
  81043. private _targetPath;
  81044. /**
  81045. * The weight of the runtime animation
  81046. */
  81047. private _weight;
  81048. /**
  81049. * The ratio offset of the runtime animation
  81050. */
  81051. private _ratioOffset;
  81052. /**
  81053. * The previous delay of the runtime animation
  81054. */
  81055. private _previousDelay;
  81056. /**
  81057. * The previous ratio of the runtime animation
  81058. */
  81059. private _previousRatio;
  81060. private _enableBlending;
  81061. private _keys;
  81062. private _minFrame;
  81063. private _maxFrame;
  81064. private _minValue;
  81065. private _maxValue;
  81066. private _targetIsArray;
  81067. /**
  81068. * Gets the current frame of the runtime animation
  81069. */
  81070. readonly currentFrame: number;
  81071. /**
  81072. * Gets the weight of the runtime animation
  81073. */
  81074. readonly weight: number;
  81075. /**
  81076. * Gets the current value of the runtime animation
  81077. */
  81078. readonly currentValue: any;
  81079. /**
  81080. * Gets the target path of the runtime animation
  81081. */
  81082. readonly targetPath: string;
  81083. /**
  81084. * Gets the actual target of the runtime animation
  81085. */
  81086. readonly target: any;
  81087. /** @hidden */
  81088. _onLoop: () => void;
  81089. /**
  81090. * Create a new RuntimeAnimation object
  81091. * @param target defines the target of the animation
  81092. * @param animation defines the source animation object
  81093. * @param scene defines the hosting scene
  81094. * @param host defines the initiating Animatable
  81095. */
  81096. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81097. private _preparePath;
  81098. /**
  81099. * Gets the animation from the runtime animation
  81100. */
  81101. readonly animation: Animation;
  81102. /**
  81103. * Resets the runtime animation to the beginning
  81104. * @param restoreOriginal defines whether to restore the target property to the original value
  81105. */
  81106. reset(restoreOriginal?: boolean): void;
  81107. /**
  81108. * Specifies if the runtime animation is stopped
  81109. * @returns Boolean specifying if the runtime animation is stopped
  81110. */
  81111. isStopped(): boolean;
  81112. /**
  81113. * Disposes of the runtime animation
  81114. */
  81115. dispose(): void;
  81116. /**
  81117. * Apply the interpolated value to the target
  81118. * @param currentValue defines the value computed by the animation
  81119. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81120. */
  81121. setValue(currentValue: any, weight: number): void;
  81122. private _getOriginalValues;
  81123. private _setValue;
  81124. /**
  81125. * Gets the loop pmode of the runtime animation
  81126. * @returns Loop Mode
  81127. */
  81128. private _getCorrectLoopMode;
  81129. /**
  81130. * Move the current animation to a given frame
  81131. * @param frame defines the frame to move to
  81132. */
  81133. goToFrame(frame: number): void;
  81134. /**
  81135. * @hidden Internal use only
  81136. */
  81137. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81138. /**
  81139. * Execute the current animation
  81140. * @param delay defines the delay to add to the current frame
  81141. * @param from defines the lower bound of the animation range
  81142. * @param to defines the upper bound of the animation range
  81143. * @param loop defines if the current animation must loop
  81144. * @param speedRatio defines the current speed ratio
  81145. * @param weight defines the weight of the animation (default is -1 so no weight)
  81146. * @param onLoop optional callback called when animation loops
  81147. * @returns a boolean indicating if the animation is running
  81148. */
  81149. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81150. }
  81151. }
  81152. declare module BABYLON {
  81153. /**
  81154. * Class used to store an actual running animation
  81155. */
  81156. export class Animatable {
  81157. /** defines the target object */
  81158. target: any;
  81159. /** defines the starting frame number (default is 0) */
  81160. fromFrame: number;
  81161. /** defines the ending frame number (default is 100) */
  81162. toFrame: number;
  81163. /** defines if the animation must loop (default is false) */
  81164. loopAnimation: boolean;
  81165. /** defines a callback to call when animation ends if it is not looping */
  81166. onAnimationEnd?: (() => void) | null | undefined;
  81167. /** defines a callback to call when animation loops */
  81168. onAnimationLoop?: (() => void) | null | undefined;
  81169. private _localDelayOffset;
  81170. private _pausedDelay;
  81171. private _runtimeAnimations;
  81172. private _paused;
  81173. private _scene;
  81174. private _speedRatio;
  81175. private _weight;
  81176. private _syncRoot;
  81177. /**
  81178. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81179. * This will only apply for non looping animation (default is true)
  81180. */
  81181. disposeOnEnd: boolean;
  81182. /**
  81183. * Gets a boolean indicating if the animation has started
  81184. */
  81185. animationStarted: boolean;
  81186. /**
  81187. * Observer raised when the animation ends
  81188. */
  81189. onAnimationEndObservable: Observable<Animatable>;
  81190. /**
  81191. * Observer raised when the animation loops
  81192. */
  81193. onAnimationLoopObservable: Observable<Animatable>;
  81194. /**
  81195. * Gets the root Animatable used to synchronize and normalize animations
  81196. */
  81197. readonly syncRoot: Nullable<Animatable>;
  81198. /**
  81199. * Gets the current frame of the first RuntimeAnimation
  81200. * Used to synchronize Animatables
  81201. */
  81202. readonly masterFrame: number;
  81203. /**
  81204. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81205. */
  81206. weight: number;
  81207. /**
  81208. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81209. */
  81210. speedRatio: number;
  81211. /**
  81212. * Creates a new Animatable
  81213. * @param scene defines the hosting scene
  81214. * @param target defines the target object
  81215. * @param fromFrame defines the starting frame number (default is 0)
  81216. * @param toFrame defines the ending frame number (default is 100)
  81217. * @param loopAnimation defines if the animation must loop (default is false)
  81218. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81219. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81220. * @param animations defines a group of animation to add to the new Animatable
  81221. * @param onAnimationLoop defines a callback to call when animation loops
  81222. */
  81223. constructor(scene: Scene,
  81224. /** defines the target object */
  81225. target: any,
  81226. /** defines the starting frame number (default is 0) */
  81227. fromFrame?: number,
  81228. /** defines the ending frame number (default is 100) */
  81229. toFrame?: number,
  81230. /** defines if the animation must loop (default is false) */
  81231. loopAnimation?: boolean, speedRatio?: number,
  81232. /** defines a callback to call when animation ends if it is not looping */
  81233. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81234. /** defines a callback to call when animation loops */
  81235. onAnimationLoop?: (() => void) | null | undefined);
  81236. /**
  81237. * Synchronize and normalize current Animatable with a source Animatable
  81238. * This is useful when using animation weights and when animations are not of the same length
  81239. * @param root defines the root Animatable to synchronize with
  81240. * @returns the current Animatable
  81241. */
  81242. syncWith(root: Animatable): Animatable;
  81243. /**
  81244. * Gets the list of runtime animations
  81245. * @returns an array of RuntimeAnimation
  81246. */
  81247. getAnimations(): RuntimeAnimation[];
  81248. /**
  81249. * Adds more animations to the current animatable
  81250. * @param target defines the target of the animations
  81251. * @param animations defines the new animations to add
  81252. */
  81253. appendAnimations(target: any, animations: Animation[]): void;
  81254. /**
  81255. * Gets the source animation for a specific property
  81256. * @param property defines the propertyu to look for
  81257. * @returns null or the source animation for the given property
  81258. */
  81259. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81260. /**
  81261. * Gets the runtime animation for a specific property
  81262. * @param property defines the propertyu to look for
  81263. * @returns null or the runtime animation for the given property
  81264. */
  81265. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81266. /**
  81267. * Resets the animatable to its original state
  81268. */
  81269. reset(): void;
  81270. /**
  81271. * Allows the animatable to blend with current running animations
  81272. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81273. * @param blendingSpeed defines the blending speed to use
  81274. */
  81275. enableBlending(blendingSpeed: number): void;
  81276. /**
  81277. * Disable animation blending
  81278. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81279. */
  81280. disableBlending(): void;
  81281. /**
  81282. * Jump directly to a given frame
  81283. * @param frame defines the frame to jump to
  81284. */
  81285. goToFrame(frame: number): void;
  81286. /**
  81287. * Pause the animation
  81288. */
  81289. pause(): void;
  81290. /**
  81291. * Restart the animation
  81292. */
  81293. restart(): void;
  81294. private _raiseOnAnimationEnd;
  81295. /**
  81296. * Stop and delete the current animation
  81297. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81298. * @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)
  81299. */
  81300. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81301. /**
  81302. * Wait asynchronously for the animation to end
  81303. * @returns a promise which will be fullfilled when the animation ends
  81304. */
  81305. waitAsync(): Promise<Animatable>;
  81306. /** @hidden */
  81307. _animate(delay: number): boolean;
  81308. }
  81309. interface Scene {
  81310. /** @hidden */
  81311. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81312. /** @hidden */
  81313. _processLateAnimationBindingsForMatrices(holder: {
  81314. totalWeight: number;
  81315. animations: RuntimeAnimation[];
  81316. originalValue: Matrix;
  81317. }): any;
  81318. /** @hidden */
  81319. _processLateAnimationBindingsForQuaternions(holder: {
  81320. totalWeight: number;
  81321. animations: RuntimeAnimation[];
  81322. originalValue: Quaternion;
  81323. }, refQuaternion: Quaternion): Quaternion;
  81324. /** @hidden */
  81325. _processLateAnimationBindings(): void;
  81326. /**
  81327. * Will start the animation sequence of a given target
  81328. * @param target defines the target
  81329. * @param from defines from which frame should animation start
  81330. * @param to defines until which frame should animation run.
  81331. * @param weight defines the weight to apply to the animation (1.0 by default)
  81332. * @param loop defines if the animation loops
  81333. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81334. * @param onAnimationEnd defines the function to be executed when the animation ends
  81335. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81336. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81337. * @param onAnimationLoop defines the callback to call when an animation loops
  81338. * @returns the animatable object created for this animation
  81339. */
  81340. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81341. /**
  81342. * Will start the animation sequence of a given target
  81343. * @param target defines the target
  81344. * @param from defines from which frame should animation start
  81345. * @param to defines until which frame should animation run.
  81346. * @param loop defines if the animation loops
  81347. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81348. * @param onAnimationEnd defines the function to be executed when the animation ends
  81349. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81350. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81351. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81352. * @param onAnimationLoop defines the callback to call when an animation loops
  81353. * @returns the animatable object created for this animation
  81354. */
  81355. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81356. /**
  81357. * Will start the animation sequence of a given target and its hierarchy
  81358. * @param target defines the target
  81359. * @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.
  81360. * @param from defines from which frame should animation start
  81361. * @param to defines until which frame should animation run.
  81362. * @param loop defines if the animation loops
  81363. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81364. * @param onAnimationEnd defines the function to be executed when the animation ends
  81365. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81366. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81367. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81368. * @param onAnimationLoop defines the callback to call when an animation loops
  81369. * @returns the list of created animatables
  81370. */
  81371. 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[];
  81372. /**
  81373. * Begin a new animation on a given node
  81374. * @param target defines the target where the animation will take place
  81375. * @param animations defines the list of animations to start
  81376. * @param from defines the initial value
  81377. * @param to defines the final value
  81378. * @param loop defines if you want animation to loop (off by default)
  81379. * @param speedRatio defines the speed ratio to apply to all animations
  81380. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81381. * @param onAnimationLoop defines the callback to call when an animation loops
  81382. * @returns the list of created animatables
  81383. */
  81384. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81385. /**
  81386. * Begin a new animation on a given node and its hierarchy
  81387. * @param target defines the root node where the animation will take place
  81388. * @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.
  81389. * @param animations defines the list of animations to start
  81390. * @param from defines the initial value
  81391. * @param to defines the final value
  81392. * @param loop defines if you want animation to loop (off by default)
  81393. * @param speedRatio defines the speed ratio to apply to all animations
  81394. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81395. * @param onAnimationLoop defines the callback to call when an animation loops
  81396. * @returns the list of animatables created for all nodes
  81397. */
  81398. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81399. /**
  81400. * Gets the animatable associated with a specific target
  81401. * @param target defines the target of the animatable
  81402. * @returns the required animatable if found
  81403. */
  81404. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81405. /**
  81406. * Gets all animatables associated with a given target
  81407. * @param target defines the target to look animatables for
  81408. * @returns an array of Animatables
  81409. */
  81410. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81411. /**
  81412. * Stops and removes all animations that have been applied to the scene
  81413. */
  81414. stopAllAnimations(): void;
  81415. /**
  81416. * Gets the current delta time used by animation engine
  81417. */
  81418. deltaTime: number;
  81419. }
  81420. interface Bone {
  81421. /**
  81422. * Copy an animation range from another bone
  81423. * @param source defines the source bone
  81424. * @param rangeName defines the range name to copy
  81425. * @param frameOffset defines the frame offset
  81426. * @param rescaleAsRequired defines if rescaling must be applied if required
  81427. * @param skelDimensionsRatio defines the scaling ratio
  81428. * @returns true if operation was successful
  81429. */
  81430. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81431. }
  81432. }
  81433. declare module BABYLON {
  81434. /**
  81435. * Class used to override all child animations of a given target
  81436. */
  81437. export class AnimationPropertiesOverride {
  81438. /**
  81439. * Gets or sets a value indicating if animation blending must be used
  81440. */
  81441. enableBlending: boolean;
  81442. /**
  81443. * Gets or sets the blending speed to use when enableBlending is true
  81444. */
  81445. blendingSpeed: number;
  81446. /**
  81447. * Gets or sets the default loop mode to use
  81448. */
  81449. loopMode: number;
  81450. }
  81451. }
  81452. declare module BABYLON {
  81453. /**
  81454. * Class used to handle skinning animations
  81455. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81456. */
  81457. export class Skeleton implements IAnimatable {
  81458. /** defines the skeleton name */
  81459. name: string;
  81460. /** defines the skeleton Id */
  81461. id: string;
  81462. /**
  81463. * Defines the list of child bones
  81464. */
  81465. bones: Bone[];
  81466. /**
  81467. * Defines an estimate of the dimension of the skeleton at rest
  81468. */
  81469. dimensionsAtRest: Vector3;
  81470. /**
  81471. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81472. */
  81473. needInitialSkinMatrix: boolean;
  81474. /**
  81475. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81476. */
  81477. overrideMesh: Nullable<AbstractMesh>;
  81478. /**
  81479. * Gets the list of animations attached to this skeleton
  81480. */
  81481. animations: Array<Animation>;
  81482. private _scene;
  81483. private _isDirty;
  81484. private _transformMatrices;
  81485. private _transformMatrixTexture;
  81486. private _meshesWithPoseMatrix;
  81487. private _animatables;
  81488. private _identity;
  81489. private _synchronizedWithMesh;
  81490. private _ranges;
  81491. private _lastAbsoluteTransformsUpdateId;
  81492. private _canUseTextureForBones;
  81493. private _uniqueId;
  81494. /** @hidden */
  81495. _numBonesWithLinkedTransformNode: number;
  81496. /** @hidden */
  81497. _hasWaitingData: Nullable<boolean>;
  81498. /**
  81499. * Specifies if the skeleton should be serialized
  81500. */
  81501. doNotSerialize: boolean;
  81502. private _useTextureToStoreBoneMatrices;
  81503. /**
  81504. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81505. * Please note that this option is not available if the hardware does not support it
  81506. */
  81507. useTextureToStoreBoneMatrices: boolean;
  81508. private _animationPropertiesOverride;
  81509. /**
  81510. * Gets or sets the animation properties override
  81511. */
  81512. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81513. /**
  81514. * List of inspectable custom properties (used by the Inspector)
  81515. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81516. */
  81517. inspectableCustomProperties: IInspectable[];
  81518. /**
  81519. * An observable triggered before computing the skeleton's matrices
  81520. */
  81521. onBeforeComputeObservable: Observable<Skeleton>;
  81522. /**
  81523. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81524. */
  81525. readonly isUsingTextureForMatrices: boolean;
  81526. /**
  81527. * Gets the unique ID of this skeleton
  81528. */
  81529. readonly uniqueId: number;
  81530. /**
  81531. * Creates a new skeleton
  81532. * @param name defines the skeleton name
  81533. * @param id defines the skeleton Id
  81534. * @param scene defines the hosting scene
  81535. */
  81536. constructor(
  81537. /** defines the skeleton name */
  81538. name: string,
  81539. /** defines the skeleton Id */
  81540. id: string, scene: Scene);
  81541. /**
  81542. * Gets the current object class name.
  81543. * @return the class name
  81544. */
  81545. getClassName(): string;
  81546. /**
  81547. * Returns an array containing the root bones
  81548. * @returns an array containing the root bones
  81549. */
  81550. getChildren(): Array<Bone>;
  81551. /**
  81552. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81553. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81554. * @returns a Float32Array containing matrices data
  81555. */
  81556. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81557. /**
  81558. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81559. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81560. * @returns a raw texture containing the data
  81561. */
  81562. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81563. /**
  81564. * Gets the current hosting scene
  81565. * @returns a scene object
  81566. */
  81567. getScene(): Scene;
  81568. /**
  81569. * Gets a string representing the current skeleton data
  81570. * @param fullDetails defines a boolean indicating if we want a verbose version
  81571. * @returns a string representing the current skeleton data
  81572. */
  81573. toString(fullDetails?: boolean): string;
  81574. /**
  81575. * Get bone's index searching by name
  81576. * @param name defines bone's name to search for
  81577. * @return the indice of the bone. Returns -1 if not found
  81578. */
  81579. getBoneIndexByName(name: string): number;
  81580. /**
  81581. * Creater a new animation range
  81582. * @param name defines the name of the range
  81583. * @param from defines the start key
  81584. * @param to defines the end key
  81585. */
  81586. createAnimationRange(name: string, from: number, to: number): void;
  81587. /**
  81588. * Delete a specific animation range
  81589. * @param name defines the name of the range
  81590. * @param deleteFrames defines if frames must be removed as well
  81591. */
  81592. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81593. /**
  81594. * Gets a specific animation range
  81595. * @param name defines the name of the range to look for
  81596. * @returns the requested animation range or null if not found
  81597. */
  81598. getAnimationRange(name: string): Nullable<AnimationRange>;
  81599. /**
  81600. * Gets the list of all animation ranges defined on this skeleton
  81601. * @returns an array
  81602. */
  81603. getAnimationRanges(): Nullable<AnimationRange>[];
  81604. /**
  81605. * Copy animation range from a source skeleton.
  81606. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81607. * @param source defines the source skeleton
  81608. * @param name defines the name of the range to copy
  81609. * @param rescaleAsRequired defines if rescaling must be applied if required
  81610. * @returns true if operation was successful
  81611. */
  81612. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81613. /**
  81614. * Forces the skeleton to go to rest pose
  81615. */
  81616. returnToRest(): void;
  81617. private _getHighestAnimationFrame;
  81618. /**
  81619. * Begin a specific animation range
  81620. * @param name defines the name of the range to start
  81621. * @param loop defines if looping must be turned on (false by default)
  81622. * @param speedRatio defines the speed ratio to apply (1 by default)
  81623. * @param onAnimationEnd defines a callback which will be called when animation will end
  81624. * @returns a new animatable
  81625. */
  81626. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81627. /** @hidden */
  81628. _markAsDirty(): void;
  81629. /** @hidden */
  81630. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81631. /** @hidden */
  81632. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81633. private _computeTransformMatrices;
  81634. /**
  81635. * Build all resources required to render a skeleton
  81636. */
  81637. prepare(): void;
  81638. /**
  81639. * Gets the list of animatables currently running for this skeleton
  81640. * @returns an array of animatables
  81641. */
  81642. getAnimatables(): IAnimatable[];
  81643. /**
  81644. * Clone the current skeleton
  81645. * @param name defines the name of the new skeleton
  81646. * @param id defines the id of the new skeleton
  81647. * @returns the new skeleton
  81648. */
  81649. clone(name: string, id?: string): Skeleton;
  81650. /**
  81651. * Enable animation blending for this skeleton
  81652. * @param blendingSpeed defines the blending speed to apply
  81653. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81654. */
  81655. enableBlending(blendingSpeed?: number): void;
  81656. /**
  81657. * Releases all resources associated with the current skeleton
  81658. */
  81659. dispose(): void;
  81660. /**
  81661. * Serialize the skeleton in a JSON object
  81662. * @returns a JSON object
  81663. */
  81664. serialize(): any;
  81665. /**
  81666. * Creates a new skeleton from serialized data
  81667. * @param parsedSkeleton defines the serialized data
  81668. * @param scene defines the hosting scene
  81669. * @returns a new skeleton
  81670. */
  81671. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81672. /**
  81673. * Compute all node absolute transforms
  81674. * @param forceUpdate defines if computation must be done even if cache is up to date
  81675. */
  81676. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81677. /**
  81678. * Gets the root pose matrix
  81679. * @returns a matrix
  81680. */
  81681. getPoseMatrix(): Nullable<Matrix>;
  81682. /**
  81683. * Sorts bones per internal index
  81684. */
  81685. sortBones(): void;
  81686. private _sortBones;
  81687. }
  81688. }
  81689. declare module BABYLON {
  81690. /**
  81691. * Class used to store bone information
  81692. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81693. */
  81694. export class Bone extends Node {
  81695. /**
  81696. * defines the bone name
  81697. */
  81698. name: string;
  81699. private static _tmpVecs;
  81700. private static _tmpQuat;
  81701. private static _tmpMats;
  81702. /**
  81703. * Gets the list of child bones
  81704. */
  81705. children: Bone[];
  81706. /** Gets the animations associated with this bone */
  81707. animations: Animation[];
  81708. /**
  81709. * Gets or sets bone length
  81710. */
  81711. length: number;
  81712. /**
  81713. * @hidden Internal only
  81714. * Set this value to map this bone to a different index in the transform matrices
  81715. * Set this value to -1 to exclude the bone from the transform matrices
  81716. */
  81717. _index: Nullable<number>;
  81718. private _skeleton;
  81719. private _localMatrix;
  81720. private _restPose;
  81721. private _baseMatrix;
  81722. private _absoluteTransform;
  81723. private _invertedAbsoluteTransform;
  81724. private _parent;
  81725. private _scalingDeterminant;
  81726. private _worldTransform;
  81727. private _localScaling;
  81728. private _localRotation;
  81729. private _localPosition;
  81730. private _needToDecompose;
  81731. private _needToCompose;
  81732. /** @hidden */
  81733. _linkedTransformNode: Nullable<TransformNode>;
  81734. /** @hidden */
  81735. _waitingTransformNodeId: Nullable<string>;
  81736. /** @hidden */
  81737. /** @hidden */
  81738. _matrix: Matrix;
  81739. /**
  81740. * Create a new bone
  81741. * @param name defines the bone name
  81742. * @param skeleton defines the parent skeleton
  81743. * @param parentBone defines the parent (can be null if the bone is the root)
  81744. * @param localMatrix defines the local matrix
  81745. * @param restPose defines the rest pose matrix
  81746. * @param baseMatrix defines the base matrix
  81747. * @param index defines index of the bone in the hiearchy
  81748. */
  81749. constructor(
  81750. /**
  81751. * defines the bone name
  81752. */
  81753. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81754. /**
  81755. * Gets the current object class name.
  81756. * @return the class name
  81757. */
  81758. getClassName(): string;
  81759. /**
  81760. * Gets the parent skeleton
  81761. * @returns a skeleton
  81762. */
  81763. getSkeleton(): Skeleton;
  81764. /**
  81765. * Gets parent bone
  81766. * @returns a bone or null if the bone is the root of the bone hierarchy
  81767. */
  81768. getParent(): Nullable<Bone>;
  81769. /**
  81770. * Returns an array containing the root bones
  81771. * @returns an array containing the root bones
  81772. */
  81773. getChildren(): Array<Bone>;
  81774. /**
  81775. * Gets the node index in matrix array generated for rendering
  81776. * @returns the node index
  81777. */
  81778. getIndex(): number;
  81779. /**
  81780. * Sets the parent bone
  81781. * @param parent defines the parent (can be null if the bone is the root)
  81782. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81783. */
  81784. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81785. /**
  81786. * Gets the local matrix
  81787. * @returns a matrix
  81788. */
  81789. getLocalMatrix(): Matrix;
  81790. /**
  81791. * Gets the base matrix (initial matrix which remains unchanged)
  81792. * @returns a matrix
  81793. */
  81794. getBaseMatrix(): Matrix;
  81795. /**
  81796. * Gets the rest pose matrix
  81797. * @returns a matrix
  81798. */
  81799. getRestPose(): Matrix;
  81800. /**
  81801. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81802. */
  81803. getWorldMatrix(): Matrix;
  81804. /**
  81805. * Sets the local matrix to rest pose matrix
  81806. */
  81807. returnToRest(): void;
  81808. /**
  81809. * Gets the inverse of the absolute transform matrix.
  81810. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81811. * @returns a matrix
  81812. */
  81813. getInvertedAbsoluteTransform(): Matrix;
  81814. /**
  81815. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81816. * @returns a matrix
  81817. */
  81818. getAbsoluteTransform(): Matrix;
  81819. /**
  81820. * Links with the given transform node.
  81821. * The local matrix of this bone is copied from the transform node every frame.
  81822. * @param transformNode defines the transform node to link to
  81823. */
  81824. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81825. /**
  81826. * Gets the node used to drive the bone's transformation
  81827. * @returns a transform node or null
  81828. */
  81829. getTransformNode(): Nullable<TransformNode>;
  81830. /** Gets or sets current position (in local space) */
  81831. position: Vector3;
  81832. /** Gets or sets current rotation (in local space) */
  81833. rotation: Vector3;
  81834. /** Gets or sets current rotation quaternion (in local space) */
  81835. rotationQuaternion: Quaternion;
  81836. /** Gets or sets current scaling (in local space) */
  81837. scaling: Vector3;
  81838. /**
  81839. * Gets the animation properties override
  81840. */
  81841. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81842. private _decompose;
  81843. private _compose;
  81844. /**
  81845. * Update the base and local matrices
  81846. * @param matrix defines the new base or local matrix
  81847. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81848. * @param updateLocalMatrix defines if the local matrix should be updated
  81849. */
  81850. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81851. /** @hidden */
  81852. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81853. /**
  81854. * Flag the bone as dirty (Forcing it to update everything)
  81855. */
  81856. markAsDirty(): void;
  81857. /** @hidden */
  81858. _markAsDirtyAndCompose(): void;
  81859. private _markAsDirtyAndDecompose;
  81860. /**
  81861. * Translate the bone in local or world space
  81862. * @param vec The amount to translate the bone
  81863. * @param space The space that the translation is in
  81864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81865. */
  81866. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81867. /**
  81868. * Set the postion of the bone in local or world space
  81869. * @param position The position to set the bone
  81870. * @param space The space that the position is in
  81871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81872. */
  81873. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81874. /**
  81875. * Set the absolute position of the bone (world space)
  81876. * @param position The position to set the bone
  81877. * @param mesh The mesh that this bone is attached to
  81878. */
  81879. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81880. /**
  81881. * Scale the bone on the x, y and z axes (in local space)
  81882. * @param x The amount to scale the bone on the x axis
  81883. * @param y The amount to scale the bone on the y axis
  81884. * @param z The amount to scale the bone on the z axis
  81885. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81886. */
  81887. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81888. /**
  81889. * Set the bone scaling in local space
  81890. * @param scale defines the scaling vector
  81891. */
  81892. setScale(scale: Vector3): void;
  81893. /**
  81894. * Gets the current scaling in local space
  81895. * @returns the current scaling vector
  81896. */
  81897. getScale(): Vector3;
  81898. /**
  81899. * Gets the current scaling in local space and stores it in a target vector
  81900. * @param result defines the target vector
  81901. */
  81902. getScaleToRef(result: Vector3): void;
  81903. /**
  81904. * Set the yaw, pitch, and roll of the bone in local or world space
  81905. * @param yaw The rotation of the bone on the y axis
  81906. * @param pitch The rotation of the bone on the x axis
  81907. * @param roll The rotation of the bone on the z axis
  81908. * @param space The space that the axes of rotation are in
  81909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81910. */
  81911. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81912. /**
  81913. * Add a rotation to the bone on an axis in local or world space
  81914. * @param axis The axis to rotate the bone on
  81915. * @param amount The amount to rotate the bone
  81916. * @param space The space that the axis is in
  81917. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81918. */
  81919. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81920. /**
  81921. * Set the rotation of the bone to a particular axis angle in local or world space
  81922. * @param axis The axis to rotate the bone on
  81923. * @param angle The angle that the bone should be rotated to
  81924. * @param space The space that the axis is in
  81925. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81926. */
  81927. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81928. /**
  81929. * Set the euler rotation of the bone in local of world space
  81930. * @param rotation The euler rotation that the bone should be set to
  81931. * @param space The space that the rotation is in
  81932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81933. */
  81934. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81935. /**
  81936. * Set the quaternion rotation of the bone in local of world space
  81937. * @param quat The quaternion rotation that the bone should be set to
  81938. * @param space The space that the rotation is in
  81939. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81940. */
  81941. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81942. /**
  81943. * Set the rotation matrix of the bone in local of world space
  81944. * @param rotMat The rotation matrix that the bone should be set to
  81945. * @param space The space that the rotation is in
  81946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81947. */
  81948. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81949. private _rotateWithMatrix;
  81950. private _getNegativeRotationToRef;
  81951. /**
  81952. * Get the position of the bone in local or world space
  81953. * @param space The space that the returned position is in
  81954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81955. * @returns The position of the bone
  81956. */
  81957. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81958. /**
  81959. * Copy the position of the bone to a vector3 in local or world space
  81960. * @param space The space that the returned position is in
  81961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81962. * @param result The vector3 to copy the position to
  81963. */
  81964. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81965. /**
  81966. * Get the absolute position of the bone (world space)
  81967. * @param mesh The mesh that this bone is attached to
  81968. * @returns The absolute position of the bone
  81969. */
  81970. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81971. /**
  81972. * Copy the absolute position of the bone (world space) to the result param
  81973. * @param mesh The mesh that this bone is attached to
  81974. * @param result The vector3 to copy the absolute position to
  81975. */
  81976. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81977. /**
  81978. * Compute the absolute transforms of this bone and its children
  81979. */
  81980. computeAbsoluteTransforms(): void;
  81981. /**
  81982. * Get the world direction from an axis that is in the local space of the bone
  81983. * @param localAxis The local direction that is used to compute the world direction
  81984. * @param mesh The mesh that this bone is attached to
  81985. * @returns The world direction
  81986. */
  81987. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81988. /**
  81989. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81990. * @param localAxis The local direction that is used to compute the world direction
  81991. * @param mesh The mesh that this bone is attached to
  81992. * @param result The vector3 that the world direction will be copied to
  81993. */
  81994. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81995. /**
  81996. * Get the euler rotation of the bone in local or world space
  81997. * @param space The space that the rotation should be in
  81998. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81999. * @returns The euler rotation
  82000. */
  82001. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82002. /**
  82003. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82004. * @param space The space that the rotation should be in
  82005. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82006. * @param result The vector3 that the rotation should be copied to
  82007. */
  82008. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82009. /**
  82010. * Get the quaternion rotation of the bone in either local or world space
  82011. * @param space The space that the rotation should be in
  82012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82013. * @returns The quaternion rotation
  82014. */
  82015. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82016. /**
  82017. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82018. * @param space The space that the rotation should be in
  82019. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82020. * @param result The quaternion that the rotation should be copied to
  82021. */
  82022. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82023. /**
  82024. * Get the rotation matrix of the bone in local or world space
  82025. * @param space The space that the rotation should be in
  82026. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82027. * @returns The rotation matrix
  82028. */
  82029. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82030. /**
  82031. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82032. * @param space The space that the rotation should be in
  82033. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82034. * @param result The quaternion that the rotation should be copied to
  82035. */
  82036. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82037. /**
  82038. * Get the world position of a point that is in the local space of the bone
  82039. * @param position The local position
  82040. * @param mesh The mesh that this bone is attached to
  82041. * @returns The world position
  82042. */
  82043. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82044. /**
  82045. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82046. * @param position The local position
  82047. * @param mesh The mesh that this bone is attached to
  82048. * @param result The vector3 that the world position should be copied to
  82049. */
  82050. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82051. /**
  82052. * Get the local position of a point that is in world space
  82053. * @param position The world position
  82054. * @param mesh The mesh that this bone is attached to
  82055. * @returns The local position
  82056. */
  82057. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82058. /**
  82059. * Get the local position of a point that is in world space and copy it to the result param
  82060. * @param position The world position
  82061. * @param mesh The mesh that this bone is attached to
  82062. * @param result The vector3 that the local position should be copied to
  82063. */
  82064. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82065. }
  82066. }
  82067. declare module BABYLON {
  82068. /**
  82069. * 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.
  82070. * @see https://doc.babylonjs.com/how_to/transformnode
  82071. */
  82072. export class TransformNode extends Node {
  82073. /**
  82074. * Object will not rotate to face the camera
  82075. */
  82076. static BILLBOARDMODE_NONE: number;
  82077. /**
  82078. * Object will rotate to face the camera but only on the x axis
  82079. */
  82080. static BILLBOARDMODE_X: number;
  82081. /**
  82082. * Object will rotate to face the camera but only on the y axis
  82083. */
  82084. static BILLBOARDMODE_Y: number;
  82085. /**
  82086. * Object will rotate to face the camera but only on the z axis
  82087. */
  82088. static BILLBOARDMODE_Z: number;
  82089. /**
  82090. * Object will rotate to face the camera
  82091. */
  82092. static BILLBOARDMODE_ALL: number;
  82093. /**
  82094. * Object will rotate to face the camera's position instead of orientation
  82095. */
  82096. static BILLBOARDMODE_USE_POSITION: number;
  82097. private _forward;
  82098. private _forwardInverted;
  82099. private _up;
  82100. private _right;
  82101. private _rightInverted;
  82102. private _position;
  82103. private _rotation;
  82104. private _rotationQuaternion;
  82105. protected _scaling: Vector3;
  82106. protected _isDirty: boolean;
  82107. private _transformToBoneReferal;
  82108. private _isAbsoluteSynced;
  82109. private _billboardMode;
  82110. /**
  82111. * Gets or sets the billboard mode. Default is 0.
  82112. *
  82113. * | Value | Type | Description |
  82114. * | --- | --- | --- |
  82115. * | 0 | BILLBOARDMODE_NONE | |
  82116. * | 1 | BILLBOARDMODE_X | |
  82117. * | 2 | BILLBOARDMODE_Y | |
  82118. * | 4 | BILLBOARDMODE_Z | |
  82119. * | 7 | BILLBOARDMODE_ALL | |
  82120. *
  82121. */
  82122. billboardMode: number;
  82123. private _preserveParentRotationForBillboard;
  82124. /**
  82125. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82126. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82127. */
  82128. preserveParentRotationForBillboard: boolean;
  82129. /**
  82130. * 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
  82131. */
  82132. scalingDeterminant: number;
  82133. private _infiniteDistance;
  82134. /**
  82135. * Gets or sets the distance of the object to max, often used by skybox
  82136. */
  82137. infiniteDistance: boolean;
  82138. /**
  82139. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82140. * By default the system will update normals to compensate
  82141. */
  82142. ignoreNonUniformScaling: boolean;
  82143. /**
  82144. * 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
  82145. */
  82146. reIntegrateRotationIntoRotationQuaternion: boolean;
  82147. /** @hidden */
  82148. _poseMatrix: Nullable<Matrix>;
  82149. /** @hidden */
  82150. _localMatrix: Matrix;
  82151. private _usePivotMatrix;
  82152. private _absolutePosition;
  82153. private _absoluteScaling;
  82154. private _absoluteRotationQuaternion;
  82155. private _pivotMatrix;
  82156. private _pivotMatrixInverse;
  82157. protected _postMultiplyPivotMatrix: boolean;
  82158. protected _isWorldMatrixFrozen: boolean;
  82159. /** @hidden */
  82160. _indexInSceneTransformNodesArray: number;
  82161. /**
  82162. * An event triggered after the world matrix is updated
  82163. */
  82164. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82165. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82166. /**
  82167. * Gets a string identifying the name of the class
  82168. * @returns "TransformNode" string
  82169. */
  82170. getClassName(): string;
  82171. /**
  82172. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82173. */
  82174. position: Vector3;
  82175. /**
  82176. * 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)).
  82177. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82178. */
  82179. rotation: Vector3;
  82180. /**
  82181. * 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)).
  82182. */
  82183. scaling: Vector3;
  82184. /**
  82185. * 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).
  82186. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82187. */
  82188. rotationQuaternion: Nullable<Quaternion>;
  82189. /**
  82190. * The forward direction of that transform in world space.
  82191. */
  82192. readonly forward: Vector3;
  82193. /**
  82194. * The up direction of that transform in world space.
  82195. */
  82196. readonly up: Vector3;
  82197. /**
  82198. * The right direction of that transform in world space.
  82199. */
  82200. readonly right: Vector3;
  82201. /**
  82202. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82203. * @param matrix the matrix to copy the pose from
  82204. * @returns this TransformNode.
  82205. */
  82206. updatePoseMatrix(matrix: Matrix): TransformNode;
  82207. /**
  82208. * Returns the mesh Pose matrix.
  82209. * @returns the pose matrix
  82210. */
  82211. getPoseMatrix(): Matrix;
  82212. /** @hidden */
  82213. _isSynchronized(): boolean;
  82214. /** @hidden */
  82215. _initCache(): void;
  82216. /**
  82217. * Flag the transform node as dirty (Forcing it to update everything)
  82218. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82219. * @returns this transform node
  82220. */
  82221. markAsDirty(property: string): TransformNode;
  82222. /**
  82223. * Returns the current mesh absolute position.
  82224. * Returns a Vector3.
  82225. */
  82226. readonly absolutePosition: Vector3;
  82227. /**
  82228. * Returns the current mesh absolute scaling.
  82229. * Returns a Vector3.
  82230. */
  82231. readonly absoluteScaling: Vector3;
  82232. /**
  82233. * Returns the current mesh absolute rotation.
  82234. * Returns a Quaternion.
  82235. */
  82236. readonly absoluteRotationQuaternion: Quaternion;
  82237. /**
  82238. * Sets a new matrix to apply before all other transformation
  82239. * @param matrix defines the transform matrix
  82240. * @returns the current TransformNode
  82241. */
  82242. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82243. /**
  82244. * Sets a new pivot matrix to the current node
  82245. * @param matrix defines the new pivot matrix to use
  82246. * @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
  82247. * @returns the current TransformNode
  82248. */
  82249. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82250. /**
  82251. * Returns the mesh pivot matrix.
  82252. * Default : Identity.
  82253. * @returns the matrix
  82254. */
  82255. getPivotMatrix(): Matrix;
  82256. /**
  82257. * Instantiate (when possible) or clone that node with its hierarchy
  82258. * @param newParent defines the new parent to use for the instance (or clone)
  82259. * @param options defines options to configure how copy is done
  82260. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82261. * @returns an instance (or a clone) of the current node with its hiearchy
  82262. */
  82263. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82264. doNotInstantiate: boolean;
  82265. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82266. /**
  82267. * Prevents the World matrix to be computed any longer
  82268. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82269. * @returns the TransformNode.
  82270. */
  82271. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82272. /**
  82273. * Allows back the World matrix computation.
  82274. * @returns the TransformNode.
  82275. */
  82276. unfreezeWorldMatrix(): this;
  82277. /**
  82278. * True if the World matrix has been frozen.
  82279. */
  82280. readonly isWorldMatrixFrozen: boolean;
  82281. /**
  82282. * Retuns the mesh absolute position in the World.
  82283. * @returns a Vector3.
  82284. */
  82285. getAbsolutePosition(): Vector3;
  82286. /**
  82287. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82288. * @param absolutePosition the absolute position to set
  82289. * @returns the TransformNode.
  82290. */
  82291. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82292. /**
  82293. * Sets the mesh position in its local space.
  82294. * @param vector3 the position to set in localspace
  82295. * @returns the TransformNode.
  82296. */
  82297. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82298. /**
  82299. * Returns the mesh position in the local space from the current World matrix values.
  82300. * @returns a new Vector3.
  82301. */
  82302. getPositionExpressedInLocalSpace(): Vector3;
  82303. /**
  82304. * Translates the mesh along the passed Vector3 in its local space.
  82305. * @param vector3 the distance to translate in localspace
  82306. * @returns the TransformNode.
  82307. */
  82308. locallyTranslate(vector3: Vector3): TransformNode;
  82309. private static _lookAtVectorCache;
  82310. /**
  82311. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82312. * @param targetPoint the position (must be in same space as current mesh) to look at
  82313. * @param yawCor optional yaw (y-axis) correction in radians
  82314. * @param pitchCor optional pitch (x-axis) correction in radians
  82315. * @param rollCor optional roll (z-axis) correction in radians
  82316. * @param space the choosen space of the target
  82317. * @returns the TransformNode.
  82318. */
  82319. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82320. /**
  82321. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82322. * This Vector3 is expressed in the World space.
  82323. * @param localAxis axis to rotate
  82324. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82325. */
  82326. getDirection(localAxis: Vector3): Vector3;
  82327. /**
  82328. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82329. * localAxis is expressed in the mesh local space.
  82330. * result is computed in the Wordl space from the mesh World matrix.
  82331. * @param localAxis axis to rotate
  82332. * @param result the resulting transformnode
  82333. * @returns this TransformNode.
  82334. */
  82335. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82336. /**
  82337. * Sets this transform node rotation to the given local axis.
  82338. * @param localAxis the axis in local space
  82339. * @param yawCor optional yaw (y-axis) correction in radians
  82340. * @param pitchCor optional pitch (x-axis) correction in radians
  82341. * @param rollCor optional roll (z-axis) correction in radians
  82342. * @returns this TransformNode
  82343. */
  82344. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82345. /**
  82346. * Sets a new pivot point to the current node
  82347. * @param point defines the new pivot point to use
  82348. * @param space defines if the point is in world or local space (local by default)
  82349. * @returns the current TransformNode
  82350. */
  82351. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82352. /**
  82353. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82354. * @returns the pivot point
  82355. */
  82356. getPivotPoint(): Vector3;
  82357. /**
  82358. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82359. * @param result the vector3 to store the result
  82360. * @returns this TransformNode.
  82361. */
  82362. getPivotPointToRef(result: Vector3): TransformNode;
  82363. /**
  82364. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82365. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82366. */
  82367. getAbsolutePivotPoint(): Vector3;
  82368. /**
  82369. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82370. * @param result vector3 to store the result
  82371. * @returns this TransformNode.
  82372. */
  82373. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82374. /**
  82375. * Defines the passed node as the parent of the current node.
  82376. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82377. * @see https://doc.babylonjs.com/how_to/parenting
  82378. * @param node the node ot set as the parent
  82379. * @returns this TransformNode.
  82380. */
  82381. setParent(node: Nullable<Node>): TransformNode;
  82382. private _nonUniformScaling;
  82383. /**
  82384. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82385. */
  82386. readonly nonUniformScaling: boolean;
  82387. /** @hidden */
  82388. _updateNonUniformScalingState(value: boolean): boolean;
  82389. /**
  82390. * Attach the current TransformNode to another TransformNode associated with a bone
  82391. * @param bone Bone affecting the TransformNode
  82392. * @param affectedTransformNode TransformNode associated with the bone
  82393. * @returns this object
  82394. */
  82395. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82396. /**
  82397. * Detach the transform node if its associated with a bone
  82398. * @returns this object
  82399. */
  82400. detachFromBone(): TransformNode;
  82401. private static _rotationAxisCache;
  82402. /**
  82403. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82404. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82405. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82406. * The passed axis is also normalized.
  82407. * @param axis the axis to rotate around
  82408. * @param amount the amount to rotate in radians
  82409. * @param space Space to rotate in (Default: local)
  82410. * @returns the TransformNode.
  82411. */
  82412. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82413. /**
  82414. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82415. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82416. * The passed axis is also normalized. .
  82417. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82418. * @param point the point to rotate around
  82419. * @param axis the axis to rotate around
  82420. * @param amount the amount to rotate in radians
  82421. * @returns the TransformNode
  82422. */
  82423. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82424. /**
  82425. * Translates the mesh along the axis vector for the passed distance in the given space.
  82426. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82427. * @param axis the axis to translate in
  82428. * @param distance the distance to translate
  82429. * @param space Space to rotate in (Default: local)
  82430. * @returns the TransformNode.
  82431. */
  82432. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82433. /**
  82434. * Adds a rotation step to the mesh current rotation.
  82435. * x, y, z are Euler angles expressed in radians.
  82436. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82437. * This means this rotation is made in the mesh local space only.
  82438. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82439. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82440. * ```javascript
  82441. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82442. * ```
  82443. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82444. * 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.
  82445. * @param x Rotation to add
  82446. * @param y Rotation to add
  82447. * @param z Rotation to add
  82448. * @returns the TransformNode.
  82449. */
  82450. addRotation(x: number, y: number, z: number): TransformNode;
  82451. /**
  82452. * @hidden
  82453. */
  82454. protected _getEffectiveParent(): Nullable<Node>;
  82455. /**
  82456. * Computes the world matrix of the node
  82457. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82458. * @returns the world matrix
  82459. */
  82460. computeWorldMatrix(force?: boolean): Matrix;
  82461. protected _afterComputeWorldMatrix(): void;
  82462. /**
  82463. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82464. * @param func callback function to add
  82465. *
  82466. * @returns the TransformNode.
  82467. */
  82468. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82469. /**
  82470. * Removes a registered callback function.
  82471. * @param func callback function to remove
  82472. * @returns the TransformNode.
  82473. */
  82474. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82475. /**
  82476. * Gets the position of the current mesh in camera space
  82477. * @param camera defines the camera to use
  82478. * @returns a position
  82479. */
  82480. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82481. /**
  82482. * Returns the distance from the mesh to the active camera
  82483. * @param camera defines the camera to use
  82484. * @returns the distance
  82485. */
  82486. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82487. /**
  82488. * Clone the current transform node
  82489. * @param name Name of the new clone
  82490. * @param newParent New parent for the clone
  82491. * @param doNotCloneChildren Do not clone children hierarchy
  82492. * @returns the new transform node
  82493. */
  82494. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82495. /**
  82496. * Serializes the objects information.
  82497. * @param currentSerializationObject defines the object to serialize in
  82498. * @returns the serialized object
  82499. */
  82500. serialize(currentSerializationObject?: any): any;
  82501. /**
  82502. * Returns a new TransformNode object parsed from the source provided.
  82503. * @param parsedTransformNode is the source.
  82504. * @param scene the scne the object belongs to
  82505. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82506. * @returns a new TransformNode object parsed from the source provided.
  82507. */
  82508. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82509. /**
  82510. * Get all child-transformNodes of this node
  82511. * @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
  82512. * @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
  82513. * @returns an array of TransformNode
  82514. */
  82515. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82516. /**
  82517. * Releases resources associated with this transform node.
  82518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82520. */
  82521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82522. /**
  82523. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82524. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82525. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82526. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82527. * @returns the current mesh
  82528. */
  82529. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82530. private _syncAbsoluteScalingAndRotation;
  82531. }
  82532. }
  82533. declare module BABYLON {
  82534. /**
  82535. * Defines the types of pose enabled controllers that are supported
  82536. */
  82537. export enum PoseEnabledControllerType {
  82538. /**
  82539. * HTC Vive
  82540. */
  82541. VIVE = 0,
  82542. /**
  82543. * Oculus Rift
  82544. */
  82545. OCULUS = 1,
  82546. /**
  82547. * Windows mixed reality
  82548. */
  82549. WINDOWS = 2,
  82550. /**
  82551. * Samsung gear VR
  82552. */
  82553. GEAR_VR = 3,
  82554. /**
  82555. * Google Daydream
  82556. */
  82557. DAYDREAM = 4,
  82558. /**
  82559. * Generic
  82560. */
  82561. GENERIC = 5
  82562. }
  82563. /**
  82564. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82565. */
  82566. export interface MutableGamepadButton {
  82567. /**
  82568. * Value of the button/trigger
  82569. */
  82570. value: number;
  82571. /**
  82572. * If the button/trigger is currently touched
  82573. */
  82574. touched: boolean;
  82575. /**
  82576. * If the button/trigger is currently pressed
  82577. */
  82578. pressed: boolean;
  82579. }
  82580. /**
  82581. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82582. * @hidden
  82583. */
  82584. export interface ExtendedGamepadButton extends GamepadButton {
  82585. /**
  82586. * If the button/trigger is currently pressed
  82587. */
  82588. readonly pressed: boolean;
  82589. /**
  82590. * If the button/trigger is currently touched
  82591. */
  82592. readonly touched: boolean;
  82593. /**
  82594. * Value of the button/trigger
  82595. */
  82596. readonly value: number;
  82597. }
  82598. /** @hidden */
  82599. export interface _GamePadFactory {
  82600. /**
  82601. * Returns wether or not the current gamepad can be created for this type of controller.
  82602. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82603. * @returns true if it can be created, otherwise false
  82604. */
  82605. canCreate(gamepadInfo: any): boolean;
  82606. /**
  82607. * Creates a new instance of the Gamepad.
  82608. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82609. * @returns the new gamepad instance
  82610. */
  82611. create(gamepadInfo: any): Gamepad;
  82612. }
  82613. /**
  82614. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82615. */
  82616. export class PoseEnabledControllerHelper {
  82617. /** @hidden */
  82618. static _ControllerFactories: _GamePadFactory[];
  82619. /** @hidden */
  82620. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82621. /**
  82622. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82623. * @param vrGamepad the gamepad to initialized
  82624. * @returns a vr controller of the type the gamepad identified as
  82625. */
  82626. static InitiateController(vrGamepad: any): Gamepad;
  82627. }
  82628. /**
  82629. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82630. */
  82631. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82632. /**
  82633. * If the controller is used in a webXR session
  82634. */
  82635. isXR: boolean;
  82636. private _deviceRoomPosition;
  82637. private _deviceRoomRotationQuaternion;
  82638. /**
  82639. * The device position in babylon space
  82640. */
  82641. devicePosition: Vector3;
  82642. /**
  82643. * The device rotation in babylon space
  82644. */
  82645. deviceRotationQuaternion: Quaternion;
  82646. /**
  82647. * The scale factor of the device in babylon space
  82648. */
  82649. deviceScaleFactor: number;
  82650. /**
  82651. * (Likely devicePosition should be used instead) The device position in its room space
  82652. */
  82653. position: Vector3;
  82654. /**
  82655. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82656. */
  82657. rotationQuaternion: Quaternion;
  82658. /**
  82659. * The type of controller (Eg. Windows mixed reality)
  82660. */
  82661. controllerType: PoseEnabledControllerType;
  82662. protected _calculatedPosition: Vector3;
  82663. private _calculatedRotation;
  82664. /**
  82665. * The raw pose from the device
  82666. */
  82667. rawPose: DevicePose;
  82668. private _trackPosition;
  82669. private _maxRotationDistFromHeadset;
  82670. private _draggedRoomRotation;
  82671. /**
  82672. * @hidden
  82673. */
  82674. _disableTrackPosition(fixedPosition: Vector3): void;
  82675. /**
  82676. * Internal, the mesh attached to the controller
  82677. * @hidden
  82678. */
  82679. _mesh: Nullable<AbstractMesh>;
  82680. private _poseControlledCamera;
  82681. private _leftHandSystemQuaternion;
  82682. /**
  82683. * Internal, matrix used to convert room space to babylon space
  82684. * @hidden
  82685. */
  82686. _deviceToWorld: Matrix;
  82687. /**
  82688. * Node to be used when casting a ray from the controller
  82689. * @hidden
  82690. */
  82691. _pointingPoseNode: Nullable<TransformNode>;
  82692. /**
  82693. * Name of the child mesh that can be used to cast a ray from the controller
  82694. */
  82695. static readonly POINTING_POSE: string;
  82696. /**
  82697. * Creates a new PoseEnabledController from a gamepad
  82698. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82699. */
  82700. constructor(browserGamepad: any);
  82701. private _workingMatrix;
  82702. /**
  82703. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82704. */
  82705. update(): void;
  82706. /**
  82707. * Updates only the pose device and mesh without doing any button event checking
  82708. */
  82709. protected _updatePoseAndMesh(): void;
  82710. /**
  82711. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82712. * @param poseData raw pose fromthe device
  82713. */
  82714. updateFromDevice(poseData: DevicePose): void;
  82715. /**
  82716. * @hidden
  82717. */
  82718. _meshAttachedObservable: Observable<AbstractMesh>;
  82719. /**
  82720. * Attaches a mesh to the controller
  82721. * @param mesh the mesh to be attached
  82722. */
  82723. attachToMesh(mesh: AbstractMesh): void;
  82724. /**
  82725. * Attaches the controllers mesh to a camera
  82726. * @param camera the camera the mesh should be attached to
  82727. */
  82728. attachToPoseControlledCamera(camera: TargetCamera): void;
  82729. /**
  82730. * Disposes of the controller
  82731. */
  82732. dispose(): void;
  82733. /**
  82734. * The mesh that is attached to the controller
  82735. */
  82736. readonly mesh: Nullable<AbstractMesh>;
  82737. /**
  82738. * Gets the ray of the controller in the direction the controller is pointing
  82739. * @param length the length the resulting ray should be
  82740. * @returns a ray in the direction the controller is pointing
  82741. */
  82742. getForwardRay(length?: number): Ray;
  82743. }
  82744. }
  82745. declare module BABYLON {
  82746. /**
  82747. * Defines the WebVRController object that represents controllers tracked in 3D space
  82748. */
  82749. export abstract class WebVRController extends PoseEnabledController {
  82750. /**
  82751. * Internal, the default controller model for the controller
  82752. */
  82753. protected _defaultModel: Nullable<AbstractMesh>;
  82754. /**
  82755. * Fired when the trigger state has changed
  82756. */
  82757. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82758. /**
  82759. * Fired when the main button state has changed
  82760. */
  82761. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82762. /**
  82763. * Fired when the secondary button state has changed
  82764. */
  82765. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82766. /**
  82767. * Fired when the pad state has changed
  82768. */
  82769. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82770. /**
  82771. * Fired when controllers stick values have changed
  82772. */
  82773. onPadValuesChangedObservable: Observable<StickValues>;
  82774. /**
  82775. * Array of button availible on the controller
  82776. */
  82777. protected _buttons: Array<MutableGamepadButton>;
  82778. private _onButtonStateChange;
  82779. /**
  82780. * Fired when a controller button's state has changed
  82781. * @param callback the callback containing the button that was modified
  82782. */
  82783. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82784. /**
  82785. * X and Y axis corresponding to the controllers joystick
  82786. */
  82787. pad: StickValues;
  82788. /**
  82789. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82790. */
  82791. hand: string;
  82792. /**
  82793. * The default controller model for the controller
  82794. */
  82795. readonly defaultModel: Nullable<AbstractMesh>;
  82796. /**
  82797. * Creates a new WebVRController from a gamepad
  82798. * @param vrGamepad the gamepad that the WebVRController should be created from
  82799. */
  82800. constructor(vrGamepad: any);
  82801. /**
  82802. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82803. */
  82804. update(): void;
  82805. /**
  82806. * Function to be called when a button is modified
  82807. */
  82808. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82809. /**
  82810. * Loads a mesh and attaches it to the controller
  82811. * @param scene the scene the mesh should be added to
  82812. * @param meshLoaded callback for when the mesh has been loaded
  82813. */
  82814. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82815. private _setButtonValue;
  82816. private _changes;
  82817. private _checkChanges;
  82818. /**
  82819. * Disposes of th webVRCOntroller
  82820. */
  82821. dispose(): void;
  82822. }
  82823. }
  82824. declare module BABYLON {
  82825. /**
  82826. * The HemisphericLight simulates the ambient environment light,
  82827. * so the passed direction is the light reflection direction, not the incoming direction.
  82828. */
  82829. export class HemisphericLight extends Light {
  82830. /**
  82831. * The groundColor is the light in the opposite direction to the one specified during creation.
  82832. * 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.
  82833. */
  82834. groundColor: Color3;
  82835. /**
  82836. * The light reflection direction, not the incoming direction.
  82837. */
  82838. direction: Vector3;
  82839. /**
  82840. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82841. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82842. * The HemisphericLight can't cast shadows.
  82843. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82844. * @param name The friendly name of the light
  82845. * @param direction The direction of the light reflection
  82846. * @param scene The scene the light belongs to
  82847. */
  82848. constructor(name: string, direction: Vector3, scene: Scene);
  82849. protected _buildUniformLayout(): void;
  82850. /**
  82851. * Returns the string "HemisphericLight".
  82852. * @return The class name
  82853. */
  82854. getClassName(): string;
  82855. /**
  82856. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82857. * Returns the updated direction.
  82858. * @param target The target the direction should point to
  82859. * @return The computed direction
  82860. */
  82861. setDirectionToTarget(target: Vector3): Vector3;
  82862. /**
  82863. * Returns the shadow generator associated to the light.
  82864. * @returns Always null for hemispheric lights because it does not support shadows.
  82865. */
  82866. getShadowGenerator(): Nullable<IShadowGenerator>;
  82867. /**
  82868. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82869. * @param effect The effect to update
  82870. * @param lightIndex The index of the light in the effect to update
  82871. * @returns The hemispheric light
  82872. */
  82873. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82874. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82875. /**
  82876. * Computes the world matrix of the node
  82877. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82878. * @param useWasUpdatedFlag defines a reserved property
  82879. * @returns the world matrix
  82880. */
  82881. computeWorldMatrix(): Matrix;
  82882. /**
  82883. * Returns the integer 3.
  82884. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82885. */
  82886. getTypeID(): number;
  82887. /**
  82888. * Prepares the list of defines specific to the light type.
  82889. * @param defines the list of defines
  82890. * @param lightIndex defines the index of the light for the effect
  82891. */
  82892. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82893. }
  82894. }
  82895. declare module BABYLON {
  82896. /** @hidden */
  82897. export var vrMultiviewToSingleviewPixelShader: {
  82898. name: string;
  82899. shader: string;
  82900. };
  82901. }
  82902. declare module BABYLON {
  82903. /**
  82904. * Renders to multiple views with a single draw call
  82905. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82906. */
  82907. export class MultiviewRenderTarget extends RenderTargetTexture {
  82908. /**
  82909. * Creates a multiview render target
  82910. * @param scene scene used with the render target
  82911. * @param size the size of the render target (used for each view)
  82912. */
  82913. constructor(scene: Scene, size?: number | {
  82914. width: number;
  82915. height: number;
  82916. } | {
  82917. ratio: number;
  82918. });
  82919. /**
  82920. * @hidden
  82921. * @param faceIndex the face index, if its a cube texture
  82922. */
  82923. _bindFrameBuffer(faceIndex?: number): void;
  82924. /**
  82925. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82926. * @returns the view count
  82927. */
  82928. getViewCount(): number;
  82929. }
  82930. }
  82931. declare module BABYLON {
  82932. /**
  82933. * Represents a camera frustum
  82934. */
  82935. export class Frustum {
  82936. /**
  82937. * Gets the planes representing the frustum
  82938. * @param transform matrix to be applied to the returned planes
  82939. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82940. */
  82941. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82942. /**
  82943. * Gets the near frustum plane transformed by the transform matrix
  82944. * @param transform transformation matrix to be applied to the resulting frustum plane
  82945. * @param frustumPlane the resuling frustum plane
  82946. */
  82947. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82948. /**
  82949. * Gets the far frustum plane transformed by the transform matrix
  82950. * @param transform transformation matrix to be applied to the resulting frustum plane
  82951. * @param frustumPlane the resuling frustum plane
  82952. */
  82953. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82954. /**
  82955. * Gets the left frustum plane transformed by the transform matrix
  82956. * @param transform transformation matrix to be applied to the resulting frustum plane
  82957. * @param frustumPlane the resuling frustum plane
  82958. */
  82959. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82960. /**
  82961. * Gets the right frustum plane transformed by the transform matrix
  82962. * @param transform transformation matrix to be applied to the resulting frustum plane
  82963. * @param frustumPlane the resuling frustum plane
  82964. */
  82965. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82966. /**
  82967. * Gets the top frustum plane transformed by the transform matrix
  82968. * @param transform transformation matrix to be applied to the resulting frustum plane
  82969. * @param frustumPlane the resuling frustum plane
  82970. */
  82971. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82972. /**
  82973. * Gets the bottom frustum plane transformed by the transform matrix
  82974. * @param transform transformation matrix to be applied to the resulting frustum plane
  82975. * @param frustumPlane the resuling frustum plane
  82976. */
  82977. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82978. /**
  82979. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82980. * @param transform transformation matrix to be applied to the resulting frustum planes
  82981. * @param frustumPlanes the resuling frustum planes
  82982. */
  82983. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82984. }
  82985. }
  82986. declare module BABYLON {
  82987. interface Engine {
  82988. /**
  82989. * Creates a new multiview render target
  82990. * @param width defines the width of the texture
  82991. * @param height defines the height of the texture
  82992. * @returns the created multiview texture
  82993. */
  82994. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82995. /**
  82996. * Binds a multiview framebuffer to be drawn to
  82997. * @param multiviewTexture texture to bind
  82998. */
  82999. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83000. }
  83001. interface Camera {
  83002. /**
  83003. * @hidden
  83004. * 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)
  83005. */
  83006. _useMultiviewToSingleView: boolean;
  83007. /**
  83008. * @hidden
  83009. * 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)
  83010. */
  83011. _multiviewTexture: Nullable<RenderTargetTexture>;
  83012. /**
  83013. * @hidden
  83014. * ensures the multiview texture of the camera exists and has the specified width/height
  83015. * @param width height to set on the multiview texture
  83016. * @param height width to set on the multiview texture
  83017. */
  83018. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83019. }
  83020. interface Scene {
  83021. /** @hidden */
  83022. _transformMatrixR: Matrix;
  83023. /** @hidden */
  83024. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83025. /** @hidden */
  83026. _createMultiviewUbo(): void;
  83027. /** @hidden */
  83028. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83029. /** @hidden */
  83030. _renderMultiviewToSingleView(camera: Camera): void;
  83031. }
  83032. }
  83033. declare module BABYLON {
  83034. /**
  83035. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83036. * This will not be used for webXR as it supports displaying texture arrays directly
  83037. */
  83038. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83039. /**
  83040. * Initializes a VRMultiviewToSingleview
  83041. * @param name name of the post process
  83042. * @param camera camera to be applied to
  83043. * @param scaleFactor scaling factor to the size of the output texture
  83044. */
  83045. constructor(name: string, camera: Camera, scaleFactor: number);
  83046. }
  83047. }
  83048. declare module BABYLON {
  83049. /**
  83050. * Interface used to define additional presentation attributes
  83051. */
  83052. export interface IVRPresentationAttributes {
  83053. /**
  83054. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83055. */
  83056. highRefreshRate: boolean;
  83057. /**
  83058. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83059. */
  83060. foveationLevel: number;
  83061. }
  83062. interface Engine {
  83063. /** @hidden */
  83064. _vrDisplay: any;
  83065. /** @hidden */
  83066. _vrSupported: boolean;
  83067. /** @hidden */
  83068. _oldSize: Size;
  83069. /** @hidden */
  83070. _oldHardwareScaleFactor: number;
  83071. /** @hidden */
  83072. _vrExclusivePointerMode: boolean;
  83073. /** @hidden */
  83074. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83075. /** @hidden */
  83076. _onVRDisplayPointerRestricted: () => void;
  83077. /** @hidden */
  83078. _onVRDisplayPointerUnrestricted: () => void;
  83079. /** @hidden */
  83080. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83081. /** @hidden */
  83082. _onVrDisplayDisconnect: Nullable<() => void>;
  83083. /** @hidden */
  83084. _onVrDisplayPresentChange: Nullable<() => void>;
  83085. /**
  83086. * Observable signaled when VR display mode changes
  83087. */
  83088. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83089. /**
  83090. * Observable signaled when VR request present is complete
  83091. */
  83092. onVRRequestPresentComplete: Observable<boolean>;
  83093. /**
  83094. * Observable signaled when VR request present starts
  83095. */
  83096. onVRRequestPresentStart: Observable<Engine>;
  83097. /**
  83098. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83099. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83100. */
  83101. isInVRExclusivePointerMode: boolean;
  83102. /**
  83103. * Gets a boolean indicating if a webVR device was detected
  83104. * @returns true if a webVR device was detected
  83105. */
  83106. isVRDevicePresent(): boolean;
  83107. /**
  83108. * Gets the current webVR device
  83109. * @returns the current webVR device (or null)
  83110. */
  83111. getVRDevice(): any;
  83112. /**
  83113. * Initializes a webVR display and starts listening to display change events
  83114. * The onVRDisplayChangedObservable will be notified upon these changes
  83115. * @returns A promise containing a VRDisplay and if vr is supported
  83116. */
  83117. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83118. /** @hidden */
  83119. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83120. /**
  83121. * Gets or sets the presentation attributes used to configure VR rendering
  83122. */
  83123. vrPresentationAttributes?: IVRPresentationAttributes;
  83124. /**
  83125. * Call this function to switch to webVR mode
  83126. * Will do nothing if webVR is not supported or if there is no webVR device
  83127. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83128. */
  83129. enableVR(): void;
  83130. /** @hidden */
  83131. _onVRFullScreenTriggered(): void;
  83132. }
  83133. }
  83134. declare module BABYLON {
  83135. /**
  83136. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83137. * IMPORTANT!! The data is right-hand data.
  83138. * @export
  83139. * @interface DevicePose
  83140. */
  83141. export interface DevicePose {
  83142. /**
  83143. * The position of the device, values in array are [x,y,z].
  83144. */
  83145. readonly position: Nullable<Float32Array>;
  83146. /**
  83147. * The linearVelocity of the device, values in array are [x,y,z].
  83148. */
  83149. readonly linearVelocity: Nullable<Float32Array>;
  83150. /**
  83151. * The linearAcceleration of the device, values in array are [x,y,z].
  83152. */
  83153. readonly linearAcceleration: Nullable<Float32Array>;
  83154. /**
  83155. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83156. */
  83157. readonly orientation: Nullable<Float32Array>;
  83158. /**
  83159. * The angularVelocity of the device, values in array are [x,y,z].
  83160. */
  83161. readonly angularVelocity: Nullable<Float32Array>;
  83162. /**
  83163. * The angularAcceleration of the device, values in array are [x,y,z].
  83164. */
  83165. readonly angularAcceleration: Nullable<Float32Array>;
  83166. }
  83167. /**
  83168. * Interface representing a pose controlled object in Babylon.
  83169. * A pose controlled object has both regular pose values as well as pose values
  83170. * from an external device such as a VR head mounted display
  83171. */
  83172. export interface PoseControlled {
  83173. /**
  83174. * The position of the object in babylon space.
  83175. */
  83176. position: Vector3;
  83177. /**
  83178. * The rotation quaternion of the object in babylon space.
  83179. */
  83180. rotationQuaternion: Quaternion;
  83181. /**
  83182. * The position of the device in babylon space.
  83183. */
  83184. devicePosition?: Vector3;
  83185. /**
  83186. * The rotation quaternion of the device in babylon space.
  83187. */
  83188. deviceRotationQuaternion: Quaternion;
  83189. /**
  83190. * The raw pose coming from the device.
  83191. */
  83192. rawPose: Nullable<DevicePose>;
  83193. /**
  83194. * The scale of the device to be used when translating from device space to babylon space.
  83195. */
  83196. deviceScaleFactor: number;
  83197. /**
  83198. * Updates the poseControlled values based on the input device pose.
  83199. * @param poseData the pose data to update the object with
  83200. */
  83201. updateFromDevice(poseData: DevicePose): void;
  83202. }
  83203. /**
  83204. * Set of options to customize the webVRCamera
  83205. */
  83206. export interface WebVROptions {
  83207. /**
  83208. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83209. */
  83210. trackPosition?: boolean;
  83211. /**
  83212. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83213. */
  83214. positionScale?: number;
  83215. /**
  83216. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83217. */
  83218. displayName?: string;
  83219. /**
  83220. * Should the native controller meshes be initialized. (default: true)
  83221. */
  83222. controllerMeshes?: boolean;
  83223. /**
  83224. * Creating a default HemiLight only on controllers. (default: true)
  83225. */
  83226. defaultLightingOnControllers?: boolean;
  83227. /**
  83228. * If you don't want to use the default VR button of the helper. (default: false)
  83229. */
  83230. useCustomVRButton?: boolean;
  83231. /**
  83232. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83233. */
  83234. customVRButton?: HTMLButtonElement;
  83235. /**
  83236. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83237. */
  83238. rayLength?: number;
  83239. /**
  83240. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83241. */
  83242. defaultHeight?: number;
  83243. /**
  83244. * If multiview should be used if availible (default: false)
  83245. */
  83246. useMultiview?: boolean;
  83247. }
  83248. /**
  83249. * This represents a WebVR camera.
  83250. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83251. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83252. */
  83253. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83254. private webVROptions;
  83255. /**
  83256. * @hidden
  83257. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83258. */
  83259. _vrDevice: any;
  83260. /**
  83261. * The rawPose of the vrDevice.
  83262. */
  83263. rawPose: Nullable<DevicePose>;
  83264. private _onVREnabled;
  83265. private _specsVersion;
  83266. private _attached;
  83267. private _frameData;
  83268. protected _descendants: Array<Node>;
  83269. private _deviceRoomPosition;
  83270. /** @hidden */
  83271. _deviceRoomRotationQuaternion: Quaternion;
  83272. private _standingMatrix;
  83273. /**
  83274. * Represents device position in babylon space.
  83275. */
  83276. devicePosition: Vector3;
  83277. /**
  83278. * Represents device rotation in babylon space.
  83279. */
  83280. deviceRotationQuaternion: Quaternion;
  83281. /**
  83282. * The scale of the device to be used when translating from device space to babylon space.
  83283. */
  83284. deviceScaleFactor: number;
  83285. private _deviceToWorld;
  83286. private _worldToDevice;
  83287. /**
  83288. * References to the webVR controllers for the vrDevice.
  83289. */
  83290. controllers: Array<WebVRController>;
  83291. /**
  83292. * Emits an event when a controller is attached.
  83293. */
  83294. onControllersAttachedObservable: Observable<WebVRController[]>;
  83295. /**
  83296. * Emits an event when a controller's mesh has been loaded;
  83297. */
  83298. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83299. /**
  83300. * Emits an event when the HMD's pose has been updated.
  83301. */
  83302. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83303. private _poseSet;
  83304. /**
  83305. * If the rig cameras be used as parent instead of this camera.
  83306. */
  83307. rigParenting: boolean;
  83308. private _lightOnControllers;
  83309. private _defaultHeight?;
  83310. /**
  83311. * Instantiates a WebVRFreeCamera.
  83312. * @param name The name of the WebVRFreeCamera
  83313. * @param position The starting anchor position for the camera
  83314. * @param scene The scene the camera belongs to
  83315. * @param webVROptions a set of customizable options for the webVRCamera
  83316. */
  83317. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83318. /**
  83319. * Gets the device distance from the ground in meters.
  83320. * @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.
  83321. */
  83322. deviceDistanceToRoomGround(): number;
  83323. /**
  83324. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83325. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83326. */
  83327. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83328. /**
  83329. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83330. * @returns A promise with a boolean set to if the standing matrix is supported.
  83331. */
  83332. useStandingMatrixAsync(): Promise<boolean>;
  83333. /**
  83334. * Disposes the camera
  83335. */
  83336. dispose(): void;
  83337. /**
  83338. * Gets a vrController by name.
  83339. * @param name The name of the controller to retreive
  83340. * @returns the controller matching the name specified or null if not found
  83341. */
  83342. getControllerByName(name: string): Nullable<WebVRController>;
  83343. private _leftController;
  83344. /**
  83345. * The controller corresponding to the users left hand.
  83346. */
  83347. readonly leftController: Nullable<WebVRController>;
  83348. private _rightController;
  83349. /**
  83350. * The controller corresponding to the users right hand.
  83351. */
  83352. readonly rightController: Nullable<WebVRController>;
  83353. /**
  83354. * Casts a ray forward from the vrCamera's gaze.
  83355. * @param length Length of the ray (default: 100)
  83356. * @returns the ray corresponding to the gaze
  83357. */
  83358. getForwardRay(length?: number): Ray;
  83359. /**
  83360. * @hidden
  83361. * Updates the camera based on device's frame data
  83362. */
  83363. _checkInputs(): void;
  83364. /**
  83365. * Updates the poseControlled values based on the input device pose.
  83366. * @param poseData Pose coming from the device
  83367. */
  83368. updateFromDevice(poseData: DevicePose): void;
  83369. private _htmlElementAttached;
  83370. private _detachIfAttached;
  83371. /**
  83372. * WebVR's attach control will start broadcasting frames to the device.
  83373. * Note that in certain browsers (chrome for example) this function must be called
  83374. * within a user-interaction callback. Example:
  83375. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83376. *
  83377. * @param element html element to attach the vrDevice to
  83378. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83379. */
  83380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83381. /**
  83382. * Detaches the camera from the html element and disables VR
  83383. *
  83384. * @param element html element to detach from
  83385. */
  83386. detachControl(element: HTMLElement): void;
  83387. /**
  83388. * @returns the name of this class
  83389. */
  83390. getClassName(): string;
  83391. /**
  83392. * Calls resetPose on the vrDisplay
  83393. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83394. */
  83395. resetToCurrentRotation(): void;
  83396. /**
  83397. * @hidden
  83398. * Updates the rig cameras (left and right eye)
  83399. */
  83400. _updateRigCameras(): void;
  83401. private _workingVector;
  83402. private _oneVector;
  83403. private _workingMatrix;
  83404. private updateCacheCalled;
  83405. private _correctPositionIfNotTrackPosition;
  83406. /**
  83407. * @hidden
  83408. * Updates the cached values of the camera
  83409. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83410. */
  83411. _updateCache(ignoreParentClass?: boolean): void;
  83412. /**
  83413. * @hidden
  83414. * Get current device position in babylon world
  83415. */
  83416. _computeDevicePosition(): void;
  83417. /**
  83418. * Updates the current device position and rotation in the babylon world
  83419. */
  83420. update(): void;
  83421. /**
  83422. * @hidden
  83423. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83424. * @returns an identity matrix
  83425. */
  83426. _getViewMatrix(): Matrix;
  83427. private _tmpMatrix;
  83428. /**
  83429. * This function is called by the two RIG cameras.
  83430. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83431. * @hidden
  83432. */
  83433. _getWebVRViewMatrix(): Matrix;
  83434. /** @hidden */
  83435. _getWebVRProjectionMatrix(): Matrix;
  83436. private _onGamepadConnectedObserver;
  83437. private _onGamepadDisconnectedObserver;
  83438. private _updateCacheWhenTrackingDisabledObserver;
  83439. /**
  83440. * Initializes the controllers and their meshes
  83441. */
  83442. initControllers(): void;
  83443. }
  83444. }
  83445. declare module BABYLON {
  83446. /**
  83447. * Size options for a post process
  83448. */
  83449. export type PostProcessOptions = {
  83450. width: number;
  83451. height: number;
  83452. };
  83453. /**
  83454. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83455. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83456. */
  83457. export class PostProcess {
  83458. /** Name of the PostProcess. */
  83459. name: string;
  83460. /**
  83461. * Gets or sets the unique id of the post process
  83462. */
  83463. uniqueId: number;
  83464. /**
  83465. * Width of the texture to apply the post process on
  83466. */
  83467. width: number;
  83468. /**
  83469. * Height of the texture to apply the post process on
  83470. */
  83471. height: number;
  83472. /**
  83473. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83474. * @hidden
  83475. */
  83476. _outputTexture: Nullable<InternalTexture>;
  83477. /**
  83478. * Sampling mode used by the shader
  83479. * See https://doc.babylonjs.com/classes/3.1/texture
  83480. */
  83481. renderTargetSamplingMode: number;
  83482. /**
  83483. * Clear color to use when screen clearing
  83484. */
  83485. clearColor: Color4;
  83486. /**
  83487. * If the buffer needs to be cleared before applying the post process. (default: true)
  83488. * Should be set to false if shader will overwrite all previous pixels.
  83489. */
  83490. autoClear: boolean;
  83491. /**
  83492. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83493. */
  83494. alphaMode: number;
  83495. /**
  83496. * Sets the setAlphaBlendConstants of the babylon engine
  83497. */
  83498. alphaConstants: Color4;
  83499. /**
  83500. * Animations to be used for the post processing
  83501. */
  83502. animations: Animation[];
  83503. /**
  83504. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83505. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83506. */
  83507. enablePixelPerfectMode: boolean;
  83508. /**
  83509. * Force the postprocess to be applied without taking in account viewport
  83510. */
  83511. forceFullscreenViewport: boolean;
  83512. /**
  83513. * List of inspectable custom properties (used by the Inspector)
  83514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83515. */
  83516. inspectableCustomProperties: IInspectable[];
  83517. /**
  83518. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83519. *
  83520. * | Value | Type | Description |
  83521. * | ----- | ----------------------------------- | ----------- |
  83522. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83523. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83524. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83525. *
  83526. */
  83527. scaleMode: number;
  83528. /**
  83529. * Force textures to be a power of two (default: false)
  83530. */
  83531. alwaysForcePOT: boolean;
  83532. private _samples;
  83533. /**
  83534. * Number of sample textures (default: 1)
  83535. */
  83536. samples: number;
  83537. /**
  83538. * Modify the scale of the post process to be the same as the viewport (default: false)
  83539. */
  83540. adaptScaleToCurrentViewport: boolean;
  83541. private _camera;
  83542. private _scene;
  83543. private _engine;
  83544. private _options;
  83545. private _reusable;
  83546. private _textureType;
  83547. /**
  83548. * Smart array of input and output textures for the post process.
  83549. * @hidden
  83550. */
  83551. _textures: SmartArray<InternalTexture>;
  83552. /**
  83553. * The index in _textures that corresponds to the output texture.
  83554. * @hidden
  83555. */
  83556. _currentRenderTextureInd: number;
  83557. private _effect;
  83558. private _samplers;
  83559. private _fragmentUrl;
  83560. private _vertexUrl;
  83561. private _parameters;
  83562. private _scaleRatio;
  83563. protected _indexParameters: any;
  83564. private _shareOutputWithPostProcess;
  83565. private _texelSize;
  83566. private _forcedOutputTexture;
  83567. /**
  83568. * Returns the fragment url or shader name used in the post process.
  83569. * @returns the fragment url or name in the shader store.
  83570. */
  83571. getEffectName(): string;
  83572. /**
  83573. * An event triggered when the postprocess is activated.
  83574. */
  83575. onActivateObservable: Observable<Camera>;
  83576. private _onActivateObserver;
  83577. /**
  83578. * A function that is added to the onActivateObservable
  83579. */
  83580. onActivate: Nullable<(camera: Camera) => void>;
  83581. /**
  83582. * An event triggered when the postprocess changes its size.
  83583. */
  83584. onSizeChangedObservable: Observable<PostProcess>;
  83585. private _onSizeChangedObserver;
  83586. /**
  83587. * A function that is added to the onSizeChangedObservable
  83588. */
  83589. onSizeChanged: (postProcess: PostProcess) => void;
  83590. /**
  83591. * An event triggered when the postprocess applies its effect.
  83592. */
  83593. onApplyObservable: Observable<Effect>;
  83594. private _onApplyObserver;
  83595. /**
  83596. * A function that is added to the onApplyObservable
  83597. */
  83598. onApply: (effect: Effect) => void;
  83599. /**
  83600. * An event triggered before rendering the postprocess
  83601. */
  83602. onBeforeRenderObservable: Observable<Effect>;
  83603. private _onBeforeRenderObserver;
  83604. /**
  83605. * A function that is added to the onBeforeRenderObservable
  83606. */
  83607. onBeforeRender: (effect: Effect) => void;
  83608. /**
  83609. * An event triggered after rendering the postprocess
  83610. */
  83611. onAfterRenderObservable: Observable<Effect>;
  83612. private _onAfterRenderObserver;
  83613. /**
  83614. * A function that is added to the onAfterRenderObservable
  83615. */
  83616. onAfterRender: (efect: Effect) => void;
  83617. /**
  83618. * 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
  83619. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83620. */
  83621. inputTexture: InternalTexture;
  83622. /**
  83623. * Gets the camera which post process is applied to.
  83624. * @returns The camera the post process is applied to.
  83625. */
  83626. getCamera(): Camera;
  83627. /**
  83628. * Gets the texel size of the postprocess.
  83629. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83630. */
  83631. readonly texelSize: Vector2;
  83632. /**
  83633. * Creates a new instance PostProcess
  83634. * @param name The name of the PostProcess.
  83635. * @param fragmentUrl The url of the fragment shader to be used.
  83636. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83637. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83638. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83639. * @param camera The camera to apply the render pass to.
  83640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83641. * @param engine The engine which the post process will be applied. (default: current engine)
  83642. * @param reusable If the post process can be reused on the same frame. (default: false)
  83643. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83644. * @param textureType Type of textures used when performing the post process. (default: 0)
  83645. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83646. * @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
  83647. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83648. */
  83649. constructor(
  83650. /** Name of the PostProcess. */
  83651. 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);
  83652. /**
  83653. * Gets a string idenfifying the name of the class
  83654. * @returns "PostProcess" string
  83655. */
  83656. getClassName(): string;
  83657. /**
  83658. * Gets the engine which this post process belongs to.
  83659. * @returns The engine the post process was enabled with.
  83660. */
  83661. getEngine(): Engine;
  83662. /**
  83663. * The effect that is created when initializing the post process.
  83664. * @returns The created effect corresponding the the postprocess.
  83665. */
  83666. getEffect(): Effect;
  83667. /**
  83668. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83669. * @param postProcess The post process to share the output with.
  83670. * @returns This post process.
  83671. */
  83672. shareOutputWith(postProcess: PostProcess): PostProcess;
  83673. /**
  83674. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83675. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83676. */
  83677. useOwnOutput(): void;
  83678. /**
  83679. * Updates the effect with the current post process compile time values and recompiles the shader.
  83680. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83681. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83682. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83683. * @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
  83684. * @param onCompiled Called when the shader has been compiled.
  83685. * @param onError Called if there is an error when compiling a shader.
  83686. */
  83687. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83688. /**
  83689. * The post process is reusable if it can be used multiple times within one frame.
  83690. * @returns If the post process is reusable
  83691. */
  83692. isReusable(): boolean;
  83693. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83694. markTextureDirty(): void;
  83695. /**
  83696. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83697. * 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.
  83698. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83699. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83700. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83701. * @returns The target texture that was bound to be written to.
  83702. */
  83703. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83704. /**
  83705. * If the post process is supported.
  83706. */
  83707. readonly isSupported: boolean;
  83708. /**
  83709. * The aspect ratio of the output texture.
  83710. */
  83711. readonly aspectRatio: number;
  83712. /**
  83713. * Get a value indicating if the post-process is ready to be used
  83714. * @returns true if the post-process is ready (shader is compiled)
  83715. */
  83716. isReady(): boolean;
  83717. /**
  83718. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83719. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83720. */
  83721. apply(): Nullable<Effect>;
  83722. private _disposeTextures;
  83723. /**
  83724. * Disposes the post process.
  83725. * @param camera The camera to dispose the post process on.
  83726. */
  83727. dispose(camera?: Camera): void;
  83728. }
  83729. }
  83730. declare module BABYLON {
  83731. /** @hidden */
  83732. export var kernelBlurVaryingDeclaration: {
  83733. name: string;
  83734. shader: string;
  83735. };
  83736. }
  83737. declare module BABYLON {
  83738. /** @hidden */
  83739. export var kernelBlurFragment: {
  83740. name: string;
  83741. shader: string;
  83742. };
  83743. }
  83744. declare module BABYLON {
  83745. /** @hidden */
  83746. export var kernelBlurFragment2: {
  83747. name: string;
  83748. shader: string;
  83749. };
  83750. }
  83751. declare module BABYLON {
  83752. /** @hidden */
  83753. export var kernelBlurPixelShader: {
  83754. name: string;
  83755. shader: string;
  83756. };
  83757. }
  83758. declare module BABYLON {
  83759. /** @hidden */
  83760. export var kernelBlurVertex: {
  83761. name: string;
  83762. shader: string;
  83763. };
  83764. }
  83765. declare module BABYLON {
  83766. /** @hidden */
  83767. export var kernelBlurVertexShader: {
  83768. name: string;
  83769. shader: string;
  83770. };
  83771. }
  83772. declare module BABYLON {
  83773. /**
  83774. * The Blur Post Process which blurs an image based on a kernel and direction.
  83775. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83776. */
  83777. export class BlurPostProcess extends PostProcess {
  83778. /** The direction in which to blur the image. */
  83779. direction: Vector2;
  83780. private blockCompilation;
  83781. protected _kernel: number;
  83782. protected _idealKernel: number;
  83783. protected _packedFloat: boolean;
  83784. private _staticDefines;
  83785. /**
  83786. * Sets the length in pixels of the blur sample region
  83787. */
  83788. /**
  83789. * Gets the length in pixels of the blur sample region
  83790. */
  83791. kernel: number;
  83792. /**
  83793. * Sets wether or not the blur needs to unpack/repack floats
  83794. */
  83795. /**
  83796. * Gets wether or not the blur is unpacking/repacking floats
  83797. */
  83798. packedFloat: boolean;
  83799. /**
  83800. * Creates a new instance BlurPostProcess
  83801. * @param name The name of the effect.
  83802. * @param direction The direction in which to blur the image.
  83803. * @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.
  83804. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83805. * @param camera The camera to apply the render pass to.
  83806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83807. * @param engine The engine which the post process will be applied. (default: current engine)
  83808. * @param reusable If the post process can be reused on the same frame. (default: false)
  83809. * @param textureType Type of textures used when performing the post process. (default: 0)
  83810. * @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)
  83811. */
  83812. constructor(name: string,
  83813. /** The direction in which to blur the image. */
  83814. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83815. /**
  83816. * Updates the effect with the current post process compile time values and recompiles the shader.
  83817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83820. * @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
  83821. * @param onCompiled Called when the shader has been compiled.
  83822. * @param onError Called if there is an error when compiling a shader.
  83823. */
  83824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83825. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83826. /**
  83827. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83828. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83829. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83830. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83831. * The gaps between physical kernels are compensated for in the weighting of the samples
  83832. * @param idealKernel Ideal blur kernel.
  83833. * @return Nearest best kernel.
  83834. */
  83835. protected _nearestBestKernel(idealKernel: number): number;
  83836. /**
  83837. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83838. * @param x The point on the Gaussian distribution to sample.
  83839. * @return the value of the Gaussian function at x.
  83840. */
  83841. protected _gaussianWeight(x: number): number;
  83842. /**
  83843. * Generates a string that can be used as a floating point number in GLSL.
  83844. * @param x Value to print.
  83845. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83846. * @return GLSL float string.
  83847. */
  83848. protected _glslFloat(x: number, decimalFigures?: number): string;
  83849. }
  83850. }
  83851. declare module BABYLON {
  83852. /**
  83853. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83854. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83855. * You can then easily use it as a reflectionTexture on a flat surface.
  83856. * In case the surface is not a plane, please consider relying on reflection probes.
  83857. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83858. */
  83859. export class MirrorTexture extends RenderTargetTexture {
  83860. private scene;
  83861. /**
  83862. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83863. * 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.
  83864. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83865. */
  83866. mirrorPlane: Plane;
  83867. /**
  83868. * Define the blur ratio used to blur the reflection if needed.
  83869. */
  83870. blurRatio: number;
  83871. /**
  83872. * Define the adaptive blur kernel used to blur the reflection if needed.
  83873. * This will autocompute the closest best match for the `blurKernel`
  83874. */
  83875. adaptiveBlurKernel: number;
  83876. /**
  83877. * Define the blur kernel used to blur the reflection if needed.
  83878. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83879. */
  83880. blurKernel: number;
  83881. /**
  83882. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83883. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83884. */
  83885. blurKernelX: number;
  83886. /**
  83887. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83888. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83889. */
  83890. blurKernelY: number;
  83891. private _autoComputeBlurKernel;
  83892. protected _onRatioRescale(): void;
  83893. private _updateGammaSpace;
  83894. private _imageProcessingConfigChangeObserver;
  83895. private _transformMatrix;
  83896. private _mirrorMatrix;
  83897. private _savedViewMatrix;
  83898. private _blurX;
  83899. private _blurY;
  83900. private _adaptiveBlurKernel;
  83901. private _blurKernelX;
  83902. private _blurKernelY;
  83903. private _blurRatio;
  83904. /**
  83905. * Instantiates a Mirror Texture.
  83906. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83907. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83908. * You can then easily use it as a reflectionTexture on a flat surface.
  83909. * In case the surface is not a plane, please consider relying on reflection probes.
  83910. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83911. * @param name
  83912. * @param size
  83913. * @param scene
  83914. * @param generateMipMaps
  83915. * @param type
  83916. * @param samplingMode
  83917. * @param generateDepthBuffer
  83918. */
  83919. constructor(name: string, size: number | {
  83920. width: number;
  83921. height: number;
  83922. } | {
  83923. ratio: number;
  83924. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83925. private _preparePostProcesses;
  83926. /**
  83927. * Clone the mirror texture.
  83928. * @returns the cloned texture
  83929. */
  83930. clone(): MirrorTexture;
  83931. /**
  83932. * Serialize the texture to a JSON representation you could use in Parse later on
  83933. * @returns the serialized JSON representation
  83934. */
  83935. serialize(): any;
  83936. /**
  83937. * Dispose the texture and release its associated resources.
  83938. */
  83939. dispose(): void;
  83940. }
  83941. }
  83942. declare module BABYLON {
  83943. /**
  83944. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83945. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83946. */
  83947. export class Texture extends BaseTexture {
  83948. /**
  83949. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83950. */
  83951. static SerializeBuffers: boolean;
  83952. /** @hidden */
  83953. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83954. /** @hidden */
  83955. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83956. /** @hidden */
  83957. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83958. /** nearest is mag = nearest and min = nearest and mip = linear */
  83959. static readonly NEAREST_SAMPLINGMODE: number;
  83960. /** nearest is mag = nearest and min = nearest and mip = linear */
  83961. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83962. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83963. static readonly BILINEAR_SAMPLINGMODE: number;
  83964. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83965. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83966. /** Trilinear is mag = linear and min = linear and mip = linear */
  83967. static readonly TRILINEAR_SAMPLINGMODE: number;
  83968. /** Trilinear is mag = linear and min = linear and mip = linear */
  83969. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83970. /** mag = nearest and min = nearest and mip = nearest */
  83971. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83972. /** mag = nearest and min = linear and mip = nearest */
  83973. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83974. /** mag = nearest and min = linear and mip = linear */
  83975. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83976. /** mag = nearest and min = linear and mip = none */
  83977. static readonly NEAREST_LINEAR: number;
  83978. /** mag = nearest and min = nearest and mip = none */
  83979. static readonly NEAREST_NEAREST: number;
  83980. /** mag = linear and min = nearest and mip = nearest */
  83981. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83982. /** mag = linear and min = nearest and mip = linear */
  83983. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83984. /** mag = linear and min = linear and mip = none */
  83985. static readonly LINEAR_LINEAR: number;
  83986. /** mag = linear and min = nearest and mip = none */
  83987. static readonly LINEAR_NEAREST: number;
  83988. /** Explicit coordinates mode */
  83989. static readonly EXPLICIT_MODE: number;
  83990. /** Spherical coordinates mode */
  83991. static readonly SPHERICAL_MODE: number;
  83992. /** Planar coordinates mode */
  83993. static readonly PLANAR_MODE: number;
  83994. /** Cubic coordinates mode */
  83995. static readonly CUBIC_MODE: number;
  83996. /** Projection coordinates mode */
  83997. static readonly PROJECTION_MODE: number;
  83998. /** Inverse Cubic coordinates mode */
  83999. static readonly SKYBOX_MODE: number;
  84000. /** Inverse Cubic coordinates mode */
  84001. static readonly INVCUBIC_MODE: number;
  84002. /** Equirectangular coordinates mode */
  84003. static readonly EQUIRECTANGULAR_MODE: number;
  84004. /** Equirectangular Fixed coordinates mode */
  84005. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84006. /** Equirectangular Fixed Mirrored coordinates mode */
  84007. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84008. /** Texture is not repeating outside of 0..1 UVs */
  84009. static readonly CLAMP_ADDRESSMODE: number;
  84010. /** Texture is repeating outside of 0..1 UVs */
  84011. static readonly WRAP_ADDRESSMODE: number;
  84012. /** Texture is repeating and mirrored */
  84013. static readonly MIRROR_ADDRESSMODE: number;
  84014. /**
  84015. * 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
  84016. */
  84017. static UseSerializedUrlIfAny: boolean;
  84018. /**
  84019. * Define the url of the texture.
  84020. */
  84021. url: Nullable<string>;
  84022. /**
  84023. * Define an offset on the texture to offset the u coordinates of the UVs
  84024. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84025. */
  84026. uOffset: number;
  84027. /**
  84028. * Define an offset on the texture to offset the v coordinates of the UVs
  84029. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84030. */
  84031. vOffset: number;
  84032. /**
  84033. * Define an offset on the texture to scale the u coordinates of the UVs
  84034. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84035. */
  84036. uScale: number;
  84037. /**
  84038. * Define an offset on the texture to scale the v coordinates of the UVs
  84039. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84040. */
  84041. vScale: number;
  84042. /**
  84043. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84044. * @see http://doc.babylonjs.com/how_to/more_materials
  84045. */
  84046. uAng: number;
  84047. /**
  84048. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84049. * @see http://doc.babylonjs.com/how_to/more_materials
  84050. */
  84051. vAng: number;
  84052. /**
  84053. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84054. * @see http://doc.babylonjs.com/how_to/more_materials
  84055. */
  84056. wAng: number;
  84057. /**
  84058. * Defines the center of rotation (U)
  84059. */
  84060. uRotationCenter: number;
  84061. /**
  84062. * Defines the center of rotation (V)
  84063. */
  84064. vRotationCenter: number;
  84065. /**
  84066. * Defines the center of rotation (W)
  84067. */
  84068. wRotationCenter: number;
  84069. /**
  84070. * Are mip maps generated for this texture or not.
  84071. */
  84072. readonly noMipmap: boolean;
  84073. /**
  84074. * List of inspectable custom properties (used by the Inspector)
  84075. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84076. */
  84077. inspectableCustomProperties: Nullable<IInspectable[]>;
  84078. private _noMipmap;
  84079. /** @hidden */
  84080. _invertY: boolean;
  84081. private _rowGenerationMatrix;
  84082. private _cachedTextureMatrix;
  84083. private _projectionModeMatrix;
  84084. private _t0;
  84085. private _t1;
  84086. private _t2;
  84087. private _cachedUOffset;
  84088. private _cachedVOffset;
  84089. private _cachedUScale;
  84090. private _cachedVScale;
  84091. private _cachedUAng;
  84092. private _cachedVAng;
  84093. private _cachedWAng;
  84094. private _cachedProjectionMatrixId;
  84095. private _cachedCoordinatesMode;
  84096. /** @hidden */
  84097. protected _initialSamplingMode: number;
  84098. /** @hidden */
  84099. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84100. private _deleteBuffer;
  84101. protected _format: Nullable<number>;
  84102. private _delayedOnLoad;
  84103. private _delayedOnError;
  84104. private _mimeType?;
  84105. /**
  84106. * Observable triggered once the texture has been loaded.
  84107. */
  84108. onLoadObservable: Observable<Texture>;
  84109. protected _isBlocking: boolean;
  84110. /**
  84111. * Is the texture preventing material to render while loading.
  84112. * If false, a default texture will be used instead of the loading one during the preparation step.
  84113. */
  84114. isBlocking: boolean;
  84115. /**
  84116. * Get the current sampling mode associated with the texture.
  84117. */
  84118. readonly samplingMode: number;
  84119. /**
  84120. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84121. */
  84122. readonly invertY: boolean;
  84123. /**
  84124. * Instantiates a new texture.
  84125. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84126. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84127. * @param url defines the url of the picture to load as a texture
  84128. * @param scene defines the scene or engine the texture will belong to
  84129. * @param noMipmap defines if the texture will require mip maps or not
  84130. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84131. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84132. * @param onLoad defines a callback triggered when the texture has been loaded
  84133. * @param onError defines a callback triggered when an error occurred during the loading session
  84134. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84135. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84136. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84137. * @param mimeType defines an optional mime type information
  84138. */
  84139. 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);
  84140. /**
  84141. * Update the url (and optional buffer) of this texture if url was null during construction.
  84142. * @param url the url of the texture
  84143. * @param buffer the buffer of the texture (defaults to null)
  84144. * @param onLoad callback called when the texture is loaded (defaults to null)
  84145. */
  84146. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84147. /**
  84148. * Finish the loading sequence of a texture flagged as delayed load.
  84149. * @hidden
  84150. */
  84151. delayLoad(): void;
  84152. private _prepareRowForTextureGeneration;
  84153. /**
  84154. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84155. * @returns the transform matrix of the texture.
  84156. */
  84157. getTextureMatrix(): Matrix;
  84158. /**
  84159. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84160. * @returns The reflection texture transform
  84161. */
  84162. getReflectionTextureMatrix(): Matrix;
  84163. /**
  84164. * Clones the texture.
  84165. * @returns the cloned texture
  84166. */
  84167. clone(): Texture;
  84168. /**
  84169. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84170. * @returns The JSON representation of the texture
  84171. */
  84172. serialize(): any;
  84173. /**
  84174. * Get the current class name of the texture useful for serialization or dynamic coding.
  84175. * @returns "Texture"
  84176. */
  84177. getClassName(): string;
  84178. /**
  84179. * Dispose the texture and release its associated resources.
  84180. */
  84181. dispose(): void;
  84182. /**
  84183. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84184. * @param parsedTexture Define the JSON representation of the texture
  84185. * @param scene Define the scene the parsed texture should be instantiated in
  84186. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84187. * @returns The parsed texture if successful
  84188. */
  84189. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84190. /**
  84191. * Creates a texture from its base 64 representation.
  84192. * @param data Define the base64 payload without the data: prefix
  84193. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84194. * @param scene Define the scene the texture should belong to
  84195. * @param noMipmap Forces the texture to not create mip map information if true
  84196. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84197. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84198. * @param onLoad define a callback triggered when the texture has been loaded
  84199. * @param onError define a callback triggered when an error occurred during the loading session
  84200. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84201. * @returns the created texture
  84202. */
  84203. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84204. /**
  84205. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84206. * @param data Define the base64 payload without the data: prefix
  84207. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84208. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84209. * @param scene Define the scene the texture should belong to
  84210. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84211. * @param noMipmap Forces the texture to not create mip map information if true
  84212. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84213. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84214. * @param onLoad define a callback triggered when the texture has been loaded
  84215. * @param onError define a callback triggered when an error occurred during the loading session
  84216. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84217. * @returns the created texture
  84218. */
  84219. 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;
  84220. }
  84221. }
  84222. declare module BABYLON {
  84223. /**
  84224. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84225. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84226. */
  84227. export class PostProcessManager {
  84228. private _scene;
  84229. private _indexBuffer;
  84230. private _vertexBuffers;
  84231. /**
  84232. * Creates a new instance PostProcess
  84233. * @param scene The scene that the post process is associated with.
  84234. */
  84235. constructor(scene: Scene);
  84236. private _prepareBuffers;
  84237. private _buildIndexBuffer;
  84238. /**
  84239. * Rebuilds the vertex buffers of the manager.
  84240. * @hidden
  84241. */
  84242. _rebuild(): void;
  84243. /**
  84244. * Prepares a frame to be run through a post process.
  84245. * @param sourceTexture The input texture to the post procesess. (default: null)
  84246. * @param postProcesses An array of post processes to be run. (default: null)
  84247. * @returns True if the post processes were able to be run.
  84248. * @hidden
  84249. */
  84250. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84251. /**
  84252. * Manually render a set of post processes to a texture.
  84253. * @param postProcesses An array of post processes to be run.
  84254. * @param targetTexture The target texture to render to.
  84255. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84256. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84257. * @param lodLevel defines which lod of the texture to render to
  84258. */
  84259. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84260. /**
  84261. * Finalize the result of the output of the postprocesses.
  84262. * @param doNotPresent If true the result will not be displayed to the screen.
  84263. * @param targetTexture The target texture to render to.
  84264. * @param faceIndex The index of the face to bind the target texture to.
  84265. * @param postProcesses The array of post processes to render.
  84266. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84267. * @hidden
  84268. */
  84269. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84270. /**
  84271. * Disposes of the post process manager.
  84272. */
  84273. dispose(): void;
  84274. }
  84275. }
  84276. declare module BABYLON {
  84277. /** Interface used by value gradients (color, factor, ...) */
  84278. export interface IValueGradient {
  84279. /**
  84280. * Gets or sets the gradient value (between 0 and 1)
  84281. */
  84282. gradient: number;
  84283. }
  84284. /** Class used to store color4 gradient */
  84285. export class ColorGradient implements IValueGradient {
  84286. /**
  84287. * Gets or sets the gradient value (between 0 and 1)
  84288. */
  84289. gradient: number;
  84290. /**
  84291. * Gets or sets first associated color
  84292. */
  84293. color1: Color4;
  84294. /**
  84295. * Gets or sets second associated color
  84296. */
  84297. color2?: Color4;
  84298. /**
  84299. * Will get a color picked randomly between color1 and color2.
  84300. * If color2 is undefined then color1 will be used
  84301. * @param result defines the target Color4 to store the result in
  84302. */
  84303. getColorToRef(result: Color4): void;
  84304. }
  84305. /** Class used to store color 3 gradient */
  84306. export class Color3Gradient implements IValueGradient {
  84307. /**
  84308. * Gets or sets the gradient value (between 0 and 1)
  84309. */
  84310. gradient: number;
  84311. /**
  84312. * Gets or sets the associated color
  84313. */
  84314. color: Color3;
  84315. }
  84316. /** Class used to store factor gradient */
  84317. export class FactorGradient implements IValueGradient {
  84318. /**
  84319. * Gets or sets the gradient value (between 0 and 1)
  84320. */
  84321. gradient: number;
  84322. /**
  84323. * Gets or sets first associated factor
  84324. */
  84325. factor1: number;
  84326. /**
  84327. * Gets or sets second associated factor
  84328. */
  84329. factor2?: number;
  84330. /**
  84331. * Will get a number picked randomly between factor1 and factor2.
  84332. * If factor2 is undefined then factor1 will be used
  84333. * @returns the picked number
  84334. */
  84335. getFactor(): number;
  84336. }
  84337. /**
  84338. * Helper used to simplify some generic gradient tasks
  84339. */
  84340. export class GradientHelper {
  84341. /**
  84342. * Gets the current gradient from an array of IValueGradient
  84343. * @param ratio defines the current ratio to get
  84344. * @param gradients defines the array of IValueGradient
  84345. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84346. */
  84347. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84348. }
  84349. }
  84350. declare module BABYLON {
  84351. interface ThinEngine {
  84352. /**
  84353. * Creates a dynamic texture
  84354. * @param width defines the width of the texture
  84355. * @param height defines the height of the texture
  84356. * @param generateMipMaps defines if the engine should generate the mip levels
  84357. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84358. * @returns the dynamic texture inside an InternalTexture
  84359. */
  84360. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84361. /**
  84362. * Update the content of a dynamic texture
  84363. * @param texture defines the texture to update
  84364. * @param canvas defines the canvas containing the source
  84365. * @param invertY defines if data must be stored with Y axis inverted
  84366. * @param premulAlpha defines if alpha is stored as premultiplied
  84367. * @param format defines the format of the data
  84368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84369. */
  84370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84371. }
  84372. }
  84373. declare module BABYLON {
  84374. /**
  84375. * Helper class used to generate a canvas to manipulate images
  84376. */
  84377. export class CanvasGenerator {
  84378. /**
  84379. * Create a new canvas (or offscreen canvas depending on the context)
  84380. * @param width defines the expected width
  84381. * @param height defines the expected height
  84382. * @return a new canvas or offscreen canvas
  84383. */
  84384. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84385. }
  84386. }
  84387. declare module BABYLON {
  84388. /**
  84389. * A class extending Texture allowing drawing on a texture
  84390. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84391. */
  84392. export class DynamicTexture extends Texture {
  84393. private _generateMipMaps;
  84394. private _canvas;
  84395. private _context;
  84396. private _engine;
  84397. /**
  84398. * Creates a DynamicTexture
  84399. * @param name defines the name of the texture
  84400. * @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
  84401. * @param scene defines the scene where you want the texture
  84402. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84403. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84404. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84405. */
  84406. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84407. /**
  84408. * Get the current class name of the texture useful for serialization or dynamic coding.
  84409. * @returns "DynamicTexture"
  84410. */
  84411. getClassName(): string;
  84412. /**
  84413. * Gets the current state of canRescale
  84414. */
  84415. readonly canRescale: boolean;
  84416. private _recreate;
  84417. /**
  84418. * Scales the texture
  84419. * @param ratio the scale factor to apply to both width and height
  84420. */
  84421. scale(ratio: number): void;
  84422. /**
  84423. * Resizes the texture
  84424. * @param width the new width
  84425. * @param height the new height
  84426. */
  84427. scaleTo(width: number, height: number): void;
  84428. /**
  84429. * Gets the context of the canvas used by the texture
  84430. * @returns the canvas context of the dynamic texture
  84431. */
  84432. getContext(): CanvasRenderingContext2D;
  84433. /**
  84434. * Clears the texture
  84435. */
  84436. clear(): void;
  84437. /**
  84438. * Updates the texture
  84439. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84440. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84441. */
  84442. update(invertY?: boolean, premulAlpha?: boolean): void;
  84443. /**
  84444. * Draws text onto the texture
  84445. * @param text defines the text to be drawn
  84446. * @param x defines the placement of the text from the left
  84447. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84448. * @param font defines the font to be used with font-style, font-size, font-name
  84449. * @param color defines the color used for the text
  84450. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84451. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84452. * @param update defines whether texture is immediately update (default is true)
  84453. */
  84454. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84455. /**
  84456. * Clones the texture
  84457. * @returns the clone of the texture.
  84458. */
  84459. clone(): DynamicTexture;
  84460. /**
  84461. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84462. * @returns a serialized dynamic texture object
  84463. */
  84464. serialize(): any;
  84465. /** @hidden */
  84466. _rebuild(): void;
  84467. }
  84468. }
  84469. declare module BABYLON {
  84470. interface AbstractScene {
  84471. /**
  84472. * The list of procedural textures added to the scene
  84473. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84474. */
  84475. proceduralTextures: Array<ProceduralTexture>;
  84476. }
  84477. /**
  84478. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84479. * in a given scene.
  84480. */
  84481. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84482. /**
  84483. * The component name helpfull to identify the component in the list of scene components.
  84484. */
  84485. readonly name: string;
  84486. /**
  84487. * The scene the component belongs to.
  84488. */
  84489. scene: Scene;
  84490. /**
  84491. * Creates a new instance of the component for the given scene
  84492. * @param scene Defines the scene to register the component in
  84493. */
  84494. constructor(scene: Scene);
  84495. /**
  84496. * Registers the component in a given scene
  84497. */
  84498. register(): void;
  84499. /**
  84500. * Rebuilds the elements related to this component in case of
  84501. * context lost for instance.
  84502. */
  84503. rebuild(): void;
  84504. /**
  84505. * Disposes the component and the associated ressources.
  84506. */
  84507. dispose(): void;
  84508. private _beforeClear;
  84509. }
  84510. }
  84511. declare module BABYLON {
  84512. interface ThinEngine {
  84513. /**
  84514. * Creates a new render target cube texture
  84515. * @param size defines the size of the texture
  84516. * @param options defines the options used to create the texture
  84517. * @returns a new render target cube texture stored in an InternalTexture
  84518. */
  84519. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84520. }
  84521. }
  84522. declare module BABYLON {
  84523. /** @hidden */
  84524. export var proceduralVertexShader: {
  84525. name: string;
  84526. shader: string;
  84527. };
  84528. }
  84529. declare module BABYLON {
  84530. /**
  84531. * 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.
  84532. * This is the base class of any Procedural texture and contains most of the shareable code.
  84533. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84534. */
  84535. export class ProceduralTexture extends Texture {
  84536. isCube: boolean;
  84537. /**
  84538. * Define if the texture is enabled or not (disabled texture will not render)
  84539. */
  84540. isEnabled: boolean;
  84541. /**
  84542. * Define if the texture must be cleared before rendering (default is true)
  84543. */
  84544. autoClear: boolean;
  84545. /**
  84546. * Callback called when the texture is generated
  84547. */
  84548. onGenerated: () => void;
  84549. /**
  84550. * Event raised when the texture is generated
  84551. */
  84552. onGeneratedObservable: Observable<ProceduralTexture>;
  84553. /** @hidden */
  84554. _generateMipMaps: boolean;
  84555. /** @hidden **/
  84556. _effect: Effect;
  84557. /** @hidden */
  84558. _textures: {
  84559. [key: string]: Texture;
  84560. };
  84561. private _size;
  84562. private _currentRefreshId;
  84563. private _refreshRate;
  84564. private _vertexBuffers;
  84565. private _indexBuffer;
  84566. private _uniforms;
  84567. private _samplers;
  84568. private _fragment;
  84569. private _floats;
  84570. private _ints;
  84571. private _floatsArrays;
  84572. private _colors3;
  84573. private _colors4;
  84574. private _vectors2;
  84575. private _vectors3;
  84576. private _matrices;
  84577. private _fallbackTexture;
  84578. private _fallbackTextureUsed;
  84579. private _engine;
  84580. private _cachedDefines;
  84581. private _contentUpdateId;
  84582. private _contentData;
  84583. /**
  84584. * Instantiates a new procedural texture.
  84585. * 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.
  84586. * This is the base class of any Procedural texture and contains most of the shareable code.
  84587. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84588. * @param name Define the name of the texture
  84589. * @param size Define the size of the texture to create
  84590. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84591. * @param scene Define the scene the texture belongs to
  84592. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84593. * @param generateMipMaps Define if the texture should creates mip maps or not
  84594. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84595. */
  84596. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84597. /**
  84598. * The effect that is created when initializing the post process.
  84599. * @returns The created effect corresponding the the postprocess.
  84600. */
  84601. getEffect(): Effect;
  84602. /**
  84603. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84604. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84605. */
  84606. getContent(): Nullable<ArrayBufferView>;
  84607. private _createIndexBuffer;
  84608. /** @hidden */
  84609. _rebuild(): void;
  84610. /**
  84611. * Resets the texture in order to recreate its associated resources.
  84612. * This can be called in case of context loss
  84613. */
  84614. reset(): void;
  84615. protected _getDefines(): string;
  84616. /**
  84617. * Is the texture ready to be used ? (rendered at least once)
  84618. * @returns true if ready, otherwise, false.
  84619. */
  84620. isReady(): boolean;
  84621. /**
  84622. * Resets the refresh counter of the texture and start bak from scratch.
  84623. * Could be useful to regenerate the texture if it is setup to render only once.
  84624. */
  84625. resetRefreshCounter(): void;
  84626. /**
  84627. * Set the fragment shader to use in order to render the texture.
  84628. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84629. */
  84630. setFragment(fragment: any): void;
  84631. /**
  84632. * Define the refresh rate of the texture or the rendering frequency.
  84633. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84634. */
  84635. refreshRate: number;
  84636. /** @hidden */
  84637. _shouldRender(): boolean;
  84638. /**
  84639. * Get the size the texture is rendering at.
  84640. * @returns the size (texture is always squared)
  84641. */
  84642. getRenderSize(): number;
  84643. /**
  84644. * Resize the texture to new value.
  84645. * @param size Define the new size the texture should have
  84646. * @param generateMipMaps Define whether the new texture should create mip maps
  84647. */
  84648. resize(size: number, generateMipMaps: boolean): void;
  84649. private _checkUniform;
  84650. /**
  84651. * Set a texture in the shader program used to render.
  84652. * @param name Define the name of the uniform samplers as defined in the shader
  84653. * @param texture Define the texture to bind to this sampler
  84654. * @return the texture itself allowing "fluent" like uniform updates
  84655. */
  84656. setTexture(name: string, texture: Texture): ProceduralTexture;
  84657. /**
  84658. * Set a float in the shader.
  84659. * @param name Define the name of the uniform as defined in the shader
  84660. * @param value Define the value to give to the uniform
  84661. * @return the texture itself allowing "fluent" like uniform updates
  84662. */
  84663. setFloat(name: string, value: number): ProceduralTexture;
  84664. /**
  84665. * Set a int in the shader.
  84666. * @param name Define the name of the uniform as defined in the shader
  84667. * @param value Define the value to give to the uniform
  84668. * @return the texture itself allowing "fluent" like uniform updates
  84669. */
  84670. setInt(name: string, value: number): ProceduralTexture;
  84671. /**
  84672. * Set an array of floats in the shader.
  84673. * @param name Define the name of the uniform as defined in the shader
  84674. * @param value Define the value to give to the uniform
  84675. * @return the texture itself allowing "fluent" like uniform updates
  84676. */
  84677. setFloats(name: string, value: number[]): ProceduralTexture;
  84678. /**
  84679. * Set a vec3 in the shader from a Color3.
  84680. * @param name Define the name of the uniform as defined in the shader
  84681. * @param value Define the value to give to the uniform
  84682. * @return the texture itself allowing "fluent" like uniform updates
  84683. */
  84684. setColor3(name: string, value: Color3): ProceduralTexture;
  84685. /**
  84686. * Set a vec4 in the shader from a Color4.
  84687. * @param name Define the name of the uniform as defined in the shader
  84688. * @param value Define the value to give to the uniform
  84689. * @return the texture itself allowing "fluent" like uniform updates
  84690. */
  84691. setColor4(name: string, value: Color4): ProceduralTexture;
  84692. /**
  84693. * Set a vec2 in the shader from a Vector2.
  84694. * @param name Define the name of the uniform as defined in the shader
  84695. * @param value Define the value to give to the uniform
  84696. * @return the texture itself allowing "fluent" like uniform updates
  84697. */
  84698. setVector2(name: string, value: Vector2): ProceduralTexture;
  84699. /**
  84700. * Set a vec3 in the shader from a Vector3.
  84701. * @param name Define the name of the uniform as defined in the shader
  84702. * @param value Define the value to give to the uniform
  84703. * @return the texture itself allowing "fluent" like uniform updates
  84704. */
  84705. setVector3(name: string, value: Vector3): ProceduralTexture;
  84706. /**
  84707. * Set a mat4 in the shader from a MAtrix.
  84708. * @param name Define the name of the uniform as defined in the shader
  84709. * @param value Define the value to give to the uniform
  84710. * @return the texture itself allowing "fluent" like uniform updates
  84711. */
  84712. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84713. /**
  84714. * Render the texture to its associated render target.
  84715. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84716. */
  84717. render(useCameraPostProcess?: boolean): void;
  84718. /**
  84719. * Clone the texture.
  84720. * @returns the cloned texture
  84721. */
  84722. clone(): ProceduralTexture;
  84723. /**
  84724. * Dispose the texture and release its asoociated resources.
  84725. */
  84726. dispose(): void;
  84727. }
  84728. }
  84729. declare module BABYLON {
  84730. /**
  84731. * This represents the base class for particle system in Babylon.
  84732. * 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.
  84733. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84734. * @example https://doc.babylonjs.com/babylon101/particles
  84735. */
  84736. export class BaseParticleSystem {
  84737. /**
  84738. * Source color is added to the destination color without alpha affecting the result
  84739. */
  84740. static BLENDMODE_ONEONE: number;
  84741. /**
  84742. * Blend current color and particle color using particle’s alpha
  84743. */
  84744. static BLENDMODE_STANDARD: number;
  84745. /**
  84746. * Add current color and particle color multiplied by particle’s alpha
  84747. */
  84748. static BLENDMODE_ADD: number;
  84749. /**
  84750. * Multiply current color with particle color
  84751. */
  84752. static BLENDMODE_MULTIPLY: number;
  84753. /**
  84754. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84755. */
  84756. static BLENDMODE_MULTIPLYADD: number;
  84757. /**
  84758. * List of animations used by the particle system.
  84759. */
  84760. animations: Animation[];
  84761. /**
  84762. * The id of the Particle system.
  84763. */
  84764. id: string;
  84765. /**
  84766. * The friendly name of the Particle system.
  84767. */
  84768. name: string;
  84769. /**
  84770. * The rendering group used by the Particle system to chose when to render.
  84771. */
  84772. renderingGroupId: number;
  84773. /**
  84774. * The emitter represents the Mesh or position we are attaching the particle system to.
  84775. */
  84776. emitter: Nullable<AbstractMesh | Vector3>;
  84777. /**
  84778. * The maximum number of particles to emit per frame
  84779. */
  84780. emitRate: number;
  84781. /**
  84782. * If you want to launch only a few particles at once, that can be done, as well.
  84783. */
  84784. manualEmitCount: number;
  84785. /**
  84786. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84787. */
  84788. updateSpeed: number;
  84789. /**
  84790. * The amount of time the particle system is running (depends of the overall update speed).
  84791. */
  84792. targetStopDuration: number;
  84793. /**
  84794. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84795. */
  84796. disposeOnStop: boolean;
  84797. /**
  84798. * Minimum power of emitting particles.
  84799. */
  84800. minEmitPower: number;
  84801. /**
  84802. * Maximum power of emitting particles.
  84803. */
  84804. maxEmitPower: number;
  84805. /**
  84806. * Minimum life time of emitting particles.
  84807. */
  84808. minLifeTime: number;
  84809. /**
  84810. * Maximum life time of emitting particles.
  84811. */
  84812. maxLifeTime: number;
  84813. /**
  84814. * Minimum Size of emitting particles.
  84815. */
  84816. minSize: number;
  84817. /**
  84818. * Maximum Size of emitting particles.
  84819. */
  84820. maxSize: number;
  84821. /**
  84822. * Minimum scale of emitting particles on X axis.
  84823. */
  84824. minScaleX: number;
  84825. /**
  84826. * Maximum scale of emitting particles on X axis.
  84827. */
  84828. maxScaleX: number;
  84829. /**
  84830. * Minimum scale of emitting particles on Y axis.
  84831. */
  84832. minScaleY: number;
  84833. /**
  84834. * Maximum scale of emitting particles on Y axis.
  84835. */
  84836. maxScaleY: number;
  84837. /**
  84838. * Gets or sets the minimal initial rotation in radians.
  84839. */
  84840. minInitialRotation: number;
  84841. /**
  84842. * Gets or sets the maximal initial rotation in radians.
  84843. */
  84844. maxInitialRotation: number;
  84845. /**
  84846. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84847. */
  84848. minAngularSpeed: number;
  84849. /**
  84850. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84851. */
  84852. maxAngularSpeed: number;
  84853. /**
  84854. * The texture used to render each particle. (this can be a spritesheet)
  84855. */
  84856. particleTexture: Nullable<Texture>;
  84857. /**
  84858. * The layer mask we are rendering the particles through.
  84859. */
  84860. layerMask: number;
  84861. /**
  84862. * This can help using your own shader to render the particle system.
  84863. * The according effect will be created
  84864. */
  84865. customShader: any;
  84866. /**
  84867. * By default particle system starts as soon as they are created. This prevents the
  84868. * automatic start to happen and let you decide when to start emitting particles.
  84869. */
  84870. preventAutoStart: boolean;
  84871. private _noiseTexture;
  84872. /**
  84873. * Gets or sets a texture used to add random noise to particle positions
  84874. */
  84875. noiseTexture: Nullable<ProceduralTexture>;
  84876. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84877. noiseStrength: Vector3;
  84878. /**
  84879. * Callback triggered when the particle animation is ending.
  84880. */
  84881. onAnimationEnd: Nullable<() => void>;
  84882. /**
  84883. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84884. */
  84885. blendMode: number;
  84886. /**
  84887. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84888. * to override the particles.
  84889. */
  84890. forceDepthWrite: boolean;
  84891. /** 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 */
  84892. preWarmCycles: number;
  84893. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84894. preWarmStepOffset: number;
  84895. /**
  84896. * 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)
  84897. */
  84898. spriteCellChangeSpeed: number;
  84899. /**
  84900. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84901. */
  84902. startSpriteCellID: number;
  84903. /**
  84904. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84905. */
  84906. endSpriteCellID: number;
  84907. /**
  84908. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84909. */
  84910. spriteCellWidth: number;
  84911. /**
  84912. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84913. */
  84914. spriteCellHeight: number;
  84915. /**
  84916. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84917. */
  84918. spriteRandomStartCell: boolean;
  84919. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84920. translationPivot: Vector2;
  84921. /** @hidden */
  84922. protected _isAnimationSheetEnabled: boolean;
  84923. /**
  84924. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84925. */
  84926. beginAnimationOnStart: boolean;
  84927. /**
  84928. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84929. */
  84930. beginAnimationFrom: number;
  84931. /**
  84932. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84933. */
  84934. beginAnimationTo: number;
  84935. /**
  84936. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84937. */
  84938. beginAnimationLoop: boolean;
  84939. /**
  84940. * Gets or sets a world offset applied to all particles
  84941. */
  84942. worldOffset: Vector3;
  84943. /**
  84944. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84945. */
  84946. isAnimationSheetEnabled: boolean;
  84947. /**
  84948. * Get hosting scene
  84949. * @returns the scene
  84950. */
  84951. getScene(): Scene;
  84952. /**
  84953. * You can use gravity if you want to give an orientation to your particles.
  84954. */
  84955. gravity: Vector3;
  84956. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84957. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84958. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84959. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84960. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84961. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84962. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84963. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84964. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84965. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84966. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84967. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84968. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84969. /**
  84970. * Defines the delay in milliseconds before starting the system (0 by default)
  84971. */
  84972. startDelay: number;
  84973. /**
  84974. * Gets the current list of drag gradients.
  84975. * You must use addDragGradient and removeDragGradient to udpate this list
  84976. * @returns the list of drag gradients
  84977. */
  84978. getDragGradients(): Nullable<Array<FactorGradient>>;
  84979. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84980. limitVelocityDamping: number;
  84981. /**
  84982. * Gets the current list of limit velocity gradients.
  84983. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84984. * @returns the list of limit velocity gradients
  84985. */
  84986. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84987. /**
  84988. * Gets the current list of color gradients.
  84989. * You must use addColorGradient and removeColorGradient to udpate this list
  84990. * @returns the list of color gradients
  84991. */
  84992. getColorGradients(): Nullable<Array<ColorGradient>>;
  84993. /**
  84994. * Gets the current list of size gradients.
  84995. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84996. * @returns the list of size gradients
  84997. */
  84998. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84999. /**
  85000. * Gets the current list of color remap gradients.
  85001. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85002. * @returns the list of color remap gradients
  85003. */
  85004. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85005. /**
  85006. * Gets the current list of alpha remap gradients.
  85007. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85008. * @returns the list of alpha remap gradients
  85009. */
  85010. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85011. /**
  85012. * Gets the current list of life time gradients.
  85013. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85014. * @returns the list of life time gradients
  85015. */
  85016. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85017. /**
  85018. * Gets the current list of angular speed gradients.
  85019. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85020. * @returns the list of angular speed gradients
  85021. */
  85022. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85023. /**
  85024. * Gets the current list of velocity gradients.
  85025. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85026. * @returns the list of velocity gradients
  85027. */
  85028. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85029. /**
  85030. * Gets the current list of start size gradients.
  85031. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85032. * @returns the list of start size gradients
  85033. */
  85034. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85035. /**
  85036. * Gets the current list of emit rate gradients.
  85037. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85038. * @returns the list of emit rate gradients
  85039. */
  85040. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85041. /**
  85042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85043. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85044. */
  85045. direction1: Vector3;
  85046. /**
  85047. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85048. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85049. */
  85050. direction2: Vector3;
  85051. /**
  85052. * 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.
  85053. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85054. */
  85055. minEmitBox: Vector3;
  85056. /**
  85057. * 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.
  85058. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85059. */
  85060. maxEmitBox: Vector3;
  85061. /**
  85062. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85063. */
  85064. color1: Color4;
  85065. /**
  85066. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85067. */
  85068. color2: Color4;
  85069. /**
  85070. * Color the particle will have at the end of its lifetime
  85071. */
  85072. colorDead: Color4;
  85073. /**
  85074. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85075. */
  85076. textureMask: Color4;
  85077. /**
  85078. * The particle emitter type defines the emitter used by the particle system.
  85079. * It can be for example box, sphere, or cone...
  85080. */
  85081. particleEmitterType: IParticleEmitterType;
  85082. /** @hidden */
  85083. _isSubEmitter: boolean;
  85084. /**
  85085. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85086. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85087. */
  85088. billboardMode: number;
  85089. protected _isBillboardBased: boolean;
  85090. /**
  85091. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85092. */
  85093. isBillboardBased: boolean;
  85094. /**
  85095. * The scene the particle system belongs to.
  85096. */
  85097. protected _scene: Scene;
  85098. /**
  85099. * Local cache of defines for image processing.
  85100. */
  85101. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85102. /**
  85103. * Default configuration related to image processing available in the standard Material.
  85104. */
  85105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85106. /**
  85107. * Gets the image processing configuration used either in this material.
  85108. */
  85109. /**
  85110. * Sets the Default image processing configuration used either in the this material.
  85111. *
  85112. * If sets to null, the scene one is in use.
  85113. */
  85114. imageProcessingConfiguration: ImageProcessingConfiguration;
  85115. /**
  85116. * Attaches a new image processing configuration to the Standard Material.
  85117. * @param configuration
  85118. */
  85119. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85120. /** @hidden */
  85121. protected _reset(): void;
  85122. /** @hidden */
  85123. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85124. /**
  85125. * Instantiates a particle system.
  85126. * 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.
  85127. * @param name The name of the particle system
  85128. */
  85129. constructor(name: string);
  85130. /**
  85131. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85134. * @returns the emitter
  85135. */
  85136. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85137. /**
  85138. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85139. * @param radius The radius of the hemisphere to emit from
  85140. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85141. * @returns the emitter
  85142. */
  85143. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85144. /**
  85145. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85146. * @param radius The radius of the sphere to emit from
  85147. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85148. * @returns the emitter
  85149. */
  85150. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85151. /**
  85152. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85153. * @param radius The radius of the sphere to emit from
  85154. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85155. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85156. * @returns the emitter
  85157. */
  85158. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85159. /**
  85160. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85161. * @param radius The radius of the emission cylinder
  85162. * @param height The height of the emission cylinder
  85163. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85164. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85165. * @returns the emitter
  85166. */
  85167. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85168. /**
  85169. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85170. * @param radius The radius of the cylinder to emit from
  85171. * @param height The height of the emission cylinder
  85172. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85173. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85174. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85175. * @returns the emitter
  85176. */
  85177. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85178. /**
  85179. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85180. * @param radius The radius of the cone to emit from
  85181. * @param angle The base angle of the cone
  85182. * @returns the emitter
  85183. */
  85184. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85185. /**
  85186. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85187. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85188. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85189. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85190. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85191. * @returns the emitter
  85192. */
  85193. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85194. }
  85195. }
  85196. declare module BABYLON {
  85197. /**
  85198. * Type of sub emitter
  85199. */
  85200. export enum SubEmitterType {
  85201. /**
  85202. * Attached to the particle over it's lifetime
  85203. */
  85204. ATTACHED = 0,
  85205. /**
  85206. * Created when the particle dies
  85207. */
  85208. END = 1
  85209. }
  85210. /**
  85211. * Sub emitter class used to emit particles from an existing particle
  85212. */
  85213. export class SubEmitter {
  85214. /**
  85215. * the particle system to be used by the sub emitter
  85216. */
  85217. particleSystem: ParticleSystem;
  85218. /**
  85219. * Type of the submitter (Default: END)
  85220. */
  85221. type: SubEmitterType;
  85222. /**
  85223. * 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)
  85224. * Note: This only is supported when using an emitter of type Mesh
  85225. */
  85226. inheritDirection: boolean;
  85227. /**
  85228. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85229. */
  85230. inheritedVelocityAmount: number;
  85231. /**
  85232. * Creates a sub emitter
  85233. * @param particleSystem the particle system to be used by the sub emitter
  85234. */
  85235. constructor(
  85236. /**
  85237. * the particle system to be used by the sub emitter
  85238. */
  85239. particleSystem: ParticleSystem);
  85240. /**
  85241. * Clones the sub emitter
  85242. * @returns the cloned sub emitter
  85243. */
  85244. clone(): SubEmitter;
  85245. /**
  85246. * Serialize current object to a JSON object
  85247. * @returns the serialized object
  85248. */
  85249. serialize(): any;
  85250. /** @hidden */
  85251. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85252. /**
  85253. * Creates a new SubEmitter from a serialized JSON version
  85254. * @param serializationObject defines the JSON object to read from
  85255. * @param scene defines the hosting scene
  85256. * @param rootUrl defines the rootUrl for data loading
  85257. * @returns a new SubEmitter
  85258. */
  85259. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85260. /** Release associated resources */
  85261. dispose(): void;
  85262. }
  85263. }
  85264. declare module BABYLON {
  85265. /** @hidden */
  85266. export var clipPlaneFragmentDeclaration: {
  85267. name: string;
  85268. shader: string;
  85269. };
  85270. }
  85271. declare module BABYLON {
  85272. /** @hidden */
  85273. export var imageProcessingDeclaration: {
  85274. name: string;
  85275. shader: string;
  85276. };
  85277. }
  85278. declare module BABYLON {
  85279. /** @hidden */
  85280. export var imageProcessingFunctions: {
  85281. name: string;
  85282. shader: string;
  85283. };
  85284. }
  85285. declare module BABYLON {
  85286. /** @hidden */
  85287. export var clipPlaneFragment: {
  85288. name: string;
  85289. shader: string;
  85290. };
  85291. }
  85292. declare module BABYLON {
  85293. /** @hidden */
  85294. export var particlesPixelShader: {
  85295. name: string;
  85296. shader: string;
  85297. };
  85298. }
  85299. declare module BABYLON {
  85300. /** @hidden */
  85301. export var clipPlaneVertexDeclaration: {
  85302. name: string;
  85303. shader: string;
  85304. };
  85305. }
  85306. declare module BABYLON {
  85307. /** @hidden */
  85308. export var clipPlaneVertex: {
  85309. name: string;
  85310. shader: string;
  85311. };
  85312. }
  85313. declare module BABYLON {
  85314. /** @hidden */
  85315. export var particlesVertexShader: {
  85316. name: string;
  85317. shader: string;
  85318. };
  85319. }
  85320. declare module BABYLON {
  85321. /**
  85322. * This represents a particle system in Babylon.
  85323. * 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.
  85324. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85325. * @example https://doc.babylonjs.com/babylon101/particles
  85326. */
  85327. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85328. /**
  85329. * Billboard mode will only apply to Y axis
  85330. */
  85331. static readonly BILLBOARDMODE_Y: number;
  85332. /**
  85333. * Billboard mode will apply to all axes
  85334. */
  85335. static readonly BILLBOARDMODE_ALL: number;
  85336. /**
  85337. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85338. */
  85339. static readonly BILLBOARDMODE_STRETCHED: number;
  85340. /**
  85341. * This function can be defined to provide custom update for active particles.
  85342. * This function will be called instead of regular update (age, position, color, etc.).
  85343. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85344. */
  85345. updateFunction: (particles: Particle[]) => void;
  85346. private _emitterWorldMatrix;
  85347. /**
  85348. * This function can be defined to specify initial direction for every new particle.
  85349. * It by default use the emitterType defined function
  85350. */
  85351. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85352. /**
  85353. * This function can be defined to specify initial position for every new particle.
  85354. * It by default use the emitterType defined function
  85355. */
  85356. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85357. /**
  85358. * @hidden
  85359. */
  85360. _inheritedVelocityOffset: Vector3;
  85361. /**
  85362. * An event triggered when the system is disposed
  85363. */
  85364. onDisposeObservable: Observable<ParticleSystem>;
  85365. private _onDisposeObserver;
  85366. /**
  85367. * Sets a callback that will be triggered when the system is disposed
  85368. */
  85369. onDispose: () => void;
  85370. private _particles;
  85371. private _epsilon;
  85372. private _capacity;
  85373. private _stockParticles;
  85374. private _newPartsExcess;
  85375. private _vertexData;
  85376. private _vertexBuffer;
  85377. private _vertexBuffers;
  85378. private _spriteBuffer;
  85379. private _indexBuffer;
  85380. private _effect;
  85381. private _customEffect;
  85382. private _cachedDefines;
  85383. private _scaledColorStep;
  85384. private _colorDiff;
  85385. private _scaledDirection;
  85386. private _scaledGravity;
  85387. private _currentRenderId;
  85388. private _alive;
  85389. private _useInstancing;
  85390. private _started;
  85391. private _stopped;
  85392. private _actualFrame;
  85393. private _scaledUpdateSpeed;
  85394. private _vertexBufferSize;
  85395. /** @hidden */
  85396. _currentEmitRateGradient: Nullable<FactorGradient>;
  85397. /** @hidden */
  85398. _currentEmitRate1: number;
  85399. /** @hidden */
  85400. _currentEmitRate2: number;
  85401. /** @hidden */
  85402. _currentStartSizeGradient: Nullable<FactorGradient>;
  85403. /** @hidden */
  85404. _currentStartSize1: number;
  85405. /** @hidden */
  85406. _currentStartSize2: number;
  85407. private readonly _rawTextureWidth;
  85408. private _rampGradientsTexture;
  85409. private _useRampGradients;
  85410. /** Gets or sets a boolean indicating that ramp gradients must be used
  85411. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85412. */
  85413. useRampGradients: boolean;
  85414. /**
  85415. * 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.
  85416. * 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: [])
  85417. */
  85418. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85419. private _subEmitters;
  85420. /**
  85421. * @hidden
  85422. * If the particle systems emitter should be disposed when the particle system is disposed
  85423. */
  85424. _disposeEmitterOnDispose: boolean;
  85425. /**
  85426. * The current active Sub-systems, this property is used by the root particle system only.
  85427. */
  85428. activeSubSystems: Array<ParticleSystem>;
  85429. private _rootParticleSystem;
  85430. /**
  85431. * Gets the current list of active particles
  85432. */
  85433. readonly particles: Particle[];
  85434. /**
  85435. * Returns the string "ParticleSystem"
  85436. * @returns a string containing the class name
  85437. */
  85438. getClassName(): string;
  85439. /**
  85440. * Instantiates a particle system.
  85441. * 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.
  85442. * @param name The name of the particle system
  85443. * @param capacity The max number of particles alive at the same time
  85444. * @param scene The scene the particle system belongs to
  85445. * @param customEffect a custom effect used to change the way particles are rendered by default
  85446. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85447. * @param epsilon Offset used to render the particles
  85448. */
  85449. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85450. private _addFactorGradient;
  85451. private _removeFactorGradient;
  85452. /**
  85453. * Adds a new life time gradient
  85454. * @param gradient defines the gradient to use (between 0 and 1)
  85455. * @param factor defines the life time factor to affect to the specified gradient
  85456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85457. * @returns the current particle system
  85458. */
  85459. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85460. /**
  85461. * Remove a specific life time gradient
  85462. * @param gradient defines the gradient to remove
  85463. * @returns the current particle system
  85464. */
  85465. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85466. /**
  85467. * Adds a new size gradient
  85468. * @param gradient defines the gradient to use (between 0 and 1)
  85469. * @param factor defines the size factor to affect to the specified gradient
  85470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85471. * @returns the current particle system
  85472. */
  85473. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85474. /**
  85475. * Remove a specific size gradient
  85476. * @param gradient defines the gradient to remove
  85477. * @returns the current particle system
  85478. */
  85479. removeSizeGradient(gradient: number): IParticleSystem;
  85480. /**
  85481. * Adds a new color remap gradient
  85482. * @param gradient defines the gradient to use (between 0 and 1)
  85483. * @param min defines the color remap minimal range
  85484. * @param max defines the color remap maximal range
  85485. * @returns the current particle system
  85486. */
  85487. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85488. /**
  85489. * Remove a specific color remap gradient
  85490. * @param gradient defines the gradient to remove
  85491. * @returns the current particle system
  85492. */
  85493. removeColorRemapGradient(gradient: number): IParticleSystem;
  85494. /**
  85495. * Adds a new alpha remap gradient
  85496. * @param gradient defines the gradient to use (between 0 and 1)
  85497. * @param min defines the alpha remap minimal range
  85498. * @param max defines the alpha remap maximal range
  85499. * @returns the current particle system
  85500. */
  85501. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85502. /**
  85503. * Remove a specific alpha remap gradient
  85504. * @param gradient defines the gradient to remove
  85505. * @returns the current particle system
  85506. */
  85507. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85508. /**
  85509. * Adds a new angular speed gradient
  85510. * @param gradient defines the gradient to use (between 0 and 1)
  85511. * @param factor defines the angular speed to affect to the specified gradient
  85512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85513. * @returns the current particle system
  85514. */
  85515. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85516. /**
  85517. * Remove a specific angular speed gradient
  85518. * @param gradient defines the gradient to remove
  85519. * @returns the current particle system
  85520. */
  85521. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85522. /**
  85523. * Adds a new velocity gradient
  85524. * @param gradient defines the gradient to use (between 0 and 1)
  85525. * @param factor defines the velocity to affect to the specified gradient
  85526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85527. * @returns the current particle system
  85528. */
  85529. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85530. /**
  85531. * Remove a specific velocity gradient
  85532. * @param gradient defines the gradient to remove
  85533. * @returns the current particle system
  85534. */
  85535. removeVelocityGradient(gradient: number): IParticleSystem;
  85536. /**
  85537. * Adds a new limit velocity gradient
  85538. * @param gradient defines the gradient to use (between 0 and 1)
  85539. * @param factor defines the limit velocity value to affect to the specified gradient
  85540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85541. * @returns the current particle system
  85542. */
  85543. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85544. /**
  85545. * Remove a specific limit velocity gradient
  85546. * @param gradient defines the gradient to remove
  85547. * @returns the current particle system
  85548. */
  85549. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85550. /**
  85551. * Adds a new drag gradient
  85552. * @param gradient defines the gradient to use (between 0 and 1)
  85553. * @param factor defines the drag value to affect to the specified gradient
  85554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85555. * @returns the current particle system
  85556. */
  85557. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85558. /**
  85559. * Remove a specific drag gradient
  85560. * @param gradient defines the gradient to remove
  85561. * @returns the current particle system
  85562. */
  85563. removeDragGradient(gradient: number): IParticleSystem;
  85564. /**
  85565. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85566. * @param gradient defines the gradient to use (between 0 and 1)
  85567. * @param factor defines the emit rate value to affect to the specified gradient
  85568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85569. * @returns the current particle system
  85570. */
  85571. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85572. /**
  85573. * Remove a specific emit rate gradient
  85574. * @param gradient defines the gradient to remove
  85575. * @returns the current particle system
  85576. */
  85577. removeEmitRateGradient(gradient: number): IParticleSystem;
  85578. /**
  85579. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85580. * @param gradient defines the gradient to use (between 0 and 1)
  85581. * @param factor defines the start size value to affect to the specified gradient
  85582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85583. * @returns the current particle system
  85584. */
  85585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85586. /**
  85587. * Remove a specific start size gradient
  85588. * @param gradient defines the gradient to remove
  85589. * @returns the current particle system
  85590. */
  85591. removeStartSizeGradient(gradient: number): IParticleSystem;
  85592. private _createRampGradientTexture;
  85593. /**
  85594. * Gets the current list of ramp gradients.
  85595. * You must use addRampGradient and removeRampGradient to udpate this list
  85596. * @returns the list of ramp gradients
  85597. */
  85598. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85599. /**
  85600. * Adds a new ramp gradient used to remap particle colors
  85601. * @param gradient defines the gradient to use (between 0 and 1)
  85602. * @param color defines the color to affect to the specified gradient
  85603. * @returns the current particle system
  85604. */
  85605. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85606. /**
  85607. * Remove a specific ramp gradient
  85608. * @param gradient defines the gradient to remove
  85609. * @returns the current particle system
  85610. */
  85611. removeRampGradient(gradient: number): ParticleSystem;
  85612. /**
  85613. * Adds a new color gradient
  85614. * @param gradient defines the gradient to use (between 0 and 1)
  85615. * @param color1 defines the color to affect to the specified gradient
  85616. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85617. * @returns this particle system
  85618. */
  85619. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85620. /**
  85621. * Remove a specific color gradient
  85622. * @param gradient defines the gradient to remove
  85623. * @returns this particle system
  85624. */
  85625. removeColorGradient(gradient: number): IParticleSystem;
  85626. private _fetchR;
  85627. protected _reset(): void;
  85628. private _resetEffect;
  85629. private _createVertexBuffers;
  85630. private _createIndexBuffer;
  85631. /**
  85632. * Gets the maximum number of particles active at the same time.
  85633. * @returns The max number of active particles.
  85634. */
  85635. getCapacity(): number;
  85636. /**
  85637. * Gets whether there are still active particles in the system.
  85638. * @returns True if it is alive, otherwise false.
  85639. */
  85640. isAlive(): boolean;
  85641. /**
  85642. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85643. * @returns True if it has been started, otherwise false.
  85644. */
  85645. isStarted(): boolean;
  85646. private _prepareSubEmitterInternalArray;
  85647. /**
  85648. * Starts the particle system and begins to emit
  85649. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85650. */
  85651. start(delay?: number): void;
  85652. /**
  85653. * Stops the particle system.
  85654. * @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.
  85655. */
  85656. stop(stopSubEmitters?: boolean): void;
  85657. /**
  85658. * Remove all active particles
  85659. */
  85660. reset(): void;
  85661. /**
  85662. * @hidden (for internal use only)
  85663. */
  85664. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85665. /**
  85666. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85667. * Its lifetime will start back at 0.
  85668. */
  85669. recycleParticle: (particle: Particle) => void;
  85670. private _stopSubEmitters;
  85671. private _createParticle;
  85672. private _removeFromRoot;
  85673. private _emitFromParticle;
  85674. private _update;
  85675. /** @hidden */
  85676. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85677. /** @hidden */
  85678. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85679. /** @hidden */
  85680. private _getEffect;
  85681. /**
  85682. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85683. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85684. */
  85685. animate(preWarmOnly?: boolean): void;
  85686. private _appendParticleVertices;
  85687. /**
  85688. * Rebuilds the particle system.
  85689. */
  85690. rebuild(): void;
  85691. /**
  85692. * Is this system ready to be used/rendered
  85693. * @return true if the system is ready
  85694. */
  85695. isReady(): boolean;
  85696. private _render;
  85697. /**
  85698. * Renders the particle system in its current state.
  85699. * @returns the current number of particles
  85700. */
  85701. render(): number;
  85702. /**
  85703. * Disposes the particle system and free the associated resources
  85704. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85705. */
  85706. dispose(disposeTexture?: boolean): void;
  85707. /**
  85708. * Clones the particle system.
  85709. * @param name The name of the cloned object
  85710. * @param newEmitter The new emitter to use
  85711. * @returns the cloned particle system
  85712. */
  85713. clone(name: string, newEmitter: any): ParticleSystem;
  85714. /**
  85715. * Serializes the particle system to a JSON object.
  85716. * @returns the JSON object
  85717. */
  85718. serialize(): any;
  85719. /** @hidden */
  85720. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85721. /** @hidden */
  85722. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85723. /**
  85724. * Parses a JSON object to create a particle system.
  85725. * @param parsedParticleSystem The JSON object to parse
  85726. * @param scene The scene to create the particle system in
  85727. * @param rootUrl The root url to use to load external dependencies like texture
  85728. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85729. * @returns the Parsed particle system
  85730. */
  85731. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85732. }
  85733. }
  85734. declare module BABYLON {
  85735. /**
  85736. * A particle represents one of the element emitted by a particle system.
  85737. * This is mainly define by its coordinates, direction, velocity and age.
  85738. */
  85739. export class Particle {
  85740. /**
  85741. * The particle system the particle belongs to.
  85742. */
  85743. particleSystem: ParticleSystem;
  85744. private static _Count;
  85745. /**
  85746. * Unique ID of the particle
  85747. */
  85748. id: number;
  85749. /**
  85750. * The world position of the particle in the scene.
  85751. */
  85752. position: Vector3;
  85753. /**
  85754. * The world direction of the particle in the scene.
  85755. */
  85756. direction: Vector3;
  85757. /**
  85758. * The color of the particle.
  85759. */
  85760. color: Color4;
  85761. /**
  85762. * The color change of the particle per step.
  85763. */
  85764. colorStep: Color4;
  85765. /**
  85766. * Defines how long will the life of the particle be.
  85767. */
  85768. lifeTime: number;
  85769. /**
  85770. * The current age of the particle.
  85771. */
  85772. age: number;
  85773. /**
  85774. * The current size of the particle.
  85775. */
  85776. size: number;
  85777. /**
  85778. * The current scale of the particle.
  85779. */
  85780. scale: Vector2;
  85781. /**
  85782. * The current angle of the particle.
  85783. */
  85784. angle: number;
  85785. /**
  85786. * Defines how fast is the angle changing.
  85787. */
  85788. angularSpeed: number;
  85789. /**
  85790. * Defines the cell index used by the particle to be rendered from a sprite.
  85791. */
  85792. cellIndex: number;
  85793. /**
  85794. * The information required to support color remapping
  85795. */
  85796. remapData: Vector4;
  85797. /** @hidden */
  85798. _randomCellOffset?: number;
  85799. /** @hidden */
  85800. _initialDirection: Nullable<Vector3>;
  85801. /** @hidden */
  85802. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85803. /** @hidden */
  85804. _initialStartSpriteCellID: number;
  85805. /** @hidden */
  85806. _initialEndSpriteCellID: number;
  85807. /** @hidden */
  85808. _currentColorGradient: Nullable<ColorGradient>;
  85809. /** @hidden */
  85810. _currentColor1: Color4;
  85811. /** @hidden */
  85812. _currentColor2: Color4;
  85813. /** @hidden */
  85814. _currentSizeGradient: Nullable<FactorGradient>;
  85815. /** @hidden */
  85816. _currentSize1: number;
  85817. /** @hidden */
  85818. _currentSize2: number;
  85819. /** @hidden */
  85820. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85821. /** @hidden */
  85822. _currentAngularSpeed1: number;
  85823. /** @hidden */
  85824. _currentAngularSpeed2: number;
  85825. /** @hidden */
  85826. _currentVelocityGradient: Nullable<FactorGradient>;
  85827. /** @hidden */
  85828. _currentVelocity1: number;
  85829. /** @hidden */
  85830. _currentVelocity2: number;
  85831. /** @hidden */
  85832. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85833. /** @hidden */
  85834. _currentLimitVelocity1: number;
  85835. /** @hidden */
  85836. _currentLimitVelocity2: number;
  85837. /** @hidden */
  85838. _currentDragGradient: Nullable<FactorGradient>;
  85839. /** @hidden */
  85840. _currentDrag1: number;
  85841. /** @hidden */
  85842. _currentDrag2: number;
  85843. /** @hidden */
  85844. _randomNoiseCoordinates1: Vector3;
  85845. /** @hidden */
  85846. _randomNoiseCoordinates2: Vector3;
  85847. /**
  85848. * Creates a new instance Particle
  85849. * @param particleSystem the particle system the particle belongs to
  85850. */
  85851. constructor(
  85852. /**
  85853. * The particle system the particle belongs to.
  85854. */
  85855. particleSystem: ParticleSystem);
  85856. private updateCellInfoFromSystem;
  85857. /**
  85858. * Defines how the sprite cell index is updated for the particle
  85859. */
  85860. updateCellIndex(): void;
  85861. /** @hidden */
  85862. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85863. /** @hidden */
  85864. _inheritParticleInfoToSubEmitters(): void;
  85865. /** @hidden */
  85866. _reset(): void;
  85867. /**
  85868. * Copy the properties of particle to another one.
  85869. * @param other the particle to copy the information to.
  85870. */
  85871. copyTo(other: Particle): void;
  85872. }
  85873. }
  85874. declare module BABYLON {
  85875. /**
  85876. * Particle emitter represents a volume emitting particles.
  85877. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85878. */
  85879. export interface IParticleEmitterType {
  85880. /**
  85881. * Called by the particle System when the direction is computed for the created particle.
  85882. * @param worldMatrix is the world matrix of the particle system
  85883. * @param directionToUpdate is the direction vector to update with the result
  85884. * @param particle is the particle we are computed the direction for
  85885. */
  85886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85887. /**
  85888. * Called by the particle System when the position is computed for the created particle.
  85889. * @param worldMatrix is the world matrix of the particle system
  85890. * @param positionToUpdate is the position vector to update with the result
  85891. * @param particle is the particle we are computed the position for
  85892. */
  85893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85894. /**
  85895. * Clones the current emitter and returns a copy of it
  85896. * @returns the new emitter
  85897. */
  85898. clone(): IParticleEmitterType;
  85899. /**
  85900. * Called by the GPUParticleSystem to setup the update shader
  85901. * @param effect defines the update shader
  85902. */
  85903. applyToShader(effect: Effect): void;
  85904. /**
  85905. * Returns a string to use to update the GPU particles update shader
  85906. * @returns the effect defines string
  85907. */
  85908. getEffectDefines(): string;
  85909. /**
  85910. * Returns a string representing the class name
  85911. * @returns a string containing the class name
  85912. */
  85913. getClassName(): string;
  85914. /**
  85915. * Serializes the particle system to a JSON object.
  85916. * @returns the JSON object
  85917. */
  85918. serialize(): any;
  85919. /**
  85920. * Parse properties from a JSON object
  85921. * @param serializationObject defines the JSON object
  85922. */
  85923. parse(serializationObject: any): void;
  85924. }
  85925. }
  85926. declare module BABYLON {
  85927. /**
  85928. * Particle emitter emitting particles from the inside of a box.
  85929. * It emits the particles randomly between 2 given directions.
  85930. */
  85931. export class BoxParticleEmitter implements IParticleEmitterType {
  85932. /**
  85933. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85934. */
  85935. direction1: Vector3;
  85936. /**
  85937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85938. */
  85939. direction2: Vector3;
  85940. /**
  85941. * 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.
  85942. */
  85943. minEmitBox: Vector3;
  85944. /**
  85945. * 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.
  85946. */
  85947. maxEmitBox: Vector3;
  85948. /**
  85949. * Creates a new instance BoxParticleEmitter
  85950. */
  85951. constructor();
  85952. /**
  85953. * Called by the particle System when the direction is computed for the created particle.
  85954. * @param worldMatrix is the world matrix of the particle system
  85955. * @param directionToUpdate is the direction vector to update with the result
  85956. * @param particle is the particle we are computed the direction for
  85957. */
  85958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85959. /**
  85960. * Called by the particle System when the position is computed for the created particle.
  85961. * @param worldMatrix is the world matrix of the particle system
  85962. * @param positionToUpdate is the position vector to update with the result
  85963. * @param particle is the particle we are computed the position for
  85964. */
  85965. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85966. /**
  85967. * Clones the current emitter and returns a copy of it
  85968. * @returns the new emitter
  85969. */
  85970. clone(): BoxParticleEmitter;
  85971. /**
  85972. * Called by the GPUParticleSystem to setup the update shader
  85973. * @param effect defines the update shader
  85974. */
  85975. applyToShader(effect: Effect): void;
  85976. /**
  85977. * Returns a string to use to update the GPU particles update shader
  85978. * @returns a string containng the defines string
  85979. */
  85980. getEffectDefines(): string;
  85981. /**
  85982. * Returns the string "BoxParticleEmitter"
  85983. * @returns a string containing the class name
  85984. */
  85985. getClassName(): string;
  85986. /**
  85987. * Serializes the particle system to a JSON object.
  85988. * @returns the JSON object
  85989. */
  85990. serialize(): any;
  85991. /**
  85992. * Parse properties from a JSON object
  85993. * @param serializationObject defines the JSON object
  85994. */
  85995. parse(serializationObject: any): void;
  85996. }
  85997. }
  85998. declare module BABYLON {
  85999. /**
  86000. * Particle emitter emitting particles from the inside of a cone.
  86001. * It emits the particles alongside the cone volume from the base to the particle.
  86002. * The emission direction might be randomized.
  86003. */
  86004. export class ConeParticleEmitter implements IParticleEmitterType {
  86005. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86006. directionRandomizer: number;
  86007. private _radius;
  86008. private _angle;
  86009. private _height;
  86010. /**
  86011. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86012. */
  86013. radiusRange: number;
  86014. /**
  86015. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86016. */
  86017. heightRange: number;
  86018. /**
  86019. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86020. */
  86021. emitFromSpawnPointOnly: boolean;
  86022. /**
  86023. * Gets or sets the radius of the emission cone
  86024. */
  86025. radius: number;
  86026. /**
  86027. * Gets or sets the angle of the emission cone
  86028. */
  86029. angle: number;
  86030. private _buildHeight;
  86031. /**
  86032. * Creates a new instance ConeParticleEmitter
  86033. * @param radius the radius of the emission cone (1 by default)
  86034. * @param angle the cone base angle (PI by default)
  86035. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86036. */
  86037. constructor(radius?: number, angle?: number,
  86038. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86039. directionRandomizer?: number);
  86040. /**
  86041. * Called by the particle System when the direction is computed for the created particle.
  86042. * @param worldMatrix is the world matrix of the particle system
  86043. * @param directionToUpdate is the direction vector to update with the result
  86044. * @param particle is the particle we are computed the direction for
  86045. */
  86046. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86047. /**
  86048. * Called by the particle System when the position is computed for the created particle.
  86049. * @param worldMatrix is the world matrix of the particle system
  86050. * @param positionToUpdate is the position vector to update with the result
  86051. * @param particle is the particle we are computed the position for
  86052. */
  86053. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86054. /**
  86055. * Clones the current emitter and returns a copy of it
  86056. * @returns the new emitter
  86057. */
  86058. clone(): ConeParticleEmitter;
  86059. /**
  86060. * Called by the GPUParticleSystem to setup the update shader
  86061. * @param effect defines the update shader
  86062. */
  86063. applyToShader(effect: Effect): void;
  86064. /**
  86065. * Returns a string to use to update the GPU particles update shader
  86066. * @returns a string containng the defines string
  86067. */
  86068. getEffectDefines(): string;
  86069. /**
  86070. * Returns the string "ConeParticleEmitter"
  86071. * @returns a string containing the class name
  86072. */
  86073. getClassName(): string;
  86074. /**
  86075. * Serializes the particle system to a JSON object.
  86076. * @returns the JSON object
  86077. */
  86078. serialize(): any;
  86079. /**
  86080. * Parse properties from a JSON object
  86081. * @param serializationObject defines the JSON object
  86082. */
  86083. parse(serializationObject: any): void;
  86084. }
  86085. }
  86086. declare module BABYLON {
  86087. /**
  86088. * Particle emitter emitting particles from the inside of a cylinder.
  86089. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86090. */
  86091. export class CylinderParticleEmitter implements IParticleEmitterType {
  86092. /**
  86093. * The radius of the emission cylinder.
  86094. */
  86095. radius: number;
  86096. /**
  86097. * The height of the emission cylinder.
  86098. */
  86099. height: number;
  86100. /**
  86101. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86102. */
  86103. radiusRange: number;
  86104. /**
  86105. * How much to randomize the particle direction [0-1].
  86106. */
  86107. directionRandomizer: number;
  86108. /**
  86109. * Creates a new instance CylinderParticleEmitter
  86110. * @param radius the radius of the emission cylinder (1 by default)
  86111. * @param height the height of the emission cylinder (1 by default)
  86112. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86113. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86114. */
  86115. constructor(
  86116. /**
  86117. * The radius of the emission cylinder.
  86118. */
  86119. radius?: number,
  86120. /**
  86121. * The height of the emission cylinder.
  86122. */
  86123. height?: number,
  86124. /**
  86125. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86126. */
  86127. radiusRange?: number,
  86128. /**
  86129. * How much to randomize the particle direction [0-1].
  86130. */
  86131. directionRandomizer?: number);
  86132. /**
  86133. * Called by the particle System when the direction is computed for the created particle.
  86134. * @param worldMatrix is the world matrix of the particle system
  86135. * @param directionToUpdate is the direction vector to update with the result
  86136. * @param particle is the particle we are computed the direction for
  86137. */
  86138. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86139. /**
  86140. * Called by the particle System when the position is computed for the created particle.
  86141. * @param worldMatrix is the world matrix of the particle system
  86142. * @param positionToUpdate is the position vector to update with the result
  86143. * @param particle is the particle we are computed the position for
  86144. */
  86145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86146. /**
  86147. * Clones the current emitter and returns a copy of it
  86148. * @returns the new emitter
  86149. */
  86150. clone(): CylinderParticleEmitter;
  86151. /**
  86152. * Called by the GPUParticleSystem to setup the update shader
  86153. * @param effect defines the update shader
  86154. */
  86155. applyToShader(effect: Effect): void;
  86156. /**
  86157. * Returns a string to use to update the GPU particles update shader
  86158. * @returns a string containng the defines string
  86159. */
  86160. getEffectDefines(): string;
  86161. /**
  86162. * Returns the string "CylinderParticleEmitter"
  86163. * @returns a string containing the class name
  86164. */
  86165. getClassName(): string;
  86166. /**
  86167. * Serializes the particle system to a JSON object.
  86168. * @returns the JSON object
  86169. */
  86170. serialize(): any;
  86171. /**
  86172. * Parse properties from a JSON object
  86173. * @param serializationObject defines the JSON object
  86174. */
  86175. parse(serializationObject: any): void;
  86176. }
  86177. /**
  86178. * Particle emitter emitting particles from the inside of a cylinder.
  86179. * It emits the particles randomly between two vectors.
  86180. */
  86181. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86182. /**
  86183. * The min limit of the emission direction.
  86184. */
  86185. direction1: Vector3;
  86186. /**
  86187. * The max limit of the emission direction.
  86188. */
  86189. direction2: Vector3;
  86190. /**
  86191. * Creates a new instance CylinderDirectedParticleEmitter
  86192. * @param radius the radius of the emission cylinder (1 by default)
  86193. * @param height the height of the emission cylinder (1 by default)
  86194. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86195. * @param direction1 the min limit of the emission direction (up vector by default)
  86196. * @param direction2 the max limit of the emission direction (up vector by default)
  86197. */
  86198. constructor(radius?: number, height?: number, radiusRange?: number,
  86199. /**
  86200. * The min limit of the emission direction.
  86201. */
  86202. direction1?: Vector3,
  86203. /**
  86204. * The max limit of the emission direction.
  86205. */
  86206. direction2?: Vector3);
  86207. /**
  86208. * Called by the particle System when the direction is computed for the created particle.
  86209. * @param worldMatrix is the world matrix of the particle system
  86210. * @param directionToUpdate is the direction vector to update with the result
  86211. * @param particle is the particle we are computed the direction for
  86212. */
  86213. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86214. /**
  86215. * Clones the current emitter and returns a copy of it
  86216. * @returns the new emitter
  86217. */
  86218. clone(): CylinderDirectedParticleEmitter;
  86219. /**
  86220. * Called by the GPUParticleSystem to setup the update shader
  86221. * @param effect defines the update shader
  86222. */
  86223. applyToShader(effect: Effect): void;
  86224. /**
  86225. * Returns a string to use to update the GPU particles update shader
  86226. * @returns a string containng the defines string
  86227. */
  86228. getEffectDefines(): string;
  86229. /**
  86230. * Returns the string "CylinderDirectedParticleEmitter"
  86231. * @returns a string containing the class name
  86232. */
  86233. getClassName(): string;
  86234. /**
  86235. * Serializes the particle system to a JSON object.
  86236. * @returns the JSON object
  86237. */
  86238. serialize(): any;
  86239. /**
  86240. * Parse properties from a JSON object
  86241. * @param serializationObject defines the JSON object
  86242. */
  86243. parse(serializationObject: any): void;
  86244. }
  86245. }
  86246. declare module BABYLON {
  86247. /**
  86248. * Particle emitter emitting particles from the inside of a hemisphere.
  86249. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86250. */
  86251. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86252. /**
  86253. * The radius of the emission hemisphere.
  86254. */
  86255. radius: number;
  86256. /**
  86257. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86258. */
  86259. radiusRange: number;
  86260. /**
  86261. * How much to randomize the particle direction [0-1].
  86262. */
  86263. directionRandomizer: number;
  86264. /**
  86265. * Creates a new instance HemisphericParticleEmitter
  86266. * @param radius the radius of the emission hemisphere (1 by default)
  86267. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86268. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86269. */
  86270. constructor(
  86271. /**
  86272. * The radius of the emission hemisphere.
  86273. */
  86274. radius?: number,
  86275. /**
  86276. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86277. */
  86278. radiusRange?: number,
  86279. /**
  86280. * How much to randomize the particle direction [0-1].
  86281. */
  86282. directionRandomizer?: number);
  86283. /**
  86284. * Called by the particle System when the direction is computed for the created particle.
  86285. * @param worldMatrix is the world matrix of the particle system
  86286. * @param directionToUpdate is the direction vector to update with the result
  86287. * @param particle is the particle we are computed the direction for
  86288. */
  86289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86290. /**
  86291. * Called by the particle System when the position is computed for the created particle.
  86292. * @param worldMatrix is the world matrix of the particle system
  86293. * @param positionToUpdate is the position vector to update with the result
  86294. * @param particle is the particle we are computed the position for
  86295. */
  86296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86297. /**
  86298. * Clones the current emitter and returns a copy of it
  86299. * @returns the new emitter
  86300. */
  86301. clone(): HemisphericParticleEmitter;
  86302. /**
  86303. * Called by the GPUParticleSystem to setup the update shader
  86304. * @param effect defines the update shader
  86305. */
  86306. applyToShader(effect: Effect): void;
  86307. /**
  86308. * Returns a string to use to update the GPU particles update shader
  86309. * @returns a string containng the defines string
  86310. */
  86311. getEffectDefines(): string;
  86312. /**
  86313. * Returns the string "HemisphericParticleEmitter"
  86314. * @returns a string containing the class name
  86315. */
  86316. getClassName(): string;
  86317. /**
  86318. * Serializes the particle system to a JSON object.
  86319. * @returns the JSON object
  86320. */
  86321. serialize(): any;
  86322. /**
  86323. * Parse properties from a JSON object
  86324. * @param serializationObject defines the JSON object
  86325. */
  86326. parse(serializationObject: any): void;
  86327. }
  86328. }
  86329. declare module BABYLON {
  86330. /**
  86331. * Particle emitter emitting particles from a point.
  86332. * It emits the particles randomly between 2 given directions.
  86333. */
  86334. export class PointParticleEmitter implements IParticleEmitterType {
  86335. /**
  86336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86337. */
  86338. direction1: Vector3;
  86339. /**
  86340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86341. */
  86342. direction2: Vector3;
  86343. /**
  86344. * Creates a new instance PointParticleEmitter
  86345. */
  86346. constructor();
  86347. /**
  86348. * Called by the particle System when the direction is computed for the created particle.
  86349. * @param worldMatrix is the world matrix of the particle system
  86350. * @param directionToUpdate is the direction vector to update with the result
  86351. * @param particle is the particle we are computed the direction for
  86352. */
  86353. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86354. /**
  86355. * Called by the particle System when the position is computed for the created particle.
  86356. * @param worldMatrix is the world matrix of the particle system
  86357. * @param positionToUpdate is the position vector to update with the result
  86358. * @param particle is the particle we are computed the position for
  86359. */
  86360. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86361. /**
  86362. * Clones the current emitter and returns a copy of it
  86363. * @returns the new emitter
  86364. */
  86365. clone(): PointParticleEmitter;
  86366. /**
  86367. * Called by the GPUParticleSystem to setup the update shader
  86368. * @param effect defines the update shader
  86369. */
  86370. applyToShader(effect: Effect): void;
  86371. /**
  86372. * Returns a string to use to update the GPU particles update shader
  86373. * @returns a string containng the defines string
  86374. */
  86375. getEffectDefines(): string;
  86376. /**
  86377. * Returns the string "PointParticleEmitter"
  86378. * @returns a string containing the class name
  86379. */
  86380. getClassName(): string;
  86381. /**
  86382. * Serializes the particle system to a JSON object.
  86383. * @returns the JSON object
  86384. */
  86385. serialize(): any;
  86386. /**
  86387. * Parse properties from a JSON object
  86388. * @param serializationObject defines the JSON object
  86389. */
  86390. parse(serializationObject: any): void;
  86391. }
  86392. }
  86393. declare module BABYLON {
  86394. /**
  86395. * Particle emitter emitting particles from the inside of a sphere.
  86396. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86397. */
  86398. export class SphereParticleEmitter implements IParticleEmitterType {
  86399. /**
  86400. * The radius of the emission sphere.
  86401. */
  86402. radius: number;
  86403. /**
  86404. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86405. */
  86406. radiusRange: number;
  86407. /**
  86408. * How much to randomize the particle direction [0-1].
  86409. */
  86410. directionRandomizer: number;
  86411. /**
  86412. * Creates a new instance SphereParticleEmitter
  86413. * @param radius the radius of the emission sphere (1 by default)
  86414. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86415. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86416. */
  86417. constructor(
  86418. /**
  86419. * The radius of the emission sphere.
  86420. */
  86421. radius?: number,
  86422. /**
  86423. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86424. */
  86425. radiusRange?: number,
  86426. /**
  86427. * How much to randomize the particle direction [0-1].
  86428. */
  86429. directionRandomizer?: number);
  86430. /**
  86431. * Called by the particle System when the direction is computed for the created particle.
  86432. * @param worldMatrix is the world matrix of the particle system
  86433. * @param directionToUpdate is the direction vector to update with the result
  86434. * @param particle is the particle we are computed the direction for
  86435. */
  86436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86437. /**
  86438. * Called by the particle System when the position is computed for the created particle.
  86439. * @param worldMatrix is the world matrix of the particle system
  86440. * @param positionToUpdate is the position vector to update with the result
  86441. * @param particle is the particle we are computed the position for
  86442. */
  86443. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86444. /**
  86445. * Clones the current emitter and returns a copy of it
  86446. * @returns the new emitter
  86447. */
  86448. clone(): SphereParticleEmitter;
  86449. /**
  86450. * Called by the GPUParticleSystem to setup the update shader
  86451. * @param effect defines the update shader
  86452. */
  86453. applyToShader(effect: Effect): void;
  86454. /**
  86455. * Returns a string to use to update the GPU particles update shader
  86456. * @returns a string containng the defines string
  86457. */
  86458. getEffectDefines(): string;
  86459. /**
  86460. * Returns the string "SphereParticleEmitter"
  86461. * @returns a string containing the class name
  86462. */
  86463. getClassName(): string;
  86464. /**
  86465. * Serializes the particle system to a JSON object.
  86466. * @returns the JSON object
  86467. */
  86468. serialize(): any;
  86469. /**
  86470. * Parse properties from a JSON object
  86471. * @param serializationObject defines the JSON object
  86472. */
  86473. parse(serializationObject: any): void;
  86474. }
  86475. /**
  86476. * Particle emitter emitting particles from the inside of a sphere.
  86477. * It emits the particles randomly between two vectors.
  86478. */
  86479. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86480. /**
  86481. * The min limit of the emission direction.
  86482. */
  86483. direction1: Vector3;
  86484. /**
  86485. * The max limit of the emission direction.
  86486. */
  86487. direction2: Vector3;
  86488. /**
  86489. * Creates a new instance SphereDirectedParticleEmitter
  86490. * @param radius the radius of the emission sphere (1 by default)
  86491. * @param direction1 the min limit of the emission direction (up vector by default)
  86492. * @param direction2 the max limit of the emission direction (up vector by default)
  86493. */
  86494. constructor(radius?: number,
  86495. /**
  86496. * The min limit of the emission direction.
  86497. */
  86498. direction1?: Vector3,
  86499. /**
  86500. * The max limit of the emission direction.
  86501. */
  86502. direction2?: Vector3);
  86503. /**
  86504. * Called by the particle System when the direction is computed for the created particle.
  86505. * @param worldMatrix is the world matrix of the particle system
  86506. * @param directionToUpdate is the direction vector to update with the result
  86507. * @param particle is the particle we are computed the direction for
  86508. */
  86509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86510. /**
  86511. * Clones the current emitter and returns a copy of it
  86512. * @returns the new emitter
  86513. */
  86514. clone(): SphereDirectedParticleEmitter;
  86515. /**
  86516. * Called by the GPUParticleSystem to setup the update shader
  86517. * @param effect defines the update shader
  86518. */
  86519. applyToShader(effect: Effect): void;
  86520. /**
  86521. * Returns a string to use to update the GPU particles update shader
  86522. * @returns a string containng the defines string
  86523. */
  86524. getEffectDefines(): string;
  86525. /**
  86526. * Returns the string "SphereDirectedParticleEmitter"
  86527. * @returns a string containing the class name
  86528. */
  86529. getClassName(): string;
  86530. /**
  86531. * Serializes the particle system to a JSON object.
  86532. * @returns the JSON object
  86533. */
  86534. serialize(): any;
  86535. /**
  86536. * Parse properties from a JSON object
  86537. * @param serializationObject defines the JSON object
  86538. */
  86539. parse(serializationObject: any): void;
  86540. }
  86541. }
  86542. declare module BABYLON {
  86543. /**
  86544. * Interface representing a particle system in Babylon.js.
  86545. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86546. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86547. */
  86548. export interface IParticleSystem {
  86549. /**
  86550. * List of animations used by the particle system.
  86551. */
  86552. animations: Animation[];
  86553. /**
  86554. * The id of the Particle system.
  86555. */
  86556. id: string;
  86557. /**
  86558. * The name of the Particle system.
  86559. */
  86560. name: string;
  86561. /**
  86562. * The emitter represents the Mesh or position we are attaching the particle system to.
  86563. */
  86564. emitter: Nullable<AbstractMesh | Vector3>;
  86565. /**
  86566. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86567. */
  86568. isBillboardBased: boolean;
  86569. /**
  86570. * The rendering group used by the Particle system to chose when to render.
  86571. */
  86572. renderingGroupId: number;
  86573. /**
  86574. * The layer mask we are rendering the particles through.
  86575. */
  86576. layerMask: number;
  86577. /**
  86578. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86579. */
  86580. updateSpeed: number;
  86581. /**
  86582. * The amount of time the particle system is running (depends of the overall update speed).
  86583. */
  86584. targetStopDuration: number;
  86585. /**
  86586. * The texture used to render each particle. (this can be a spritesheet)
  86587. */
  86588. particleTexture: Nullable<Texture>;
  86589. /**
  86590. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86591. */
  86592. blendMode: number;
  86593. /**
  86594. * Minimum life time of emitting particles.
  86595. */
  86596. minLifeTime: number;
  86597. /**
  86598. * Maximum life time of emitting particles.
  86599. */
  86600. maxLifeTime: number;
  86601. /**
  86602. * Minimum Size of emitting particles.
  86603. */
  86604. minSize: number;
  86605. /**
  86606. * Maximum Size of emitting particles.
  86607. */
  86608. maxSize: number;
  86609. /**
  86610. * Minimum scale of emitting particles on X axis.
  86611. */
  86612. minScaleX: number;
  86613. /**
  86614. * Maximum scale of emitting particles on X axis.
  86615. */
  86616. maxScaleX: number;
  86617. /**
  86618. * Minimum scale of emitting particles on Y axis.
  86619. */
  86620. minScaleY: number;
  86621. /**
  86622. * Maximum scale of emitting particles on Y axis.
  86623. */
  86624. maxScaleY: number;
  86625. /**
  86626. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86627. */
  86628. color1: Color4;
  86629. /**
  86630. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86631. */
  86632. color2: Color4;
  86633. /**
  86634. * Color the particle will have at the end of its lifetime.
  86635. */
  86636. colorDead: Color4;
  86637. /**
  86638. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86639. */
  86640. emitRate: number;
  86641. /**
  86642. * You can use gravity if you want to give an orientation to your particles.
  86643. */
  86644. gravity: Vector3;
  86645. /**
  86646. * Minimum power of emitting particles.
  86647. */
  86648. minEmitPower: number;
  86649. /**
  86650. * Maximum power of emitting particles.
  86651. */
  86652. maxEmitPower: number;
  86653. /**
  86654. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86655. */
  86656. minAngularSpeed: number;
  86657. /**
  86658. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86659. */
  86660. maxAngularSpeed: number;
  86661. /**
  86662. * Gets or sets the minimal initial rotation in radians.
  86663. */
  86664. minInitialRotation: number;
  86665. /**
  86666. * Gets or sets the maximal initial rotation in radians.
  86667. */
  86668. maxInitialRotation: number;
  86669. /**
  86670. * The particle emitter type defines the emitter used by the particle system.
  86671. * It can be for example box, sphere, or cone...
  86672. */
  86673. particleEmitterType: Nullable<IParticleEmitterType>;
  86674. /**
  86675. * Defines the delay in milliseconds before starting the system (0 by default)
  86676. */
  86677. startDelay: number;
  86678. /**
  86679. * 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
  86680. */
  86681. preWarmCycles: number;
  86682. /**
  86683. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86684. */
  86685. preWarmStepOffset: number;
  86686. /**
  86687. * 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)
  86688. */
  86689. spriteCellChangeSpeed: number;
  86690. /**
  86691. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86692. */
  86693. startSpriteCellID: number;
  86694. /**
  86695. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86696. */
  86697. endSpriteCellID: number;
  86698. /**
  86699. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86700. */
  86701. spriteCellWidth: number;
  86702. /**
  86703. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86704. */
  86705. spriteCellHeight: number;
  86706. /**
  86707. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86708. */
  86709. spriteRandomStartCell: boolean;
  86710. /**
  86711. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86712. */
  86713. isAnimationSheetEnabled: boolean;
  86714. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86715. translationPivot: Vector2;
  86716. /**
  86717. * Gets or sets a texture used to add random noise to particle positions
  86718. */
  86719. noiseTexture: Nullable<BaseTexture>;
  86720. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86721. noiseStrength: Vector3;
  86722. /**
  86723. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86724. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86725. */
  86726. billboardMode: number;
  86727. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86728. limitVelocityDamping: number;
  86729. /**
  86730. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86731. */
  86732. beginAnimationOnStart: boolean;
  86733. /**
  86734. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86735. */
  86736. beginAnimationFrom: number;
  86737. /**
  86738. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86739. */
  86740. beginAnimationTo: number;
  86741. /**
  86742. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86743. */
  86744. beginAnimationLoop: boolean;
  86745. /**
  86746. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86747. */
  86748. disposeOnStop: boolean;
  86749. /**
  86750. * Gets the maximum number of particles active at the same time.
  86751. * @returns The max number of active particles.
  86752. */
  86753. getCapacity(): number;
  86754. /**
  86755. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86756. * @returns True if it has been started, otherwise false.
  86757. */
  86758. isStarted(): boolean;
  86759. /**
  86760. * Animates the particle system for this frame.
  86761. */
  86762. animate(): void;
  86763. /**
  86764. * Renders the particle system in its current state.
  86765. * @returns the current number of particles
  86766. */
  86767. render(): number;
  86768. /**
  86769. * Dispose the particle system and frees its associated resources.
  86770. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86771. */
  86772. dispose(disposeTexture?: boolean): void;
  86773. /**
  86774. * Clones the particle system.
  86775. * @param name The name of the cloned object
  86776. * @param newEmitter The new emitter to use
  86777. * @returns the cloned particle system
  86778. */
  86779. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86780. /**
  86781. * Serializes the particle system to a JSON object.
  86782. * @returns the JSON object
  86783. */
  86784. serialize(): any;
  86785. /**
  86786. * Rebuild the particle system
  86787. */
  86788. rebuild(): void;
  86789. /**
  86790. * Starts the particle system and begins to emit
  86791. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86792. */
  86793. start(delay?: number): void;
  86794. /**
  86795. * Stops the particle system.
  86796. */
  86797. stop(): void;
  86798. /**
  86799. * Remove all active particles
  86800. */
  86801. reset(): void;
  86802. /**
  86803. * Is this system ready to be used/rendered
  86804. * @return true if the system is ready
  86805. */
  86806. isReady(): boolean;
  86807. /**
  86808. * Adds a new color gradient
  86809. * @param gradient defines the gradient to use (between 0 and 1)
  86810. * @param color1 defines the color to affect to the specified gradient
  86811. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86812. * @returns the current particle system
  86813. */
  86814. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86815. /**
  86816. * Remove a specific color gradient
  86817. * @param gradient defines the gradient to remove
  86818. * @returns the current particle system
  86819. */
  86820. removeColorGradient(gradient: number): IParticleSystem;
  86821. /**
  86822. * Adds a new size gradient
  86823. * @param gradient defines the gradient to use (between 0 and 1)
  86824. * @param factor defines the size factor to affect to the specified gradient
  86825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86826. * @returns the current particle system
  86827. */
  86828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86829. /**
  86830. * Remove a specific size gradient
  86831. * @param gradient defines the gradient to remove
  86832. * @returns the current particle system
  86833. */
  86834. removeSizeGradient(gradient: number): IParticleSystem;
  86835. /**
  86836. * Gets the current list of color gradients.
  86837. * You must use addColorGradient and removeColorGradient to udpate this list
  86838. * @returns the list of color gradients
  86839. */
  86840. getColorGradients(): Nullable<Array<ColorGradient>>;
  86841. /**
  86842. * Gets the current list of size gradients.
  86843. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86844. * @returns the list of size gradients
  86845. */
  86846. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86847. /**
  86848. * Gets the current list of angular speed gradients.
  86849. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86850. * @returns the list of angular speed gradients
  86851. */
  86852. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86853. /**
  86854. * Adds a new angular speed gradient
  86855. * @param gradient defines the gradient to use (between 0 and 1)
  86856. * @param factor defines the angular speed to affect to the specified gradient
  86857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86858. * @returns the current particle system
  86859. */
  86860. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86861. /**
  86862. * Remove a specific angular speed gradient
  86863. * @param gradient defines the gradient to remove
  86864. * @returns the current particle system
  86865. */
  86866. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86867. /**
  86868. * Gets the current list of velocity gradients.
  86869. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86870. * @returns the list of velocity gradients
  86871. */
  86872. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86873. /**
  86874. * Adds a new velocity gradient
  86875. * @param gradient defines the gradient to use (between 0 and 1)
  86876. * @param factor defines the velocity to affect to the specified gradient
  86877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86878. * @returns the current particle system
  86879. */
  86880. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86881. /**
  86882. * Remove a specific velocity gradient
  86883. * @param gradient defines the gradient to remove
  86884. * @returns the current particle system
  86885. */
  86886. removeVelocityGradient(gradient: number): IParticleSystem;
  86887. /**
  86888. * Gets the current list of limit velocity gradients.
  86889. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86890. * @returns the list of limit velocity gradients
  86891. */
  86892. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86893. /**
  86894. * Adds a new limit velocity gradient
  86895. * @param gradient defines the gradient to use (between 0 and 1)
  86896. * @param factor defines the limit velocity to affect to the specified gradient
  86897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86898. * @returns the current particle system
  86899. */
  86900. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86901. /**
  86902. * Remove a specific limit velocity gradient
  86903. * @param gradient defines the gradient to remove
  86904. * @returns the current particle system
  86905. */
  86906. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86907. /**
  86908. * Adds a new drag gradient
  86909. * @param gradient defines the gradient to use (between 0 and 1)
  86910. * @param factor defines the drag to affect to the specified gradient
  86911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86912. * @returns the current particle system
  86913. */
  86914. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86915. /**
  86916. * Remove a specific drag gradient
  86917. * @param gradient defines the gradient to remove
  86918. * @returns the current particle system
  86919. */
  86920. removeDragGradient(gradient: number): IParticleSystem;
  86921. /**
  86922. * Gets the current list of drag gradients.
  86923. * You must use addDragGradient and removeDragGradient to udpate this list
  86924. * @returns the list of drag gradients
  86925. */
  86926. getDragGradients(): Nullable<Array<FactorGradient>>;
  86927. /**
  86928. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86929. * @param gradient defines the gradient to use (between 0 and 1)
  86930. * @param factor defines the emit rate to affect to the specified gradient
  86931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86932. * @returns the current particle system
  86933. */
  86934. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86935. /**
  86936. * Remove a specific emit rate gradient
  86937. * @param gradient defines the gradient to remove
  86938. * @returns the current particle system
  86939. */
  86940. removeEmitRateGradient(gradient: number): IParticleSystem;
  86941. /**
  86942. * Gets the current list of emit rate gradients.
  86943. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86944. * @returns the list of emit rate gradients
  86945. */
  86946. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86947. /**
  86948. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86949. * @param gradient defines the gradient to use (between 0 and 1)
  86950. * @param factor defines the start size to affect to the specified gradient
  86951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86952. * @returns the current particle system
  86953. */
  86954. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86955. /**
  86956. * Remove a specific start size gradient
  86957. * @param gradient defines the gradient to remove
  86958. * @returns the current particle system
  86959. */
  86960. removeStartSizeGradient(gradient: number): IParticleSystem;
  86961. /**
  86962. * Gets the current list of start size gradients.
  86963. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86964. * @returns the list of start size gradients
  86965. */
  86966. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86967. /**
  86968. * Adds a new life time gradient
  86969. * @param gradient defines the gradient to use (between 0 and 1)
  86970. * @param factor defines the life time factor to affect to the specified gradient
  86971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86972. * @returns the current particle system
  86973. */
  86974. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86975. /**
  86976. * Remove a specific life time gradient
  86977. * @param gradient defines the gradient to remove
  86978. * @returns the current particle system
  86979. */
  86980. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86981. /**
  86982. * Gets the current list of life time gradients.
  86983. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86984. * @returns the list of life time gradients
  86985. */
  86986. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86987. /**
  86988. * Gets the current list of color gradients.
  86989. * You must use addColorGradient and removeColorGradient to udpate this list
  86990. * @returns the list of color gradients
  86991. */
  86992. getColorGradients(): Nullable<Array<ColorGradient>>;
  86993. /**
  86994. * Adds a new ramp gradient used to remap particle colors
  86995. * @param gradient defines the gradient to use (between 0 and 1)
  86996. * @param color defines the color to affect to the specified gradient
  86997. * @returns the current particle system
  86998. */
  86999. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87000. /**
  87001. * Gets the current list of ramp gradients.
  87002. * You must use addRampGradient and removeRampGradient to udpate this list
  87003. * @returns the list of ramp gradients
  87004. */
  87005. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87006. /** Gets or sets a boolean indicating that ramp gradients must be used
  87007. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87008. */
  87009. useRampGradients: boolean;
  87010. /**
  87011. * Adds a new color remap gradient
  87012. * @param gradient defines the gradient to use (between 0 and 1)
  87013. * @param min defines the color remap minimal range
  87014. * @param max defines the color remap maximal range
  87015. * @returns the current particle system
  87016. */
  87017. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87018. /**
  87019. * Gets the current list of color remap gradients.
  87020. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87021. * @returns the list of color remap gradients
  87022. */
  87023. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87024. /**
  87025. * Adds a new alpha remap gradient
  87026. * @param gradient defines the gradient to use (between 0 and 1)
  87027. * @param min defines the alpha remap minimal range
  87028. * @param max defines the alpha remap maximal range
  87029. * @returns the current particle system
  87030. */
  87031. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87032. /**
  87033. * Gets the current list of alpha remap gradients.
  87034. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87035. * @returns the list of alpha remap gradients
  87036. */
  87037. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87038. /**
  87039. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87040. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87041. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87042. * @returns the emitter
  87043. */
  87044. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87045. /**
  87046. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87047. * @param radius The radius of the hemisphere to emit from
  87048. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87049. * @returns the emitter
  87050. */
  87051. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87052. /**
  87053. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87054. * @param radius The radius of the sphere to emit from
  87055. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87056. * @returns the emitter
  87057. */
  87058. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87059. /**
  87060. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87061. * @param radius The radius of the sphere to emit from
  87062. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87063. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87064. * @returns the emitter
  87065. */
  87066. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87067. /**
  87068. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87069. * @param radius The radius of the emission cylinder
  87070. * @param height The height of the emission cylinder
  87071. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87072. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87073. * @returns the emitter
  87074. */
  87075. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87076. /**
  87077. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87078. * @param radius The radius of the cylinder to emit from
  87079. * @param height The height of the emission cylinder
  87080. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87081. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87082. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87083. * @returns the emitter
  87084. */
  87085. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87086. /**
  87087. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87088. * @param radius The radius of the cone to emit from
  87089. * @param angle The base angle of the cone
  87090. * @returns the emitter
  87091. */
  87092. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87093. /**
  87094. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87095. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87096. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87097. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87098. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87099. * @returns the emitter
  87100. */
  87101. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87102. /**
  87103. * Get hosting scene
  87104. * @returns the scene
  87105. */
  87106. getScene(): Scene;
  87107. }
  87108. }
  87109. declare module BABYLON {
  87110. /**
  87111. * Creates an instance based on a source mesh.
  87112. */
  87113. export class InstancedMesh extends AbstractMesh {
  87114. private _sourceMesh;
  87115. private _currentLOD;
  87116. /** @hidden */
  87117. _indexInSourceMeshInstanceArray: number;
  87118. constructor(name: string, source: Mesh);
  87119. /**
  87120. * Returns the string "InstancedMesh".
  87121. */
  87122. getClassName(): string;
  87123. /** Gets the list of lights affecting that mesh */
  87124. readonly lightSources: Light[];
  87125. _resyncLightSources(): void;
  87126. _resyncLighSource(light: Light): void;
  87127. _removeLightSource(light: Light, dispose: boolean): void;
  87128. /**
  87129. * If the source mesh receives shadows
  87130. */
  87131. readonly receiveShadows: boolean;
  87132. /**
  87133. * The material of the source mesh
  87134. */
  87135. readonly material: Nullable<Material>;
  87136. /**
  87137. * Visibility of the source mesh
  87138. */
  87139. readonly visibility: number;
  87140. /**
  87141. * Skeleton of the source mesh
  87142. */
  87143. readonly skeleton: Nullable<Skeleton>;
  87144. /**
  87145. * Rendering ground id of the source mesh
  87146. */
  87147. renderingGroupId: number;
  87148. /**
  87149. * Returns the total number of vertices (integer).
  87150. */
  87151. getTotalVertices(): number;
  87152. /**
  87153. * Returns a positive integer : the total number of indices in this mesh geometry.
  87154. * @returns the numner of indices or zero if the mesh has no geometry.
  87155. */
  87156. getTotalIndices(): number;
  87157. /**
  87158. * The source mesh of the instance
  87159. */
  87160. readonly sourceMesh: Mesh;
  87161. /**
  87162. * Is this node ready to be used/rendered
  87163. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87164. * @return {boolean} is it ready
  87165. */
  87166. isReady(completeCheck?: boolean): boolean;
  87167. /**
  87168. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87169. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87170. * @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.
  87171. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87172. */
  87173. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87174. /**
  87175. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87176. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87177. * The `data` are either a numeric array either a Float32Array.
  87178. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87179. * 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).
  87180. * Note that a new underlying VertexBuffer object is created each call.
  87181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87182. *
  87183. * Possible `kind` values :
  87184. * - VertexBuffer.PositionKind
  87185. * - VertexBuffer.UVKind
  87186. * - VertexBuffer.UV2Kind
  87187. * - VertexBuffer.UV3Kind
  87188. * - VertexBuffer.UV4Kind
  87189. * - VertexBuffer.UV5Kind
  87190. * - VertexBuffer.UV6Kind
  87191. * - VertexBuffer.ColorKind
  87192. * - VertexBuffer.MatricesIndicesKind
  87193. * - VertexBuffer.MatricesIndicesExtraKind
  87194. * - VertexBuffer.MatricesWeightsKind
  87195. * - VertexBuffer.MatricesWeightsExtraKind
  87196. *
  87197. * Returns the Mesh.
  87198. */
  87199. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87200. /**
  87201. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87202. * If the mesh has no geometry, it is simply returned as it is.
  87203. * The `data` are either a numeric array either a Float32Array.
  87204. * No new underlying VertexBuffer object is created.
  87205. * 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.
  87206. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87207. *
  87208. * Possible `kind` values :
  87209. * - VertexBuffer.PositionKind
  87210. * - VertexBuffer.UVKind
  87211. * - VertexBuffer.UV2Kind
  87212. * - VertexBuffer.UV3Kind
  87213. * - VertexBuffer.UV4Kind
  87214. * - VertexBuffer.UV5Kind
  87215. * - VertexBuffer.UV6Kind
  87216. * - VertexBuffer.ColorKind
  87217. * - VertexBuffer.MatricesIndicesKind
  87218. * - VertexBuffer.MatricesIndicesExtraKind
  87219. * - VertexBuffer.MatricesWeightsKind
  87220. * - VertexBuffer.MatricesWeightsExtraKind
  87221. *
  87222. * Returns the Mesh.
  87223. */
  87224. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87225. /**
  87226. * Sets the mesh indices.
  87227. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87228. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87229. * This method creates a new index buffer each call.
  87230. * Returns the Mesh.
  87231. */
  87232. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87233. /**
  87234. * Boolean : True if the mesh owns the requested kind of data.
  87235. */
  87236. isVerticesDataPresent(kind: string): boolean;
  87237. /**
  87238. * Returns an array of indices (IndicesArray).
  87239. */
  87240. getIndices(): Nullable<IndicesArray>;
  87241. readonly _positions: Nullable<Vector3[]>;
  87242. /**
  87243. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87244. * This means the mesh underlying bounding box and sphere are recomputed.
  87245. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87246. * @returns the current mesh
  87247. */
  87248. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87249. /** @hidden */
  87250. _preActivate(): InstancedMesh;
  87251. /** @hidden */
  87252. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87253. /** @hidden */
  87254. _postActivate(): void;
  87255. getWorldMatrix(): Matrix;
  87256. readonly isAnInstance: boolean;
  87257. /**
  87258. * Returns the current associated LOD AbstractMesh.
  87259. */
  87260. getLOD(camera: Camera): AbstractMesh;
  87261. /** @hidden */
  87262. _syncSubMeshes(): InstancedMesh;
  87263. /** @hidden */
  87264. _generatePointsArray(): boolean;
  87265. /**
  87266. * Creates a new InstancedMesh from the current mesh.
  87267. * - name (string) : the cloned mesh name
  87268. * - newParent (optional Node) : the optional Node to parent the clone to.
  87269. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87270. *
  87271. * Returns the clone.
  87272. */
  87273. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87274. /**
  87275. * Disposes the InstancedMesh.
  87276. * Returns nothing.
  87277. */
  87278. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87279. }
  87280. interface Mesh {
  87281. /**
  87282. * Register a custom buffer that will be instanced
  87283. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87284. * @param kind defines the buffer kind
  87285. * @param stride defines the stride in floats
  87286. */
  87287. registerInstancedBuffer(kind: string, stride: number): void;
  87288. /** @hidden */
  87289. _userInstancedBuffersStorage: {
  87290. data: {
  87291. [key: string]: Float32Array;
  87292. };
  87293. sizes: {
  87294. [key: string]: number;
  87295. };
  87296. vertexBuffers: {
  87297. [key: string]: Nullable<VertexBuffer>;
  87298. };
  87299. strides: {
  87300. [key: string]: number;
  87301. };
  87302. };
  87303. }
  87304. interface AbstractMesh {
  87305. /**
  87306. * Object used to store instanced buffers defined by user
  87307. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87308. */
  87309. instancedBuffers: {
  87310. [key: string]: any;
  87311. };
  87312. }
  87313. }
  87314. declare module BABYLON {
  87315. /**
  87316. * Defines the options associated with the creation of a shader material.
  87317. */
  87318. export interface IShaderMaterialOptions {
  87319. /**
  87320. * Does the material work in alpha blend mode
  87321. */
  87322. needAlphaBlending: boolean;
  87323. /**
  87324. * Does the material work in alpha test mode
  87325. */
  87326. needAlphaTesting: boolean;
  87327. /**
  87328. * The list of attribute names used in the shader
  87329. */
  87330. attributes: string[];
  87331. /**
  87332. * The list of unifrom names used in the shader
  87333. */
  87334. uniforms: string[];
  87335. /**
  87336. * The list of UBO names used in the shader
  87337. */
  87338. uniformBuffers: string[];
  87339. /**
  87340. * The list of sampler names used in the shader
  87341. */
  87342. samplers: string[];
  87343. /**
  87344. * The list of defines used in the shader
  87345. */
  87346. defines: string[];
  87347. }
  87348. /**
  87349. * 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.
  87350. *
  87351. * This returned material effects how the mesh will look based on the code in the shaders.
  87352. *
  87353. * @see http://doc.babylonjs.com/how_to/shader_material
  87354. */
  87355. export class ShaderMaterial extends Material {
  87356. private _shaderPath;
  87357. private _options;
  87358. private _textures;
  87359. private _textureArrays;
  87360. private _floats;
  87361. private _ints;
  87362. private _floatsArrays;
  87363. private _colors3;
  87364. private _colors3Arrays;
  87365. private _colors4;
  87366. private _colors4Arrays;
  87367. private _vectors2;
  87368. private _vectors3;
  87369. private _vectors4;
  87370. private _matrices;
  87371. private _matrixArrays;
  87372. private _matrices3x3;
  87373. private _matrices2x2;
  87374. private _vectors2Arrays;
  87375. private _vectors3Arrays;
  87376. private _vectors4Arrays;
  87377. private _cachedWorldViewMatrix;
  87378. private _cachedWorldViewProjectionMatrix;
  87379. private _renderId;
  87380. private _multiview;
  87381. /**
  87382. * Instantiate a new shader material.
  87383. * 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.
  87384. * This returned material effects how the mesh will look based on the code in the shaders.
  87385. * @see http://doc.babylonjs.com/how_to/shader_material
  87386. * @param name Define the name of the material in the scene
  87387. * @param scene Define the scene the material belongs to
  87388. * @param shaderPath Defines the route to the shader code in one of three ways:
  87389. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87390. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87391. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87392. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87393. * @param options Define the options used to create the shader
  87394. */
  87395. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87396. /**
  87397. * Gets the shader path used to define the shader code
  87398. * It can be modified to trigger a new compilation
  87399. */
  87400. /**
  87401. * Sets the shader path used to define the shader code
  87402. * It can be modified to trigger a new compilation
  87403. */
  87404. shaderPath: any;
  87405. /**
  87406. * Gets the options used to compile the shader.
  87407. * They can be modified to trigger a new compilation
  87408. */
  87409. readonly options: IShaderMaterialOptions;
  87410. /**
  87411. * Gets the current class name of the material e.g. "ShaderMaterial"
  87412. * Mainly use in serialization.
  87413. * @returns the class name
  87414. */
  87415. getClassName(): string;
  87416. /**
  87417. * Specifies if the material will require alpha blending
  87418. * @returns a boolean specifying if alpha blending is needed
  87419. */
  87420. needAlphaBlending(): boolean;
  87421. /**
  87422. * Specifies if this material should be rendered in alpha test mode
  87423. * @returns a boolean specifying if an alpha test is needed.
  87424. */
  87425. needAlphaTesting(): boolean;
  87426. private _checkUniform;
  87427. /**
  87428. * Set a texture in the shader.
  87429. * @param name Define the name of the uniform samplers as defined in the shader
  87430. * @param texture Define the texture to bind to this sampler
  87431. * @return the material itself allowing "fluent" like uniform updates
  87432. */
  87433. setTexture(name: string, texture: Texture): ShaderMaterial;
  87434. /**
  87435. * Set a texture array in the shader.
  87436. * @param name Define the name of the uniform sampler array as defined in the shader
  87437. * @param textures Define the list of textures to bind to this sampler
  87438. * @return the material itself allowing "fluent" like uniform updates
  87439. */
  87440. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87441. /**
  87442. * Set a float in the shader.
  87443. * @param name Define the name of the uniform as defined in the shader
  87444. * @param value Define the value to give to the uniform
  87445. * @return the material itself allowing "fluent" like uniform updates
  87446. */
  87447. setFloat(name: string, value: number): ShaderMaterial;
  87448. /**
  87449. * Set a int in the shader.
  87450. * @param name Define the name of the uniform as defined in the shader
  87451. * @param value Define the value to give to the uniform
  87452. * @return the material itself allowing "fluent" like uniform updates
  87453. */
  87454. setInt(name: string, value: number): ShaderMaterial;
  87455. /**
  87456. * Set an array of floats in the shader.
  87457. * @param name Define the name of the uniform as defined in the shader
  87458. * @param value Define the value to give to the uniform
  87459. * @return the material itself allowing "fluent" like uniform updates
  87460. */
  87461. setFloats(name: string, value: number[]): ShaderMaterial;
  87462. /**
  87463. * Set a vec3 in the shader from a Color3.
  87464. * @param name Define the name of the uniform as defined in the shader
  87465. * @param value Define the value to give to the uniform
  87466. * @return the material itself allowing "fluent" like uniform updates
  87467. */
  87468. setColor3(name: string, value: Color3): ShaderMaterial;
  87469. /**
  87470. * Set a vec3 array in the shader from a Color3 array.
  87471. * @param name Define the name of the uniform as defined in the shader
  87472. * @param value Define the value to give to the uniform
  87473. * @return the material itself allowing "fluent" like uniform updates
  87474. */
  87475. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87476. /**
  87477. * Set a vec4 in the shader from a Color4.
  87478. * @param name Define the name of the uniform as defined in the shader
  87479. * @param value Define the value to give to the uniform
  87480. * @return the material itself allowing "fluent" like uniform updates
  87481. */
  87482. setColor4(name: string, value: Color4): ShaderMaterial;
  87483. /**
  87484. * Set a vec4 array in the shader from a Color4 array.
  87485. * @param name Define the name of the uniform as defined in the shader
  87486. * @param value Define the value to give to the uniform
  87487. * @return the material itself allowing "fluent" like uniform updates
  87488. */
  87489. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87490. /**
  87491. * Set a vec2 in the shader from a Vector2.
  87492. * @param name Define the name of the uniform as defined in the shader
  87493. * @param value Define the value to give to the uniform
  87494. * @return the material itself allowing "fluent" like uniform updates
  87495. */
  87496. setVector2(name: string, value: Vector2): ShaderMaterial;
  87497. /**
  87498. * Set a vec3 in the shader from a Vector3.
  87499. * @param name Define the name of the uniform as defined in the shader
  87500. * @param value Define the value to give to the uniform
  87501. * @return the material itself allowing "fluent" like uniform updates
  87502. */
  87503. setVector3(name: string, value: Vector3): ShaderMaterial;
  87504. /**
  87505. * Set a vec4 in the shader from a Vector4.
  87506. * @param name Define the name of the uniform as defined in the shader
  87507. * @param value Define the value to give to the uniform
  87508. * @return the material itself allowing "fluent" like uniform updates
  87509. */
  87510. setVector4(name: string, value: Vector4): ShaderMaterial;
  87511. /**
  87512. * Set a mat4 in the shader from a Matrix.
  87513. * @param name Define the name of the uniform as defined in the shader
  87514. * @param value Define the value to give to the uniform
  87515. * @return the material itself allowing "fluent" like uniform updates
  87516. */
  87517. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87518. /**
  87519. * Set a float32Array in the shader from a matrix array.
  87520. * @param name Define the name of the uniform as defined in the shader
  87521. * @param value Define the value to give to the uniform
  87522. * @return the material itself allowing "fluent" like uniform updates
  87523. */
  87524. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87525. /**
  87526. * Set a mat3 in the shader from a Float32Array.
  87527. * @param name Define the name of the uniform as defined in the shader
  87528. * @param value Define the value to give to the uniform
  87529. * @return the material itself allowing "fluent" like uniform updates
  87530. */
  87531. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87532. /**
  87533. * Set a mat2 in the shader from a Float32Array.
  87534. * @param name Define the name of the uniform as defined in the shader
  87535. * @param value Define the value to give to the uniform
  87536. * @return the material itself allowing "fluent" like uniform updates
  87537. */
  87538. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87539. /**
  87540. * Set a vec2 array in the shader from a number array.
  87541. * @param name Define the name of the uniform as defined in the shader
  87542. * @param value Define the value to give to the uniform
  87543. * @return the material itself allowing "fluent" like uniform updates
  87544. */
  87545. setArray2(name: string, value: number[]): ShaderMaterial;
  87546. /**
  87547. * Set a vec3 array in the shader from a number array.
  87548. * @param name Define the name of the uniform as defined in the shader
  87549. * @param value Define the value to give to the uniform
  87550. * @return the material itself allowing "fluent" like uniform updates
  87551. */
  87552. setArray3(name: string, value: number[]): ShaderMaterial;
  87553. /**
  87554. * Set a vec4 array in the shader from a number array.
  87555. * @param name Define the name of the uniform as defined in the shader
  87556. * @param value Define the value to give to the uniform
  87557. * @return the material itself allowing "fluent" like uniform updates
  87558. */
  87559. setArray4(name: string, value: number[]): ShaderMaterial;
  87560. private _checkCache;
  87561. /**
  87562. * Specifies that the submesh is ready to be used
  87563. * @param mesh defines the mesh to check
  87564. * @param subMesh defines which submesh to check
  87565. * @param useInstances specifies that instances should be used
  87566. * @returns a boolean indicating that the submesh is ready or not
  87567. */
  87568. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87569. /**
  87570. * Checks if the material is ready to render the requested mesh
  87571. * @param mesh Define the mesh to render
  87572. * @param useInstances Define whether or not the material is used with instances
  87573. * @returns true if ready, otherwise false
  87574. */
  87575. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87576. /**
  87577. * Binds the world matrix to the material
  87578. * @param world defines the world transformation matrix
  87579. */
  87580. bindOnlyWorldMatrix(world: Matrix): void;
  87581. /**
  87582. * Binds the material to the mesh
  87583. * @param world defines the world transformation matrix
  87584. * @param mesh defines the mesh to bind the material to
  87585. */
  87586. bind(world: Matrix, mesh?: Mesh): void;
  87587. /**
  87588. * Gets the active textures from the material
  87589. * @returns an array of textures
  87590. */
  87591. getActiveTextures(): BaseTexture[];
  87592. /**
  87593. * Specifies if the material uses a texture
  87594. * @param texture defines the texture to check against the material
  87595. * @returns a boolean specifying if the material uses the texture
  87596. */
  87597. hasTexture(texture: BaseTexture): boolean;
  87598. /**
  87599. * Makes a duplicate of the material, and gives it a new name
  87600. * @param name defines the new name for the duplicated material
  87601. * @returns the cloned material
  87602. */
  87603. clone(name: string): ShaderMaterial;
  87604. /**
  87605. * Disposes the material
  87606. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87607. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87608. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87609. */
  87610. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87611. /**
  87612. * Serializes this material in a JSON representation
  87613. * @returns the serialized material object
  87614. */
  87615. serialize(): any;
  87616. /**
  87617. * Creates a shader material from parsed shader material data
  87618. * @param source defines the JSON represnetation of the material
  87619. * @param scene defines the hosting scene
  87620. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87621. * @returns a new material
  87622. */
  87623. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87624. }
  87625. }
  87626. declare module BABYLON {
  87627. /** @hidden */
  87628. export var colorPixelShader: {
  87629. name: string;
  87630. shader: string;
  87631. };
  87632. }
  87633. declare module BABYLON {
  87634. /** @hidden */
  87635. export var colorVertexShader: {
  87636. name: string;
  87637. shader: string;
  87638. };
  87639. }
  87640. declare module BABYLON {
  87641. /**
  87642. * Line mesh
  87643. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87644. */
  87645. export class LinesMesh extends Mesh {
  87646. /**
  87647. * If vertex color should be applied to the mesh
  87648. */
  87649. readonly useVertexColor?: boolean | undefined;
  87650. /**
  87651. * If vertex alpha should be applied to the mesh
  87652. */
  87653. readonly useVertexAlpha?: boolean | undefined;
  87654. /**
  87655. * Color of the line (Default: White)
  87656. */
  87657. color: Color3;
  87658. /**
  87659. * Alpha of the line (Default: 1)
  87660. */
  87661. alpha: number;
  87662. /**
  87663. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87664. * This margin is expressed in world space coordinates, so its value may vary.
  87665. * Default value is 0.1
  87666. */
  87667. intersectionThreshold: number;
  87668. private _colorShader;
  87669. private color4;
  87670. /**
  87671. * Creates a new LinesMesh
  87672. * @param name defines the name
  87673. * @param scene defines the hosting scene
  87674. * @param parent defines the parent mesh if any
  87675. * @param source defines the optional source LinesMesh used to clone data from
  87676. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87677. * When false, achieved by calling a clone(), also passing False.
  87678. * This will make creation of children, recursive.
  87679. * @param useVertexColor defines if this LinesMesh supports vertex color
  87680. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87681. */
  87682. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87683. /**
  87684. * If vertex color should be applied to the mesh
  87685. */
  87686. useVertexColor?: boolean | undefined,
  87687. /**
  87688. * If vertex alpha should be applied to the mesh
  87689. */
  87690. useVertexAlpha?: boolean | undefined);
  87691. private _addClipPlaneDefine;
  87692. private _removeClipPlaneDefine;
  87693. isReady(): boolean;
  87694. /**
  87695. * Returns the string "LineMesh"
  87696. */
  87697. getClassName(): string;
  87698. /**
  87699. * @hidden
  87700. */
  87701. /**
  87702. * @hidden
  87703. */
  87704. material: Material;
  87705. /**
  87706. * @hidden
  87707. */
  87708. readonly checkCollisions: boolean;
  87709. /** @hidden */
  87710. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87711. /** @hidden */
  87712. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87713. /**
  87714. * Disposes of the line mesh
  87715. * @param doNotRecurse If children should be disposed
  87716. */
  87717. dispose(doNotRecurse?: boolean): void;
  87718. /**
  87719. * Returns a new LineMesh object cloned from the current one.
  87720. */
  87721. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87722. /**
  87723. * Creates a new InstancedLinesMesh object from the mesh model.
  87724. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87725. * @param name defines the name of the new instance
  87726. * @returns a new InstancedLinesMesh
  87727. */
  87728. createInstance(name: string): InstancedLinesMesh;
  87729. }
  87730. /**
  87731. * Creates an instance based on a source LinesMesh
  87732. */
  87733. export class InstancedLinesMesh extends InstancedMesh {
  87734. /**
  87735. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87736. * This margin is expressed in world space coordinates, so its value may vary.
  87737. * Initilized with the intersectionThreshold value of the source LinesMesh
  87738. */
  87739. intersectionThreshold: number;
  87740. constructor(name: string, source: LinesMesh);
  87741. /**
  87742. * Returns the string "InstancedLinesMesh".
  87743. */
  87744. getClassName(): string;
  87745. }
  87746. }
  87747. declare module BABYLON {
  87748. /** @hidden */
  87749. export var linePixelShader: {
  87750. name: string;
  87751. shader: string;
  87752. };
  87753. }
  87754. declare module BABYLON {
  87755. /** @hidden */
  87756. export var lineVertexShader: {
  87757. name: string;
  87758. shader: string;
  87759. };
  87760. }
  87761. declare module BABYLON {
  87762. interface AbstractMesh {
  87763. /**
  87764. * Gets the edgesRenderer associated with the mesh
  87765. */
  87766. edgesRenderer: Nullable<EdgesRenderer>;
  87767. }
  87768. interface LinesMesh {
  87769. /**
  87770. * Enables the edge rendering mode on the mesh.
  87771. * This mode makes the mesh edges visible
  87772. * @param epsilon defines the maximal distance between two angles to detect a face
  87773. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87774. * @returns the currentAbstractMesh
  87775. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87776. */
  87777. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87778. }
  87779. interface InstancedLinesMesh {
  87780. /**
  87781. * Enables the edge rendering mode on the mesh.
  87782. * This mode makes the mesh edges visible
  87783. * @param epsilon defines the maximal distance between two angles to detect a face
  87784. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87785. * @returns the current InstancedLinesMesh
  87786. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87787. */
  87788. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87789. }
  87790. /**
  87791. * Defines the minimum contract an Edges renderer should follow.
  87792. */
  87793. export interface IEdgesRenderer extends IDisposable {
  87794. /**
  87795. * Gets or sets a boolean indicating if the edgesRenderer is active
  87796. */
  87797. isEnabled: boolean;
  87798. /**
  87799. * Renders the edges of the attached mesh,
  87800. */
  87801. render(): void;
  87802. /**
  87803. * Checks wether or not the edges renderer is ready to render.
  87804. * @return true if ready, otherwise false.
  87805. */
  87806. isReady(): boolean;
  87807. }
  87808. /**
  87809. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87810. */
  87811. export class EdgesRenderer implements IEdgesRenderer {
  87812. /**
  87813. * Define the size of the edges with an orthographic camera
  87814. */
  87815. edgesWidthScalerForOrthographic: number;
  87816. /**
  87817. * Define the size of the edges with a perspective camera
  87818. */
  87819. edgesWidthScalerForPerspective: number;
  87820. protected _source: AbstractMesh;
  87821. protected _linesPositions: number[];
  87822. protected _linesNormals: number[];
  87823. protected _linesIndices: number[];
  87824. protected _epsilon: number;
  87825. protected _indicesCount: number;
  87826. protected _lineShader: ShaderMaterial;
  87827. protected _ib: DataBuffer;
  87828. protected _buffers: {
  87829. [key: string]: Nullable<VertexBuffer>;
  87830. };
  87831. protected _checkVerticesInsteadOfIndices: boolean;
  87832. private _meshRebuildObserver;
  87833. private _meshDisposeObserver;
  87834. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87835. isEnabled: boolean;
  87836. /**
  87837. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87838. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87839. * @param source Mesh used to create edges
  87840. * @param epsilon sum of angles in adjacency to check for edge
  87841. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87842. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87843. */
  87844. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87845. protected _prepareRessources(): void;
  87846. /** @hidden */
  87847. _rebuild(): void;
  87848. /**
  87849. * Releases the required resources for the edges renderer
  87850. */
  87851. dispose(): void;
  87852. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87853. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87854. /**
  87855. * Checks if the pair of p0 and p1 is en edge
  87856. * @param faceIndex
  87857. * @param edge
  87858. * @param faceNormals
  87859. * @param p0
  87860. * @param p1
  87861. * @private
  87862. */
  87863. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87864. /**
  87865. * push line into the position, normal and index buffer
  87866. * @protected
  87867. */
  87868. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87869. /**
  87870. * Generates lines edges from adjacencjes
  87871. * @private
  87872. */
  87873. _generateEdgesLines(): void;
  87874. /**
  87875. * Checks wether or not the edges renderer is ready to render.
  87876. * @return true if ready, otherwise false.
  87877. */
  87878. isReady(): boolean;
  87879. /**
  87880. * Renders the edges of the attached mesh,
  87881. */
  87882. render(): void;
  87883. }
  87884. /**
  87885. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87886. */
  87887. export class LineEdgesRenderer extends EdgesRenderer {
  87888. /**
  87889. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87890. * @param source LineMesh used to generate edges
  87891. * @param epsilon not important (specified angle for edge detection)
  87892. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87893. */
  87894. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87895. /**
  87896. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87897. */
  87898. _generateEdgesLines(): void;
  87899. }
  87900. }
  87901. declare module BABYLON {
  87902. /**
  87903. * This represents the object necessary to create a rendering group.
  87904. * This is exclusively used and created by the rendering manager.
  87905. * To modify the behavior, you use the available helpers in your scene or meshes.
  87906. * @hidden
  87907. */
  87908. export class RenderingGroup {
  87909. index: number;
  87910. private static _zeroVector;
  87911. private _scene;
  87912. private _opaqueSubMeshes;
  87913. private _transparentSubMeshes;
  87914. private _alphaTestSubMeshes;
  87915. private _depthOnlySubMeshes;
  87916. private _particleSystems;
  87917. private _spriteManagers;
  87918. private _opaqueSortCompareFn;
  87919. private _alphaTestSortCompareFn;
  87920. private _transparentSortCompareFn;
  87921. private _renderOpaque;
  87922. private _renderAlphaTest;
  87923. private _renderTransparent;
  87924. /** @hidden */
  87925. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87926. onBeforeTransparentRendering: () => void;
  87927. /**
  87928. * Set the opaque sort comparison function.
  87929. * If null the sub meshes will be render in the order they were created
  87930. */
  87931. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87932. /**
  87933. * Set the alpha test sort comparison function.
  87934. * If null the sub meshes will be render in the order they were created
  87935. */
  87936. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87937. /**
  87938. * Set the transparent sort comparison function.
  87939. * If null the sub meshes will be render in the order they were created
  87940. */
  87941. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87942. /**
  87943. * Creates a new rendering group.
  87944. * @param index The rendering group index
  87945. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87946. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87947. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87948. */
  87949. 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>);
  87950. /**
  87951. * Render all the sub meshes contained in the group.
  87952. * @param customRenderFunction Used to override the default render behaviour of the group.
  87953. * @returns true if rendered some submeshes.
  87954. */
  87955. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87956. /**
  87957. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87958. * @param subMeshes The submeshes to render
  87959. */
  87960. private renderOpaqueSorted;
  87961. /**
  87962. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87963. * @param subMeshes The submeshes to render
  87964. */
  87965. private renderAlphaTestSorted;
  87966. /**
  87967. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87968. * @param subMeshes The submeshes to render
  87969. */
  87970. private renderTransparentSorted;
  87971. /**
  87972. * Renders the submeshes in a specified order.
  87973. * @param subMeshes The submeshes to sort before render
  87974. * @param sortCompareFn The comparison function use to sort
  87975. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87976. * @param transparent Specifies to activate blending if true
  87977. */
  87978. private static renderSorted;
  87979. /**
  87980. * Renders the submeshes in the order they were dispatched (no sort applied).
  87981. * @param subMeshes The submeshes to render
  87982. */
  87983. private static renderUnsorted;
  87984. /**
  87985. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87986. * are rendered back to front if in the same alpha index.
  87987. *
  87988. * @param a The first submesh
  87989. * @param b The second submesh
  87990. * @returns The result of the comparison
  87991. */
  87992. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87993. /**
  87994. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87995. * are rendered back to front.
  87996. *
  87997. * @param a The first submesh
  87998. * @param b The second submesh
  87999. * @returns The result of the comparison
  88000. */
  88001. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88002. /**
  88003. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88004. * are rendered front to back (prevent overdraw).
  88005. *
  88006. * @param a The first submesh
  88007. * @param b The second submesh
  88008. * @returns The result of the comparison
  88009. */
  88010. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88011. /**
  88012. * Resets the different lists of submeshes to prepare a new frame.
  88013. */
  88014. prepare(): void;
  88015. dispose(): void;
  88016. /**
  88017. * Inserts the submesh in its correct queue depending on its material.
  88018. * @param subMesh The submesh to dispatch
  88019. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88020. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88021. */
  88022. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88023. dispatchSprites(spriteManager: ISpriteManager): void;
  88024. dispatchParticles(particleSystem: IParticleSystem): void;
  88025. private _renderParticles;
  88026. private _renderSprites;
  88027. }
  88028. }
  88029. declare module BABYLON {
  88030. /**
  88031. * Interface describing the different options available in the rendering manager
  88032. * regarding Auto Clear between groups.
  88033. */
  88034. export interface IRenderingManagerAutoClearSetup {
  88035. /**
  88036. * Defines whether or not autoclear is enable.
  88037. */
  88038. autoClear: boolean;
  88039. /**
  88040. * Defines whether or not to autoclear the depth buffer.
  88041. */
  88042. depth: boolean;
  88043. /**
  88044. * Defines whether or not to autoclear the stencil buffer.
  88045. */
  88046. stencil: boolean;
  88047. }
  88048. /**
  88049. * This class is used by the onRenderingGroupObservable
  88050. */
  88051. export class RenderingGroupInfo {
  88052. /**
  88053. * The Scene that being rendered
  88054. */
  88055. scene: Scene;
  88056. /**
  88057. * The camera currently used for the rendering pass
  88058. */
  88059. camera: Nullable<Camera>;
  88060. /**
  88061. * The ID of the renderingGroup being processed
  88062. */
  88063. renderingGroupId: number;
  88064. }
  88065. /**
  88066. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88067. * It is enable to manage the different groups as well as the different necessary sort functions.
  88068. * This should not be used directly aside of the few static configurations
  88069. */
  88070. export class RenderingManager {
  88071. /**
  88072. * The max id used for rendering groups (not included)
  88073. */
  88074. static MAX_RENDERINGGROUPS: number;
  88075. /**
  88076. * The min id used for rendering groups (included)
  88077. */
  88078. static MIN_RENDERINGGROUPS: number;
  88079. /**
  88080. * Used to globally prevent autoclearing scenes.
  88081. */
  88082. static AUTOCLEAR: boolean;
  88083. /**
  88084. * @hidden
  88085. */
  88086. _useSceneAutoClearSetup: boolean;
  88087. private _scene;
  88088. private _renderingGroups;
  88089. private _depthStencilBufferAlreadyCleaned;
  88090. private _autoClearDepthStencil;
  88091. private _customOpaqueSortCompareFn;
  88092. private _customAlphaTestSortCompareFn;
  88093. private _customTransparentSortCompareFn;
  88094. private _renderingGroupInfo;
  88095. /**
  88096. * Instantiates a new rendering group for a particular scene
  88097. * @param scene Defines the scene the groups belongs to
  88098. */
  88099. constructor(scene: Scene);
  88100. private _clearDepthStencilBuffer;
  88101. /**
  88102. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88103. * @hidden
  88104. */
  88105. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88106. /**
  88107. * Resets the different information of the group to prepare a new frame
  88108. * @hidden
  88109. */
  88110. reset(): void;
  88111. /**
  88112. * Dispose and release the group and its associated resources.
  88113. * @hidden
  88114. */
  88115. dispose(): void;
  88116. /**
  88117. * Clear the info related to rendering groups preventing retention points during dispose.
  88118. */
  88119. freeRenderingGroups(): void;
  88120. private _prepareRenderingGroup;
  88121. /**
  88122. * Add a sprite manager to the rendering manager in order to render it this frame.
  88123. * @param spriteManager Define the sprite manager to render
  88124. */
  88125. dispatchSprites(spriteManager: ISpriteManager): void;
  88126. /**
  88127. * Add a particle system to the rendering manager in order to render it this frame.
  88128. * @param particleSystem Define the particle system to render
  88129. */
  88130. dispatchParticles(particleSystem: IParticleSystem): void;
  88131. /**
  88132. * Add a submesh to the manager in order to render it this frame
  88133. * @param subMesh The submesh to dispatch
  88134. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88135. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88136. */
  88137. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88138. /**
  88139. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88140. * This allowed control for front to back rendering or reversly depending of the special needs.
  88141. *
  88142. * @param renderingGroupId The rendering group id corresponding to its index
  88143. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88144. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88145. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88146. */
  88147. 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;
  88148. /**
  88149. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88150. *
  88151. * @param renderingGroupId The rendering group id corresponding to its index
  88152. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88153. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88154. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88155. */
  88156. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88157. /**
  88158. * Gets the current auto clear configuration for one rendering group of the rendering
  88159. * manager.
  88160. * @param index the rendering group index to get the information for
  88161. * @returns The auto clear setup for the requested rendering group
  88162. */
  88163. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88164. }
  88165. }
  88166. declare module BABYLON {
  88167. /**
  88168. * This Helps creating a texture that will be created from a camera in your scene.
  88169. * It is basically a dynamic texture that could be used to create special effects for instance.
  88170. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88171. */
  88172. export class RenderTargetTexture extends Texture {
  88173. isCube: boolean;
  88174. /**
  88175. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88176. */
  88177. static readonly REFRESHRATE_RENDER_ONCE: number;
  88178. /**
  88179. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88180. */
  88181. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88182. /**
  88183. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88184. * the central point of your effect and can save a lot of performances.
  88185. */
  88186. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88187. /**
  88188. * Use this predicate to dynamically define the list of mesh you want to render.
  88189. * If set, the renderList property will be overwritten.
  88190. */
  88191. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88192. private _renderList;
  88193. /**
  88194. * Use this list to define the list of mesh you want to render.
  88195. */
  88196. renderList: Nullable<Array<AbstractMesh>>;
  88197. private _hookArray;
  88198. /**
  88199. * Define if particles should be rendered in your texture.
  88200. */
  88201. renderParticles: boolean;
  88202. /**
  88203. * Define if sprites should be rendered in your texture.
  88204. */
  88205. renderSprites: boolean;
  88206. /**
  88207. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88208. */
  88209. coordinatesMode: number;
  88210. /**
  88211. * Define the camera used to render the texture.
  88212. */
  88213. activeCamera: Nullable<Camera>;
  88214. /**
  88215. * Override the render function of the texture with your own one.
  88216. */
  88217. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88218. /**
  88219. * Define if camera post processes should be use while rendering the texture.
  88220. */
  88221. useCameraPostProcesses: boolean;
  88222. /**
  88223. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88224. */
  88225. ignoreCameraViewport: boolean;
  88226. private _postProcessManager;
  88227. private _postProcesses;
  88228. private _resizeObserver;
  88229. /**
  88230. * An event triggered when the texture is unbind.
  88231. */
  88232. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88233. /**
  88234. * An event triggered when the texture is unbind.
  88235. */
  88236. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88237. private _onAfterUnbindObserver;
  88238. /**
  88239. * Set a after unbind callback in the texture.
  88240. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88241. */
  88242. onAfterUnbind: () => void;
  88243. /**
  88244. * An event triggered before rendering the texture
  88245. */
  88246. onBeforeRenderObservable: Observable<number>;
  88247. private _onBeforeRenderObserver;
  88248. /**
  88249. * Set a before render callback in the texture.
  88250. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88251. */
  88252. onBeforeRender: (faceIndex: number) => void;
  88253. /**
  88254. * An event triggered after rendering the texture
  88255. */
  88256. onAfterRenderObservable: Observable<number>;
  88257. private _onAfterRenderObserver;
  88258. /**
  88259. * Set a after render callback in the texture.
  88260. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88261. */
  88262. onAfterRender: (faceIndex: number) => void;
  88263. /**
  88264. * An event triggered after the texture clear
  88265. */
  88266. onClearObservable: Observable<Engine>;
  88267. private _onClearObserver;
  88268. /**
  88269. * Set a clear callback in the texture.
  88270. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88271. */
  88272. onClear: (Engine: Engine) => void;
  88273. /**
  88274. * An event triggered when the texture is resized.
  88275. */
  88276. onResizeObservable: Observable<RenderTargetTexture>;
  88277. /**
  88278. * Define the clear color of the Render Target if it should be different from the scene.
  88279. */
  88280. clearColor: Color4;
  88281. protected _size: number | {
  88282. width: number;
  88283. height: number;
  88284. };
  88285. protected _initialSizeParameter: number | {
  88286. width: number;
  88287. height: number;
  88288. } | {
  88289. ratio: number;
  88290. };
  88291. protected _sizeRatio: Nullable<number>;
  88292. /** @hidden */
  88293. _generateMipMaps: boolean;
  88294. protected _renderingManager: RenderingManager;
  88295. /** @hidden */
  88296. _waitingRenderList: string[];
  88297. protected _doNotChangeAspectRatio: boolean;
  88298. protected _currentRefreshId: number;
  88299. protected _refreshRate: number;
  88300. protected _textureMatrix: Matrix;
  88301. protected _samples: number;
  88302. protected _renderTargetOptions: RenderTargetCreationOptions;
  88303. /**
  88304. * Gets render target creation options that were used.
  88305. */
  88306. readonly renderTargetOptions: RenderTargetCreationOptions;
  88307. protected _engine: Engine;
  88308. protected _onRatioRescale(): void;
  88309. /**
  88310. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88311. * It must define where the camera used to render the texture is set
  88312. */
  88313. boundingBoxPosition: Vector3;
  88314. private _boundingBoxSize;
  88315. /**
  88316. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88317. * When defined, the cubemap will switch to local mode
  88318. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88319. * @example https://www.babylonjs-playground.com/#RNASML
  88320. */
  88321. boundingBoxSize: Vector3;
  88322. /**
  88323. * In case the RTT has been created with a depth texture, get the associated
  88324. * depth texture.
  88325. * Otherwise, return null.
  88326. */
  88327. depthStencilTexture: Nullable<InternalTexture>;
  88328. /**
  88329. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88330. * or used a shadow, depth texture...
  88331. * @param name The friendly name of the texture
  88332. * @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)
  88333. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88334. * @param generateMipMaps True if mip maps need to be generated after render.
  88335. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88336. * @param type The type of the buffer in the RTT (int, half float, float...)
  88337. * @param isCube True if a cube texture needs to be created
  88338. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88339. * @param generateDepthBuffer True to generate a depth buffer
  88340. * @param generateStencilBuffer True to generate a stencil buffer
  88341. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88342. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88343. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88344. */
  88345. constructor(name: string, size: number | {
  88346. width: number;
  88347. height: number;
  88348. } | {
  88349. ratio: number;
  88350. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88351. /**
  88352. * Creates a depth stencil texture.
  88353. * This is only available in WebGL 2 or with the depth texture extension available.
  88354. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88355. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88356. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88357. */
  88358. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88359. private _processSizeParameter;
  88360. /**
  88361. * Define the number of samples to use in case of MSAA.
  88362. * It defaults to one meaning no MSAA has been enabled.
  88363. */
  88364. samples: number;
  88365. /**
  88366. * Resets the refresh counter of the texture and start bak from scratch.
  88367. * Could be useful to regenerate the texture if it is setup to render only once.
  88368. */
  88369. resetRefreshCounter(): void;
  88370. /**
  88371. * Define the refresh rate of the texture or the rendering frequency.
  88372. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88373. */
  88374. refreshRate: number;
  88375. /**
  88376. * Adds a post process to the render target rendering passes.
  88377. * @param postProcess define the post process to add
  88378. */
  88379. addPostProcess(postProcess: PostProcess): void;
  88380. /**
  88381. * Clear all the post processes attached to the render target
  88382. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88383. */
  88384. clearPostProcesses(dispose?: boolean): void;
  88385. /**
  88386. * Remove one of the post process from the list of attached post processes to the texture
  88387. * @param postProcess define the post process to remove from the list
  88388. */
  88389. removePostProcess(postProcess: PostProcess): void;
  88390. /** @hidden */
  88391. _shouldRender(): boolean;
  88392. /**
  88393. * Gets the actual render size of the texture.
  88394. * @returns the width of the render size
  88395. */
  88396. getRenderSize(): number;
  88397. /**
  88398. * Gets the actual render width of the texture.
  88399. * @returns the width of the render size
  88400. */
  88401. getRenderWidth(): number;
  88402. /**
  88403. * Gets the actual render height of the texture.
  88404. * @returns the height of the render size
  88405. */
  88406. getRenderHeight(): number;
  88407. /**
  88408. * Get if the texture can be rescaled or not.
  88409. */
  88410. readonly canRescale: boolean;
  88411. /**
  88412. * Resize the texture using a ratio.
  88413. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88414. */
  88415. scale(ratio: number): void;
  88416. /**
  88417. * Get the texture reflection matrix used to rotate/transform the reflection.
  88418. * @returns the reflection matrix
  88419. */
  88420. getReflectionTextureMatrix(): Matrix;
  88421. /**
  88422. * Resize the texture to a new desired size.
  88423. * Be carrefull as it will recreate all the data in the new texture.
  88424. * @param size Define the new size. It can be:
  88425. * - a number for squared texture,
  88426. * - an object containing { width: number, height: number }
  88427. * - or an object containing a ratio { ratio: number }
  88428. */
  88429. resize(size: number | {
  88430. width: number;
  88431. height: number;
  88432. } | {
  88433. ratio: number;
  88434. }): void;
  88435. /**
  88436. * Renders all the objects from the render list into the texture.
  88437. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88438. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88439. */
  88440. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88441. private _bestReflectionRenderTargetDimension;
  88442. /**
  88443. * @hidden
  88444. * @param faceIndex face index to bind to if this is a cubetexture
  88445. */
  88446. _bindFrameBuffer(faceIndex?: number): void;
  88447. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88448. private renderToTarget;
  88449. /**
  88450. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88451. * This allowed control for front to back rendering or reversly depending of the special needs.
  88452. *
  88453. * @param renderingGroupId The rendering group id corresponding to its index
  88454. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88455. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88456. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88457. */
  88458. 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;
  88459. /**
  88460. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88461. *
  88462. * @param renderingGroupId The rendering group id corresponding to its index
  88463. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88464. */
  88465. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88466. /**
  88467. * Clones the texture.
  88468. * @returns the cloned texture
  88469. */
  88470. clone(): RenderTargetTexture;
  88471. /**
  88472. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88473. * @returns The JSON representation of the texture
  88474. */
  88475. serialize(): any;
  88476. /**
  88477. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88478. */
  88479. disposeFramebufferObjects(): void;
  88480. /**
  88481. * Dispose the texture and release its associated resources.
  88482. */
  88483. dispose(): void;
  88484. /** @hidden */
  88485. _rebuild(): void;
  88486. /**
  88487. * Clear the info related to rendering groups preventing retention point in material dispose.
  88488. */
  88489. freeRenderingGroups(): void;
  88490. /**
  88491. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88492. * @returns the view count
  88493. */
  88494. getViewCount(): number;
  88495. }
  88496. }
  88497. declare module BABYLON {
  88498. /**
  88499. * Options for compiling materials.
  88500. */
  88501. export interface IMaterialCompilationOptions {
  88502. /**
  88503. * Defines whether clip planes are enabled.
  88504. */
  88505. clipPlane: boolean;
  88506. /**
  88507. * Defines whether instances are enabled.
  88508. */
  88509. useInstances: boolean;
  88510. }
  88511. /**
  88512. * Base class for the main features of a material in Babylon.js
  88513. */
  88514. export class Material implements IAnimatable {
  88515. /**
  88516. * Returns the triangle fill mode
  88517. */
  88518. static readonly TriangleFillMode: number;
  88519. /**
  88520. * Returns the wireframe mode
  88521. */
  88522. static readonly WireFrameFillMode: number;
  88523. /**
  88524. * Returns the point fill mode
  88525. */
  88526. static readonly PointFillMode: number;
  88527. /**
  88528. * Returns the point list draw mode
  88529. */
  88530. static readonly PointListDrawMode: number;
  88531. /**
  88532. * Returns the line list draw mode
  88533. */
  88534. static readonly LineListDrawMode: number;
  88535. /**
  88536. * Returns the line loop draw mode
  88537. */
  88538. static readonly LineLoopDrawMode: number;
  88539. /**
  88540. * Returns the line strip draw mode
  88541. */
  88542. static readonly LineStripDrawMode: number;
  88543. /**
  88544. * Returns the triangle strip draw mode
  88545. */
  88546. static readonly TriangleStripDrawMode: number;
  88547. /**
  88548. * Returns the triangle fan draw mode
  88549. */
  88550. static readonly TriangleFanDrawMode: number;
  88551. /**
  88552. * Stores the clock-wise side orientation
  88553. */
  88554. static readonly ClockWiseSideOrientation: number;
  88555. /**
  88556. * Stores the counter clock-wise side orientation
  88557. */
  88558. static readonly CounterClockWiseSideOrientation: number;
  88559. /**
  88560. * The dirty texture flag value
  88561. */
  88562. static readonly TextureDirtyFlag: number;
  88563. /**
  88564. * The dirty light flag value
  88565. */
  88566. static readonly LightDirtyFlag: number;
  88567. /**
  88568. * The dirty fresnel flag value
  88569. */
  88570. static readonly FresnelDirtyFlag: number;
  88571. /**
  88572. * The dirty attribute flag value
  88573. */
  88574. static readonly AttributesDirtyFlag: number;
  88575. /**
  88576. * The dirty misc flag value
  88577. */
  88578. static readonly MiscDirtyFlag: number;
  88579. /**
  88580. * The all dirty flag value
  88581. */
  88582. static readonly AllDirtyFlag: number;
  88583. /**
  88584. * The ID of the material
  88585. */
  88586. id: string;
  88587. /**
  88588. * Gets or sets the unique id of the material
  88589. */
  88590. uniqueId: number;
  88591. /**
  88592. * The name of the material
  88593. */
  88594. name: string;
  88595. /**
  88596. * Gets or sets user defined metadata
  88597. */
  88598. metadata: any;
  88599. /**
  88600. * For internal use only. Please do not use.
  88601. */
  88602. reservedDataStore: any;
  88603. /**
  88604. * Specifies if the ready state should be checked on each call
  88605. */
  88606. checkReadyOnEveryCall: boolean;
  88607. /**
  88608. * Specifies if the ready state should be checked once
  88609. */
  88610. checkReadyOnlyOnce: boolean;
  88611. /**
  88612. * The state of the material
  88613. */
  88614. state: string;
  88615. /**
  88616. * The alpha value of the material
  88617. */
  88618. protected _alpha: number;
  88619. /**
  88620. * List of inspectable custom properties (used by the Inspector)
  88621. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88622. */
  88623. inspectableCustomProperties: IInspectable[];
  88624. /**
  88625. * Sets the alpha value of the material
  88626. */
  88627. /**
  88628. * Gets the alpha value of the material
  88629. */
  88630. alpha: number;
  88631. /**
  88632. * Specifies if back face culling is enabled
  88633. */
  88634. protected _backFaceCulling: boolean;
  88635. /**
  88636. * Sets the back-face culling state
  88637. */
  88638. /**
  88639. * Gets the back-face culling state
  88640. */
  88641. backFaceCulling: boolean;
  88642. /**
  88643. * Stores the value for side orientation
  88644. */
  88645. sideOrientation: number;
  88646. /**
  88647. * Callback triggered when the material is compiled
  88648. */
  88649. onCompiled: Nullable<(effect: Effect) => void>;
  88650. /**
  88651. * Callback triggered when an error occurs
  88652. */
  88653. onError: Nullable<(effect: Effect, errors: string) => void>;
  88654. /**
  88655. * Callback triggered to get the render target textures
  88656. */
  88657. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88658. /**
  88659. * Gets a boolean indicating that current material needs to register RTT
  88660. */
  88661. readonly hasRenderTargetTextures: boolean;
  88662. /**
  88663. * Specifies if the material should be serialized
  88664. */
  88665. doNotSerialize: boolean;
  88666. /**
  88667. * @hidden
  88668. */
  88669. _storeEffectOnSubMeshes: boolean;
  88670. /**
  88671. * Stores the animations for the material
  88672. */
  88673. animations: Nullable<Array<Animation>>;
  88674. /**
  88675. * An event triggered when the material is disposed
  88676. */
  88677. onDisposeObservable: Observable<Material>;
  88678. /**
  88679. * An observer which watches for dispose events
  88680. */
  88681. private _onDisposeObserver;
  88682. private _onUnBindObservable;
  88683. /**
  88684. * Called during a dispose event
  88685. */
  88686. onDispose: () => void;
  88687. private _onBindObservable;
  88688. /**
  88689. * An event triggered when the material is bound
  88690. */
  88691. readonly onBindObservable: Observable<AbstractMesh>;
  88692. /**
  88693. * An observer which watches for bind events
  88694. */
  88695. private _onBindObserver;
  88696. /**
  88697. * Called during a bind event
  88698. */
  88699. onBind: (Mesh: AbstractMesh) => void;
  88700. /**
  88701. * An event triggered when the material is unbound
  88702. */
  88703. readonly onUnBindObservable: Observable<Material>;
  88704. /**
  88705. * Stores the value of the alpha mode
  88706. */
  88707. private _alphaMode;
  88708. /**
  88709. * Sets the value of the alpha mode.
  88710. *
  88711. * | Value | Type | Description |
  88712. * | --- | --- | --- |
  88713. * | 0 | ALPHA_DISABLE | |
  88714. * | 1 | ALPHA_ADD | |
  88715. * | 2 | ALPHA_COMBINE | |
  88716. * | 3 | ALPHA_SUBTRACT | |
  88717. * | 4 | ALPHA_MULTIPLY | |
  88718. * | 5 | ALPHA_MAXIMIZED | |
  88719. * | 6 | ALPHA_ONEONE | |
  88720. * | 7 | ALPHA_PREMULTIPLIED | |
  88721. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88722. * | 9 | ALPHA_INTERPOLATE | |
  88723. * | 10 | ALPHA_SCREENMODE | |
  88724. *
  88725. */
  88726. /**
  88727. * Gets the value of the alpha mode
  88728. */
  88729. alphaMode: number;
  88730. /**
  88731. * Stores the state of the need depth pre-pass value
  88732. */
  88733. private _needDepthPrePass;
  88734. /**
  88735. * Sets the need depth pre-pass value
  88736. */
  88737. /**
  88738. * Gets the depth pre-pass value
  88739. */
  88740. needDepthPrePass: boolean;
  88741. /**
  88742. * Specifies if depth writing should be disabled
  88743. */
  88744. disableDepthWrite: boolean;
  88745. /**
  88746. * Specifies if depth writing should be forced
  88747. */
  88748. forceDepthWrite: boolean;
  88749. /**
  88750. * Specifies the depth function that should be used. 0 means the default engine function
  88751. */
  88752. depthFunction: number;
  88753. /**
  88754. * Specifies if there should be a separate pass for culling
  88755. */
  88756. separateCullingPass: boolean;
  88757. /**
  88758. * Stores the state specifing if fog should be enabled
  88759. */
  88760. private _fogEnabled;
  88761. /**
  88762. * Sets the state for enabling fog
  88763. */
  88764. /**
  88765. * Gets the value of the fog enabled state
  88766. */
  88767. fogEnabled: boolean;
  88768. /**
  88769. * Stores the size of points
  88770. */
  88771. pointSize: number;
  88772. /**
  88773. * Stores the z offset value
  88774. */
  88775. zOffset: number;
  88776. /**
  88777. * Gets a value specifying if wireframe mode is enabled
  88778. */
  88779. /**
  88780. * Sets the state of wireframe mode
  88781. */
  88782. wireframe: boolean;
  88783. /**
  88784. * Gets the value specifying if point clouds are enabled
  88785. */
  88786. /**
  88787. * Sets the state of point cloud mode
  88788. */
  88789. pointsCloud: boolean;
  88790. /**
  88791. * Gets the material fill mode
  88792. */
  88793. /**
  88794. * Sets the material fill mode
  88795. */
  88796. fillMode: number;
  88797. /**
  88798. * @hidden
  88799. * Stores the effects for the material
  88800. */
  88801. _effect: Nullable<Effect>;
  88802. /**
  88803. * @hidden
  88804. * Specifies if the material was previously ready
  88805. */
  88806. _wasPreviouslyReady: boolean;
  88807. /**
  88808. * Specifies if uniform buffers should be used
  88809. */
  88810. private _useUBO;
  88811. /**
  88812. * Stores a reference to the scene
  88813. */
  88814. private _scene;
  88815. /**
  88816. * Stores the fill mode state
  88817. */
  88818. private _fillMode;
  88819. /**
  88820. * Specifies if the depth write state should be cached
  88821. */
  88822. private _cachedDepthWriteState;
  88823. /**
  88824. * Specifies if the depth function state should be cached
  88825. */
  88826. private _cachedDepthFunctionState;
  88827. /**
  88828. * Stores the uniform buffer
  88829. */
  88830. protected _uniformBuffer: UniformBuffer;
  88831. /** @hidden */
  88832. _indexInSceneMaterialArray: number;
  88833. /** @hidden */
  88834. meshMap: Nullable<{
  88835. [id: string]: AbstractMesh | undefined;
  88836. }>;
  88837. /**
  88838. * Creates a material instance
  88839. * @param name defines the name of the material
  88840. * @param scene defines the scene to reference
  88841. * @param doNotAdd specifies if the material should be added to the scene
  88842. */
  88843. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88844. /**
  88845. * Returns a string representation of the current material
  88846. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88847. * @returns a string with material information
  88848. */
  88849. toString(fullDetails?: boolean): string;
  88850. /**
  88851. * Gets the class name of the material
  88852. * @returns a string with the class name of the material
  88853. */
  88854. getClassName(): string;
  88855. /**
  88856. * Specifies if updates for the material been locked
  88857. */
  88858. readonly isFrozen: boolean;
  88859. /**
  88860. * Locks updates for the material
  88861. */
  88862. freeze(): void;
  88863. /**
  88864. * Unlocks updates for the material
  88865. */
  88866. unfreeze(): void;
  88867. /**
  88868. * Specifies if the material is ready to be used
  88869. * @param mesh defines the mesh to check
  88870. * @param useInstances specifies if instances should be used
  88871. * @returns a boolean indicating if the material is ready to be used
  88872. */
  88873. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88874. /**
  88875. * Specifies that the submesh is ready to be used
  88876. * @param mesh defines the mesh to check
  88877. * @param subMesh defines which submesh to check
  88878. * @param useInstances specifies that instances should be used
  88879. * @returns a boolean indicating that the submesh is ready or not
  88880. */
  88881. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88882. /**
  88883. * Returns the material effect
  88884. * @returns the effect associated with the material
  88885. */
  88886. getEffect(): Nullable<Effect>;
  88887. /**
  88888. * Returns the current scene
  88889. * @returns a Scene
  88890. */
  88891. getScene(): Scene;
  88892. /**
  88893. * Specifies if the material will require alpha blending
  88894. * @returns a boolean specifying if alpha blending is needed
  88895. */
  88896. needAlphaBlending(): boolean;
  88897. /**
  88898. * Specifies if the mesh will require alpha blending
  88899. * @param mesh defines the mesh to check
  88900. * @returns a boolean specifying if alpha blending is needed for the mesh
  88901. */
  88902. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88903. /**
  88904. * Specifies if this material should be rendered in alpha test mode
  88905. * @returns a boolean specifying if an alpha test is needed.
  88906. */
  88907. needAlphaTesting(): boolean;
  88908. /**
  88909. * Gets the texture used for the alpha test
  88910. * @returns the texture to use for alpha testing
  88911. */
  88912. getAlphaTestTexture(): Nullable<BaseTexture>;
  88913. /**
  88914. * Marks the material to indicate that it needs to be re-calculated
  88915. */
  88916. markDirty(): void;
  88917. /** @hidden */
  88918. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88919. /**
  88920. * Binds the material to the mesh
  88921. * @param world defines the world transformation matrix
  88922. * @param mesh defines the mesh to bind the material to
  88923. */
  88924. bind(world: Matrix, mesh?: Mesh): void;
  88925. /**
  88926. * Binds the submesh to the material
  88927. * @param world defines the world transformation matrix
  88928. * @param mesh defines the mesh containing the submesh
  88929. * @param subMesh defines the submesh to bind the material to
  88930. */
  88931. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88932. /**
  88933. * Binds the world matrix to the material
  88934. * @param world defines the world transformation matrix
  88935. */
  88936. bindOnlyWorldMatrix(world: Matrix): void;
  88937. /**
  88938. * Binds the scene's uniform buffer to the effect.
  88939. * @param effect defines the effect to bind to the scene uniform buffer
  88940. * @param sceneUbo defines the uniform buffer storing scene data
  88941. */
  88942. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88943. /**
  88944. * Binds the view matrix to the effect
  88945. * @param effect defines the effect to bind the view matrix to
  88946. */
  88947. bindView(effect: Effect): void;
  88948. /**
  88949. * Binds the view projection matrix to the effect
  88950. * @param effect defines the effect to bind the view projection matrix to
  88951. */
  88952. bindViewProjection(effect: Effect): void;
  88953. /**
  88954. * Specifies if material alpha testing should be turned on for the mesh
  88955. * @param mesh defines the mesh to check
  88956. */
  88957. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88958. /**
  88959. * Processes to execute after binding the material to a mesh
  88960. * @param mesh defines the rendered mesh
  88961. */
  88962. protected _afterBind(mesh?: Mesh): void;
  88963. /**
  88964. * Unbinds the material from the mesh
  88965. */
  88966. unbind(): void;
  88967. /**
  88968. * Gets the active textures from the material
  88969. * @returns an array of textures
  88970. */
  88971. getActiveTextures(): BaseTexture[];
  88972. /**
  88973. * Specifies if the material uses a texture
  88974. * @param texture defines the texture to check against the material
  88975. * @returns a boolean specifying if the material uses the texture
  88976. */
  88977. hasTexture(texture: BaseTexture): boolean;
  88978. /**
  88979. * Makes a duplicate of the material, and gives it a new name
  88980. * @param name defines the new name for the duplicated material
  88981. * @returns the cloned material
  88982. */
  88983. clone(name: string): Nullable<Material>;
  88984. /**
  88985. * Gets the meshes bound to the material
  88986. * @returns an array of meshes bound to the material
  88987. */
  88988. getBindedMeshes(): AbstractMesh[];
  88989. /**
  88990. * Force shader compilation
  88991. * @param mesh defines the mesh associated with this material
  88992. * @param onCompiled defines a function to execute once the material is compiled
  88993. * @param options defines the options to configure the compilation
  88994. * @param onError defines a function to execute if the material fails compiling
  88995. */
  88996. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88997. /**
  88998. * Force shader compilation
  88999. * @param mesh defines the mesh that will use this material
  89000. * @param options defines additional options for compiling the shaders
  89001. * @returns a promise that resolves when the compilation completes
  89002. */
  89003. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89004. private static readonly _AllDirtyCallBack;
  89005. private static readonly _ImageProcessingDirtyCallBack;
  89006. private static readonly _TextureDirtyCallBack;
  89007. private static readonly _FresnelDirtyCallBack;
  89008. private static readonly _MiscDirtyCallBack;
  89009. private static readonly _LightsDirtyCallBack;
  89010. private static readonly _AttributeDirtyCallBack;
  89011. private static _FresnelAndMiscDirtyCallBack;
  89012. private static _TextureAndMiscDirtyCallBack;
  89013. private static readonly _DirtyCallbackArray;
  89014. private static readonly _RunDirtyCallBacks;
  89015. /**
  89016. * Marks a define in the material to indicate that it needs to be re-computed
  89017. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89018. */
  89019. markAsDirty(flag: number): void;
  89020. /**
  89021. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89022. * @param func defines a function which checks material defines against the submeshes
  89023. */
  89024. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89025. /**
  89026. * Indicates that we need to re-calculated for all submeshes
  89027. */
  89028. protected _markAllSubMeshesAsAllDirty(): void;
  89029. /**
  89030. * Indicates that image processing needs to be re-calculated for all submeshes
  89031. */
  89032. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89033. /**
  89034. * Indicates that textures need to be re-calculated for all submeshes
  89035. */
  89036. protected _markAllSubMeshesAsTexturesDirty(): void;
  89037. /**
  89038. * Indicates that fresnel needs to be re-calculated for all submeshes
  89039. */
  89040. protected _markAllSubMeshesAsFresnelDirty(): void;
  89041. /**
  89042. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89043. */
  89044. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89045. /**
  89046. * Indicates that lights need to be re-calculated for all submeshes
  89047. */
  89048. protected _markAllSubMeshesAsLightsDirty(): void;
  89049. /**
  89050. * Indicates that attributes need to be re-calculated for all submeshes
  89051. */
  89052. protected _markAllSubMeshesAsAttributesDirty(): void;
  89053. /**
  89054. * Indicates that misc needs to be re-calculated for all submeshes
  89055. */
  89056. protected _markAllSubMeshesAsMiscDirty(): void;
  89057. /**
  89058. * Indicates that textures and misc need to be re-calculated for all submeshes
  89059. */
  89060. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89061. /**
  89062. * Disposes the material
  89063. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89064. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89065. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89066. */
  89067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89068. /** @hidden */
  89069. private releaseVertexArrayObject;
  89070. /**
  89071. * Serializes this material
  89072. * @returns the serialized material object
  89073. */
  89074. serialize(): any;
  89075. /**
  89076. * Creates a material from parsed material data
  89077. * @param parsedMaterial defines parsed material data
  89078. * @param scene defines the hosting scene
  89079. * @param rootUrl defines the root URL to use to load textures
  89080. * @returns a new material
  89081. */
  89082. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89083. }
  89084. }
  89085. declare module BABYLON {
  89086. /**
  89087. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89088. * separate meshes. This can be use to improve performances.
  89089. * @see http://doc.babylonjs.com/how_to/multi_materials
  89090. */
  89091. export class MultiMaterial extends Material {
  89092. private _subMaterials;
  89093. /**
  89094. * Gets or Sets the list of Materials used within the multi material.
  89095. * They need to be ordered according to the submeshes order in the associated mesh
  89096. */
  89097. subMaterials: Nullable<Material>[];
  89098. /**
  89099. * Function used to align with Node.getChildren()
  89100. * @returns the list of Materials used within the multi material
  89101. */
  89102. getChildren(): Nullable<Material>[];
  89103. /**
  89104. * Instantiates a new Multi Material
  89105. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89106. * separate meshes. This can be use to improve performances.
  89107. * @see http://doc.babylonjs.com/how_to/multi_materials
  89108. * @param name Define the name in the scene
  89109. * @param scene Define the scene the material belongs to
  89110. */
  89111. constructor(name: string, scene: Scene);
  89112. private _hookArray;
  89113. /**
  89114. * Get one of the submaterial by its index in the submaterials array
  89115. * @param index The index to look the sub material at
  89116. * @returns The Material if the index has been defined
  89117. */
  89118. getSubMaterial(index: number): Nullable<Material>;
  89119. /**
  89120. * Get the list of active textures for the whole sub materials list.
  89121. * @returns All the textures that will be used during the rendering
  89122. */
  89123. getActiveTextures(): BaseTexture[];
  89124. /**
  89125. * Gets the current class name of the material e.g. "MultiMaterial"
  89126. * Mainly use in serialization.
  89127. * @returns the class name
  89128. */
  89129. getClassName(): string;
  89130. /**
  89131. * Checks if the material is ready to render the requested sub mesh
  89132. * @param mesh Define the mesh the submesh belongs to
  89133. * @param subMesh Define the sub mesh to look readyness for
  89134. * @param useInstances Define whether or not the material is used with instances
  89135. * @returns true if ready, otherwise false
  89136. */
  89137. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89138. /**
  89139. * Clones the current material and its related sub materials
  89140. * @param name Define the name of the newly cloned material
  89141. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89142. * @returns the cloned material
  89143. */
  89144. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89145. /**
  89146. * Serializes the materials into a JSON representation.
  89147. * @returns the JSON representation
  89148. */
  89149. serialize(): any;
  89150. /**
  89151. * Dispose the material and release its associated resources
  89152. * @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)
  89153. * @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)
  89154. * @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)
  89155. */
  89156. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89157. /**
  89158. * Creates a MultiMaterial from parsed MultiMaterial data.
  89159. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89160. * @param scene defines the hosting scene
  89161. * @returns a new MultiMaterial
  89162. */
  89163. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89164. }
  89165. }
  89166. declare module BABYLON {
  89167. /**
  89168. * Base class for submeshes
  89169. */
  89170. export class BaseSubMesh {
  89171. /** @hidden */
  89172. _materialDefines: Nullable<MaterialDefines>;
  89173. /** @hidden */
  89174. _materialEffect: Nullable<Effect>;
  89175. /**
  89176. * Gets associated effect
  89177. */
  89178. readonly effect: Nullable<Effect>;
  89179. /**
  89180. * Sets associated effect (effect used to render this submesh)
  89181. * @param effect defines the effect to associate with
  89182. * @param defines defines the set of defines used to compile this effect
  89183. */
  89184. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89185. }
  89186. /**
  89187. * Defines a subdivision inside a mesh
  89188. */
  89189. export class SubMesh extends BaseSubMesh implements ICullable {
  89190. /** the material index to use */
  89191. materialIndex: number;
  89192. /** vertex index start */
  89193. verticesStart: number;
  89194. /** vertices count */
  89195. verticesCount: number;
  89196. /** index start */
  89197. indexStart: number;
  89198. /** indices count */
  89199. indexCount: number;
  89200. /** @hidden */
  89201. _linesIndexCount: number;
  89202. private _mesh;
  89203. private _renderingMesh;
  89204. private _boundingInfo;
  89205. private _linesIndexBuffer;
  89206. /** @hidden */
  89207. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89208. /** @hidden */
  89209. _trianglePlanes: Plane[];
  89210. /** @hidden */
  89211. _lastColliderTransformMatrix: Nullable<Matrix>;
  89212. /** @hidden */
  89213. _renderId: number;
  89214. /** @hidden */
  89215. _alphaIndex: number;
  89216. /** @hidden */
  89217. _distanceToCamera: number;
  89218. /** @hidden */
  89219. _id: number;
  89220. private _currentMaterial;
  89221. /**
  89222. * Add a new submesh to a mesh
  89223. * @param materialIndex defines the material index to use
  89224. * @param verticesStart defines vertex index start
  89225. * @param verticesCount defines vertices count
  89226. * @param indexStart defines index start
  89227. * @param indexCount defines indices count
  89228. * @param mesh defines the parent mesh
  89229. * @param renderingMesh defines an optional rendering mesh
  89230. * @param createBoundingBox defines if bounding box should be created for this submesh
  89231. * @returns the new submesh
  89232. */
  89233. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89234. /**
  89235. * Creates a new submesh
  89236. * @param materialIndex defines the material index to use
  89237. * @param verticesStart defines vertex index start
  89238. * @param verticesCount defines vertices count
  89239. * @param indexStart defines index start
  89240. * @param indexCount defines indices count
  89241. * @param mesh defines the parent mesh
  89242. * @param renderingMesh defines an optional rendering mesh
  89243. * @param createBoundingBox defines if bounding box should be created for this submesh
  89244. */
  89245. constructor(
  89246. /** the material index to use */
  89247. materialIndex: number,
  89248. /** vertex index start */
  89249. verticesStart: number,
  89250. /** vertices count */
  89251. verticesCount: number,
  89252. /** index start */
  89253. indexStart: number,
  89254. /** indices count */
  89255. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89256. /**
  89257. * Returns true if this submesh covers the entire parent mesh
  89258. * @ignorenaming
  89259. */
  89260. readonly IsGlobal: boolean;
  89261. /**
  89262. * Returns the submesh BoudingInfo object
  89263. * @returns current bounding info (or mesh's one if the submesh is global)
  89264. */
  89265. getBoundingInfo(): BoundingInfo;
  89266. /**
  89267. * Sets the submesh BoundingInfo
  89268. * @param boundingInfo defines the new bounding info to use
  89269. * @returns the SubMesh
  89270. */
  89271. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89272. /**
  89273. * Returns the mesh of the current submesh
  89274. * @return the parent mesh
  89275. */
  89276. getMesh(): AbstractMesh;
  89277. /**
  89278. * Returns the rendering mesh of the submesh
  89279. * @returns the rendering mesh (could be different from parent mesh)
  89280. */
  89281. getRenderingMesh(): Mesh;
  89282. /**
  89283. * Returns the submesh material
  89284. * @returns null or the current material
  89285. */
  89286. getMaterial(): Nullable<Material>;
  89287. /**
  89288. * Sets a new updated BoundingInfo object to the submesh
  89289. * @param data defines an optional position array to use to determine the bounding info
  89290. * @returns the SubMesh
  89291. */
  89292. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89293. /** @hidden */
  89294. _checkCollision(collider: Collider): boolean;
  89295. /**
  89296. * Updates the submesh BoundingInfo
  89297. * @param world defines the world matrix to use to update the bounding info
  89298. * @returns the submesh
  89299. */
  89300. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89301. /**
  89302. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89303. * @param frustumPlanes defines the frustum planes
  89304. * @returns true if the submesh is intersecting with the frustum
  89305. */
  89306. isInFrustum(frustumPlanes: Plane[]): boolean;
  89307. /**
  89308. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89309. * @param frustumPlanes defines the frustum planes
  89310. * @returns true if the submesh is inside the frustum
  89311. */
  89312. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89313. /**
  89314. * Renders the submesh
  89315. * @param enableAlphaMode defines if alpha needs to be used
  89316. * @returns the submesh
  89317. */
  89318. render(enableAlphaMode: boolean): SubMesh;
  89319. /**
  89320. * @hidden
  89321. */
  89322. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89323. /**
  89324. * Checks if the submesh intersects with a ray
  89325. * @param ray defines the ray to test
  89326. * @returns true is the passed ray intersects the submesh bounding box
  89327. */
  89328. canIntersects(ray: Ray): boolean;
  89329. /**
  89330. * Intersects current submesh with a ray
  89331. * @param ray defines the ray to test
  89332. * @param positions defines mesh's positions array
  89333. * @param indices defines mesh's indices array
  89334. * @param fastCheck defines if only bounding info should be used
  89335. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89336. * @returns intersection info or null if no intersection
  89337. */
  89338. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89339. /** @hidden */
  89340. private _intersectLines;
  89341. /** @hidden */
  89342. private _intersectUnIndexedLines;
  89343. /** @hidden */
  89344. private _intersectTriangles;
  89345. /** @hidden */
  89346. private _intersectUnIndexedTriangles;
  89347. /** @hidden */
  89348. _rebuild(): void;
  89349. /**
  89350. * Creates a new submesh from the passed mesh
  89351. * @param newMesh defines the new hosting mesh
  89352. * @param newRenderingMesh defines an optional rendering mesh
  89353. * @returns the new submesh
  89354. */
  89355. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89356. /**
  89357. * Release associated resources
  89358. */
  89359. dispose(): void;
  89360. /**
  89361. * Gets the class name
  89362. * @returns the string "SubMesh".
  89363. */
  89364. getClassName(): string;
  89365. /**
  89366. * Creates a new submesh from indices data
  89367. * @param materialIndex the index of the main mesh material
  89368. * @param startIndex the index where to start the copy in the mesh indices array
  89369. * @param indexCount the number of indices to copy then from the startIndex
  89370. * @param mesh the main mesh to create the submesh from
  89371. * @param renderingMesh the optional rendering mesh
  89372. * @returns a new submesh
  89373. */
  89374. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89375. }
  89376. }
  89377. declare module BABYLON {
  89378. /**
  89379. * Class used to represent data loading progression
  89380. */
  89381. export class SceneLoaderFlags {
  89382. private static _ForceFullSceneLoadingForIncremental;
  89383. private static _ShowLoadingScreen;
  89384. private static _CleanBoneMatrixWeights;
  89385. private static _loggingLevel;
  89386. /**
  89387. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89388. */
  89389. static ForceFullSceneLoadingForIncremental: boolean;
  89390. /**
  89391. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89392. */
  89393. static ShowLoadingScreen: boolean;
  89394. /**
  89395. * Defines the current logging level (while loading the scene)
  89396. * @ignorenaming
  89397. */
  89398. static loggingLevel: number;
  89399. /**
  89400. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89401. */
  89402. static CleanBoneMatrixWeights: boolean;
  89403. }
  89404. }
  89405. declare module BABYLON {
  89406. /**
  89407. * Class used to store geometry data (vertex buffers + index buffer)
  89408. */
  89409. export class Geometry implements IGetSetVerticesData {
  89410. /**
  89411. * Gets or sets the ID of the geometry
  89412. */
  89413. id: string;
  89414. /**
  89415. * Gets or sets the unique ID of the geometry
  89416. */
  89417. uniqueId: number;
  89418. /**
  89419. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89420. */
  89421. delayLoadState: number;
  89422. /**
  89423. * Gets the file containing the data to load when running in delay load state
  89424. */
  89425. delayLoadingFile: Nullable<string>;
  89426. /**
  89427. * Callback called when the geometry is updated
  89428. */
  89429. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89430. private _scene;
  89431. private _engine;
  89432. private _meshes;
  89433. private _totalVertices;
  89434. /** @hidden */
  89435. _indices: IndicesArray;
  89436. /** @hidden */
  89437. _vertexBuffers: {
  89438. [key: string]: VertexBuffer;
  89439. };
  89440. private _isDisposed;
  89441. private _extend;
  89442. private _boundingBias;
  89443. /** @hidden */
  89444. _delayInfo: Array<string>;
  89445. private _indexBuffer;
  89446. private _indexBufferIsUpdatable;
  89447. /** @hidden */
  89448. _boundingInfo: Nullable<BoundingInfo>;
  89449. /** @hidden */
  89450. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89451. /** @hidden */
  89452. _softwareSkinningFrameId: number;
  89453. private _vertexArrayObjects;
  89454. private _updatable;
  89455. /** @hidden */
  89456. _positions: Nullable<Vector3[]>;
  89457. /**
  89458. * 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
  89459. */
  89460. /**
  89461. * 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
  89462. */
  89463. boundingBias: Vector2;
  89464. /**
  89465. * Static function used to attach a new empty geometry to a mesh
  89466. * @param mesh defines the mesh to attach the geometry to
  89467. * @returns the new Geometry
  89468. */
  89469. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89470. /**
  89471. * Creates a new geometry
  89472. * @param id defines the unique ID
  89473. * @param scene defines the hosting scene
  89474. * @param vertexData defines the VertexData used to get geometry data
  89475. * @param updatable defines if geometry must be updatable (false by default)
  89476. * @param mesh defines the mesh that will be associated with the geometry
  89477. */
  89478. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89479. /**
  89480. * Gets the current extend of the geometry
  89481. */
  89482. readonly extend: {
  89483. minimum: Vector3;
  89484. maximum: Vector3;
  89485. };
  89486. /**
  89487. * Gets the hosting scene
  89488. * @returns the hosting Scene
  89489. */
  89490. getScene(): Scene;
  89491. /**
  89492. * Gets the hosting engine
  89493. * @returns the hosting Engine
  89494. */
  89495. getEngine(): Engine;
  89496. /**
  89497. * Defines if the geometry is ready to use
  89498. * @returns true if the geometry is ready to be used
  89499. */
  89500. isReady(): boolean;
  89501. /**
  89502. * Gets a value indicating that the geometry should not be serialized
  89503. */
  89504. readonly doNotSerialize: boolean;
  89505. /** @hidden */
  89506. _rebuild(): void;
  89507. /**
  89508. * Affects all geometry data in one call
  89509. * @param vertexData defines the geometry data
  89510. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89511. */
  89512. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89513. /**
  89514. * Set specific vertex data
  89515. * @param kind defines the data kind (Position, normal, etc...)
  89516. * @param data defines the vertex data to use
  89517. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89518. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89519. */
  89520. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89521. /**
  89522. * Removes a specific vertex data
  89523. * @param kind defines the data kind (Position, normal, etc...)
  89524. */
  89525. removeVerticesData(kind: string): void;
  89526. /**
  89527. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89528. * @param buffer defines the vertex buffer to use
  89529. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89530. */
  89531. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89532. /**
  89533. * Update a specific vertex buffer
  89534. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89535. * It will do nothing if the buffer is not updatable
  89536. * @param kind defines the data kind (Position, normal, etc...)
  89537. * @param data defines the data to use
  89538. * @param offset defines the offset in the target buffer where to store the data
  89539. * @param useBytes set to true if the offset is in bytes
  89540. */
  89541. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89542. /**
  89543. * Update a specific vertex buffer
  89544. * This function will create a new buffer if the current one is not updatable
  89545. * @param kind defines the data kind (Position, normal, etc...)
  89546. * @param data defines the data to use
  89547. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89548. */
  89549. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89550. private _updateBoundingInfo;
  89551. /** @hidden */
  89552. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89553. /**
  89554. * Gets total number of vertices
  89555. * @returns the total number of vertices
  89556. */
  89557. getTotalVertices(): number;
  89558. /**
  89559. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89560. * @param kind defines the data kind (Position, normal, etc...)
  89561. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89562. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89563. * @returns a float array containing vertex data
  89564. */
  89565. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89566. /**
  89567. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89568. * @param kind defines the data kind (Position, normal, etc...)
  89569. * @returns true if the vertex buffer with the specified kind is updatable
  89570. */
  89571. isVertexBufferUpdatable(kind: string): boolean;
  89572. /**
  89573. * Gets a specific vertex buffer
  89574. * @param kind defines the data kind (Position, normal, etc...)
  89575. * @returns a VertexBuffer
  89576. */
  89577. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89578. /**
  89579. * Returns all vertex buffers
  89580. * @return an object holding all vertex buffers indexed by kind
  89581. */
  89582. getVertexBuffers(): Nullable<{
  89583. [key: string]: VertexBuffer;
  89584. }>;
  89585. /**
  89586. * Gets a boolean indicating if specific vertex buffer is present
  89587. * @param kind defines the data kind (Position, normal, etc...)
  89588. * @returns true if data is present
  89589. */
  89590. isVerticesDataPresent(kind: string): boolean;
  89591. /**
  89592. * Gets a list of all attached data kinds (Position, normal, etc...)
  89593. * @returns a list of string containing all kinds
  89594. */
  89595. getVerticesDataKinds(): string[];
  89596. /**
  89597. * Update index buffer
  89598. * @param indices defines the indices to store in the index buffer
  89599. * @param offset defines the offset in the target buffer where to store the data
  89600. * @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)
  89601. */
  89602. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89603. /**
  89604. * Creates a new index buffer
  89605. * @param indices defines the indices to store in the index buffer
  89606. * @param totalVertices defines the total number of vertices (could be null)
  89607. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89608. */
  89609. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89610. /**
  89611. * Return the total number of indices
  89612. * @returns the total number of indices
  89613. */
  89614. getTotalIndices(): number;
  89615. /**
  89616. * Gets the index buffer array
  89617. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89618. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89619. * @returns the index buffer array
  89620. */
  89621. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89622. /**
  89623. * Gets the index buffer
  89624. * @return the index buffer
  89625. */
  89626. getIndexBuffer(): Nullable<DataBuffer>;
  89627. /** @hidden */
  89628. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89629. /**
  89630. * Release the associated resources for a specific mesh
  89631. * @param mesh defines the source mesh
  89632. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89633. */
  89634. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89635. /**
  89636. * Apply current geometry to a given mesh
  89637. * @param mesh defines the mesh to apply geometry to
  89638. */
  89639. applyToMesh(mesh: Mesh): void;
  89640. private _updateExtend;
  89641. private _applyToMesh;
  89642. private notifyUpdate;
  89643. /**
  89644. * Load the geometry if it was flagged as delay loaded
  89645. * @param scene defines the hosting scene
  89646. * @param onLoaded defines a callback called when the geometry is loaded
  89647. */
  89648. load(scene: Scene, onLoaded?: () => void): void;
  89649. private _queueLoad;
  89650. /**
  89651. * Invert the geometry to move from a right handed system to a left handed one.
  89652. */
  89653. toLeftHanded(): void;
  89654. /** @hidden */
  89655. _resetPointsArrayCache(): void;
  89656. /** @hidden */
  89657. _generatePointsArray(): boolean;
  89658. /**
  89659. * Gets a value indicating if the geometry is disposed
  89660. * @returns true if the geometry was disposed
  89661. */
  89662. isDisposed(): boolean;
  89663. private _disposeVertexArrayObjects;
  89664. /**
  89665. * Free all associated resources
  89666. */
  89667. dispose(): void;
  89668. /**
  89669. * Clone the current geometry into a new geometry
  89670. * @param id defines the unique ID of the new geometry
  89671. * @returns a new geometry object
  89672. */
  89673. copy(id: string): Geometry;
  89674. /**
  89675. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89676. * @return a JSON representation of the current geometry data (without the vertices data)
  89677. */
  89678. serialize(): any;
  89679. private toNumberArray;
  89680. /**
  89681. * Serialize all vertices data into a JSON oject
  89682. * @returns a JSON representation of the current geometry data
  89683. */
  89684. serializeVerticeData(): any;
  89685. /**
  89686. * Extracts a clone of a mesh geometry
  89687. * @param mesh defines the source mesh
  89688. * @param id defines the unique ID of the new geometry object
  89689. * @returns the new geometry object
  89690. */
  89691. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89692. /**
  89693. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89694. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89695. * Be aware Math.random() could cause collisions, but:
  89696. * "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"
  89697. * @returns a string containing a new GUID
  89698. */
  89699. static RandomId(): string;
  89700. /** @hidden */
  89701. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89702. private static _CleanMatricesWeights;
  89703. /**
  89704. * Create a new geometry from persisted data (Using .babylon file format)
  89705. * @param parsedVertexData defines the persisted data
  89706. * @param scene defines the hosting scene
  89707. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89708. * @returns the new geometry object
  89709. */
  89710. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89711. }
  89712. }
  89713. declare module BABYLON {
  89714. /**
  89715. * Define an interface for all classes that will get and set the data on vertices
  89716. */
  89717. export interface IGetSetVerticesData {
  89718. /**
  89719. * Gets a boolean indicating if specific vertex data is present
  89720. * @param kind defines the vertex data kind to use
  89721. * @returns true is data kind is present
  89722. */
  89723. isVerticesDataPresent(kind: string): boolean;
  89724. /**
  89725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89726. * @param kind defines the data kind (Position, normal, etc...)
  89727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89729. * @returns a float array containing vertex data
  89730. */
  89731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89732. /**
  89733. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89734. * @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.
  89735. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89736. * @returns the indices array or an empty array if the mesh has no geometry
  89737. */
  89738. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89739. /**
  89740. * Set specific vertex data
  89741. * @param kind defines the data kind (Position, normal, etc...)
  89742. * @param data defines the vertex data to use
  89743. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89744. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89745. */
  89746. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89747. /**
  89748. * Update a specific associated vertex buffer
  89749. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89750. * - VertexBuffer.PositionKind
  89751. * - VertexBuffer.UVKind
  89752. * - VertexBuffer.UV2Kind
  89753. * - VertexBuffer.UV3Kind
  89754. * - VertexBuffer.UV4Kind
  89755. * - VertexBuffer.UV5Kind
  89756. * - VertexBuffer.UV6Kind
  89757. * - VertexBuffer.ColorKind
  89758. * - VertexBuffer.MatricesIndicesKind
  89759. * - VertexBuffer.MatricesIndicesExtraKind
  89760. * - VertexBuffer.MatricesWeightsKind
  89761. * - VertexBuffer.MatricesWeightsExtraKind
  89762. * @param data defines the data source
  89763. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89764. * @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)
  89765. */
  89766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89767. /**
  89768. * Creates a new index buffer
  89769. * @param indices defines the indices to store in the index buffer
  89770. * @param totalVertices defines the total number of vertices (could be null)
  89771. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89772. */
  89773. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89774. }
  89775. /**
  89776. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89777. */
  89778. export class VertexData {
  89779. /**
  89780. * Mesh side orientation : usually the external or front surface
  89781. */
  89782. static readonly FRONTSIDE: number;
  89783. /**
  89784. * Mesh side orientation : usually the internal or back surface
  89785. */
  89786. static readonly BACKSIDE: number;
  89787. /**
  89788. * Mesh side orientation : both internal and external or front and back surfaces
  89789. */
  89790. static readonly DOUBLESIDE: number;
  89791. /**
  89792. * Mesh side orientation : by default, `FRONTSIDE`
  89793. */
  89794. static readonly DEFAULTSIDE: number;
  89795. /**
  89796. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89797. */
  89798. positions: Nullable<FloatArray>;
  89799. /**
  89800. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89801. */
  89802. normals: Nullable<FloatArray>;
  89803. /**
  89804. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89805. */
  89806. tangents: Nullable<FloatArray>;
  89807. /**
  89808. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89809. */
  89810. uvs: Nullable<FloatArray>;
  89811. /**
  89812. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89813. */
  89814. uvs2: Nullable<FloatArray>;
  89815. /**
  89816. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89817. */
  89818. uvs3: Nullable<FloatArray>;
  89819. /**
  89820. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89821. */
  89822. uvs4: Nullable<FloatArray>;
  89823. /**
  89824. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89825. */
  89826. uvs5: Nullable<FloatArray>;
  89827. /**
  89828. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89829. */
  89830. uvs6: Nullable<FloatArray>;
  89831. /**
  89832. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89833. */
  89834. colors: Nullable<FloatArray>;
  89835. /**
  89836. * 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).
  89837. */
  89838. matricesIndices: Nullable<FloatArray>;
  89839. /**
  89840. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89841. */
  89842. matricesWeights: Nullable<FloatArray>;
  89843. /**
  89844. * An array extending the number of possible indices
  89845. */
  89846. matricesIndicesExtra: Nullable<FloatArray>;
  89847. /**
  89848. * An array extending the number of possible weights when the number of indices is extended
  89849. */
  89850. matricesWeightsExtra: Nullable<FloatArray>;
  89851. /**
  89852. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89853. */
  89854. indices: Nullable<IndicesArray>;
  89855. /**
  89856. * Uses the passed data array to set the set the values for the specified kind of data
  89857. * @param data a linear array of floating numbers
  89858. * @param kind the type of data that is being set, eg positions, colors etc
  89859. */
  89860. set(data: FloatArray, kind: string): void;
  89861. /**
  89862. * Associates the vertexData to the passed Mesh.
  89863. * Sets it as updatable or not (default `false`)
  89864. * @param mesh the mesh the vertexData is applied to
  89865. * @param updatable when used and having the value true allows new data to update the vertexData
  89866. * @returns the VertexData
  89867. */
  89868. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89869. /**
  89870. * Associates the vertexData to the passed Geometry.
  89871. * Sets it as updatable or not (default `false`)
  89872. * @param geometry the geometry the vertexData is applied to
  89873. * @param updatable when used and having the value true allows new data to update the vertexData
  89874. * @returns VertexData
  89875. */
  89876. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89877. /**
  89878. * Updates the associated mesh
  89879. * @param mesh the mesh to be updated
  89880. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89881. * @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
  89882. * @returns VertexData
  89883. */
  89884. updateMesh(mesh: Mesh): VertexData;
  89885. /**
  89886. * Updates the associated geometry
  89887. * @param geometry the geometry to be updated
  89888. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89889. * @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
  89890. * @returns VertexData.
  89891. */
  89892. updateGeometry(geometry: Geometry): VertexData;
  89893. private _applyTo;
  89894. private _update;
  89895. /**
  89896. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89897. * @param matrix the transforming matrix
  89898. * @returns the VertexData
  89899. */
  89900. transform(matrix: Matrix): VertexData;
  89901. /**
  89902. * Merges the passed VertexData into the current one
  89903. * @param other the VertexData to be merged into the current one
  89904. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89905. * @returns the modified VertexData
  89906. */
  89907. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89908. private _mergeElement;
  89909. private _validate;
  89910. /**
  89911. * Serializes the VertexData
  89912. * @returns a serialized object
  89913. */
  89914. serialize(): any;
  89915. /**
  89916. * Extracts the vertexData from a mesh
  89917. * @param mesh the mesh from which to extract the VertexData
  89918. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89919. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89920. * @returns the object VertexData associated to the passed mesh
  89921. */
  89922. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89923. /**
  89924. * Extracts the vertexData from the geometry
  89925. * @param geometry the geometry from which to extract the VertexData
  89926. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89927. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89928. * @returns the object VertexData associated to the passed mesh
  89929. */
  89930. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89931. private static _ExtractFrom;
  89932. /**
  89933. * Creates the VertexData for a Ribbon
  89934. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89935. * * pathArray array of paths, each of which an array of successive Vector3
  89936. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89937. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89938. * * 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
  89939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89940. * * 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)
  89941. * * 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)
  89942. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89943. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89944. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89945. * @returns the VertexData of the ribbon
  89946. */
  89947. static CreateRibbon(options: {
  89948. pathArray: Vector3[][];
  89949. closeArray?: boolean;
  89950. closePath?: boolean;
  89951. offset?: number;
  89952. sideOrientation?: number;
  89953. frontUVs?: Vector4;
  89954. backUVs?: Vector4;
  89955. invertUV?: boolean;
  89956. uvs?: Vector2[];
  89957. colors?: Color4[];
  89958. }): VertexData;
  89959. /**
  89960. * Creates the VertexData for a box
  89961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89962. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89963. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89964. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89965. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89966. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89967. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89969. * * 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)
  89970. * * 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)
  89971. * @returns the VertexData of the box
  89972. */
  89973. static CreateBox(options: {
  89974. size?: number;
  89975. width?: number;
  89976. height?: number;
  89977. depth?: number;
  89978. faceUV?: Vector4[];
  89979. faceColors?: Color4[];
  89980. sideOrientation?: number;
  89981. frontUVs?: Vector4;
  89982. backUVs?: Vector4;
  89983. }): VertexData;
  89984. /**
  89985. * Creates the VertexData for a tiled box
  89986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89987. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89988. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89989. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89991. * @returns the VertexData of the box
  89992. */
  89993. static CreateTiledBox(options: {
  89994. pattern?: number;
  89995. width?: number;
  89996. height?: number;
  89997. depth?: number;
  89998. tileSize?: number;
  89999. tileWidth?: number;
  90000. tileHeight?: number;
  90001. alignHorizontal?: number;
  90002. alignVertical?: number;
  90003. faceUV?: Vector4[];
  90004. faceColors?: Color4[];
  90005. sideOrientation?: number;
  90006. }): VertexData;
  90007. /**
  90008. * Creates the VertexData for a tiled plane
  90009. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90010. * * pattern a limited pattern arrangement depending on the number
  90011. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90012. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90013. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90015. * * 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)
  90016. * * 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)
  90017. * @returns the VertexData of the tiled plane
  90018. */
  90019. static CreateTiledPlane(options: {
  90020. pattern?: number;
  90021. tileSize?: number;
  90022. tileWidth?: number;
  90023. tileHeight?: number;
  90024. size?: number;
  90025. width?: number;
  90026. height?: number;
  90027. alignHorizontal?: number;
  90028. alignVertical?: number;
  90029. sideOrientation?: number;
  90030. frontUVs?: Vector4;
  90031. backUVs?: Vector4;
  90032. }): VertexData;
  90033. /**
  90034. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90035. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90036. * * segments sets the number of horizontal strips optional, default 32
  90037. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90038. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90039. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90040. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90041. * * 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
  90042. * * 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
  90043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90044. * * 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)
  90045. * * 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)
  90046. * @returns the VertexData of the ellipsoid
  90047. */
  90048. static CreateSphere(options: {
  90049. segments?: number;
  90050. diameter?: number;
  90051. diameterX?: number;
  90052. diameterY?: number;
  90053. diameterZ?: number;
  90054. arc?: number;
  90055. slice?: number;
  90056. sideOrientation?: number;
  90057. frontUVs?: Vector4;
  90058. backUVs?: Vector4;
  90059. }): VertexData;
  90060. /**
  90061. * Creates the VertexData for a cylinder, cone or prism
  90062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90063. * * height sets the height (y direction) of the cylinder, optional, default 2
  90064. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90065. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90066. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90067. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90068. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90069. * * 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
  90070. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90071. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90072. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90073. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90075. * * 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)
  90076. * * 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)
  90077. * @returns the VertexData of the cylinder, cone or prism
  90078. */
  90079. static CreateCylinder(options: {
  90080. height?: number;
  90081. diameterTop?: number;
  90082. diameterBottom?: number;
  90083. diameter?: number;
  90084. tessellation?: number;
  90085. subdivisions?: number;
  90086. arc?: number;
  90087. faceColors?: Color4[];
  90088. faceUV?: Vector4[];
  90089. hasRings?: boolean;
  90090. enclose?: boolean;
  90091. sideOrientation?: number;
  90092. frontUVs?: Vector4;
  90093. backUVs?: Vector4;
  90094. }): VertexData;
  90095. /**
  90096. * Creates the VertexData for a torus
  90097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90098. * * diameter the diameter of the torus, optional default 1
  90099. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90100. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90102. * * 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)
  90103. * * 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)
  90104. * @returns the VertexData of the torus
  90105. */
  90106. static CreateTorus(options: {
  90107. diameter?: number;
  90108. thickness?: number;
  90109. tessellation?: number;
  90110. sideOrientation?: number;
  90111. frontUVs?: Vector4;
  90112. backUVs?: Vector4;
  90113. }): VertexData;
  90114. /**
  90115. * Creates the VertexData of the LineSystem
  90116. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90117. * - lines an array of lines, each line being an array of successive Vector3
  90118. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90119. * @returns the VertexData of the LineSystem
  90120. */
  90121. static CreateLineSystem(options: {
  90122. lines: Vector3[][];
  90123. colors?: Nullable<Color4[][]>;
  90124. }): VertexData;
  90125. /**
  90126. * Create the VertexData for a DashedLines
  90127. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90128. * - points an array successive Vector3
  90129. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90130. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90131. * - dashNb the intended total number of dashes, optional, default 200
  90132. * @returns the VertexData for the DashedLines
  90133. */
  90134. static CreateDashedLines(options: {
  90135. points: Vector3[];
  90136. dashSize?: number;
  90137. gapSize?: number;
  90138. dashNb?: number;
  90139. }): VertexData;
  90140. /**
  90141. * Creates the VertexData for a Ground
  90142. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90143. * - width the width (x direction) of the ground, optional, default 1
  90144. * - height the height (z direction) of the ground, optional, default 1
  90145. * - subdivisions the number of subdivisions per side, optional, default 1
  90146. * @returns the VertexData of the Ground
  90147. */
  90148. static CreateGround(options: {
  90149. width?: number;
  90150. height?: number;
  90151. subdivisions?: number;
  90152. subdivisionsX?: number;
  90153. subdivisionsY?: number;
  90154. }): VertexData;
  90155. /**
  90156. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90157. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90158. * * xmin the ground minimum X coordinate, optional, default -1
  90159. * * zmin the ground minimum Z coordinate, optional, default -1
  90160. * * xmax the ground maximum X coordinate, optional, default 1
  90161. * * zmax the ground maximum Z coordinate, optional, default 1
  90162. * * 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}
  90163. * * 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}
  90164. * @returns the VertexData of the TiledGround
  90165. */
  90166. static CreateTiledGround(options: {
  90167. xmin: number;
  90168. zmin: number;
  90169. xmax: number;
  90170. zmax: number;
  90171. subdivisions?: {
  90172. w: number;
  90173. h: number;
  90174. };
  90175. precision?: {
  90176. w: number;
  90177. h: number;
  90178. };
  90179. }): VertexData;
  90180. /**
  90181. * Creates the VertexData of the Ground designed from a heightmap
  90182. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90183. * * width the width (x direction) of the ground
  90184. * * height the height (z direction) of the ground
  90185. * * subdivisions the number of subdivisions per side
  90186. * * minHeight the minimum altitude on the ground, optional, default 0
  90187. * * maxHeight the maximum altitude on the ground, optional default 1
  90188. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90189. * * buffer the array holding the image color data
  90190. * * bufferWidth the width of image
  90191. * * bufferHeight the height of image
  90192. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90193. * @returns the VertexData of the Ground designed from a heightmap
  90194. */
  90195. static CreateGroundFromHeightMap(options: {
  90196. width: number;
  90197. height: number;
  90198. subdivisions: number;
  90199. minHeight: number;
  90200. maxHeight: number;
  90201. colorFilter: Color3;
  90202. buffer: Uint8Array;
  90203. bufferWidth: number;
  90204. bufferHeight: number;
  90205. alphaFilter: number;
  90206. }): VertexData;
  90207. /**
  90208. * Creates the VertexData for a Plane
  90209. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90210. * * size sets the width and height of the plane to the value of size, optional default 1
  90211. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90212. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90214. * * 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)
  90215. * * 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)
  90216. * @returns the VertexData of the box
  90217. */
  90218. static CreatePlane(options: {
  90219. size?: number;
  90220. width?: number;
  90221. height?: number;
  90222. sideOrientation?: number;
  90223. frontUVs?: Vector4;
  90224. backUVs?: Vector4;
  90225. }): VertexData;
  90226. /**
  90227. * Creates the VertexData of the Disc or regular Polygon
  90228. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90229. * * radius the radius of the disc, optional default 0.5
  90230. * * tessellation the number of polygon sides, optional, default 64
  90231. * * 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
  90232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90233. * * 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)
  90234. * * 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)
  90235. * @returns the VertexData of the box
  90236. */
  90237. static CreateDisc(options: {
  90238. radius?: number;
  90239. tessellation?: number;
  90240. arc?: number;
  90241. sideOrientation?: number;
  90242. frontUVs?: Vector4;
  90243. backUVs?: Vector4;
  90244. }): VertexData;
  90245. /**
  90246. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90247. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90248. * @param polygon a mesh built from polygonTriangulation.build()
  90249. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90250. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90251. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90252. * @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)
  90253. * @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)
  90254. * @returns the VertexData of the Polygon
  90255. */
  90256. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90257. /**
  90258. * Creates the VertexData of the IcoSphere
  90259. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90260. * * radius the radius of the IcoSphere, optional default 1
  90261. * * radiusX allows stretching in the x direction, optional, default radius
  90262. * * radiusY allows stretching in the y direction, optional, default radius
  90263. * * radiusZ allows stretching in the z direction, optional, default radius
  90264. * * flat when true creates a flat shaded mesh, optional, default true
  90265. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90267. * * 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)
  90268. * * 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)
  90269. * @returns the VertexData of the IcoSphere
  90270. */
  90271. static CreateIcoSphere(options: {
  90272. radius?: number;
  90273. radiusX?: number;
  90274. radiusY?: number;
  90275. radiusZ?: number;
  90276. flat?: boolean;
  90277. subdivisions?: number;
  90278. sideOrientation?: number;
  90279. frontUVs?: Vector4;
  90280. backUVs?: Vector4;
  90281. }): VertexData;
  90282. /**
  90283. * Creates the VertexData for a Polyhedron
  90284. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90285. * * type provided types are:
  90286. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90287. * * 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)
  90288. * * size the size of the IcoSphere, optional default 1
  90289. * * sizeX allows stretching in the x direction, optional, default size
  90290. * * sizeY allows stretching in the y direction, optional, default size
  90291. * * sizeZ allows stretching in the z direction, optional, default size
  90292. * * 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
  90293. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90294. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90295. * * flat when true creates a flat shaded mesh, optional, default true
  90296. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90298. * * 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)
  90299. * * 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)
  90300. * @returns the VertexData of the Polyhedron
  90301. */
  90302. static CreatePolyhedron(options: {
  90303. type?: number;
  90304. size?: number;
  90305. sizeX?: number;
  90306. sizeY?: number;
  90307. sizeZ?: number;
  90308. custom?: any;
  90309. faceUV?: Vector4[];
  90310. faceColors?: Color4[];
  90311. flat?: boolean;
  90312. sideOrientation?: number;
  90313. frontUVs?: Vector4;
  90314. backUVs?: Vector4;
  90315. }): VertexData;
  90316. /**
  90317. * Creates the VertexData for a TorusKnot
  90318. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90319. * * radius the radius of the torus knot, optional, default 2
  90320. * * tube the thickness of the tube, optional, default 0.5
  90321. * * radialSegments the number of sides on each tube segments, optional, default 32
  90322. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90323. * * p the number of windings around the z axis, optional, default 2
  90324. * * q the number of windings around the x axis, optional, default 3
  90325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90326. * * 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)
  90327. * * 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)
  90328. * @returns the VertexData of the Torus Knot
  90329. */
  90330. static CreateTorusKnot(options: {
  90331. radius?: number;
  90332. tube?: number;
  90333. radialSegments?: number;
  90334. tubularSegments?: number;
  90335. p?: number;
  90336. q?: number;
  90337. sideOrientation?: number;
  90338. frontUVs?: Vector4;
  90339. backUVs?: Vector4;
  90340. }): VertexData;
  90341. /**
  90342. * Compute normals for given positions and indices
  90343. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90344. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90345. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90346. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90347. * * facetNormals : optional array of facet normals (vector3)
  90348. * * facetPositions : optional array of facet positions (vector3)
  90349. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90350. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90351. * * bInfo : optional bounding info, required for facetPartitioning computation
  90352. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90353. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90354. * * useRightHandedSystem: optional boolean to for right handed system computation
  90355. * * depthSort : optional boolean to enable the facet depth sort computation
  90356. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90357. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90358. */
  90359. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90360. facetNormals?: any;
  90361. facetPositions?: any;
  90362. facetPartitioning?: any;
  90363. ratio?: number;
  90364. bInfo?: any;
  90365. bbSize?: Vector3;
  90366. subDiv?: any;
  90367. useRightHandedSystem?: boolean;
  90368. depthSort?: boolean;
  90369. distanceTo?: Vector3;
  90370. depthSortedFacets?: any;
  90371. }): void;
  90372. /** @hidden */
  90373. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90374. /**
  90375. * Applies VertexData created from the imported parameters to the geometry
  90376. * @param parsedVertexData the parsed data from an imported file
  90377. * @param geometry the geometry to apply the VertexData to
  90378. */
  90379. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90380. }
  90381. }
  90382. declare module BABYLON {
  90383. /**
  90384. * Defines a target to use with MorphTargetManager
  90385. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90386. */
  90387. export class MorphTarget implements IAnimatable {
  90388. /** defines the name of the target */
  90389. name: string;
  90390. /**
  90391. * Gets or sets the list of animations
  90392. */
  90393. animations: Animation[];
  90394. private _scene;
  90395. private _positions;
  90396. private _normals;
  90397. private _tangents;
  90398. private _uvs;
  90399. private _influence;
  90400. private _uniqueId;
  90401. /**
  90402. * Observable raised when the influence changes
  90403. */
  90404. onInfluenceChanged: Observable<boolean>;
  90405. /** @hidden */
  90406. _onDataLayoutChanged: Observable<void>;
  90407. /**
  90408. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90409. */
  90410. influence: number;
  90411. /**
  90412. * Gets or sets the id of the morph Target
  90413. */
  90414. id: string;
  90415. private _animationPropertiesOverride;
  90416. /**
  90417. * Gets or sets the animation properties override
  90418. */
  90419. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90420. /**
  90421. * Creates a new MorphTarget
  90422. * @param name defines the name of the target
  90423. * @param influence defines the influence to use
  90424. * @param scene defines the scene the morphtarget belongs to
  90425. */
  90426. constructor(
  90427. /** defines the name of the target */
  90428. name: string, influence?: number, scene?: Nullable<Scene>);
  90429. /**
  90430. * Gets the unique ID of this manager
  90431. */
  90432. readonly uniqueId: number;
  90433. /**
  90434. * Gets a boolean defining if the target contains position data
  90435. */
  90436. readonly hasPositions: boolean;
  90437. /**
  90438. * Gets a boolean defining if the target contains normal data
  90439. */
  90440. readonly hasNormals: boolean;
  90441. /**
  90442. * Gets a boolean defining if the target contains tangent data
  90443. */
  90444. readonly hasTangents: boolean;
  90445. /**
  90446. * Gets a boolean defining if the target contains texture coordinates data
  90447. */
  90448. readonly hasUVs: boolean;
  90449. /**
  90450. * Affects position data to this target
  90451. * @param data defines the position data to use
  90452. */
  90453. setPositions(data: Nullable<FloatArray>): void;
  90454. /**
  90455. * Gets the position data stored in this target
  90456. * @returns a FloatArray containing the position data (or null if not present)
  90457. */
  90458. getPositions(): Nullable<FloatArray>;
  90459. /**
  90460. * Affects normal data to this target
  90461. * @param data defines the normal data to use
  90462. */
  90463. setNormals(data: Nullable<FloatArray>): void;
  90464. /**
  90465. * Gets the normal data stored in this target
  90466. * @returns a FloatArray containing the normal data (or null if not present)
  90467. */
  90468. getNormals(): Nullable<FloatArray>;
  90469. /**
  90470. * Affects tangent data to this target
  90471. * @param data defines the tangent data to use
  90472. */
  90473. setTangents(data: Nullable<FloatArray>): void;
  90474. /**
  90475. * Gets the tangent data stored in this target
  90476. * @returns a FloatArray containing the tangent data (or null if not present)
  90477. */
  90478. getTangents(): Nullable<FloatArray>;
  90479. /**
  90480. * Affects texture coordinates data to this target
  90481. * @param data defines the texture coordinates data to use
  90482. */
  90483. setUVs(data: Nullable<FloatArray>): void;
  90484. /**
  90485. * Gets the texture coordinates data stored in this target
  90486. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90487. */
  90488. getUVs(): Nullable<FloatArray>;
  90489. /**
  90490. * Clone the current target
  90491. * @returns a new MorphTarget
  90492. */
  90493. clone(): MorphTarget;
  90494. /**
  90495. * Serializes the current target into a Serialization object
  90496. * @returns the serialized object
  90497. */
  90498. serialize(): any;
  90499. /**
  90500. * Returns the string "MorphTarget"
  90501. * @returns "MorphTarget"
  90502. */
  90503. getClassName(): string;
  90504. /**
  90505. * Creates a new target from serialized data
  90506. * @param serializationObject defines the serialized data to use
  90507. * @returns a new MorphTarget
  90508. */
  90509. static Parse(serializationObject: any): MorphTarget;
  90510. /**
  90511. * Creates a MorphTarget from mesh data
  90512. * @param mesh defines the source mesh
  90513. * @param name defines the name to use for the new target
  90514. * @param influence defines the influence to attach to the target
  90515. * @returns a new MorphTarget
  90516. */
  90517. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90518. }
  90519. }
  90520. declare module BABYLON {
  90521. /**
  90522. * This class is used to deform meshes using morphing between different targets
  90523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90524. */
  90525. export class MorphTargetManager {
  90526. private _targets;
  90527. private _targetInfluenceChangedObservers;
  90528. private _targetDataLayoutChangedObservers;
  90529. private _activeTargets;
  90530. private _scene;
  90531. private _influences;
  90532. private _supportsNormals;
  90533. private _supportsTangents;
  90534. private _supportsUVs;
  90535. private _vertexCount;
  90536. private _uniqueId;
  90537. private _tempInfluences;
  90538. /**
  90539. * Gets or sets a boolean indicating if normals must be morphed
  90540. */
  90541. enableNormalMorphing: boolean;
  90542. /**
  90543. * Gets or sets a boolean indicating if tangents must be morphed
  90544. */
  90545. enableTangentMorphing: boolean;
  90546. /**
  90547. * Gets or sets a boolean indicating if UV must be morphed
  90548. */
  90549. enableUVMorphing: boolean;
  90550. /**
  90551. * Creates a new MorphTargetManager
  90552. * @param scene defines the current scene
  90553. */
  90554. constructor(scene?: Nullable<Scene>);
  90555. /**
  90556. * Gets the unique ID of this manager
  90557. */
  90558. readonly uniqueId: number;
  90559. /**
  90560. * Gets the number of vertices handled by this manager
  90561. */
  90562. readonly vertexCount: number;
  90563. /**
  90564. * Gets a boolean indicating if this manager supports morphing of normals
  90565. */
  90566. readonly supportsNormals: boolean;
  90567. /**
  90568. * Gets a boolean indicating if this manager supports morphing of tangents
  90569. */
  90570. readonly supportsTangents: boolean;
  90571. /**
  90572. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90573. */
  90574. readonly supportsUVs: boolean;
  90575. /**
  90576. * Gets the number of targets stored in this manager
  90577. */
  90578. readonly numTargets: number;
  90579. /**
  90580. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90581. */
  90582. readonly numInfluencers: number;
  90583. /**
  90584. * Gets the list of influences (one per target)
  90585. */
  90586. readonly influences: Float32Array;
  90587. /**
  90588. * Gets the active target at specified index. An active target is a target with an influence > 0
  90589. * @param index defines the index to check
  90590. * @returns the requested target
  90591. */
  90592. getActiveTarget(index: number): MorphTarget;
  90593. /**
  90594. * Gets the target at specified index
  90595. * @param index defines the index to check
  90596. * @returns the requested target
  90597. */
  90598. getTarget(index: number): MorphTarget;
  90599. /**
  90600. * Add a new target to this manager
  90601. * @param target defines the target to add
  90602. */
  90603. addTarget(target: MorphTarget): void;
  90604. /**
  90605. * Removes a target from the manager
  90606. * @param target defines the target to remove
  90607. */
  90608. removeTarget(target: MorphTarget): void;
  90609. /**
  90610. * Clone the current manager
  90611. * @returns a new MorphTargetManager
  90612. */
  90613. clone(): MorphTargetManager;
  90614. /**
  90615. * Serializes the current manager into a Serialization object
  90616. * @returns the serialized object
  90617. */
  90618. serialize(): any;
  90619. private _syncActiveTargets;
  90620. /**
  90621. * Syncrhonize the targets with all the meshes using this morph target manager
  90622. */
  90623. synchronize(): void;
  90624. /**
  90625. * Creates a new MorphTargetManager from serialized data
  90626. * @param serializationObject defines the serialized data
  90627. * @param scene defines the hosting scene
  90628. * @returns the new MorphTargetManager
  90629. */
  90630. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90631. }
  90632. }
  90633. declare module BABYLON {
  90634. /**
  90635. * Class used to represent a specific level of detail of a mesh
  90636. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90637. */
  90638. export class MeshLODLevel {
  90639. /** Defines the distance where this level should start being displayed */
  90640. distance: number;
  90641. /** Defines the mesh to use to render this level */
  90642. mesh: Nullable<Mesh>;
  90643. /**
  90644. * Creates a new LOD level
  90645. * @param distance defines the distance where this level should star being displayed
  90646. * @param mesh defines the mesh to use to render this level
  90647. */
  90648. constructor(
  90649. /** Defines the distance where this level should start being displayed */
  90650. distance: number,
  90651. /** Defines the mesh to use to render this level */
  90652. mesh: Nullable<Mesh>);
  90653. }
  90654. }
  90655. declare module BABYLON {
  90656. /**
  90657. * Mesh representing the gorund
  90658. */
  90659. export class GroundMesh extends Mesh {
  90660. /** If octree should be generated */
  90661. generateOctree: boolean;
  90662. private _heightQuads;
  90663. /** @hidden */
  90664. _subdivisionsX: number;
  90665. /** @hidden */
  90666. _subdivisionsY: number;
  90667. /** @hidden */
  90668. _width: number;
  90669. /** @hidden */
  90670. _height: number;
  90671. /** @hidden */
  90672. _minX: number;
  90673. /** @hidden */
  90674. _maxX: number;
  90675. /** @hidden */
  90676. _minZ: number;
  90677. /** @hidden */
  90678. _maxZ: number;
  90679. constructor(name: string, scene: Scene);
  90680. /**
  90681. * "GroundMesh"
  90682. * @returns "GroundMesh"
  90683. */
  90684. getClassName(): string;
  90685. /**
  90686. * The minimum of x and y subdivisions
  90687. */
  90688. readonly subdivisions: number;
  90689. /**
  90690. * X subdivisions
  90691. */
  90692. readonly subdivisionsX: number;
  90693. /**
  90694. * Y subdivisions
  90695. */
  90696. readonly subdivisionsY: number;
  90697. /**
  90698. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90699. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90700. * @param chunksCount the number of subdivisions for x and y
  90701. * @param octreeBlocksSize (Default: 32)
  90702. */
  90703. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90704. /**
  90705. * Returns a height (y) value in the Worl system :
  90706. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90707. * @param x x coordinate
  90708. * @param z z coordinate
  90709. * @returns the ground y position if (x, z) are outside the ground surface.
  90710. */
  90711. getHeightAtCoordinates(x: number, z: number): number;
  90712. /**
  90713. * Returns a normalized vector (Vector3) orthogonal to the ground
  90714. * at the ground coordinates (x, z) expressed in the World system.
  90715. * @param x x coordinate
  90716. * @param z z coordinate
  90717. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90718. */
  90719. getNormalAtCoordinates(x: number, z: number): Vector3;
  90720. /**
  90721. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90722. * at the ground coordinates (x, z) expressed in the World system.
  90723. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90724. * @param x x coordinate
  90725. * @param z z coordinate
  90726. * @param ref vector to store the result
  90727. * @returns the GroundMesh.
  90728. */
  90729. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90730. /**
  90731. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90732. * if the ground has been updated.
  90733. * This can be used in the render loop.
  90734. * @returns the GroundMesh.
  90735. */
  90736. updateCoordinateHeights(): GroundMesh;
  90737. private _getFacetAt;
  90738. private _initHeightQuads;
  90739. private _computeHeightQuads;
  90740. /**
  90741. * Serializes this ground mesh
  90742. * @param serializationObject object to write serialization to
  90743. */
  90744. serialize(serializationObject: any): void;
  90745. /**
  90746. * Parses a serialized ground mesh
  90747. * @param parsedMesh the serialized mesh
  90748. * @param scene the scene to create the ground mesh in
  90749. * @returns the created ground mesh
  90750. */
  90751. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90752. }
  90753. }
  90754. declare module BABYLON {
  90755. /**
  90756. * Interface for Physics-Joint data
  90757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90758. */
  90759. export interface PhysicsJointData {
  90760. /**
  90761. * The main pivot of the joint
  90762. */
  90763. mainPivot?: Vector3;
  90764. /**
  90765. * The connected pivot of the joint
  90766. */
  90767. connectedPivot?: Vector3;
  90768. /**
  90769. * The main axis of the joint
  90770. */
  90771. mainAxis?: Vector3;
  90772. /**
  90773. * The connected axis of the joint
  90774. */
  90775. connectedAxis?: Vector3;
  90776. /**
  90777. * The collision of the joint
  90778. */
  90779. collision?: boolean;
  90780. /**
  90781. * Native Oimo/Cannon/Energy data
  90782. */
  90783. nativeParams?: any;
  90784. }
  90785. /**
  90786. * This is a holder class for the physics joint created by the physics plugin
  90787. * It holds a set of functions to control the underlying joint
  90788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90789. */
  90790. export class PhysicsJoint {
  90791. /**
  90792. * The type of the physics joint
  90793. */
  90794. type: number;
  90795. /**
  90796. * The data for the physics joint
  90797. */
  90798. jointData: PhysicsJointData;
  90799. private _physicsJoint;
  90800. protected _physicsPlugin: IPhysicsEnginePlugin;
  90801. /**
  90802. * Initializes the physics joint
  90803. * @param type The type of the physics joint
  90804. * @param jointData The data for the physics joint
  90805. */
  90806. constructor(
  90807. /**
  90808. * The type of the physics joint
  90809. */
  90810. type: number,
  90811. /**
  90812. * The data for the physics joint
  90813. */
  90814. jointData: PhysicsJointData);
  90815. /**
  90816. * Gets the physics joint
  90817. */
  90818. /**
  90819. * Sets the physics joint
  90820. */
  90821. physicsJoint: any;
  90822. /**
  90823. * Sets the physics plugin
  90824. */
  90825. physicsPlugin: IPhysicsEnginePlugin;
  90826. /**
  90827. * Execute a function that is physics-plugin specific.
  90828. * @param {Function} func the function that will be executed.
  90829. * It accepts two parameters: the physics world and the physics joint
  90830. */
  90831. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90832. /**
  90833. * Distance-Joint type
  90834. */
  90835. static DistanceJoint: number;
  90836. /**
  90837. * Hinge-Joint type
  90838. */
  90839. static HingeJoint: number;
  90840. /**
  90841. * Ball-and-Socket joint type
  90842. */
  90843. static BallAndSocketJoint: number;
  90844. /**
  90845. * Wheel-Joint type
  90846. */
  90847. static WheelJoint: number;
  90848. /**
  90849. * Slider-Joint type
  90850. */
  90851. static SliderJoint: number;
  90852. /**
  90853. * Prismatic-Joint type
  90854. */
  90855. static PrismaticJoint: number;
  90856. /**
  90857. * Universal-Joint type
  90858. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90859. */
  90860. static UniversalJoint: number;
  90861. /**
  90862. * Hinge-Joint 2 type
  90863. */
  90864. static Hinge2Joint: number;
  90865. /**
  90866. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90867. */
  90868. static PointToPointJoint: number;
  90869. /**
  90870. * Spring-Joint type
  90871. */
  90872. static SpringJoint: number;
  90873. /**
  90874. * Lock-Joint type
  90875. */
  90876. static LockJoint: number;
  90877. }
  90878. /**
  90879. * A class representing a physics distance joint
  90880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90881. */
  90882. export class DistanceJoint extends PhysicsJoint {
  90883. /**
  90884. *
  90885. * @param jointData The data for the Distance-Joint
  90886. */
  90887. constructor(jointData: DistanceJointData);
  90888. /**
  90889. * Update the predefined distance.
  90890. * @param maxDistance The maximum preferred distance
  90891. * @param minDistance The minimum preferred distance
  90892. */
  90893. updateDistance(maxDistance: number, minDistance?: number): void;
  90894. }
  90895. /**
  90896. * Represents a Motor-Enabled Joint
  90897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90898. */
  90899. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90900. /**
  90901. * Initializes the Motor-Enabled Joint
  90902. * @param type The type of the joint
  90903. * @param jointData The physica joint data for the joint
  90904. */
  90905. constructor(type: number, jointData: PhysicsJointData);
  90906. /**
  90907. * Set the motor values.
  90908. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90909. * @param force the force to apply
  90910. * @param maxForce max force for this motor.
  90911. */
  90912. setMotor(force?: number, maxForce?: number): void;
  90913. /**
  90914. * Set the motor's limits.
  90915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90916. * @param upperLimit The upper limit of the motor
  90917. * @param lowerLimit The lower limit of the motor
  90918. */
  90919. setLimit(upperLimit: number, lowerLimit?: number): void;
  90920. }
  90921. /**
  90922. * This class represents a single physics Hinge-Joint
  90923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90924. */
  90925. export class HingeJoint extends MotorEnabledJoint {
  90926. /**
  90927. * Initializes the Hinge-Joint
  90928. * @param jointData The joint data for the Hinge-Joint
  90929. */
  90930. constructor(jointData: PhysicsJointData);
  90931. /**
  90932. * Set the motor values.
  90933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90934. * @param {number} force the force to apply
  90935. * @param {number} maxForce max force for this motor.
  90936. */
  90937. setMotor(force?: number, maxForce?: number): void;
  90938. /**
  90939. * Set the motor's limits.
  90940. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90941. * @param upperLimit The upper limit of the motor
  90942. * @param lowerLimit The lower limit of the motor
  90943. */
  90944. setLimit(upperLimit: number, lowerLimit?: number): void;
  90945. }
  90946. /**
  90947. * This class represents a dual hinge physics joint (same as wheel joint)
  90948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90949. */
  90950. export class Hinge2Joint extends MotorEnabledJoint {
  90951. /**
  90952. * Initializes the Hinge2-Joint
  90953. * @param jointData The joint data for the Hinge2-Joint
  90954. */
  90955. constructor(jointData: PhysicsJointData);
  90956. /**
  90957. * Set the motor values.
  90958. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90959. * @param {number} targetSpeed the speed the motor is to reach
  90960. * @param {number} maxForce max force for this motor.
  90961. * @param {motorIndex} the motor's index, 0 or 1.
  90962. */
  90963. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90964. /**
  90965. * Set the motor limits.
  90966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90967. * @param {number} upperLimit the upper limit
  90968. * @param {number} lowerLimit lower limit
  90969. * @param {motorIndex} the motor's index, 0 or 1.
  90970. */
  90971. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90972. }
  90973. /**
  90974. * Interface for a motor enabled joint
  90975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90976. */
  90977. export interface IMotorEnabledJoint {
  90978. /**
  90979. * Physics joint
  90980. */
  90981. physicsJoint: any;
  90982. /**
  90983. * Sets the motor of the motor-enabled joint
  90984. * @param force The force of the motor
  90985. * @param maxForce The maximum force of the motor
  90986. * @param motorIndex The index of the motor
  90987. */
  90988. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90989. /**
  90990. * Sets the limit of the motor
  90991. * @param upperLimit The upper limit of the motor
  90992. * @param lowerLimit The lower limit of the motor
  90993. * @param motorIndex The index of the motor
  90994. */
  90995. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90996. }
  90997. /**
  90998. * Joint data for a Distance-Joint
  90999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91000. */
  91001. export interface DistanceJointData extends PhysicsJointData {
  91002. /**
  91003. * Max distance the 2 joint objects can be apart
  91004. */
  91005. maxDistance: number;
  91006. }
  91007. /**
  91008. * Joint data from a spring joint
  91009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91010. */
  91011. export interface SpringJointData extends PhysicsJointData {
  91012. /**
  91013. * Length of the spring
  91014. */
  91015. length: number;
  91016. /**
  91017. * Stiffness of the spring
  91018. */
  91019. stiffness: number;
  91020. /**
  91021. * Damping of the spring
  91022. */
  91023. damping: number;
  91024. /** this callback will be called when applying the force to the impostors. */
  91025. forceApplicationCallback: () => void;
  91026. }
  91027. }
  91028. declare module BABYLON {
  91029. /**
  91030. * Holds the data for the raycast result
  91031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91032. */
  91033. export class PhysicsRaycastResult {
  91034. private _hasHit;
  91035. private _hitDistance;
  91036. private _hitNormalWorld;
  91037. private _hitPointWorld;
  91038. private _rayFromWorld;
  91039. private _rayToWorld;
  91040. /**
  91041. * Gets if there was a hit
  91042. */
  91043. readonly hasHit: boolean;
  91044. /**
  91045. * Gets the distance from the hit
  91046. */
  91047. readonly hitDistance: number;
  91048. /**
  91049. * Gets the hit normal/direction in the world
  91050. */
  91051. readonly hitNormalWorld: Vector3;
  91052. /**
  91053. * Gets the hit point in the world
  91054. */
  91055. readonly hitPointWorld: Vector3;
  91056. /**
  91057. * Gets the ray "start point" of the ray in the world
  91058. */
  91059. readonly rayFromWorld: Vector3;
  91060. /**
  91061. * Gets the ray "end point" of the ray in the world
  91062. */
  91063. readonly rayToWorld: Vector3;
  91064. /**
  91065. * Sets the hit data (normal & point in world space)
  91066. * @param hitNormalWorld defines the normal in world space
  91067. * @param hitPointWorld defines the point in world space
  91068. */
  91069. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91070. /**
  91071. * Sets the distance from the start point to the hit point
  91072. * @param distance
  91073. */
  91074. setHitDistance(distance: number): void;
  91075. /**
  91076. * Calculates the distance manually
  91077. */
  91078. calculateHitDistance(): void;
  91079. /**
  91080. * Resets all the values to default
  91081. * @param from The from point on world space
  91082. * @param to The to point on world space
  91083. */
  91084. reset(from?: Vector3, to?: Vector3): void;
  91085. }
  91086. /**
  91087. * Interface for the size containing width and height
  91088. */
  91089. interface IXYZ {
  91090. /**
  91091. * X
  91092. */
  91093. x: number;
  91094. /**
  91095. * Y
  91096. */
  91097. y: number;
  91098. /**
  91099. * Z
  91100. */
  91101. z: number;
  91102. }
  91103. }
  91104. declare module BABYLON {
  91105. /**
  91106. * Interface used to describe a physics joint
  91107. */
  91108. export interface PhysicsImpostorJoint {
  91109. /** Defines the main impostor to which the joint is linked */
  91110. mainImpostor: PhysicsImpostor;
  91111. /** Defines the impostor that is connected to the main impostor using this joint */
  91112. connectedImpostor: PhysicsImpostor;
  91113. /** Defines the joint itself */
  91114. joint: PhysicsJoint;
  91115. }
  91116. /** @hidden */
  91117. export interface IPhysicsEnginePlugin {
  91118. world: any;
  91119. name: string;
  91120. setGravity(gravity: Vector3): void;
  91121. setTimeStep(timeStep: number): void;
  91122. getTimeStep(): number;
  91123. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91124. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91126. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91127. removePhysicsBody(impostor: PhysicsImpostor): void;
  91128. generateJoint(joint: PhysicsImpostorJoint): void;
  91129. removeJoint(joint: PhysicsImpostorJoint): void;
  91130. isSupported(): boolean;
  91131. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91132. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91133. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91134. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91136. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91137. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91138. getBodyMass(impostor: PhysicsImpostor): number;
  91139. getBodyFriction(impostor: PhysicsImpostor): number;
  91140. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91141. getBodyRestitution(impostor: PhysicsImpostor): number;
  91142. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91143. getBodyPressure?(impostor: PhysicsImpostor): number;
  91144. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91145. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91146. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91147. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91148. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91149. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91150. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91151. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91152. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91153. sleepBody(impostor: PhysicsImpostor): void;
  91154. wakeUpBody(impostor: PhysicsImpostor): void;
  91155. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91156. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91157. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91158. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91159. getRadius(impostor: PhysicsImpostor): number;
  91160. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91161. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91162. dispose(): void;
  91163. }
  91164. /**
  91165. * Interface used to define a physics engine
  91166. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91167. */
  91168. export interface IPhysicsEngine {
  91169. /**
  91170. * Gets the gravity vector used by the simulation
  91171. */
  91172. gravity: Vector3;
  91173. /**
  91174. * Sets the gravity vector used by the simulation
  91175. * @param gravity defines the gravity vector to use
  91176. */
  91177. setGravity(gravity: Vector3): void;
  91178. /**
  91179. * Set the time step of the physics engine.
  91180. * Default is 1/60.
  91181. * To slow it down, enter 1/600 for example.
  91182. * To speed it up, 1/30
  91183. * @param newTimeStep the new timestep to apply to this world.
  91184. */
  91185. setTimeStep(newTimeStep: number): void;
  91186. /**
  91187. * Get the time step of the physics engine.
  91188. * @returns the current time step
  91189. */
  91190. getTimeStep(): number;
  91191. /**
  91192. * Release all resources
  91193. */
  91194. dispose(): void;
  91195. /**
  91196. * Gets the name of the current physics plugin
  91197. * @returns the name of the plugin
  91198. */
  91199. getPhysicsPluginName(): string;
  91200. /**
  91201. * Adding a new impostor for the impostor tracking.
  91202. * This will be done by the impostor itself.
  91203. * @param impostor the impostor to add
  91204. */
  91205. addImpostor(impostor: PhysicsImpostor): void;
  91206. /**
  91207. * Remove an impostor from the engine.
  91208. * This impostor and its mesh will not longer be updated by the physics engine.
  91209. * @param impostor the impostor to remove
  91210. */
  91211. removeImpostor(impostor: PhysicsImpostor): void;
  91212. /**
  91213. * Add a joint to the physics engine
  91214. * @param mainImpostor defines the main impostor to which the joint is added.
  91215. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91216. * @param joint defines the joint that will connect both impostors.
  91217. */
  91218. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91219. /**
  91220. * Removes a joint from the simulation
  91221. * @param mainImpostor defines the impostor used with the joint
  91222. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91223. * @param joint defines the joint to remove
  91224. */
  91225. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91226. /**
  91227. * Gets the current plugin used to run the simulation
  91228. * @returns current plugin
  91229. */
  91230. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91231. /**
  91232. * Gets the list of physic impostors
  91233. * @returns an array of PhysicsImpostor
  91234. */
  91235. getImpostors(): Array<PhysicsImpostor>;
  91236. /**
  91237. * Gets the impostor for a physics enabled object
  91238. * @param object defines the object impersonated by the impostor
  91239. * @returns the PhysicsImpostor or null if not found
  91240. */
  91241. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91242. /**
  91243. * Gets the impostor for a physics body object
  91244. * @param body defines physics body used by the impostor
  91245. * @returns the PhysicsImpostor or null if not found
  91246. */
  91247. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91248. /**
  91249. * Does a raycast in the physics world
  91250. * @param from when should the ray start?
  91251. * @param to when should the ray end?
  91252. * @returns PhysicsRaycastResult
  91253. */
  91254. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91255. /**
  91256. * Called by the scene. No need to call it.
  91257. * @param delta defines the timespam between frames
  91258. */
  91259. _step(delta: number): void;
  91260. }
  91261. }
  91262. declare module BABYLON {
  91263. /**
  91264. * The interface for the physics imposter parameters
  91265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91266. */
  91267. export interface PhysicsImpostorParameters {
  91268. /**
  91269. * The mass of the physics imposter
  91270. */
  91271. mass: number;
  91272. /**
  91273. * The friction of the physics imposter
  91274. */
  91275. friction?: number;
  91276. /**
  91277. * The coefficient of restitution of the physics imposter
  91278. */
  91279. restitution?: number;
  91280. /**
  91281. * The native options of the physics imposter
  91282. */
  91283. nativeOptions?: any;
  91284. /**
  91285. * Specifies if the parent should be ignored
  91286. */
  91287. ignoreParent?: boolean;
  91288. /**
  91289. * Specifies if bi-directional transformations should be disabled
  91290. */
  91291. disableBidirectionalTransformation?: boolean;
  91292. /**
  91293. * The pressure inside the physics imposter, soft object only
  91294. */
  91295. pressure?: number;
  91296. /**
  91297. * The stiffness the physics imposter, soft object only
  91298. */
  91299. stiffness?: number;
  91300. /**
  91301. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91302. */
  91303. velocityIterations?: number;
  91304. /**
  91305. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91306. */
  91307. positionIterations?: number;
  91308. /**
  91309. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91310. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91311. * Add to fix multiple points
  91312. */
  91313. fixedPoints?: number;
  91314. /**
  91315. * The collision margin around a soft object
  91316. */
  91317. margin?: number;
  91318. /**
  91319. * The collision margin around a soft object
  91320. */
  91321. damping?: number;
  91322. /**
  91323. * The path for a rope based on an extrusion
  91324. */
  91325. path?: any;
  91326. /**
  91327. * The shape of an extrusion used for a rope based on an extrusion
  91328. */
  91329. shape?: any;
  91330. }
  91331. /**
  91332. * Interface for a physics-enabled object
  91333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91334. */
  91335. export interface IPhysicsEnabledObject {
  91336. /**
  91337. * The position of the physics-enabled object
  91338. */
  91339. position: Vector3;
  91340. /**
  91341. * The rotation of the physics-enabled object
  91342. */
  91343. rotationQuaternion: Nullable<Quaternion>;
  91344. /**
  91345. * The scale of the physics-enabled object
  91346. */
  91347. scaling: Vector3;
  91348. /**
  91349. * The rotation of the physics-enabled object
  91350. */
  91351. rotation?: Vector3;
  91352. /**
  91353. * The parent of the physics-enabled object
  91354. */
  91355. parent?: any;
  91356. /**
  91357. * The bounding info of the physics-enabled object
  91358. * @returns The bounding info of the physics-enabled object
  91359. */
  91360. getBoundingInfo(): BoundingInfo;
  91361. /**
  91362. * Computes the world matrix
  91363. * @param force Specifies if the world matrix should be computed by force
  91364. * @returns A world matrix
  91365. */
  91366. computeWorldMatrix(force: boolean): Matrix;
  91367. /**
  91368. * Gets the world matrix
  91369. * @returns A world matrix
  91370. */
  91371. getWorldMatrix?(): Matrix;
  91372. /**
  91373. * Gets the child meshes
  91374. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91375. * @returns An array of abstract meshes
  91376. */
  91377. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91378. /**
  91379. * Gets the vertex data
  91380. * @param kind The type of vertex data
  91381. * @returns A nullable array of numbers, or a float32 array
  91382. */
  91383. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91384. /**
  91385. * Gets the indices from the mesh
  91386. * @returns A nullable array of index arrays
  91387. */
  91388. getIndices?(): Nullable<IndicesArray>;
  91389. /**
  91390. * Gets the scene from the mesh
  91391. * @returns the indices array or null
  91392. */
  91393. getScene?(): Scene;
  91394. /**
  91395. * Gets the absolute position from the mesh
  91396. * @returns the absolute position
  91397. */
  91398. getAbsolutePosition(): Vector3;
  91399. /**
  91400. * Gets the absolute pivot point from the mesh
  91401. * @returns the absolute pivot point
  91402. */
  91403. getAbsolutePivotPoint(): Vector3;
  91404. /**
  91405. * Rotates the mesh
  91406. * @param axis The axis of rotation
  91407. * @param amount The amount of rotation
  91408. * @param space The space of the rotation
  91409. * @returns The rotation transform node
  91410. */
  91411. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91412. /**
  91413. * Translates the mesh
  91414. * @param axis The axis of translation
  91415. * @param distance The distance of translation
  91416. * @param space The space of the translation
  91417. * @returns The transform node
  91418. */
  91419. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91420. /**
  91421. * Sets the absolute position of the mesh
  91422. * @param absolutePosition The absolute position of the mesh
  91423. * @returns The transform node
  91424. */
  91425. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91426. /**
  91427. * Gets the class name of the mesh
  91428. * @returns The class name
  91429. */
  91430. getClassName(): string;
  91431. }
  91432. /**
  91433. * Represents a physics imposter
  91434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91435. */
  91436. export class PhysicsImpostor {
  91437. /**
  91438. * The physics-enabled object used as the physics imposter
  91439. */
  91440. object: IPhysicsEnabledObject;
  91441. /**
  91442. * The type of the physics imposter
  91443. */
  91444. type: number;
  91445. private _options;
  91446. private _scene?;
  91447. /**
  91448. * The default object size of the imposter
  91449. */
  91450. static DEFAULT_OBJECT_SIZE: Vector3;
  91451. /**
  91452. * The identity quaternion of the imposter
  91453. */
  91454. static IDENTITY_QUATERNION: Quaternion;
  91455. /** @hidden */
  91456. _pluginData: any;
  91457. private _physicsEngine;
  91458. private _physicsBody;
  91459. private _bodyUpdateRequired;
  91460. private _onBeforePhysicsStepCallbacks;
  91461. private _onAfterPhysicsStepCallbacks;
  91462. /** @hidden */
  91463. _onPhysicsCollideCallbacks: Array<{
  91464. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91465. otherImpostors: Array<PhysicsImpostor>;
  91466. }>;
  91467. private _deltaPosition;
  91468. private _deltaRotation;
  91469. private _deltaRotationConjugated;
  91470. /** @hidden */
  91471. _isFromLine: boolean;
  91472. private _parent;
  91473. private _isDisposed;
  91474. private static _tmpVecs;
  91475. private static _tmpQuat;
  91476. /**
  91477. * Specifies if the physics imposter is disposed
  91478. */
  91479. readonly isDisposed: boolean;
  91480. /**
  91481. * Gets the mass of the physics imposter
  91482. */
  91483. mass: number;
  91484. /**
  91485. * Gets the coefficient of friction
  91486. */
  91487. /**
  91488. * Sets the coefficient of friction
  91489. */
  91490. friction: number;
  91491. /**
  91492. * Gets the coefficient of restitution
  91493. */
  91494. /**
  91495. * Sets the coefficient of restitution
  91496. */
  91497. restitution: number;
  91498. /**
  91499. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91500. */
  91501. /**
  91502. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91503. */
  91504. pressure: number;
  91505. /**
  91506. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91507. */
  91508. /**
  91509. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91510. */
  91511. stiffness: number;
  91512. /**
  91513. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91514. */
  91515. /**
  91516. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91517. */
  91518. velocityIterations: number;
  91519. /**
  91520. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91521. */
  91522. /**
  91523. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91524. */
  91525. positionIterations: number;
  91526. /**
  91527. * The unique id of the physics imposter
  91528. * set by the physics engine when adding this impostor to the array
  91529. */
  91530. uniqueId: number;
  91531. /**
  91532. * @hidden
  91533. */
  91534. soft: boolean;
  91535. /**
  91536. * @hidden
  91537. */
  91538. segments: number;
  91539. private _joints;
  91540. /**
  91541. * Initializes the physics imposter
  91542. * @param object The physics-enabled object used as the physics imposter
  91543. * @param type The type of the physics imposter
  91544. * @param _options The options for the physics imposter
  91545. * @param _scene The Babylon scene
  91546. */
  91547. constructor(
  91548. /**
  91549. * The physics-enabled object used as the physics imposter
  91550. */
  91551. object: IPhysicsEnabledObject,
  91552. /**
  91553. * The type of the physics imposter
  91554. */
  91555. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91556. /**
  91557. * This function will completly initialize this impostor.
  91558. * It will create a new body - but only if this mesh has no parent.
  91559. * If it has, this impostor will not be used other than to define the impostor
  91560. * of the child mesh.
  91561. * @hidden
  91562. */
  91563. _init(): void;
  91564. private _getPhysicsParent;
  91565. /**
  91566. * Should a new body be generated.
  91567. * @returns boolean specifying if body initialization is required
  91568. */
  91569. isBodyInitRequired(): boolean;
  91570. /**
  91571. * Sets the updated scaling
  91572. * @param updated Specifies if the scaling is updated
  91573. */
  91574. setScalingUpdated(): void;
  91575. /**
  91576. * Force a regeneration of this or the parent's impostor's body.
  91577. * Use under cautious - This will remove all joints already implemented.
  91578. */
  91579. forceUpdate(): void;
  91580. /**
  91581. * Gets the body that holds this impostor. Either its own, or its parent.
  91582. */
  91583. /**
  91584. * Set the physics body. Used mainly by the physics engine/plugin
  91585. */
  91586. physicsBody: any;
  91587. /**
  91588. * Get the parent of the physics imposter
  91589. * @returns Physics imposter or null
  91590. */
  91591. /**
  91592. * Sets the parent of the physics imposter
  91593. */
  91594. parent: Nullable<PhysicsImpostor>;
  91595. /**
  91596. * Resets the update flags
  91597. */
  91598. resetUpdateFlags(): void;
  91599. /**
  91600. * Gets the object extend size
  91601. * @returns the object extend size
  91602. */
  91603. getObjectExtendSize(): Vector3;
  91604. /**
  91605. * Gets the object center
  91606. * @returns The object center
  91607. */
  91608. getObjectCenter(): Vector3;
  91609. /**
  91610. * Get a specific parametes from the options parameter
  91611. * @param paramName The object parameter name
  91612. * @returns The object parameter
  91613. */
  91614. getParam(paramName: string): any;
  91615. /**
  91616. * Sets a specific parameter in the options given to the physics plugin
  91617. * @param paramName The parameter name
  91618. * @param value The value of the parameter
  91619. */
  91620. setParam(paramName: string, value: number): void;
  91621. /**
  91622. * Specifically change the body's mass option. Won't recreate the physics body object
  91623. * @param mass The mass of the physics imposter
  91624. */
  91625. setMass(mass: number): void;
  91626. /**
  91627. * Gets the linear velocity
  91628. * @returns linear velocity or null
  91629. */
  91630. getLinearVelocity(): Nullable<Vector3>;
  91631. /**
  91632. * Sets the linear velocity
  91633. * @param velocity linear velocity or null
  91634. */
  91635. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91636. /**
  91637. * Gets the angular velocity
  91638. * @returns angular velocity or null
  91639. */
  91640. getAngularVelocity(): Nullable<Vector3>;
  91641. /**
  91642. * Sets the angular velocity
  91643. * @param velocity The velocity or null
  91644. */
  91645. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91646. /**
  91647. * Execute a function with the physics plugin native code
  91648. * Provide a function the will have two variables - the world object and the physics body object
  91649. * @param func The function to execute with the physics plugin native code
  91650. */
  91651. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91652. /**
  91653. * Register a function that will be executed before the physics world is stepping forward
  91654. * @param func The function to execute before the physics world is stepped forward
  91655. */
  91656. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91657. /**
  91658. * Unregister a function that will be executed before the physics world is stepping forward
  91659. * @param func The function to execute before the physics world is stepped forward
  91660. */
  91661. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91662. /**
  91663. * Register a function that will be executed after the physics step
  91664. * @param func The function to execute after physics step
  91665. */
  91666. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91667. /**
  91668. * Unregisters a function that will be executed after the physics step
  91669. * @param func The function to execute after physics step
  91670. */
  91671. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91672. /**
  91673. * register a function that will be executed when this impostor collides against a different body
  91674. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91675. * @param func Callback that is executed on collision
  91676. */
  91677. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91678. /**
  91679. * Unregisters the physics imposter on contact
  91680. * @param collideAgainst The physics object to collide against
  91681. * @param func Callback to execute on collision
  91682. */
  91683. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91684. private _tmpQuat;
  91685. private _tmpQuat2;
  91686. /**
  91687. * Get the parent rotation
  91688. * @returns The parent rotation
  91689. */
  91690. getParentsRotation(): Quaternion;
  91691. /**
  91692. * this function is executed by the physics engine.
  91693. */
  91694. beforeStep: () => void;
  91695. /**
  91696. * this function is executed by the physics engine
  91697. */
  91698. afterStep: () => void;
  91699. /**
  91700. * Legacy collision detection event support
  91701. */
  91702. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91703. /**
  91704. * event and body object due to cannon's event-based architecture.
  91705. */
  91706. onCollide: (e: {
  91707. body: any;
  91708. }) => void;
  91709. /**
  91710. * Apply a force
  91711. * @param force The force to apply
  91712. * @param contactPoint The contact point for the force
  91713. * @returns The physics imposter
  91714. */
  91715. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91716. /**
  91717. * Apply an impulse
  91718. * @param force The impulse force
  91719. * @param contactPoint The contact point for the impulse force
  91720. * @returns The physics imposter
  91721. */
  91722. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91723. /**
  91724. * A help function to create a joint
  91725. * @param otherImpostor A physics imposter used to create a joint
  91726. * @param jointType The type of joint
  91727. * @param jointData The data for the joint
  91728. * @returns The physics imposter
  91729. */
  91730. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91731. /**
  91732. * Add a joint to this impostor with a different impostor
  91733. * @param otherImpostor A physics imposter used to add a joint
  91734. * @param joint The joint to add
  91735. * @returns The physics imposter
  91736. */
  91737. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91738. /**
  91739. * Add an anchor to a cloth impostor
  91740. * @param otherImpostor rigid impostor to anchor to
  91741. * @param width ratio across width from 0 to 1
  91742. * @param height ratio up height from 0 to 1
  91743. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91744. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91745. * @returns impostor the soft imposter
  91746. */
  91747. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91748. /**
  91749. * Add a hook to a rope impostor
  91750. * @param otherImpostor rigid impostor to anchor to
  91751. * @param length ratio across rope from 0 to 1
  91752. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91754. * @returns impostor the rope imposter
  91755. */
  91756. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91757. /**
  91758. * Will keep this body still, in a sleep mode.
  91759. * @returns the physics imposter
  91760. */
  91761. sleep(): PhysicsImpostor;
  91762. /**
  91763. * Wake the body up.
  91764. * @returns The physics imposter
  91765. */
  91766. wakeUp(): PhysicsImpostor;
  91767. /**
  91768. * Clones the physics imposter
  91769. * @param newObject The physics imposter clones to this physics-enabled object
  91770. * @returns A nullable physics imposter
  91771. */
  91772. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91773. /**
  91774. * Disposes the physics imposter
  91775. */
  91776. dispose(): void;
  91777. /**
  91778. * Sets the delta position
  91779. * @param position The delta position amount
  91780. */
  91781. setDeltaPosition(position: Vector3): void;
  91782. /**
  91783. * Sets the delta rotation
  91784. * @param rotation The delta rotation amount
  91785. */
  91786. setDeltaRotation(rotation: Quaternion): void;
  91787. /**
  91788. * Gets the box size of the physics imposter and stores the result in the input parameter
  91789. * @param result Stores the box size
  91790. * @returns The physics imposter
  91791. */
  91792. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91793. /**
  91794. * Gets the radius of the physics imposter
  91795. * @returns Radius of the physics imposter
  91796. */
  91797. getRadius(): number;
  91798. /**
  91799. * Sync a bone with this impostor
  91800. * @param bone The bone to sync to the impostor.
  91801. * @param boneMesh The mesh that the bone is influencing.
  91802. * @param jointPivot The pivot of the joint / bone in local space.
  91803. * @param distToJoint Optional distance from the impostor to the joint.
  91804. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91805. */
  91806. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91807. /**
  91808. * Sync impostor to a bone
  91809. * @param bone The bone that the impostor will be synced to.
  91810. * @param boneMesh The mesh that the bone is influencing.
  91811. * @param jointPivot The pivot of the joint / bone in local space.
  91812. * @param distToJoint Optional distance from the impostor to the joint.
  91813. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91814. * @param boneAxis Optional vector3 axis the bone is aligned with
  91815. */
  91816. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91817. /**
  91818. * No-Imposter type
  91819. */
  91820. static NoImpostor: number;
  91821. /**
  91822. * Sphere-Imposter type
  91823. */
  91824. static SphereImpostor: number;
  91825. /**
  91826. * Box-Imposter type
  91827. */
  91828. static BoxImpostor: number;
  91829. /**
  91830. * Plane-Imposter type
  91831. */
  91832. static PlaneImpostor: number;
  91833. /**
  91834. * Mesh-imposter type
  91835. */
  91836. static MeshImpostor: number;
  91837. /**
  91838. * Capsule-Impostor type (Ammo.js plugin only)
  91839. */
  91840. static CapsuleImpostor: number;
  91841. /**
  91842. * Cylinder-Imposter type
  91843. */
  91844. static CylinderImpostor: number;
  91845. /**
  91846. * Particle-Imposter type
  91847. */
  91848. static ParticleImpostor: number;
  91849. /**
  91850. * Heightmap-Imposter type
  91851. */
  91852. static HeightmapImpostor: number;
  91853. /**
  91854. * ConvexHull-Impostor type (Ammo.js plugin only)
  91855. */
  91856. static ConvexHullImpostor: number;
  91857. /**
  91858. * Rope-Imposter type
  91859. */
  91860. static RopeImpostor: number;
  91861. /**
  91862. * Cloth-Imposter type
  91863. */
  91864. static ClothImpostor: number;
  91865. /**
  91866. * Softbody-Imposter type
  91867. */
  91868. static SoftbodyImpostor: number;
  91869. }
  91870. }
  91871. declare module BABYLON {
  91872. /**
  91873. * @hidden
  91874. **/
  91875. export class _CreationDataStorage {
  91876. closePath?: boolean;
  91877. closeArray?: boolean;
  91878. idx: number[];
  91879. dashSize: number;
  91880. gapSize: number;
  91881. path3D: Path3D;
  91882. pathArray: Vector3[][];
  91883. arc: number;
  91884. radius: number;
  91885. cap: number;
  91886. tessellation: number;
  91887. }
  91888. /**
  91889. * @hidden
  91890. **/
  91891. class _InstanceDataStorage {
  91892. visibleInstances: any;
  91893. batchCache: _InstancesBatch;
  91894. instancesBufferSize: number;
  91895. instancesBuffer: Nullable<Buffer>;
  91896. instancesData: Float32Array;
  91897. overridenInstanceCount: number;
  91898. isFrozen: boolean;
  91899. previousBatch: Nullable<_InstancesBatch>;
  91900. hardwareInstancedRendering: boolean;
  91901. sideOrientation: number;
  91902. manualUpdate: boolean;
  91903. }
  91904. /**
  91905. * @hidden
  91906. **/
  91907. export class _InstancesBatch {
  91908. mustReturn: boolean;
  91909. visibleInstances: Nullable<InstancedMesh[]>[];
  91910. renderSelf: boolean[];
  91911. hardwareInstancedRendering: boolean[];
  91912. }
  91913. /**
  91914. * Class used to represent renderable models
  91915. */
  91916. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91917. /**
  91918. * Mesh side orientation : usually the external or front surface
  91919. */
  91920. static readonly FRONTSIDE: number;
  91921. /**
  91922. * Mesh side orientation : usually the internal or back surface
  91923. */
  91924. static readonly BACKSIDE: number;
  91925. /**
  91926. * Mesh side orientation : both internal and external or front and back surfaces
  91927. */
  91928. static readonly DOUBLESIDE: number;
  91929. /**
  91930. * Mesh side orientation : by default, `FRONTSIDE`
  91931. */
  91932. static readonly DEFAULTSIDE: number;
  91933. /**
  91934. * Mesh cap setting : no cap
  91935. */
  91936. static readonly NO_CAP: number;
  91937. /**
  91938. * Mesh cap setting : one cap at the beginning of the mesh
  91939. */
  91940. static readonly CAP_START: number;
  91941. /**
  91942. * Mesh cap setting : one cap at the end of the mesh
  91943. */
  91944. static readonly CAP_END: number;
  91945. /**
  91946. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91947. */
  91948. static readonly CAP_ALL: number;
  91949. /**
  91950. * Mesh pattern setting : no flip or rotate
  91951. */
  91952. static readonly NO_FLIP: number;
  91953. /**
  91954. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91955. */
  91956. static readonly FLIP_TILE: number;
  91957. /**
  91958. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91959. */
  91960. static readonly ROTATE_TILE: number;
  91961. /**
  91962. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91963. */
  91964. static readonly FLIP_ROW: number;
  91965. /**
  91966. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91967. */
  91968. static readonly ROTATE_ROW: number;
  91969. /**
  91970. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91971. */
  91972. static readonly FLIP_N_ROTATE_TILE: number;
  91973. /**
  91974. * Mesh pattern setting : rotate pattern and rotate
  91975. */
  91976. static readonly FLIP_N_ROTATE_ROW: number;
  91977. /**
  91978. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91979. */
  91980. static readonly CENTER: number;
  91981. /**
  91982. * Mesh tile positioning : part tiles on left
  91983. */
  91984. static readonly LEFT: number;
  91985. /**
  91986. * Mesh tile positioning : part tiles on right
  91987. */
  91988. static readonly RIGHT: number;
  91989. /**
  91990. * Mesh tile positioning : part tiles on top
  91991. */
  91992. static readonly TOP: number;
  91993. /**
  91994. * Mesh tile positioning : part tiles on bottom
  91995. */
  91996. static readonly BOTTOM: number;
  91997. /**
  91998. * Gets the default side orientation.
  91999. * @param orientation the orientation to value to attempt to get
  92000. * @returns the default orientation
  92001. * @hidden
  92002. */
  92003. static _GetDefaultSideOrientation(orientation?: number): number;
  92004. private _internalMeshDataInfo;
  92005. /**
  92006. * An event triggered before rendering the mesh
  92007. */
  92008. readonly onBeforeRenderObservable: Observable<Mesh>;
  92009. /**
  92010. * An event triggered before binding the mesh
  92011. */
  92012. readonly onBeforeBindObservable: Observable<Mesh>;
  92013. /**
  92014. * An event triggered after rendering the mesh
  92015. */
  92016. readonly onAfterRenderObservable: Observable<Mesh>;
  92017. /**
  92018. * An event triggered before drawing the mesh
  92019. */
  92020. readonly onBeforeDrawObservable: Observable<Mesh>;
  92021. private _onBeforeDrawObserver;
  92022. /**
  92023. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92024. */
  92025. onBeforeDraw: () => void;
  92026. readonly hasInstances: boolean;
  92027. /**
  92028. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92029. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92030. */
  92031. delayLoadState: number;
  92032. /**
  92033. * Gets the list of instances created from this mesh
  92034. * it is not supposed to be modified manually.
  92035. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92036. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92037. */
  92038. instances: InstancedMesh[];
  92039. /**
  92040. * Gets the file containing delay loading data for this mesh
  92041. */
  92042. delayLoadingFile: string;
  92043. /** @hidden */
  92044. _binaryInfo: any;
  92045. /**
  92046. * User defined function used to change how LOD level selection is done
  92047. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92048. */
  92049. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92050. /**
  92051. * Gets or sets the morph target manager
  92052. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92053. */
  92054. morphTargetManager: Nullable<MorphTargetManager>;
  92055. /** @hidden */
  92056. _creationDataStorage: Nullable<_CreationDataStorage>;
  92057. /** @hidden */
  92058. _geometry: Nullable<Geometry>;
  92059. /** @hidden */
  92060. _delayInfo: Array<string>;
  92061. /** @hidden */
  92062. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92063. /** @hidden */
  92064. _instanceDataStorage: _InstanceDataStorage;
  92065. private _effectiveMaterial;
  92066. /** @hidden */
  92067. _shouldGenerateFlatShading: boolean;
  92068. /** @hidden */
  92069. _originalBuilderSideOrientation: number;
  92070. /**
  92071. * Use this property to change the original side orientation defined at construction time
  92072. */
  92073. overrideMaterialSideOrientation: Nullable<number>;
  92074. /**
  92075. * Gets the source mesh (the one used to clone this one from)
  92076. */
  92077. readonly source: Nullable<Mesh>;
  92078. /**
  92079. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92080. */
  92081. isUnIndexed: boolean;
  92082. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92083. readonly worldMatrixInstancedBuffer: Float32Array;
  92084. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92085. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92086. /**
  92087. * @constructor
  92088. * @param name The value used by scene.getMeshByName() to do a lookup.
  92089. * @param scene The scene to add this mesh to.
  92090. * @param parent The parent of this mesh, if it has one
  92091. * @param source An optional Mesh from which geometry is shared, cloned.
  92092. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92093. * When false, achieved by calling a clone(), also passing False.
  92094. * This will make creation of children, recursive.
  92095. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92096. */
  92097. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92098. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92099. doNotInstantiate: boolean;
  92100. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92101. /**
  92102. * Gets the class name
  92103. * @returns the string "Mesh".
  92104. */
  92105. getClassName(): string;
  92106. /** @hidden */
  92107. readonly _isMesh: boolean;
  92108. /**
  92109. * Returns a description of this mesh
  92110. * @param fullDetails define if full details about this mesh must be used
  92111. * @returns a descriptive string representing this mesh
  92112. */
  92113. toString(fullDetails?: boolean): string;
  92114. /** @hidden */
  92115. _unBindEffect(): void;
  92116. /**
  92117. * Gets a boolean indicating if this mesh has LOD
  92118. */
  92119. readonly hasLODLevels: boolean;
  92120. /**
  92121. * Gets the list of MeshLODLevel associated with the current mesh
  92122. * @returns an array of MeshLODLevel
  92123. */
  92124. getLODLevels(): MeshLODLevel[];
  92125. private _sortLODLevels;
  92126. /**
  92127. * Add a mesh as LOD level triggered at the given distance.
  92128. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92129. * @param distance The distance from the center of the object to show this level
  92130. * @param mesh The mesh to be added as LOD level (can be null)
  92131. * @return This mesh (for chaining)
  92132. */
  92133. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92134. /**
  92135. * Returns the LOD level mesh at the passed distance or null if not found.
  92136. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92137. * @param distance The distance from the center of the object to show this level
  92138. * @returns a Mesh or `null`
  92139. */
  92140. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92141. /**
  92142. * Remove a mesh from the LOD array
  92143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92144. * @param mesh defines the mesh to be removed
  92145. * @return This mesh (for chaining)
  92146. */
  92147. removeLODLevel(mesh: Mesh): Mesh;
  92148. /**
  92149. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92150. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92151. * @param camera defines the camera to use to compute distance
  92152. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92153. * @return This mesh (for chaining)
  92154. */
  92155. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92156. /**
  92157. * Gets the mesh internal Geometry object
  92158. */
  92159. readonly geometry: Nullable<Geometry>;
  92160. /**
  92161. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92162. * @returns the total number of vertices
  92163. */
  92164. getTotalVertices(): number;
  92165. /**
  92166. * Returns the content of an associated vertex buffer
  92167. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92168. * - VertexBuffer.PositionKind
  92169. * - VertexBuffer.UVKind
  92170. * - VertexBuffer.UV2Kind
  92171. * - VertexBuffer.UV3Kind
  92172. * - VertexBuffer.UV4Kind
  92173. * - VertexBuffer.UV5Kind
  92174. * - VertexBuffer.UV6Kind
  92175. * - VertexBuffer.ColorKind
  92176. * - VertexBuffer.MatricesIndicesKind
  92177. * - VertexBuffer.MatricesIndicesExtraKind
  92178. * - VertexBuffer.MatricesWeightsKind
  92179. * - VertexBuffer.MatricesWeightsExtraKind
  92180. * @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
  92181. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92182. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92183. */
  92184. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92185. /**
  92186. * Returns the mesh VertexBuffer object from the requested `kind`
  92187. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92188. * - VertexBuffer.PositionKind
  92189. * - VertexBuffer.NormalKind
  92190. * - VertexBuffer.UVKind
  92191. * - VertexBuffer.UV2Kind
  92192. * - VertexBuffer.UV3Kind
  92193. * - VertexBuffer.UV4Kind
  92194. * - VertexBuffer.UV5Kind
  92195. * - VertexBuffer.UV6Kind
  92196. * - VertexBuffer.ColorKind
  92197. * - VertexBuffer.MatricesIndicesKind
  92198. * - VertexBuffer.MatricesIndicesExtraKind
  92199. * - VertexBuffer.MatricesWeightsKind
  92200. * - VertexBuffer.MatricesWeightsExtraKind
  92201. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92202. */
  92203. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92204. /**
  92205. * Tests if a specific vertex buffer is associated with this mesh
  92206. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92207. * - VertexBuffer.PositionKind
  92208. * - VertexBuffer.NormalKind
  92209. * - VertexBuffer.UVKind
  92210. * - VertexBuffer.UV2Kind
  92211. * - VertexBuffer.UV3Kind
  92212. * - VertexBuffer.UV4Kind
  92213. * - VertexBuffer.UV5Kind
  92214. * - VertexBuffer.UV6Kind
  92215. * - VertexBuffer.ColorKind
  92216. * - VertexBuffer.MatricesIndicesKind
  92217. * - VertexBuffer.MatricesIndicesExtraKind
  92218. * - VertexBuffer.MatricesWeightsKind
  92219. * - VertexBuffer.MatricesWeightsExtraKind
  92220. * @returns a boolean
  92221. */
  92222. isVerticesDataPresent(kind: string): boolean;
  92223. /**
  92224. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92225. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92226. * - VertexBuffer.PositionKind
  92227. * - VertexBuffer.UVKind
  92228. * - VertexBuffer.UV2Kind
  92229. * - VertexBuffer.UV3Kind
  92230. * - VertexBuffer.UV4Kind
  92231. * - VertexBuffer.UV5Kind
  92232. * - VertexBuffer.UV6Kind
  92233. * - VertexBuffer.ColorKind
  92234. * - VertexBuffer.MatricesIndicesKind
  92235. * - VertexBuffer.MatricesIndicesExtraKind
  92236. * - VertexBuffer.MatricesWeightsKind
  92237. * - VertexBuffer.MatricesWeightsExtraKind
  92238. * @returns a boolean
  92239. */
  92240. isVertexBufferUpdatable(kind: string): boolean;
  92241. /**
  92242. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92243. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92244. * - VertexBuffer.PositionKind
  92245. * - VertexBuffer.NormalKind
  92246. * - VertexBuffer.UVKind
  92247. * - VertexBuffer.UV2Kind
  92248. * - VertexBuffer.UV3Kind
  92249. * - VertexBuffer.UV4Kind
  92250. * - VertexBuffer.UV5Kind
  92251. * - VertexBuffer.UV6Kind
  92252. * - VertexBuffer.ColorKind
  92253. * - VertexBuffer.MatricesIndicesKind
  92254. * - VertexBuffer.MatricesIndicesExtraKind
  92255. * - VertexBuffer.MatricesWeightsKind
  92256. * - VertexBuffer.MatricesWeightsExtraKind
  92257. * @returns an array of strings
  92258. */
  92259. getVerticesDataKinds(): string[];
  92260. /**
  92261. * Returns a positive integer : the total number of indices in this mesh geometry.
  92262. * @returns the numner of indices or zero if the mesh has no geometry.
  92263. */
  92264. getTotalIndices(): number;
  92265. /**
  92266. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92267. * @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.
  92268. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92269. * @returns the indices array or an empty array if the mesh has no geometry
  92270. */
  92271. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92272. readonly isBlocked: boolean;
  92273. /**
  92274. * Determine if the current mesh is ready to be rendered
  92275. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92276. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92277. * @returns true if all associated assets are ready (material, textures, shaders)
  92278. */
  92279. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92280. /**
  92281. * 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.
  92282. */
  92283. readonly areNormalsFrozen: boolean;
  92284. /**
  92285. * 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.
  92286. * @returns the current mesh
  92287. */
  92288. freezeNormals(): Mesh;
  92289. /**
  92290. * 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
  92291. * @returns the current mesh
  92292. */
  92293. unfreezeNormals(): Mesh;
  92294. /**
  92295. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92296. */
  92297. overridenInstanceCount: number;
  92298. /** @hidden */
  92299. _preActivate(): Mesh;
  92300. /** @hidden */
  92301. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92302. /** @hidden */
  92303. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92304. /**
  92305. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92306. * This means the mesh underlying bounding box and sphere are recomputed.
  92307. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92308. * @returns the current mesh
  92309. */
  92310. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92311. /** @hidden */
  92312. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92313. /**
  92314. * This function will subdivide the mesh into multiple submeshes
  92315. * @param count defines the expected number of submeshes
  92316. */
  92317. subdivide(count: number): void;
  92318. /**
  92319. * Copy a FloatArray into a specific associated vertex buffer
  92320. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92321. * - VertexBuffer.PositionKind
  92322. * - VertexBuffer.UVKind
  92323. * - VertexBuffer.UV2Kind
  92324. * - VertexBuffer.UV3Kind
  92325. * - VertexBuffer.UV4Kind
  92326. * - VertexBuffer.UV5Kind
  92327. * - VertexBuffer.UV6Kind
  92328. * - VertexBuffer.ColorKind
  92329. * - VertexBuffer.MatricesIndicesKind
  92330. * - VertexBuffer.MatricesIndicesExtraKind
  92331. * - VertexBuffer.MatricesWeightsKind
  92332. * - VertexBuffer.MatricesWeightsExtraKind
  92333. * @param data defines the data source
  92334. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92335. * @param stride defines the data stride size (can be null)
  92336. * @returns the current mesh
  92337. */
  92338. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92339. /**
  92340. * Delete a vertex buffer associated with this mesh
  92341. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92342. * - VertexBuffer.PositionKind
  92343. * - VertexBuffer.UVKind
  92344. * - VertexBuffer.UV2Kind
  92345. * - VertexBuffer.UV3Kind
  92346. * - VertexBuffer.UV4Kind
  92347. * - VertexBuffer.UV5Kind
  92348. * - VertexBuffer.UV6Kind
  92349. * - VertexBuffer.ColorKind
  92350. * - VertexBuffer.MatricesIndicesKind
  92351. * - VertexBuffer.MatricesIndicesExtraKind
  92352. * - VertexBuffer.MatricesWeightsKind
  92353. * - VertexBuffer.MatricesWeightsExtraKind
  92354. */
  92355. removeVerticesData(kind: string): void;
  92356. /**
  92357. * Flags an associated vertex buffer as updatable
  92358. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92359. * - VertexBuffer.PositionKind
  92360. * - VertexBuffer.UVKind
  92361. * - VertexBuffer.UV2Kind
  92362. * - VertexBuffer.UV3Kind
  92363. * - VertexBuffer.UV4Kind
  92364. * - VertexBuffer.UV5Kind
  92365. * - VertexBuffer.UV6Kind
  92366. * - VertexBuffer.ColorKind
  92367. * - VertexBuffer.MatricesIndicesKind
  92368. * - VertexBuffer.MatricesIndicesExtraKind
  92369. * - VertexBuffer.MatricesWeightsKind
  92370. * - VertexBuffer.MatricesWeightsExtraKind
  92371. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92372. */
  92373. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92374. /**
  92375. * Sets the mesh global Vertex Buffer
  92376. * @param buffer defines the buffer to use
  92377. * @returns the current mesh
  92378. */
  92379. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92380. /**
  92381. * Update a specific associated vertex buffer
  92382. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92383. * - VertexBuffer.PositionKind
  92384. * - VertexBuffer.UVKind
  92385. * - VertexBuffer.UV2Kind
  92386. * - VertexBuffer.UV3Kind
  92387. * - VertexBuffer.UV4Kind
  92388. * - VertexBuffer.UV5Kind
  92389. * - VertexBuffer.UV6Kind
  92390. * - VertexBuffer.ColorKind
  92391. * - VertexBuffer.MatricesIndicesKind
  92392. * - VertexBuffer.MatricesIndicesExtraKind
  92393. * - VertexBuffer.MatricesWeightsKind
  92394. * - VertexBuffer.MatricesWeightsExtraKind
  92395. * @param data defines the data source
  92396. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92397. * @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)
  92398. * @returns the current mesh
  92399. */
  92400. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92401. /**
  92402. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92403. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92404. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92405. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92406. * @returns the current mesh
  92407. */
  92408. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92409. /**
  92410. * Creates a un-shared specific occurence of the geometry for the mesh.
  92411. * @returns the current mesh
  92412. */
  92413. makeGeometryUnique(): Mesh;
  92414. /**
  92415. * Set the index buffer of this mesh
  92416. * @param indices defines the source data
  92417. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92418. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92419. * @returns the current mesh
  92420. */
  92421. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92422. /**
  92423. * Update the current index buffer
  92424. * @param indices defines the source data
  92425. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92426. * @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)
  92427. * @returns the current mesh
  92428. */
  92429. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92430. /**
  92431. * Invert the geometry to move from a right handed system to a left handed one.
  92432. * @returns the current mesh
  92433. */
  92434. toLeftHanded(): Mesh;
  92435. /** @hidden */
  92436. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92437. /** @hidden */
  92438. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92439. /**
  92440. * Registers for this mesh a javascript function called just before the rendering process
  92441. * @param func defines the function to call before rendering this mesh
  92442. * @returns the current mesh
  92443. */
  92444. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92445. /**
  92446. * Disposes a previously registered javascript function called before the rendering
  92447. * @param func defines the function to remove
  92448. * @returns the current mesh
  92449. */
  92450. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92451. /**
  92452. * Registers for this mesh a javascript function called just after the rendering is complete
  92453. * @param func defines the function to call after rendering this mesh
  92454. * @returns the current mesh
  92455. */
  92456. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92457. /**
  92458. * Disposes a previously registered javascript function called after the rendering.
  92459. * @param func defines the function to remove
  92460. * @returns the current mesh
  92461. */
  92462. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92463. /** @hidden */
  92464. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  92465. /** @hidden */
  92466. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92467. /** @hidden */
  92468. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92469. /** @hidden */
  92470. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92471. /** @hidden */
  92472. _rebuild(): void;
  92473. /** @hidden */
  92474. _freeze(): void;
  92475. /** @hidden */
  92476. _unFreeze(): void;
  92477. /**
  92478. * 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
  92479. * @param subMesh defines the subMesh to render
  92480. * @param enableAlphaMode defines if alpha mode can be changed
  92481. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92482. * @returns the current mesh
  92483. */
  92484. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92485. private _onBeforeDraw;
  92486. /**
  92487. * Renormalize the mesh and patch it up if there are no weights
  92488. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92489. * However in the case of zero weights then we set just a single influence to 1.
  92490. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92491. */
  92492. cleanMatrixWeights(): void;
  92493. private normalizeSkinFourWeights;
  92494. private normalizeSkinWeightsAndExtra;
  92495. /**
  92496. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92497. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92498. * the user know there was an issue with importing the mesh
  92499. * @returns a validation object with skinned, valid and report string
  92500. */
  92501. validateSkinning(): {
  92502. skinned: boolean;
  92503. valid: boolean;
  92504. report: string;
  92505. };
  92506. /** @hidden */
  92507. _checkDelayState(): Mesh;
  92508. private _queueLoad;
  92509. /**
  92510. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92511. * A mesh is in the frustum if its bounding box intersects the frustum
  92512. * @param frustumPlanes defines the frustum to test
  92513. * @returns true if the mesh is in the frustum planes
  92514. */
  92515. isInFrustum(frustumPlanes: Plane[]): boolean;
  92516. /**
  92517. * Sets the mesh material by the material or multiMaterial `id` property
  92518. * @param id is a string identifying the material or the multiMaterial
  92519. * @returns the current mesh
  92520. */
  92521. setMaterialByID(id: string): Mesh;
  92522. /**
  92523. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92524. * @returns an array of IAnimatable
  92525. */
  92526. getAnimatables(): IAnimatable[];
  92527. /**
  92528. * Modifies the mesh geometry according to the passed transformation matrix.
  92529. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92530. * The mesh normals are modified using the same transformation.
  92531. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92532. * @param transform defines the transform matrix to use
  92533. * @see http://doc.babylonjs.com/resources/baking_transformations
  92534. * @returns the current mesh
  92535. */
  92536. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92537. /**
  92538. * Modifies the mesh geometry according to its own current World Matrix.
  92539. * The mesh World Matrix is then reset.
  92540. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92541. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92542. * @see http://doc.babylonjs.com/resources/baking_transformations
  92543. * @returns the current mesh
  92544. */
  92545. bakeCurrentTransformIntoVertices(): Mesh;
  92546. /** @hidden */
  92547. readonly _positions: Nullable<Vector3[]>;
  92548. /** @hidden */
  92549. _resetPointsArrayCache(): Mesh;
  92550. /** @hidden */
  92551. _generatePointsArray(): boolean;
  92552. /**
  92553. * Returns a new Mesh object generated from the current mesh properties.
  92554. * This method must not get confused with createInstance()
  92555. * @param name is a string, the name given to the new mesh
  92556. * @param newParent can be any Node object (default `null`)
  92557. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92558. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92559. * @returns a new mesh
  92560. */
  92561. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92562. /**
  92563. * Releases resources associated with this mesh.
  92564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92566. */
  92567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92568. /** @hidden */
  92569. _disposeInstanceSpecificData(): void;
  92570. /**
  92571. * Modifies the mesh geometry according to a displacement map.
  92572. * 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.
  92573. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92574. * @param url is a string, the URL from the image file is to be downloaded.
  92575. * @param minHeight is the lower limit of the displacement.
  92576. * @param maxHeight is the upper limit of the displacement.
  92577. * @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.
  92578. * @param uvOffset is an optional vector2 used to offset UV.
  92579. * @param uvScale is an optional vector2 used to scale UV.
  92580. * @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.
  92581. * @returns the Mesh.
  92582. */
  92583. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92584. /**
  92585. * Modifies the mesh geometry according to a displacementMap buffer.
  92586. * 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.
  92587. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92588. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92589. * @param heightMapWidth is the width of the buffer image.
  92590. * @param heightMapHeight is the height of the buffer image.
  92591. * @param minHeight is the lower limit of the displacement.
  92592. * @param maxHeight is the upper limit of the displacement.
  92593. * @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.
  92594. * @param uvOffset is an optional vector2 used to offset UV.
  92595. * @param uvScale is an optional vector2 used to scale UV.
  92596. * @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.
  92597. * @returns the Mesh.
  92598. */
  92599. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92600. /**
  92601. * Modify the mesh to get a flat shading rendering.
  92602. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92603. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92604. * @returns current mesh
  92605. */
  92606. convertToFlatShadedMesh(): Mesh;
  92607. /**
  92608. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92609. * In other words, more vertices, no more indices and a single bigger VBO.
  92610. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92611. * @returns current mesh
  92612. */
  92613. convertToUnIndexedMesh(): Mesh;
  92614. /**
  92615. * Inverses facet orientations.
  92616. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92617. * @param flipNormals will also inverts the normals
  92618. * @returns current mesh
  92619. */
  92620. flipFaces(flipNormals?: boolean): Mesh;
  92621. /**
  92622. * Increase the number of facets and hence vertices in a mesh
  92623. * Vertex normals are interpolated from existing vertex normals
  92624. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92625. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92626. */
  92627. increaseVertices(numberPerEdge: number): void;
  92628. /**
  92629. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92630. * This will undo any application of covertToFlatShadedMesh
  92631. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92632. */
  92633. forceSharedVertices(): void;
  92634. /** @hidden */
  92635. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92636. /** @hidden */
  92637. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92638. /**
  92639. * Creates a new InstancedMesh object from the mesh model.
  92640. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92641. * @param name defines the name of the new instance
  92642. * @returns a new InstancedMesh
  92643. */
  92644. createInstance(name: string): InstancedMesh;
  92645. /**
  92646. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92647. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92648. * @returns the current mesh
  92649. */
  92650. synchronizeInstances(): Mesh;
  92651. /**
  92652. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92653. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92654. * This should be used together with the simplification to avoid disappearing triangles.
  92655. * @param successCallback an optional success callback to be called after the optimization finished.
  92656. * @returns the current mesh
  92657. */
  92658. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92659. /**
  92660. * Serialize current mesh
  92661. * @param serializationObject defines the object which will receive the serialization data
  92662. */
  92663. serialize(serializationObject: any): void;
  92664. /** @hidden */
  92665. _syncGeometryWithMorphTargetManager(): void;
  92666. /** @hidden */
  92667. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92668. /**
  92669. * Returns a new Mesh object parsed from the source provided.
  92670. * @param parsedMesh is the source
  92671. * @param scene defines the hosting scene
  92672. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92673. * @returns a new Mesh
  92674. */
  92675. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92676. /**
  92677. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92678. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92679. * @param name defines the name of the mesh to create
  92680. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92681. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92682. * @param closePath creates a seam between the first and the last points of each path of the path array
  92683. * @param offset is taken in account only if the `pathArray` is containing a single path
  92684. * @param scene defines the hosting scene
  92685. * @param updatable defines if the mesh must be flagged as updatable
  92686. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92687. * @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)
  92688. * @returns a new Mesh
  92689. */
  92690. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92691. /**
  92692. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92693. * @param name defines the name of the mesh to create
  92694. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92695. * @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
  92696. * @param scene defines the hosting scene
  92697. * @param updatable defines if the mesh must be flagged as updatable
  92698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92699. * @returns a new Mesh
  92700. */
  92701. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92702. /**
  92703. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92704. * @param name defines the name of the mesh to create
  92705. * @param size sets the size (float) of each box side (default 1)
  92706. * @param scene defines the hosting scene
  92707. * @param updatable defines if the mesh must be flagged as updatable
  92708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92709. * @returns a new Mesh
  92710. */
  92711. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92712. /**
  92713. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92714. * @param name defines the name of the mesh to create
  92715. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92716. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92717. * @param scene defines the hosting scene
  92718. * @param updatable defines if the mesh must be flagged as updatable
  92719. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92720. * @returns a new Mesh
  92721. */
  92722. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92723. /**
  92724. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92725. * @param name defines the name of the mesh to create
  92726. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92727. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92728. * @param scene defines the hosting scene
  92729. * @returns a new Mesh
  92730. */
  92731. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92732. /**
  92733. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92734. * @param name defines the name of the mesh to create
  92735. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92736. * @param diameterTop set the top cap diameter (floats, default 1)
  92737. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92738. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92739. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92740. * @param scene defines the hosting scene
  92741. * @param updatable defines if the mesh must be flagged as updatable
  92742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92743. * @returns a new Mesh
  92744. */
  92745. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92746. /**
  92747. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92748. * @param name defines the name of the mesh to create
  92749. * @param diameter sets the diameter size (float) of the torus (default 1)
  92750. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92751. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92752. * @param scene defines the hosting scene
  92753. * @param updatable defines if the mesh must be flagged as updatable
  92754. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92755. * @returns a new Mesh
  92756. */
  92757. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92758. /**
  92759. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92760. * @param name defines the name of the mesh to create
  92761. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92762. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92763. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92764. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92765. * @param p the number of windings on X axis (positive integers, default 2)
  92766. * @param q the number of windings on Y axis (positive integers, default 3)
  92767. * @param scene defines the hosting scene
  92768. * @param updatable defines if the mesh must be flagged as updatable
  92769. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92770. * @returns a new Mesh
  92771. */
  92772. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92773. /**
  92774. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92775. * @param name defines the name of the mesh to create
  92776. * @param points is an array successive Vector3
  92777. * @param scene defines the hosting scene
  92778. * @param updatable defines if the mesh must be flagged as updatable
  92779. * @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).
  92780. * @returns a new Mesh
  92781. */
  92782. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92783. /**
  92784. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92785. * @param name defines the name of the mesh to create
  92786. * @param points is an array successive Vector3
  92787. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92788. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92789. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92790. * @param scene defines the hosting scene
  92791. * @param updatable defines if the mesh must be flagged as updatable
  92792. * @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)
  92793. * @returns a new Mesh
  92794. */
  92795. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92796. /**
  92797. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92798. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92799. * 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.
  92800. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92801. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92802. * Remember you can only change the shape positions, not their number when updating a polygon.
  92803. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92804. * @param name defines the name of the mesh to create
  92805. * @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
  92806. * @param scene defines the hosting scene
  92807. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92808. * @param updatable defines if the mesh must be flagged as updatable
  92809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92810. * @param earcutInjection can be used to inject your own earcut reference
  92811. * @returns a new Mesh
  92812. */
  92813. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92814. /**
  92815. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92816. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92817. * @param name defines the name of the mesh to create
  92818. * @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
  92819. * @param depth defines the height of extrusion
  92820. * @param scene defines the hosting scene
  92821. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92822. * @param updatable defines if the mesh must be flagged as updatable
  92823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92824. * @param earcutInjection can be used to inject your own earcut reference
  92825. * @returns a new Mesh
  92826. */
  92827. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92828. /**
  92829. * Creates an extruded shape mesh.
  92830. * 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
  92831. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92832. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92833. * @param name defines the name of the mesh to create
  92834. * @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
  92835. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92836. * @param scale is the value to scale the shape
  92837. * @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
  92838. * @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
  92839. * @param scene defines the hosting scene
  92840. * @param updatable defines if the mesh must be flagged as updatable
  92841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92842. * @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)
  92843. * @returns a new Mesh
  92844. */
  92845. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92846. /**
  92847. * Creates an custom extruded shape mesh.
  92848. * The custom extrusion is a parametric shape.
  92849. * It has no predefined shape. Its final shape will depend on the input parameters.
  92850. * Please consider using the same method from the MeshBuilder class instead
  92851. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92852. * @param name defines the name of the mesh to create
  92853. * @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
  92854. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92855. * @param scaleFunction is a custom Javascript function called on each path point
  92856. * @param rotationFunction is a custom Javascript function called on each path point
  92857. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92858. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92859. * @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
  92860. * @param scene defines the hosting scene
  92861. * @param updatable defines if the mesh must be flagged as updatable
  92862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92863. * @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)
  92864. * @returns a new Mesh
  92865. */
  92866. 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;
  92867. /**
  92868. * Creates lathe mesh.
  92869. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92870. * Please consider using the same method from the MeshBuilder class instead
  92871. * @param name defines the name of the mesh to create
  92872. * @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
  92873. * @param radius is the radius value of the lathe
  92874. * @param tessellation is the side number of the lathe.
  92875. * @param scene defines the hosting scene
  92876. * @param updatable defines if the mesh must be flagged as updatable
  92877. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92878. * @returns a new Mesh
  92879. */
  92880. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92881. /**
  92882. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92883. * @param name defines the name of the mesh to create
  92884. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92885. * @param scene defines the hosting scene
  92886. * @param updatable defines if the mesh must be flagged as updatable
  92887. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92888. * @returns a new Mesh
  92889. */
  92890. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92891. /**
  92892. * Creates a ground mesh.
  92893. * Please consider using the same method from the MeshBuilder class instead
  92894. * @param name defines the name of the mesh to create
  92895. * @param width set the width of the ground
  92896. * @param height set the height of the ground
  92897. * @param subdivisions sets the number of subdivisions per side
  92898. * @param scene defines the hosting scene
  92899. * @param updatable defines if the mesh must be flagged as updatable
  92900. * @returns a new Mesh
  92901. */
  92902. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92903. /**
  92904. * Creates a tiled ground mesh.
  92905. * Please consider using the same method from the MeshBuilder class instead
  92906. * @param name defines the name of the mesh to create
  92907. * @param xmin set the ground minimum X coordinate
  92908. * @param zmin set the ground minimum Y coordinate
  92909. * @param xmax set the ground maximum X coordinate
  92910. * @param zmax set the ground maximum Z coordinate
  92911. * @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
  92912. * @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
  92913. * @param scene defines the hosting scene
  92914. * @param updatable defines if the mesh must be flagged as updatable
  92915. * @returns a new Mesh
  92916. */
  92917. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92918. w: number;
  92919. h: number;
  92920. }, precision: {
  92921. w: number;
  92922. h: number;
  92923. }, scene: Scene, updatable?: boolean): Mesh;
  92924. /**
  92925. * Creates a ground mesh from a height map.
  92926. * Please consider using the same method from the MeshBuilder class instead
  92927. * @see http://doc.babylonjs.com/babylon101/height_map
  92928. * @param name defines the name of the mesh to create
  92929. * @param url sets the URL of the height map image resource
  92930. * @param width set the ground width size
  92931. * @param height set the ground height size
  92932. * @param subdivisions sets the number of subdivision per side
  92933. * @param minHeight is the minimum altitude on the ground
  92934. * @param maxHeight is the maximum altitude on the ground
  92935. * @param scene defines the hosting scene
  92936. * @param updatable defines if the mesh must be flagged as updatable
  92937. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92938. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92939. * @returns a new Mesh
  92940. */
  92941. 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;
  92942. /**
  92943. * Creates a tube mesh.
  92944. * The tube is a parametric shape.
  92945. * It has no predefined shape. Its final shape will depend on the input parameters.
  92946. * Please consider using the same method from the MeshBuilder class instead
  92947. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92948. * @param name defines the name of the mesh to create
  92949. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92950. * @param radius sets the tube radius size
  92951. * @param tessellation is the number of sides on the tubular surface
  92952. * @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
  92953. * @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
  92954. * @param scene defines the hosting scene
  92955. * @param updatable defines if the mesh must be flagged as updatable
  92956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92957. * @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)
  92958. * @returns a new Mesh
  92959. */
  92960. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92961. (i: number, distance: number): number;
  92962. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92963. /**
  92964. * Creates a polyhedron mesh.
  92965. * Please consider using the same method from the MeshBuilder class instead.
  92966. * * 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
  92967. * * The parameter `size` (positive float, default 1) sets the polygon size
  92968. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92969. * * 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`
  92970. * * 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
  92971. * * 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)`)
  92972. * * 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
  92973. * * 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
  92974. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92975. * * If you create a double-sided mesh, you can choose what parts of 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
  92976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92977. * @param name defines the name of the mesh to create
  92978. * @param options defines the options used to create the mesh
  92979. * @param scene defines the hosting scene
  92980. * @returns a new Mesh
  92981. */
  92982. static CreatePolyhedron(name: string, options: {
  92983. type?: number;
  92984. size?: number;
  92985. sizeX?: number;
  92986. sizeY?: number;
  92987. sizeZ?: number;
  92988. custom?: any;
  92989. faceUV?: Vector4[];
  92990. faceColors?: Color4[];
  92991. updatable?: boolean;
  92992. sideOrientation?: number;
  92993. }, scene: Scene): Mesh;
  92994. /**
  92995. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92996. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92997. * * 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`)
  92998. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92999. * * 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
  93000. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93001. * * If you create a double-sided mesh, you can choose what parts of 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
  93002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93003. * @param name defines the name of the mesh
  93004. * @param options defines the options used to create the mesh
  93005. * @param scene defines the hosting scene
  93006. * @returns a new Mesh
  93007. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93008. */
  93009. static CreateIcoSphere(name: string, options: {
  93010. radius?: number;
  93011. flat?: boolean;
  93012. subdivisions?: number;
  93013. sideOrientation?: number;
  93014. updatable?: boolean;
  93015. }, scene: Scene): Mesh;
  93016. /**
  93017. * Creates a decal mesh.
  93018. * Please consider using the same method from the MeshBuilder class instead.
  93019. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93020. * @param name defines the name of the mesh
  93021. * @param sourceMesh defines the mesh receiving the decal
  93022. * @param position sets the position of the decal in world coordinates
  93023. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93024. * @param size sets the decal scaling
  93025. * @param angle sets the angle to rotate the decal
  93026. * @returns a new Mesh
  93027. */
  93028. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93029. /**
  93030. * Prepare internal position array for software CPU skinning
  93031. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93032. */
  93033. setPositionsForCPUSkinning(): Float32Array;
  93034. /**
  93035. * Prepare internal normal array for software CPU skinning
  93036. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93037. */
  93038. setNormalsForCPUSkinning(): Float32Array;
  93039. /**
  93040. * Updates the vertex buffer by applying transformation from the bones
  93041. * @param skeleton defines the skeleton to apply to current mesh
  93042. * @returns the current mesh
  93043. */
  93044. applySkeleton(skeleton: Skeleton): Mesh;
  93045. /**
  93046. * 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
  93047. * @param meshes defines the list of meshes to scan
  93048. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93049. */
  93050. static MinMax(meshes: AbstractMesh[]): {
  93051. min: Vector3;
  93052. max: Vector3;
  93053. };
  93054. /**
  93055. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93056. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93057. * @returns a vector3
  93058. */
  93059. static Center(meshesOrMinMaxVector: {
  93060. min: Vector3;
  93061. max: Vector3;
  93062. } | AbstractMesh[]): Vector3;
  93063. /**
  93064. * Merge the array of meshes into a single mesh for performance reasons.
  93065. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93066. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93067. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93068. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93069. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93070. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93071. * @returns a new mesh
  93072. */
  93073. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93074. /** @hidden */
  93075. addInstance(instance: InstancedMesh): void;
  93076. /** @hidden */
  93077. removeInstance(instance: InstancedMesh): void;
  93078. }
  93079. }
  93080. declare module BABYLON {
  93081. /**
  93082. * This is the base class of all the camera used in the application.
  93083. * @see http://doc.babylonjs.com/features/cameras
  93084. */
  93085. export class Camera extends Node {
  93086. /** @hidden */
  93087. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93088. /**
  93089. * This is the default projection mode used by the cameras.
  93090. * It helps recreating a feeling of perspective and better appreciate depth.
  93091. * This is the best way to simulate real life cameras.
  93092. */
  93093. static readonly PERSPECTIVE_CAMERA: number;
  93094. /**
  93095. * This helps creating camera with an orthographic mode.
  93096. * 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.
  93097. */
  93098. static readonly ORTHOGRAPHIC_CAMERA: number;
  93099. /**
  93100. * This is the default FOV mode for perspective cameras.
  93101. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93102. */
  93103. static readonly FOVMODE_VERTICAL_FIXED: number;
  93104. /**
  93105. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93106. */
  93107. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93108. /**
  93109. * This specifies ther is no need for a camera rig.
  93110. * Basically only one eye is rendered corresponding to the camera.
  93111. */
  93112. static readonly RIG_MODE_NONE: number;
  93113. /**
  93114. * Simulates a camera Rig with one blue eye and one red eye.
  93115. * This can be use with 3d blue and red glasses.
  93116. */
  93117. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93118. /**
  93119. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93120. */
  93121. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93122. /**
  93123. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93124. */
  93125. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93126. /**
  93127. * Defines that both eyes of the camera will be rendered over under each other.
  93128. */
  93129. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93130. /**
  93131. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93132. */
  93133. static readonly RIG_MODE_VR: number;
  93134. /**
  93135. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93136. */
  93137. static readonly RIG_MODE_WEBVR: number;
  93138. /**
  93139. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93140. */
  93141. static readonly RIG_MODE_CUSTOM: number;
  93142. /**
  93143. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93144. */
  93145. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93146. /**
  93147. * Define the input manager associated with the camera.
  93148. */
  93149. inputs: CameraInputsManager<Camera>;
  93150. /** @hidden */
  93151. _position: Vector3;
  93152. /**
  93153. * Define the current local position of the camera in the scene
  93154. */
  93155. position: Vector3;
  93156. /**
  93157. * The vector the camera should consider as up.
  93158. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93159. */
  93160. upVector: Vector3;
  93161. /**
  93162. * Define the current limit on the left side for an orthographic camera
  93163. * In scene unit
  93164. */
  93165. orthoLeft: Nullable<number>;
  93166. /**
  93167. * Define the current limit on the right side for an orthographic camera
  93168. * In scene unit
  93169. */
  93170. orthoRight: Nullable<number>;
  93171. /**
  93172. * Define the current limit on the bottom side for an orthographic camera
  93173. * In scene unit
  93174. */
  93175. orthoBottom: Nullable<number>;
  93176. /**
  93177. * Define the current limit on the top side for an orthographic camera
  93178. * In scene unit
  93179. */
  93180. orthoTop: Nullable<number>;
  93181. /**
  93182. * Field Of View is set in Radians. (default is 0.8)
  93183. */
  93184. fov: number;
  93185. /**
  93186. * Define the minimum distance the camera can see from.
  93187. * This is important to note that the depth buffer are not infinite and the closer it starts
  93188. * the more your scene might encounter depth fighting issue.
  93189. */
  93190. minZ: number;
  93191. /**
  93192. * Define the maximum distance the camera can see to.
  93193. * This is important to note that the depth buffer are not infinite and the further it end
  93194. * the more your scene might encounter depth fighting issue.
  93195. */
  93196. maxZ: number;
  93197. /**
  93198. * Define the default inertia of the camera.
  93199. * This helps giving a smooth feeling to the camera movement.
  93200. */
  93201. inertia: number;
  93202. /**
  93203. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93204. */
  93205. mode: number;
  93206. /**
  93207. * Define wether the camera is intermediate.
  93208. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93209. */
  93210. isIntermediate: boolean;
  93211. /**
  93212. * Define the viewport of the camera.
  93213. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93214. */
  93215. viewport: Viewport;
  93216. /**
  93217. * Restricts the camera to viewing objects with the same layerMask.
  93218. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93219. */
  93220. layerMask: number;
  93221. /**
  93222. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93223. */
  93224. fovMode: number;
  93225. /**
  93226. * Rig mode of the camera.
  93227. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93228. * This is normally controlled byt the camera themselves as internal use.
  93229. */
  93230. cameraRigMode: number;
  93231. /**
  93232. * Defines the distance between both "eyes" in case of a RIG
  93233. */
  93234. interaxialDistance: number;
  93235. /**
  93236. * Defines if stereoscopic rendering is done side by side or over under.
  93237. */
  93238. isStereoscopicSideBySide: boolean;
  93239. /**
  93240. * 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
  93241. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93242. * else in the scene. (Eg. security camera)
  93243. *
  93244. * 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)
  93245. */
  93246. customRenderTargets: RenderTargetTexture[];
  93247. /**
  93248. * When set, the camera will render to this render target instead of the default canvas
  93249. *
  93250. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93251. */
  93252. outputRenderTarget: Nullable<RenderTargetTexture>;
  93253. /**
  93254. * Observable triggered when the camera view matrix has changed.
  93255. */
  93256. onViewMatrixChangedObservable: Observable<Camera>;
  93257. /**
  93258. * Observable triggered when the camera Projection matrix has changed.
  93259. */
  93260. onProjectionMatrixChangedObservable: Observable<Camera>;
  93261. /**
  93262. * Observable triggered when the inputs have been processed.
  93263. */
  93264. onAfterCheckInputsObservable: Observable<Camera>;
  93265. /**
  93266. * Observable triggered when reset has been called and applied to the camera.
  93267. */
  93268. onRestoreStateObservable: Observable<Camera>;
  93269. /** @hidden */
  93270. _cameraRigParams: any;
  93271. /** @hidden */
  93272. _rigCameras: Camera[];
  93273. /** @hidden */
  93274. _rigPostProcess: Nullable<PostProcess>;
  93275. protected _webvrViewMatrix: Matrix;
  93276. /** @hidden */
  93277. _skipRendering: boolean;
  93278. /** @hidden */
  93279. _projectionMatrix: Matrix;
  93280. /** @hidden */
  93281. _postProcesses: Nullable<PostProcess>[];
  93282. /** @hidden */
  93283. _activeMeshes: SmartArray<AbstractMesh>;
  93284. protected _globalPosition: Vector3;
  93285. /** @hidden */
  93286. _computedViewMatrix: Matrix;
  93287. private _doNotComputeProjectionMatrix;
  93288. private _transformMatrix;
  93289. private _frustumPlanes;
  93290. private _refreshFrustumPlanes;
  93291. private _storedFov;
  93292. private _stateStored;
  93293. /**
  93294. * Instantiates a new camera object.
  93295. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93296. * @see http://doc.babylonjs.com/features/cameras
  93297. * @param name Defines the name of the camera in the scene
  93298. * @param position Defines the position of the camera
  93299. * @param scene Defines the scene the camera belongs too
  93300. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93301. */
  93302. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93303. /**
  93304. * Store current camera state (fov, position, etc..)
  93305. * @returns the camera
  93306. */
  93307. storeState(): Camera;
  93308. /**
  93309. * Restores the camera state values if it has been stored. You must call storeState() first
  93310. */
  93311. protected _restoreStateValues(): boolean;
  93312. /**
  93313. * Restored camera state. You must call storeState() first.
  93314. * @returns true if restored and false otherwise
  93315. */
  93316. restoreState(): boolean;
  93317. /**
  93318. * Gets the class name of the camera.
  93319. * @returns the class name
  93320. */
  93321. getClassName(): string;
  93322. /** @hidden */
  93323. readonly _isCamera: boolean;
  93324. /**
  93325. * Gets a string representation of the camera useful for debug purpose.
  93326. * @param fullDetails Defines that a more verboe level of logging is required
  93327. * @returns the string representation
  93328. */
  93329. toString(fullDetails?: boolean): string;
  93330. /**
  93331. * Gets the current world space position of the camera.
  93332. */
  93333. readonly globalPosition: Vector3;
  93334. /**
  93335. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93336. * @returns the active meshe list
  93337. */
  93338. getActiveMeshes(): SmartArray<AbstractMesh>;
  93339. /**
  93340. * Check wether a mesh is part of the current active mesh list of the camera
  93341. * @param mesh Defines the mesh to check
  93342. * @returns true if active, false otherwise
  93343. */
  93344. isActiveMesh(mesh: Mesh): boolean;
  93345. /**
  93346. * Is this camera ready to be used/rendered
  93347. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93348. * @return true if the camera is ready
  93349. */
  93350. isReady(completeCheck?: boolean): boolean;
  93351. /** @hidden */
  93352. _initCache(): void;
  93353. /** @hidden */
  93354. _updateCache(ignoreParentClass?: boolean): void;
  93355. /** @hidden */
  93356. _isSynchronized(): boolean;
  93357. /** @hidden */
  93358. _isSynchronizedViewMatrix(): boolean;
  93359. /** @hidden */
  93360. _isSynchronizedProjectionMatrix(): boolean;
  93361. /**
  93362. * Attach the input controls to a specific dom element to get the input from.
  93363. * @param element Defines the element the controls should be listened from
  93364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93365. */
  93366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93367. /**
  93368. * Detach the current controls from the specified dom element.
  93369. * @param element Defines the element to stop listening the inputs from
  93370. */
  93371. detachControl(element: HTMLElement): void;
  93372. /**
  93373. * Update the camera state according to the different inputs gathered during the frame.
  93374. */
  93375. update(): void;
  93376. /** @hidden */
  93377. _checkInputs(): void;
  93378. /** @hidden */
  93379. readonly rigCameras: Camera[];
  93380. /**
  93381. * Gets the post process used by the rig cameras
  93382. */
  93383. readonly rigPostProcess: Nullable<PostProcess>;
  93384. /**
  93385. * Internal, gets the first post proces.
  93386. * @returns the first post process to be run on this camera.
  93387. */
  93388. _getFirstPostProcess(): Nullable<PostProcess>;
  93389. private _cascadePostProcessesToRigCams;
  93390. /**
  93391. * Attach a post process to the camera.
  93392. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93393. * @param postProcess The post process to attach to the camera
  93394. * @param insertAt The position of the post process in case several of them are in use in the scene
  93395. * @returns the position the post process has been inserted at
  93396. */
  93397. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93398. /**
  93399. * Detach a post process to the camera.
  93400. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93401. * @param postProcess The post process to detach from the camera
  93402. */
  93403. detachPostProcess(postProcess: PostProcess): void;
  93404. /**
  93405. * Gets the current world matrix of the camera
  93406. */
  93407. getWorldMatrix(): Matrix;
  93408. /** @hidden */
  93409. _getViewMatrix(): Matrix;
  93410. /**
  93411. * Gets the current view matrix of the camera.
  93412. * @param force forces the camera to recompute the matrix without looking at the cached state
  93413. * @returns the view matrix
  93414. */
  93415. getViewMatrix(force?: boolean): Matrix;
  93416. /**
  93417. * Freeze the projection matrix.
  93418. * It will prevent the cache check of the camera projection compute and can speed up perf
  93419. * if no parameter of the camera are meant to change
  93420. * @param projection Defines manually a projection if necessary
  93421. */
  93422. freezeProjectionMatrix(projection?: Matrix): void;
  93423. /**
  93424. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93425. */
  93426. unfreezeProjectionMatrix(): void;
  93427. /**
  93428. * Gets the current projection matrix of the camera.
  93429. * @param force forces the camera to recompute the matrix without looking at the cached state
  93430. * @returns the projection matrix
  93431. */
  93432. getProjectionMatrix(force?: boolean): Matrix;
  93433. /**
  93434. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93435. * @returns a Matrix
  93436. */
  93437. getTransformationMatrix(): Matrix;
  93438. private _updateFrustumPlanes;
  93439. /**
  93440. * Checks if a cullable object (mesh...) is in the camera frustum
  93441. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93442. * @param target The object to check
  93443. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93444. * @returns true if the object is in frustum otherwise false
  93445. */
  93446. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93447. /**
  93448. * Checks if a cullable object (mesh...) is in the camera frustum
  93449. * Unlike isInFrustum this cheks the full bounding box
  93450. * @param target The object to check
  93451. * @returns true if the object is in frustum otherwise false
  93452. */
  93453. isCompletelyInFrustum(target: ICullable): boolean;
  93454. /**
  93455. * Gets a ray in the forward direction from the camera.
  93456. * @param length Defines the length of the ray to create
  93457. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93458. * @param origin Defines the start point of the ray which defaults to the camera position
  93459. * @returns the forward ray
  93460. */
  93461. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93462. /**
  93463. * Releases resources associated with this node.
  93464. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93465. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93466. */
  93467. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93468. /** @hidden */
  93469. _isLeftCamera: boolean;
  93470. /**
  93471. * Gets the left camera of a rig setup in case of Rigged Camera
  93472. */
  93473. readonly isLeftCamera: boolean;
  93474. /** @hidden */
  93475. _isRightCamera: boolean;
  93476. /**
  93477. * Gets the right camera of a rig setup in case of Rigged Camera
  93478. */
  93479. readonly isRightCamera: boolean;
  93480. /**
  93481. * Gets the left camera of a rig setup in case of Rigged Camera
  93482. */
  93483. readonly leftCamera: Nullable<FreeCamera>;
  93484. /**
  93485. * Gets the right camera of a rig setup in case of Rigged Camera
  93486. */
  93487. readonly rightCamera: Nullable<FreeCamera>;
  93488. /**
  93489. * Gets the left camera target of a rig setup in case of Rigged Camera
  93490. * @returns the target position
  93491. */
  93492. getLeftTarget(): Nullable<Vector3>;
  93493. /**
  93494. * Gets the right camera target of a rig setup in case of Rigged Camera
  93495. * @returns the target position
  93496. */
  93497. getRightTarget(): Nullable<Vector3>;
  93498. /**
  93499. * @hidden
  93500. */
  93501. setCameraRigMode(mode: number, rigParams: any): void;
  93502. /** @hidden */
  93503. static _setStereoscopicRigMode(camera: Camera): void;
  93504. /** @hidden */
  93505. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93506. /** @hidden */
  93507. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93508. /** @hidden */
  93509. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93510. /** @hidden */
  93511. _getVRProjectionMatrix(): Matrix;
  93512. protected _updateCameraRotationMatrix(): void;
  93513. protected _updateWebVRCameraRotationMatrix(): void;
  93514. /**
  93515. * This function MUST be overwritten by the different WebVR cameras available.
  93516. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93517. * @hidden
  93518. */
  93519. _getWebVRProjectionMatrix(): Matrix;
  93520. /**
  93521. * This function MUST be overwritten by the different WebVR cameras available.
  93522. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93523. * @hidden
  93524. */
  93525. _getWebVRViewMatrix(): Matrix;
  93526. /** @hidden */
  93527. setCameraRigParameter(name: string, value: any): void;
  93528. /**
  93529. * needs to be overridden by children so sub has required properties to be copied
  93530. * @hidden
  93531. */
  93532. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93533. /**
  93534. * May need to be overridden by children
  93535. * @hidden
  93536. */
  93537. _updateRigCameras(): void;
  93538. /** @hidden */
  93539. _setupInputs(): void;
  93540. /**
  93541. * Serialiaze the camera setup to a json represention
  93542. * @returns the JSON representation
  93543. */
  93544. serialize(): any;
  93545. /**
  93546. * Clones the current camera.
  93547. * @param name The cloned camera name
  93548. * @returns the cloned camera
  93549. */
  93550. clone(name: string): Camera;
  93551. /**
  93552. * Gets the direction of the camera relative to a given local axis.
  93553. * @param localAxis Defines the reference axis to provide a relative direction.
  93554. * @return the direction
  93555. */
  93556. getDirection(localAxis: Vector3): Vector3;
  93557. /**
  93558. * Returns the current camera absolute rotation
  93559. */
  93560. readonly absoluteRotation: Quaternion;
  93561. /**
  93562. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93563. * @param localAxis Defines the reference axis to provide a relative direction.
  93564. * @param result Defines the vector to store the result in
  93565. */
  93566. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93567. /**
  93568. * Gets a camera constructor for a given camera type
  93569. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93570. * @param name The name of the camera the result will be able to instantiate
  93571. * @param scene The scene the result will construct the camera in
  93572. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93573. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93574. * @returns a factory method to construc the camera
  93575. */
  93576. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93577. /**
  93578. * Compute the world matrix of the camera.
  93579. * @returns the camera world matrix
  93580. */
  93581. computeWorldMatrix(): Matrix;
  93582. /**
  93583. * Parse a JSON and creates the camera from the parsed information
  93584. * @param parsedCamera The JSON to parse
  93585. * @param scene The scene to instantiate the camera in
  93586. * @returns the newly constructed camera
  93587. */
  93588. static Parse(parsedCamera: any, scene: Scene): Camera;
  93589. }
  93590. }
  93591. declare module BABYLON {
  93592. /**
  93593. * Class containing static functions to help procedurally build meshes
  93594. */
  93595. export class DiscBuilder {
  93596. /**
  93597. * Creates a plane polygonal mesh. By default, this is a disc
  93598. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93599. * * 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
  93600. * * 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
  93601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93604. * @param name defines the name of the mesh
  93605. * @param options defines the options used to create the mesh
  93606. * @param scene defines the hosting scene
  93607. * @returns the plane polygonal mesh
  93608. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93609. */
  93610. static CreateDisc(name: string, options: {
  93611. radius?: number;
  93612. tessellation?: number;
  93613. arc?: number;
  93614. updatable?: boolean;
  93615. sideOrientation?: number;
  93616. frontUVs?: Vector4;
  93617. backUVs?: Vector4;
  93618. }, scene?: Nullable<Scene>): Mesh;
  93619. }
  93620. }
  93621. declare module BABYLON {
  93622. /**
  93623. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93624. *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.
  93625. * The SPS is also a particle system. It provides some methods to manage the particles.
  93626. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93627. *
  93628. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93629. */
  93630. export class SolidParticleSystem implements IDisposable {
  93631. /**
  93632. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93633. * Example : var p = SPS.particles[i];
  93634. */
  93635. particles: SolidParticle[];
  93636. /**
  93637. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93638. */
  93639. nbParticles: number;
  93640. /**
  93641. * If the particles must ever face the camera (default false). Useful for planar particles.
  93642. */
  93643. billboard: boolean;
  93644. /**
  93645. * Recompute normals when adding a shape
  93646. */
  93647. recomputeNormals: boolean;
  93648. /**
  93649. * This a counter ofr your own usage. It's not set by any SPS functions.
  93650. */
  93651. counter: number;
  93652. /**
  93653. * The SPS name. This name is also given to the underlying mesh.
  93654. */
  93655. name: string;
  93656. /**
  93657. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93658. */
  93659. mesh: Mesh;
  93660. /**
  93661. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93662. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93663. */
  93664. vars: any;
  93665. /**
  93666. * This array is populated when the SPS is set as 'pickable'.
  93667. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93668. * Each element of this array is an object `{idx: int, faceId: int}`.
  93669. * `idx` is the picked particle index in the `SPS.particles` array
  93670. * `faceId` is the picked face index counted within this particle.
  93671. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93672. */
  93673. pickedParticles: {
  93674. idx: number;
  93675. faceId: number;
  93676. }[];
  93677. /**
  93678. * This array is populated when `enableDepthSort` is set to true.
  93679. * Each element of this array is an instance of the class DepthSortedParticle.
  93680. */
  93681. depthSortedParticles: DepthSortedParticle[];
  93682. /**
  93683. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93684. * @hidden
  93685. */
  93686. _bSphereOnly: boolean;
  93687. /**
  93688. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93689. * @hidden
  93690. */
  93691. _bSphereRadiusFactor: number;
  93692. private _scene;
  93693. private _positions;
  93694. private _indices;
  93695. private _normals;
  93696. private _colors;
  93697. private _uvs;
  93698. private _indices32;
  93699. private _positions32;
  93700. private _normals32;
  93701. private _fixedNormal32;
  93702. private _colors32;
  93703. private _uvs32;
  93704. private _index;
  93705. private _updatable;
  93706. private _pickable;
  93707. private _isVisibilityBoxLocked;
  93708. private _alwaysVisible;
  93709. private _depthSort;
  93710. private _expandable;
  93711. private _shapeCounter;
  93712. private _copy;
  93713. private _color;
  93714. private _computeParticleColor;
  93715. private _computeParticleTexture;
  93716. private _computeParticleRotation;
  93717. private _computeParticleVertex;
  93718. private _computeBoundingBox;
  93719. private _depthSortParticles;
  93720. private _camera;
  93721. private _mustUnrotateFixedNormals;
  93722. private _particlesIntersect;
  93723. private _needs32Bits;
  93724. private _isNotBuilt;
  93725. private _lastParticleId;
  93726. private _idxOfId;
  93727. /**
  93728. * Creates a SPS (Solid Particle System) object.
  93729. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93730. * @param scene (Scene) is the scene in which the SPS is added.
  93731. * @param options defines the options of the sps e.g.
  93732. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93733. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93734. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93735. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93736. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93737. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93738. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93739. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93740. */
  93741. constructor(name: string, scene: Scene, options?: {
  93742. updatable?: boolean;
  93743. isPickable?: boolean;
  93744. enableDepthSort?: boolean;
  93745. particleIntersection?: boolean;
  93746. boundingSphereOnly?: boolean;
  93747. bSphereRadiusFactor?: number;
  93748. expandable?: boolean;
  93749. });
  93750. /**
  93751. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93752. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93753. * @returns the created mesh
  93754. */
  93755. buildMesh(): Mesh;
  93756. /**
  93757. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93758. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93759. * Thus the particles generated from `digest()` have their property `position` set yet.
  93760. * @param mesh ( Mesh ) is the mesh to be digested
  93761. * @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
  93762. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93763. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93764. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93765. * @returns the current SPS
  93766. */
  93767. digest(mesh: Mesh, options?: {
  93768. facetNb?: number;
  93769. number?: number;
  93770. delta?: number;
  93771. storage?: [];
  93772. }): SolidParticleSystem;
  93773. /**
  93774. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93775. * @hidden
  93776. */
  93777. private _unrotateFixedNormals;
  93778. /**
  93779. * Resets the temporary working copy particle
  93780. * @hidden
  93781. */
  93782. private _resetCopy;
  93783. /**
  93784. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93785. * @param p the current index in the positions array to be updated
  93786. * @param shape a Vector3 array, the shape geometry
  93787. * @param positions the positions array to be updated
  93788. * @param meshInd the shape indices array
  93789. * @param indices the indices array to be updated
  93790. * @param meshUV the shape uv array
  93791. * @param uvs the uv array to be updated
  93792. * @param meshCol the shape color array
  93793. * @param colors the color array to be updated
  93794. * @param meshNor the shape normals array
  93795. * @param normals the normals array to be updated
  93796. * @param idx the particle index
  93797. * @param idxInShape the particle index in its shape
  93798. * @param options the addShape() method passed options
  93799. * @hidden
  93800. */
  93801. private _meshBuilder;
  93802. /**
  93803. * Returns a shape Vector3 array from positions float array
  93804. * @param positions float array
  93805. * @returns a vector3 array
  93806. * @hidden
  93807. */
  93808. private _posToShape;
  93809. /**
  93810. * Returns a shapeUV array from a float uvs (array deep copy)
  93811. * @param uvs as a float array
  93812. * @returns a shapeUV array
  93813. * @hidden
  93814. */
  93815. private _uvsToShapeUV;
  93816. /**
  93817. * Adds a new particle object in the particles array
  93818. * @param idx particle index in particles array
  93819. * @param id particle id
  93820. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93821. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93822. * @param model particle ModelShape object
  93823. * @param shapeId model shape identifier
  93824. * @param idxInShape index of the particle in the current model
  93825. * @param bInfo model bounding info object
  93826. * @param storage target storage array, if any
  93827. * @hidden
  93828. */
  93829. private _addParticle;
  93830. /**
  93831. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93832. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93833. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93834. * @param nb (positive integer) the number of particles to be created from this model
  93835. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93836. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93837. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93838. * @returns the number of shapes in the system
  93839. */
  93840. addShape(mesh: Mesh, nb: number, options?: {
  93841. positionFunction?: any;
  93842. vertexFunction?: any;
  93843. storage?: [];
  93844. }): number;
  93845. /**
  93846. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93847. * @hidden
  93848. */
  93849. private _rebuildParticle;
  93850. /**
  93851. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93852. * @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.
  93853. * @returns the SPS.
  93854. */
  93855. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93856. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93857. * Returns an array with the removed particles.
  93858. * 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.
  93859. * The SPS can't be empty so at least one particle needs to remain in place.
  93860. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93861. * @param start index of the first particle to remove
  93862. * @param end index of the last particle to remove (included)
  93863. * @returns an array populated with the removed particles
  93864. */
  93865. removeParticles(start: number, end: number): SolidParticle[];
  93866. /**
  93867. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93868. * @param solidParticleArray an array populated with Solid Particles objects
  93869. * @returns the SPS
  93870. */
  93871. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93872. /**
  93873. * Creates a new particle and modifies the SPS mesh geometry :
  93874. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93875. * - calls _addParticle() to populate the particle array
  93876. * factorized code from addShape() and insertParticlesFromArray()
  93877. * @param idx particle index in the particles array
  93878. * @param i particle index in its shape
  93879. * @param modelShape particle ModelShape object
  93880. * @param shape shape vertex array
  93881. * @param meshInd shape indices array
  93882. * @param meshUV shape uv array
  93883. * @param meshCol shape color array
  93884. * @param meshNor shape normals array
  93885. * @param bbInfo shape bounding info
  93886. * @param storage target particle storage
  93887. * @options addShape() passed options
  93888. * @hidden
  93889. */
  93890. private _insertNewParticle;
  93891. /**
  93892. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93893. * This method calls `updateParticle()` for each particle of the SPS.
  93894. * For an animated SPS, it is usually called within the render loop.
  93895. * 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.
  93896. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93897. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93898. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93899. * @returns the SPS.
  93900. */
  93901. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93902. /**
  93903. * Disposes the SPS.
  93904. */
  93905. dispose(): void;
  93906. /**
  93907. * Returns a SolidParticle object from its identifier : particle.id
  93908. * @param id (integer) the particle Id
  93909. * @returns the searched particle or null if not found in the SPS.
  93910. */
  93911. getParticleById(id: number): Nullable<SolidParticle>;
  93912. /**
  93913. * Returns a new array populated with the particles having the passed shapeId.
  93914. * @param shapeId (integer) the shape identifier
  93915. * @returns a new solid particle array
  93916. */
  93917. getParticlesByShapeId(shapeId: number): SolidParticle[];
  93918. /**
  93919. * Populates the passed array "ref" with the particles having the passed shapeId.
  93920. * @param shapeId the shape identifier
  93921. * @returns the SPS
  93922. * @param ref
  93923. */
  93924. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  93925. /**
  93926. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93927. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93928. * @returns the SPS.
  93929. */
  93930. refreshVisibleSize(): SolidParticleSystem;
  93931. /**
  93932. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93933. * @param size the size (float) of the visibility box
  93934. * note : this doesn't lock the SPS mesh bounding box.
  93935. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93936. */
  93937. setVisibilityBox(size: number): void;
  93938. /**
  93939. * Gets whether the SPS as always visible or not
  93940. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93941. */
  93942. /**
  93943. * Sets the SPS as always visible or not
  93944. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93945. */
  93946. isAlwaysVisible: boolean;
  93947. /**
  93948. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93949. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93950. */
  93951. /**
  93952. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93953. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93954. */
  93955. isVisibilityBoxLocked: boolean;
  93956. /**
  93957. * Tells to `setParticles()` to compute the particle rotations or not.
  93958. * Default value : true. The SPS is faster when it's set to false.
  93959. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93960. */
  93961. /**
  93962. * Gets if `setParticles()` computes the particle rotations or not.
  93963. * Default value : true. The SPS is faster when it's set to false.
  93964. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93965. */
  93966. computeParticleRotation: boolean;
  93967. /**
  93968. * Tells to `setParticles()` to compute the particle colors or not.
  93969. * Default value : true. The SPS is faster when it's set to false.
  93970. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93971. */
  93972. /**
  93973. * Gets if `setParticles()` computes the particle colors or not.
  93974. * Default value : true. The SPS is faster when it's set to false.
  93975. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93976. */
  93977. computeParticleColor: boolean;
  93978. /**
  93979. * Gets if `setParticles()` computes the particle textures or not.
  93980. * Default value : true. The SPS is faster when it's set to false.
  93981. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93982. */
  93983. computeParticleTexture: boolean;
  93984. /**
  93985. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93986. * Default value : false. The SPS is faster when it's set to false.
  93987. * Note : the particle custom vertex positions aren't stored values.
  93988. */
  93989. /**
  93990. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93991. * Default value : false. The SPS is faster when it's set to false.
  93992. * Note : the particle custom vertex positions aren't stored values.
  93993. */
  93994. computeParticleVertex: boolean;
  93995. /**
  93996. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93997. */
  93998. /**
  93999. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  94000. */
  94001. computeBoundingBox: boolean;
  94002. /**
  94003. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  94004. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94005. * Default : `true`
  94006. */
  94007. /**
  94008. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  94009. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94010. * Default : `true`
  94011. */
  94012. depthSortParticles: boolean;
  94013. /**
  94014. * Gets if the SPS is created as expandable at construction time.
  94015. * Default : `false`
  94016. */
  94017. readonly expandable: boolean;
  94018. /**
  94019. * This function does nothing. It may be overwritten to set all the particle first values.
  94020. * The SPS doesn't call this function, you may have to call it by your own.
  94021. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94022. */
  94023. initParticles(): void;
  94024. /**
  94025. * This function does nothing. It may be overwritten to recycle a particle.
  94026. * The SPS doesn't call this function, you may have to call it by your own.
  94027. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94028. * @param particle The particle to recycle
  94029. * @returns the recycled particle
  94030. */
  94031. recycleParticle(particle: SolidParticle): SolidParticle;
  94032. /**
  94033. * Updates a particle : this function should be overwritten by the user.
  94034. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94035. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94036. * @example : just set a particle position or velocity and recycle conditions
  94037. * @param particle The particle to update
  94038. * @returns the updated particle
  94039. */
  94040. updateParticle(particle: SolidParticle): SolidParticle;
  94041. /**
  94042. * Updates a vertex of a particle : it can be overwritten by the user.
  94043. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94044. * @param particle the current particle
  94045. * @param vertex the current index of the current particle
  94046. * @param pt the index of the current vertex in the particle shape
  94047. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94048. * @example : just set a vertex particle position
  94049. * @returns the updated vertex
  94050. */
  94051. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94052. /**
  94053. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94054. * This does nothing and may be overwritten by the user.
  94055. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94056. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94057. * @param update the boolean update value actually passed to setParticles()
  94058. */
  94059. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94060. /**
  94061. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94062. * This will be passed three parameters.
  94063. * This does nothing and may be overwritten by the user.
  94064. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94065. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94066. * @param update the boolean update value actually passed to setParticles()
  94067. */
  94068. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94069. }
  94070. }
  94071. declare module BABYLON {
  94072. /**
  94073. * Represents one particle of a solid particle system.
  94074. */
  94075. export class SolidParticle {
  94076. /**
  94077. * particle global index
  94078. */
  94079. idx: number;
  94080. /**
  94081. * particle identifier
  94082. */
  94083. id: number;
  94084. /**
  94085. * The color of the particle
  94086. */
  94087. color: Nullable<Color4>;
  94088. /**
  94089. * The world space position of the particle.
  94090. */
  94091. position: Vector3;
  94092. /**
  94093. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94094. */
  94095. rotation: Vector3;
  94096. /**
  94097. * The world space rotation quaternion of the particle.
  94098. */
  94099. rotationQuaternion: Nullable<Quaternion>;
  94100. /**
  94101. * The scaling of the particle.
  94102. */
  94103. scaling: Vector3;
  94104. /**
  94105. * The uvs of the particle.
  94106. */
  94107. uvs: Vector4;
  94108. /**
  94109. * The current speed of the particle.
  94110. */
  94111. velocity: Vector3;
  94112. /**
  94113. * The pivot point in the particle local space.
  94114. */
  94115. pivot: Vector3;
  94116. /**
  94117. * Must the particle be translated from its pivot point in its local space ?
  94118. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94119. * Default : false
  94120. */
  94121. translateFromPivot: boolean;
  94122. /**
  94123. * Is the particle active or not ?
  94124. */
  94125. alive: boolean;
  94126. /**
  94127. * Is the particle visible or not ?
  94128. */
  94129. isVisible: boolean;
  94130. /**
  94131. * Index of this particle in the global "positions" array (Internal use)
  94132. * @hidden
  94133. */
  94134. _pos: number;
  94135. /**
  94136. * @hidden Index of this particle in the global "indices" array (Internal use)
  94137. */
  94138. _ind: number;
  94139. /**
  94140. * @hidden ModelShape of this particle (Internal use)
  94141. */
  94142. _model: ModelShape;
  94143. /**
  94144. * ModelShape id of this particle
  94145. */
  94146. shapeId: number;
  94147. /**
  94148. * Index of the particle in its shape id
  94149. */
  94150. idxInShape: number;
  94151. /**
  94152. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94153. */
  94154. _modelBoundingInfo: BoundingInfo;
  94155. /**
  94156. * @hidden Particle BoundingInfo object (Internal use)
  94157. */
  94158. _boundingInfo: BoundingInfo;
  94159. /**
  94160. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94161. */
  94162. _sps: SolidParticleSystem;
  94163. /**
  94164. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94165. */
  94166. _stillInvisible: boolean;
  94167. /**
  94168. * @hidden Last computed particle rotation matrix
  94169. */
  94170. _rotationMatrix: number[];
  94171. /**
  94172. * Parent particle Id, if any.
  94173. * Default null.
  94174. */
  94175. parentId: Nullable<number>;
  94176. /**
  94177. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94178. * The possible values are :
  94179. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94180. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94181. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94182. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94183. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94184. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94185. * */
  94186. cullingStrategy: number;
  94187. /**
  94188. * @hidden Internal global position in the SPS.
  94189. */
  94190. _globalPosition: Vector3;
  94191. /**
  94192. * Creates a Solid Particle object.
  94193. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94194. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94195. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94196. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94197. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94198. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94199. * @param shapeId (integer) is the model shape identifier in the SPS.
  94200. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94201. * @param sps defines the sps it is associated to
  94202. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94203. */
  94204. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  94205. /**
  94206. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94207. * @param target the particle target
  94208. * @returns the current particle
  94209. */
  94210. copyToRef(target: SolidParticle): SolidParticle;
  94211. /**
  94212. * Legacy support, changed scale to scaling
  94213. */
  94214. /**
  94215. * Legacy support, changed scale to scaling
  94216. */
  94217. scale: Vector3;
  94218. /**
  94219. * Legacy support, changed quaternion to rotationQuaternion
  94220. */
  94221. /**
  94222. * Legacy support, changed quaternion to rotationQuaternion
  94223. */
  94224. quaternion: Nullable<Quaternion>;
  94225. /**
  94226. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94227. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94228. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94229. * @returns true if it intersects
  94230. */
  94231. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94232. /**
  94233. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94234. * A particle is in the frustum if its bounding box intersects the frustum
  94235. * @param frustumPlanes defines the frustum to test
  94236. * @returns true if the particle is in the frustum planes
  94237. */
  94238. isInFrustum(frustumPlanes: Plane[]): boolean;
  94239. /**
  94240. * get the rotation matrix of the particle
  94241. * @hidden
  94242. */
  94243. getRotationMatrix(m: Matrix): void;
  94244. }
  94245. /**
  94246. * Represents the shape of the model used by one particle of a solid particle system.
  94247. * SPS internal tool, don't use it manually.
  94248. */
  94249. export class ModelShape {
  94250. /**
  94251. * The shape id
  94252. * @hidden
  94253. */
  94254. shapeID: number;
  94255. /**
  94256. * flat array of model positions (internal use)
  94257. * @hidden
  94258. */
  94259. _shape: Vector3[];
  94260. /**
  94261. * flat array of model UVs (internal use)
  94262. * @hidden
  94263. */
  94264. _shapeUV: number[];
  94265. /**
  94266. * color array of the model
  94267. * @hidden
  94268. */
  94269. _shapeColors: number[];
  94270. /**
  94271. * indices array of the model
  94272. * @hidden
  94273. */
  94274. _indices: number[];
  94275. /**
  94276. * normals array of the model
  94277. * @hidden
  94278. */
  94279. _normals: number[];
  94280. /**
  94281. * length of the shape in the model indices array (internal use)
  94282. * @hidden
  94283. */
  94284. _indicesLength: number;
  94285. /**
  94286. * Custom position function (internal use)
  94287. * @hidden
  94288. */
  94289. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94290. /**
  94291. * Custom vertex function (internal use)
  94292. * @hidden
  94293. */
  94294. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94295. /**
  94296. * 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.
  94297. * SPS internal tool, don't use it manually.
  94298. * @hidden
  94299. */
  94300. 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>);
  94301. }
  94302. /**
  94303. * Represents a Depth Sorted Particle in the solid particle system.
  94304. */
  94305. export class DepthSortedParticle {
  94306. /**
  94307. * Index of the particle in the "indices" array
  94308. */
  94309. ind: number;
  94310. /**
  94311. * Length of the particle shape in the "indices" array
  94312. */
  94313. indicesLength: number;
  94314. /**
  94315. * Squared distance from the particle to the camera
  94316. */
  94317. sqDistance: number;
  94318. }
  94319. }
  94320. declare module BABYLON {
  94321. /**
  94322. * @hidden
  94323. */
  94324. export class _MeshCollisionData {
  94325. _checkCollisions: boolean;
  94326. _collisionMask: number;
  94327. _collisionGroup: number;
  94328. _collider: Nullable<Collider>;
  94329. _oldPositionForCollisions: Vector3;
  94330. _diffPositionForCollisions: Vector3;
  94331. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94332. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94333. }
  94334. }
  94335. declare module BABYLON {
  94336. /** @hidden */
  94337. class _FacetDataStorage {
  94338. facetPositions: Vector3[];
  94339. facetNormals: Vector3[];
  94340. facetPartitioning: number[][];
  94341. facetNb: number;
  94342. partitioningSubdivisions: number;
  94343. partitioningBBoxRatio: number;
  94344. facetDataEnabled: boolean;
  94345. facetParameters: any;
  94346. bbSize: Vector3;
  94347. subDiv: {
  94348. max: number;
  94349. X: number;
  94350. Y: number;
  94351. Z: number;
  94352. };
  94353. facetDepthSort: boolean;
  94354. facetDepthSortEnabled: boolean;
  94355. depthSortedIndices: IndicesArray;
  94356. depthSortedFacets: {
  94357. ind: number;
  94358. sqDistance: number;
  94359. }[];
  94360. facetDepthSortFunction: (f1: {
  94361. ind: number;
  94362. sqDistance: number;
  94363. }, f2: {
  94364. ind: number;
  94365. sqDistance: number;
  94366. }) => number;
  94367. facetDepthSortFrom: Vector3;
  94368. facetDepthSortOrigin: Vector3;
  94369. invertedMatrix: Matrix;
  94370. }
  94371. /**
  94372. * @hidden
  94373. **/
  94374. class _InternalAbstractMeshDataInfo {
  94375. _hasVertexAlpha: boolean;
  94376. _useVertexColors: boolean;
  94377. _numBoneInfluencers: number;
  94378. _applyFog: boolean;
  94379. _receiveShadows: boolean;
  94380. _facetData: _FacetDataStorage;
  94381. _visibility: number;
  94382. _skeleton: Nullable<Skeleton>;
  94383. _layerMask: number;
  94384. _computeBonesUsingShaders: boolean;
  94385. _isActive: boolean;
  94386. _onlyForInstances: boolean;
  94387. _isActiveIntermediate: boolean;
  94388. _onlyForInstancesIntermediate: boolean;
  94389. _actAsRegularMesh: boolean;
  94390. }
  94391. /**
  94392. * Class used to store all common mesh properties
  94393. */
  94394. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94395. /** No occlusion */
  94396. static OCCLUSION_TYPE_NONE: number;
  94397. /** Occlusion set to optimisitic */
  94398. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94399. /** Occlusion set to strict */
  94400. static OCCLUSION_TYPE_STRICT: number;
  94401. /** Use an accurante occlusion algorithm */
  94402. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94403. /** Use a conservative occlusion algorithm */
  94404. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94405. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94406. * Test order :
  94407. * Is the bounding sphere outside the frustum ?
  94408. * If not, are the bounding box vertices outside the frustum ?
  94409. * It not, then the cullable object is in the frustum.
  94410. */
  94411. static readonly CULLINGSTRATEGY_STANDARD: number;
  94412. /** Culling strategy : Bounding Sphere Only.
  94413. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94414. * It's also less accurate than the standard because some not visible objects can still be selected.
  94415. * Test : is the bounding sphere outside the frustum ?
  94416. * If not, then the cullable object is in the frustum.
  94417. */
  94418. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94419. /** Culling strategy : Optimistic Inclusion.
  94420. * This in an inclusion test first, then the standard exclusion test.
  94421. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94422. * 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.
  94423. * Anyway, it's as accurate as the standard strategy.
  94424. * Test :
  94425. * Is the cullable object bounding sphere center in the frustum ?
  94426. * If not, apply the default culling strategy.
  94427. */
  94428. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94429. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94430. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94431. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94432. * 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.
  94433. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94434. * Test :
  94435. * Is the cullable object bounding sphere center in the frustum ?
  94436. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94437. */
  94438. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94439. /**
  94440. * No billboard
  94441. */
  94442. static readonly BILLBOARDMODE_NONE: number;
  94443. /** Billboard on X axis */
  94444. static readonly BILLBOARDMODE_X: number;
  94445. /** Billboard on Y axis */
  94446. static readonly BILLBOARDMODE_Y: number;
  94447. /** Billboard on Z axis */
  94448. static readonly BILLBOARDMODE_Z: number;
  94449. /** Billboard on all axes */
  94450. static readonly BILLBOARDMODE_ALL: number;
  94451. /** Billboard on using position instead of orientation */
  94452. static readonly BILLBOARDMODE_USE_POSITION: number;
  94453. /** @hidden */
  94454. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94455. /**
  94456. * The culling strategy to use to check whether the mesh must be rendered or not.
  94457. * This value can be changed at any time and will be used on the next render mesh selection.
  94458. * The possible values are :
  94459. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94460. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94461. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94462. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94463. * Please read each static variable documentation to get details about the culling process.
  94464. * */
  94465. cullingStrategy: number;
  94466. /**
  94467. * Gets the number of facets in the mesh
  94468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94469. */
  94470. readonly facetNb: number;
  94471. /**
  94472. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94474. */
  94475. partitioningSubdivisions: number;
  94476. /**
  94477. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94478. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94480. */
  94481. partitioningBBoxRatio: number;
  94482. /**
  94483. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94484. * Works only for updatable meshes.
  94485. * Doesn't work with multi-materials
  94486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94487. */
  94488. mustDepthSortFacets: boolean;
  94489. /**
  94490. * The location (Vector3) where the facet depth sort must be computed from.
  94491. * By default, the active camera position.
  94492. * Used only when facet depth sort is enabled
  94493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94494. */
  94495. facetDepthSortFrom: Vector3;
  94496. /**
  94497. * gets a boolean indicating if facetData is enabled
  94498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94499. */
  94500. readonly isFacetDataEnabled: boolean;
  94501. /** @hidden */
  94502. _updateNonUniformScalingState(value: boolean): boolean;
  94503. /**
  94504. * An event triggered when this mesh collides with another one
  94505. */
  94506. onCollideObservable: Observable<AbstractMesh>;
  94507. /** Set a function to call when this mesh collides with another one */
  94508. onCollide: () => void;
  94509. /**
  94510. * An event triggered when the collision's position changes
  94511. */
  94512. onCollisionPositionChangeObservable: Observable<Vector3>;
  94513. /** Set a function to call when the collision's position changes */
  94514. onCollisionPositionChange: () => void;
  94515. /**
  94516. * An event triggered when material is changed
  94517. */
  94518. onMaterialChangedObservable: Observable<AbstractMesh>;
  94519. /**
  94520. * Gets or sets the orientation for POV movement & rotation
  94521. */
  94522. definedFacingForward: boolean;
  94523. /** @hidden */
  94524. _occlusionQuery: Nullable<WebGLQuery>;
  94525. /** @hidden */
  94526. _renderingGroup: Nullable<RenderingGroup>;
  94527. /**
  94528. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94529. */
  94530. /**
  94531. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94532. */
  94533. visibility: number;
  94534. /** Gets or sets the alpha index used to sort transparent meshes
  94535. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94536. */
  94537. alphaIndex: number;
  94538. /**
  94539. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94540. */
  94541. isVisible: boolean;
  94542. /**
  94543. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94544. */
  94545. isPickable: boolean;
  94546. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94547. showSubMeshesBoundingBox: boolean;
  94548. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94549. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94550. */
  94551. isBlocker: boolean;
  94552. /**
  94553. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94554. */
  94555. enablePointerMoveEvents: boolean;
  94556. /**
  94557. * Specifies the rendering group id for this mesh (0 by default)
  94558. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94559. */
  94560. renderingGroupId: number;
  94561. private _material;
  94562. /** Gets or sets current material */
  94563. material: Nullable<Material>;
  94564. /**
  94565. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94566. * @see http://doc.babylonjs.com/babylon101/shadows
  94567. */
  94568. receiveShadows: boolean;
  94569. /** Defines color to use when rendering outline */
  94570. outlineColor: Color3;
  94571. /** Define width to use when rendering outline */
  94572. outlineWidth: number;
  94573. /** Defines color to use when rendering overlay */
  94574. overlayColor: Color3;
  94575. /** Defines alpha to use when rendering overlay */
  94576. overlayAlpha: number;
  94577. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94578. hasVertexAlpha: boolean;
  94579. /** 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) */
  94580. useVertexColors: boolean;
  94581. /**
  94582. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94583. */
  94584. computeBonesUsingShaders: boolean;
  94585. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94586. numBoneInfluencers: number;
  94587. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94588. applyFog: boolean;
  94589. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94590. useOctreeForRenderingSelection: boolean;
  94591. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94592. useOctreeForPicking: boolean;
  94593. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94594. useOctreeForCollisions: boolean;
  94595. /**
  94596. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94597. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94598. */
  94599. layerMask: number;
  94600. /**
  94601. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94602. */
  94603. alwaysSelectAsActiveMesh: boolean;
  94604. /**
  94605. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94606. */
  94607. doNotSyncBoundingInfo: boolean;
  94608. /**
  94609. * Gets or sets the current action manager
  94610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94611. */
  94612. actionManager: Nullable<AbstractActionManager>;
  94613. private _meshCollisionData;
  94614. /**
  94615. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94616. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94617. */
  94618. ellipsoid: Vector3;
  94619. /**
  94620. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94621. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94622. */
  94623. ellipsoidOffset: Vector3;
  94624. /**
  94625. * Gets or sets a collision mask used to mask collisions (default is -1).
  94626. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94627. */
  94628. collisionMask: number;
  94629. /**
  94630. * Gets or sets the current collision group mask (-1 by default).
  94631. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94632. */
  94633. collisionGroup: number;
  94634. /**
  94635. * Defines edge width used when edgesRenderer is enabled
  94636. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94637. */
  94638. edgesWidth: number;
  94639. /**
  94640. * Defines edge color used when edgesRenderer is enabled
  94641. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94642. */
  94643. edgesColor: Color4;
  94644. /** @hidden */
  94645. _edgesRenderer: Nullable<IEdgesRenderer>;
  94646. /** @hidden */
  94647. _masterMesh: Nullable<AbstractMesh>;
  94648. /** @hidden */
  94649. _boundingInfo: Nullable<BoundingInfo>;
  94650. /** @hidden */
  94651. _renderId: number;
  94652. /**
  94653. * Gets or sets the list of subMeshes
  94654. * @see http://doc.babylonjs.com/how_to/multi_materials
  94655. */
  94656. subMeshes: SubMesh[];
  94657. /** @hidden */
  94658. _intersectionsInProgress: AbstractMesh[];
  94659. /** @hidden */
  94660. _unIndexed: boolean;
  94661. /** @hidden */
  94662. _lightSources: Light[];
  94663. /** Gets the list of lights affecting that mesh */
  94664. readonly lightSources: Light[];
  94665. /** @hidden */
  94666. readonly _positions: Nullable<Vector3[]>;
  94667. /** @hidden */
  94668. _waitingData: {
  94669. lods: Nullable<any>;
  94670. actions: Nullable<any>;
  94671. freezeWorldMatrix: Nullable<boolean>;
  94672. };
  94673. /** @hidden */
  94674. _bonesTransformMatrices: Nullable<Float32Array>;
  94675. /** @hidden */
  94676. _transformMatrixTexture: Nullable<RawTexture>;
  94677. /**
  94678. * Gets or sets a skeleton to apply skining transformations
  94679. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94680. */
  94681. skeleton: Nullable<Skeleton>;
  94682. /**
  94683. * An event triggered when the mesh is rebuilt.
  94684. */
  94685. onRebuildObservable: Observable<AbstractMesh>;
  94686. /**
  94687. * Creates a new AbstractMesh
  94688. * @param name defines the name of the mesh
  94689. * @param scene defines the hosting scene
  94690. */
  94691. constructor(name: string, scene?: Nullable<Scene>);
  94692. /**
  94693. * Returns the string "AbstractMesh"
  94694. * @returns "AbstractMesh"
  94695. */
  94696. getClassName(): string;
  94697. /**
  94698. * Gets a string representation of the current mesh
  94699. * @param fullDetails defines a boolean indicating if full details must be included
  94700. * @returns a string representation of the current mesh
  94701. */
  94702. toString(fullDetails?: boolean): string;
  94703. /**
  94704. * @hidden
  94705. */
  94706. protected _getEffectiveParent(): Nullable<Node>;
  94707. /** @hidden */
  94708. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94709. /** @hidden */
  94710. _rebuild(): void;
  94711. /** @hidden */
  94712. _resyncLightSources(): void;
  94713. /** @hidden */
  94714. _resyncLighSource(light: Light): void;
  94715. /** @hidden */
  94716. _unBindEffect(): void;
  94717. /** @hidden */
  94718. _removeLightSource(light: Light, dispose: boolean): void;
  94719. private _markSubMeshesAsDirty;
  94720. /** @hidden */
  94721. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94722. /** @hidden */
  94723. _markSubMeshesAsAttributesDirty(): void;
  94724. /** @hidden */
  94725. _markSubMeshesAsMiscDirty(): void;
  94726. /**
  94727. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94728. */
  94729. scaling: Vector3;
  94730. /**
  94731. * Returns true if the mesh is blocked. Implemented by child classes
  94732. */
  94733. readonly isBlocked: boolean;
  94734. /**
  94735. * Returns the mesh itself by default. Implemented by child classes
  94736. * @param camera defines the camera to use to pick the right LOD level
  94737. * @returns the currentAbstractMesh
  94738. */
  94739. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94740. /**
  94741. * Returns 0 by default. Implemented by child classes
  94742. * @returns an integer
  94743. */
  94744. getTotalVertices(): number;
  94745. /**
  94746. * Returns a positive integer : the total number of indices in this mesh geometry.
  94747. * @returns the numner of indices or zero if the mesh has no geometry.
  94748. */
  94749. getTotalIndices(): number;
  94750. /**
  94751. * Returns null by default. Implemented by child classes
  94752. * @returns null
  94753. */
  94754. getIndices(): Nullable<IndicesArray>;
  94755. /**
  94756. * Returns the array of the requested vertex data kind. Implemented by child classes
  94757. * @param kind defines the vertex data kind to use
  94758. * @returns null
  94759. */
  94760. getVerticesData(kind: string): Nullable<FloatArray>;
  94761. /**
  94762. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94763. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94764. * Note that a new underlying VertexBuffer object is created each call.
  94765. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94766. * @param kind defines vertex data kind:
  94767. * * VertexBuffer.PositionKind
  94768. * * VertexBuffer.UVKind
  94769. * * VertexBuffer.UV2Kind
  94770. * * VertexBuffer.UV3Kind
  94771. * * VertexBuffer.UV4Kind
  94772. * * VertexBuffer.UV5Kind
  94773. * * VertexBuffer.UV6Kind
  94774. * * VertexBuffer.ColorKind
  94775. * * VertexBuffer.MatricesIndicesKind
  94776. * * VertexBuffer.MatricesIndicesExtraKind
  94777. * * VertexBuffer.MatricesWeightsKind
  94778. * * VertexBuffer.MatricesWeightsExtraKind
  94779. * @param data defines the data source
  94780. * @param updatable defines if the data must be flagged as updatable (or static)
  94781. * @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
  94782. * @returns the current mesh
  94783. */
  94784. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94785. /**
  94786. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94787. * If the mesh has no geometry, it is simply returned as it is.
  94788. * @param kind defines vertex data kind:
  94789. * * VertexBuffer.PositionKind
  94790. * * VertexBuffer.UVKind
  94791. * * VertexBuffer.UV2Kind
  94792. * * VertexBuffer.UV3Kind
  94793. * * VertexBuffer.UV4Kind
  94794. * * VertexBuffer.UV5Kind
  94795. * * VertexBuffer.UV6Kind
  94796. * * VertexBuffer.ColorKind
  94797. * * VertexBuffer.MatricesIndicesKind
  94798. * * VertexBuffer.MatricesIndicesExtraKind
  94799. * * VertexBuffer.MatricesWeightsKind
  94800. * * VertexBuffer.MatricesWeightsExtraKind
  94801. * @param data defines the data source
  94802. * @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
  94803. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94804. * @returns the current mesh
  94805. */
  94806. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94807. /**
  94808. * Sets the mesh indices,
  94809. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94810. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94811. * @param totalVertices Defines the total number of vertices
  94812. * @returns the current mesh
  94813. */
  94814. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94815. /**
  94816. * Gets a boolean indicating if specific vertex data is present
  94817. * @param kind defines the vertex data kind to use
  94818. * @returns true is data kind is present
  94819. */
  94820. isVerticesDataPresent(kind: string): boolean;
  94821. /**
  94822. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94823. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94824. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94825. * @returns a BoundingInfo
  94826. */
  94827. getBoundingInfo(): BoundingInfo;
  94828. /**
  94829. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94830. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94831. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94832. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94833. * @returns the current mesh
  94834. */
  94835. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94836. /**
  94837. * Overwrite the current bounding info
  94838. * @param boundingInfo defines the new bounding info
  94839. * @returns the current mesh
  94840. */
  94841. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94842. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94843. readonly useBones: boolean;
  94844. /** @hidden */
  94845. _preActivate(): void;
  94846. /** @hidden */
  94847. _preActivateForIntermediateRendering(renderId: number): void;
  94848. /** @hidden */
  94849. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94850. /** @hidden */
  94851. _postActivate(): void;
  94852. /** @hidden */
  94853. _freeze(): void;
  94854. /** @hidden */
  94855. _unFreeze(): void;
  94856. /**
  94857. * Gets the current world matrix
  94858. * @returns a Matrix
  94859. */
  94860. getWorldMatrix(): Matrix;
  94861. /** @hidden */
  94862. _getWorldMatrixDeterminant(): number;
  94863. /**
  94864. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94865. */
  94866. readonly isAnInstance: boolean;
  94867. /**
  94868. * Gets a boolean indicating if this mesh has instances
  94869. */
  94870. readonly hasInstances: boolean;
  94871. /**
  94872. * Perform relative position change from the point of view of behind the front of the mesh.
  94873. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94874. * Supports definition of mesh facing forward or backward
  94875. * @param amountRight defines the distance on the right axis
  94876. * @param amountUp defines the distance on the up axis
  94877. * @param amountForward defines the distance on the forward axis
  94878. * @returns the current mesh
  94879. */
  94880. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94881. /**
  94882. * Calculate relative position change from the point of view of behind the front of the mesh.
  94883. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94884. * Supports definition of mesh facing forward or backward
  94885. * @param amountRight defines the distance on the right axis
  94886. * @param amountUp defines the distance on the up axis
  94887. * @param amountForward defines the distance on the forward axis
  94888. * @returns the new displacement vector
  94889. */
  94890. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94891. /**
  94892. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94893. * Supports definition of mesh facing forward or backward
  94894. * @param flipBack defines the flip
  94895. * @param twirlClockwise defines the twirl
  94896. * @param tiltRight defines the tilt
  94897. * @returns the current mesh
  94898. */
  94899. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94900. /**
  94901. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94902. * Supports definition of mesh facing forward or backward.
  94903. * @param flipBack defines the flip
  94904. * @param twirlClockwise defines the twirl
  94905. * @param tiltRight defines the tilt
  94906. * @returns the new rotation vector
  94907. */
  94908. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94909. /**
  94910. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94911. * This means the mesh underlying bounding box and sphere are recomputed.
  94912. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94913. * @returns the current mesh
  94914. */
  94915. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94916. /** @hidden */
  94917. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94918. /** @hidden */
  94919. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94920. /** @hidden */
  94921. _updateBoundingInfo(): AbstractMesh;
  94922. /** @hidden */
  94923. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94924. /** @hidden */
  94925. protected _afterComputeWorldMatrix(): void;
  94926. /** @hidden */
  94927. readonly _effectiveMesh: AbstractMesh;
  94928. /**
  94929. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94930. * A mesh is in the frustum if its bounding box intersects the frustum
  94931. * @param frustumPlanes defines the frustum to test
  94932. * @returns true if the mesh is in the frustum planes
  94933. */
  94934. isInFrustum(frustumPlanes: Plane[]): boolean;
  94935. /**
  94936. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94937. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94938. * @param frustumPlanes defines the frustum to test
  94939. * @returns true if the mesh is completely in the frustum planes
  94940. */
  94941. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94942. /**
  94943. * True if the mesh intersects another mesh or a SolidParticle object
  94944. * @param mesh defines a target mesh or SolidParticle to test
  94945. * @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)
  94946. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94947. * @returns true if there is an intersection
  94948. */
  94949. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94950. /**
  94951. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94952. * @param point defines the point to test
  94953. * @returns true if there is an intersection
  94954. */
  94955. intersectsPoint(point: Vector3): boolean;
  94956. /**
  94957. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94959. */
  94960. checkCollisions: boolean;
  94961. /**
  94962. * Gets Collider object used to compute collisions (not physics)
  94963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94964. */
  94965. readonly collider: Nullable<Collider>;
  94966. /**
  94967. * Move the mesh using collision engine
  94968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94969. * @param displacement defines the requested displacement vector
  94970. * @returns the current mesh
  94971. */
  94972. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94973. private _onCollisionPositionChange;
  94974. /** @hidden */
  94975. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94976. /** @hidden */
  94977. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94978. /** @hidden */
  94979. _checkCollision(collider: Collider): AbstractMesh;
  94980. /** @hidden */
  94981. _generatePointsArray(): boolean;
  94982. /**
  94983. * Checks if the passed Ray intersects with the mesh
  94984. * @param ray defines the ray to use
  94985. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94986. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94987. * @returns the picking info
  94988. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94989. */
  94990. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94991. /**
  94992. * Clones the current mesh
  94993. * @param name defines the mesh name
  94994. * @param newParent defines the new mesh parent
  94995. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94996. * @returns the new mesh
  94997. */
  94998. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94999. /**
  95000. * Disposes all the submeshes of the current meshnp
  95001. * @returns the current mesh
  95002. */
  95003. releaseSubMeshes(): AbstractMesh;
  95004. /**
  95005. * Releases resources associated with this abstract mesh.
  95006. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95007. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95008. */
  95009. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95010. /**
  95011. * Adds the passed mesh as a child to the current mesh
  95012. * @param mesh defines the child mesh
  95013. * @returns the current mesh
  95014. */
  95015. addChild(mesh: AbstractMesh): AbstractMesh;
  95016. /**
  95017. * Removes the passed mesh from the current mesh children list
  95018. * @param mesh defines the child mesh
  95019. * @returns the current mesh
  95020. */
  95021. removeChild(mesh: AbstractMesh): AbstractMesh;
  95022. /** @hidden */
  95023. private _initFacetData;
  95024. /**
  95025. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95026. * This method can be called within the render loop.
  95027. * 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
  95028. * @returns the current mesh
  95029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95030. */
  95031. updateFacetData(): AbstractMesh;
  95032. /**
  95033. * Returns the facetLocalNormals array.
  95034. * The normals are expressed in the mesh local spac
  95035. * @returns an array of Vector3
  95036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95037. */
  95038. getFacetLocalNormals(): Vector3[];
  95039. /**
  95040. * Returns the facetLocalPositions array.
  95041. * The facet positions are expressed in the mesh local space
  95042. * @returns an array of Vector3
  95043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95044. */
  95045. getFacetLocalPositions(): Vector3[];
  95046. /**
  95047. * Returns the facetLocalPartioning array
  95048. * @returns an array of array of numbers
  95049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95050. */
  95051. getFacetLocalPartitioning(): number[][];
  95052. /**
  95053. * Returns the i-th facet position in the world system.
  95054. * This method allocates a new Vector3 per call
  95055. * @param i defines the facet index
  95056. * @returns a new Vector3
  95057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95058. */
  95059. getFacetPosition(i: number): Vector3;
  95060. /**
  95061. * Sets the reference Vector3 with the i-th facet position in the world system
  95062. * @param i defines the facet index
  95063. * @param ref defines the target vector
  95064. * @returns the current mesh
  95065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95066. */
  95067. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95068. /**
  95069. * Returns the i-th facet normal in the world system.
  95070. * This method allocates a new Vector3 per call
  95071. * @param i defines the facet index
  95072. * @returns a new Vector3
  95073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95074. */
  95075. getFacetNormal(i: number): Vector3;
  95076. /**
  95077. * Sets the reference Vector3 with the i-th facet normal in the world system
  95078. * @param i defines the facet index
  95079. * @param ref defines the target vector
  95080. * @returns the current mesh
  95081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95082. */
  95083. getFacetNormalToRef(i: number, ref: Vector3): this;
  95084. /**
  95085. * 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)
  95086. * @param x defines x coordinate
  95087. * @param y defines y coordinate
  95088. * @param z defines z coordinate
  95089. * @returns the array of facet indexes
  95090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95091. */
  95092. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95093. /**
  95094. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95095. * @param projected sets as the (x,y,z) world projection on the facet
  95096. * @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
  95097. * @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
  95098. * @param x defines x coordinate
  95099. * @param y defines y coordinate
  95100. * @param z defines z coordinate
  95101. * @returns the face index if found (or null instead)
  95102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95103. */
  95104. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95105. /**
  95106. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95107. * @param projected sets as the (x,y,z) local projection on the facet
  95108. * @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
  95109. * @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
  95110. * @param x defines x coordinate
  95111. * @param y defines y coordinate
  95112. * @param z defines z coordinate
  95113. * @returns the face index if found (or null instead)
  95114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95115. */
  95116. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95117. /**
  95118. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95119. * @returns the parameters
  95120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95121. */
  95122. getFacetDataParameters(): any;
  95123. /**
  95124. * Disables the feature FacetData and frees the related memory
  95125. * @returns the current mesh
  95126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95127. */
  95128. disableFacetData(): AbstractMesh;
  95129. /**
  95130. * Updates the AbstractMesh indices array
  95131. * @param indices defines the data source
  95132. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95133. * @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)
  95134. * @returns the current mesh
  95135. */
  95136. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95137. /**
  95138. * Creates new normals data for the mesh
  95139. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95140. * @returns the current mesh
  95141. */
  95142. createNormals(updatable: boolean): AbstractMesh;
  95143. /**
  95144. * Align the mesh with a normal
  95145. * @param normal defines the normal to use
  95146. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95147. * @returns the current mesh
  95148. */
  95149. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95150. /** @hidden */
  95151. _checkOcclusionQuery(): boolean;
  95152. /**
  95153. * Disables the mesh edge rendering mode
  95154. * @returns the currentAbstractMesh
  95155. */
  95156. disableEdgesRendering(): AbstractMesh;
  95157. /**
  95158. * Enables the edge rendering mode on the mesh.
  95159. * This mode makes the mesh edges visible
  95160. * @param epsilon defines the maximal distance between two angles to detect a face
  95161. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95162. * @returns the currentAbstractMesh
  95163. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95164. */
  95165. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95166. }
  95167. }
  95168. declare module BABYLON {
  95169. /**
  95170. * Interface used to define ActionEvent
  95171. */
  95172. export interface IActionEvent {
  95173. /** The mesh or sprite that triggered the action */
  95174. source: any;
  95175. /** The X mouse cursor position at the time of the event */
  95176. pointerX: number;
  95177. /** The Y mouse cursor position at the time of the event */
  95178. pointerY: number;
  95179. /** The mesh that is currently pointed at (can be null) */
  95180. meshUnderPointer: Nullable<AbstractMesh>;
  95181. /** the original (browser) event that triggered the ActionEvent */
  95182. sourceEvent?: any;
  95183. /** additional data for the event */
  95184. additionalData?: any;
  95185. }
  95186. /**
  95187. * ActionEvent is the event being sent when an action is triggered.
  95188. */
  95189. export class ActionEvent implements IActionEvent {
  95190. /** The mesh or sprite that triggered the action */
  95191. source: any;
  95192. /** The X mouse cursor position at the time of the event */
  95193. pointerX: number;
  95194. /** The Y mouse cursor position at the time of the event */
  95195. pointerY: number;
  95196. /** The mesh that is currently pointed at (can be null) */
  95197. meshUnderPointer: Nullable<AbstractMesh>;
  95198. /** the original (browser) event that triggered the ActionEvent */
  95199. sourceEvent?: any;
  95200. /** additional data for the event */
  95201. additionalData?: any;
  95202. /**
  95203. * Creates a new ActionEvent
  95204. * @param source The mesh or sprite that triggered the action
  95205. * @param pointerX The X mouse cursor position at the time of the event
  95206. * @param pointerY The Y mouse cursor position at the time of the event
  95207. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95208. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95209. * @param additionalData additional data for the event
  95210. */
  95211. constructor(
  95212. /** The mesh or sprite that triggered the action */
  95213. source: any,
  95214. /** The X mouse cursor position at the time of the event */
  95215. pointerX: number,
  95216. /** The Y mouse cursor position at the time of the event */
  95217. pointerY: number,
  95218. /** The mesh that is currently pointed at (can be null) */
  95219. meshUnderPointer: Nullable<AbstractMesh>,
  95220. /** the original (browser) event that triggered the ActionEvent */
  95221. sourceEvent?: any,
  95222. /** additional data for the event */
  95223. additionalData?: any);
  95224. /**
  95225. * Helper function to auto-create an ActionEvent from a source mesh.
  95226. * @param source The source mesh that triggered the event
  95227. * @param evt The original (browser) event
  95228. * @param additionalData additional data for the event
  95229. * @returns the new ActionEvent
  95230. */
  95231. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95232. /**
  95233. * Helper function to auto-create an ActionEvent from a source sprite
  95234. * @param source The source sprite that triggered the event
  95235. * @param scene Scene associated with the sprite
  95236. * @param evt The original (browser) event
  95237. * @param additionalData additional data for the event
  95238. * @returns the new ActionEvent
  95239. */
  95240. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95241. /**
  95242. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95243. * @param scene the scene where the event occurred
  95244. * @param evt The original (browser) event
  95245. * @returns the new ActionEvent
  95246. */
  95247. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95248. /**
  95249. * Helper function to auto-create an ActionEvent from a primitive
  95250. * @param prim defines the target primitive
  95251. * @param pointerPos defines the pointer position
  95252. * @param evt The original (browser) event
  95253. * @param additionalData additional data for the event
  95254. * @returns the new ActionEvent
  95255. */
  95256. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95257. }
  95258. }
  95259. declare module BABYLON {
  95260. /**
  95261. * Abstract class used to decouple action Manager from scene and meshes.
  95262. * Do not instantiate.
  95263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95264. */
  95265. export abstract class AbstractActionManager implements IDisposable {
  95266. /** Gets the list of active triggers */
  95267. static Triggers: {
  95268. [key: string]: number;
  95269. };
  95270. /** Gets the cursor to use when hovering items */
  95271. hoverCursor: string;
  95272. /** Gets the list of actions */
  95273. actions: IAction[];
  95274. /**
  95275. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95276. */
  95277. isRecursive: boolean;
  95278. /**
  95279. * Releases all associated resources
  95280. */
  95281. abstract dispose(): void;
  95282. /**
  95283. * Does this action manager has pointer triggers
  95284. */
  95285. abstract readonly hasPointerTriggers: boolean;
  95286. /**
  95287. * Does this action manager has pick triggers
  95288. */
  95289. abstract readonly hasPickTriggers: boolean;
  95290. /**
  95291. * Process a specific trigger
  95292. * @param trigger defines the trigger to process
  95293. * @param evt defines the event details to be processed
  95294. */
  95295. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95296. /**
  95297. * Does this action manager handles actions of any of the given triggers
  95298. * @param triggers defines the triggers to be tested
  95299. * @return a boolean indicating whether one (or more) of the triggers is handled
  95300. */
  95301. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95302. /**
  95303. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95304. * speed.
  95305. * @param triggerA defines the trigger to be tested
  95306. * @param triggerB defines the trigger to be tested
  95307. * @return a boolean indicating whether one (or more) of the triggers is handled
  95308. */
  95309. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95310. /**
  95311. * Does this action manager handles actions of a given trigger
  95312. * @param trigger defines the trigger to be tested
  95313. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95314. * @return whether the trigger is handled
  95315. */
  95316. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95317. /**
  95318. * Serialize this manager to a JSON object
  95319. * @param name defines the property name to store this manager
  95320. * @returns a JSON representation of this manager
  95321. */
  95322. abstract serialize(name: string): any;
  95323. /**
  95324. * Registers an action to this action manager
  95325. * @param action defines the action to be registered
  95326. * @return the action amended (prepared) after registration
  95327. */
  95328. abstract registerAction(action: IAction): Nullable<IAction>;
  95329. /**
  95330. * Unregisters an action to this action manager
  95331. * @param action defines the action to be unregistered
  95332. * @return a boolean indicating whether the action has been unregistered
  95333. */
  95334. abstract unregisterAction(action: IAction): Boolean;
  95335. /**
  95336. * Does exist one action manager with at least one trigger
  95337. **/
  95338. static readonly HasTriggers: boolean;
  95339. /**
  95340. * Does exist one action manager with at least one pick trigger
  95341. **/
  95342. static readonly HasPickTriggers: boolean;
  95343. /**
  95344. * Does exist one action manager that handles actions of a given trigger
  95345. * @param trigger defines the trigger to be tested
  95346. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95347. **/
  95348. static HasSpecificTrigger(trigger: number): boolean;
  95349. }
  95350. }
  95351. declare module BABYLON {
  95352. /**
  95353. * Defines how a node can be built from a string name.
  95354. */
  95355. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95356. /**
  95357. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95358. */
  95359. export class Node implements IBehaviorAware<Node> {
  95360. /** @hidden */
  95361. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95362. private static _NodeConstructors;
  95363. /**
  95364. * Add a new node constructor
  95365. * @param type defines the type name of the node to construct
  95366. * @param constructorFunc defines the constructor function
  95367. */
  95368. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95369. /**
  95370. * Returns a node constructor based on type name
  95371. * @param type defines the type name
  95372. * @param name defines the new node name
  95373. * @param scene defines the hosting scene
  95374. * @param options defines optional options to transmit to constructors
  95375. * @returns the new constructor or null
  95376. */
  95377. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95378. /**
  95379. * Gets or sets the name of the node
  95380. */
  95381. name: string;
  95382. /**
  95383. * Gets or sets the id of the node
  95384. */
  95385. id: string;
  95386. /**
  95387. * Gets or sets the unique id of the node
  95388. */
  95389. uniqueId: number;
  95390. /**
  95391. * Gets or sets a string used to store user defined state for the node
  95392. */
  95393. state: string;
  95394. /**
  95395. * Gets or sets an object used to store user defined information for the node
  95396. */
  95397. metadata: any;
  95398. /**
  95399. * For internal use only. Please do not use.
  95400. */
  95401. reservedDataStore: any;
  95402. /**
  95403. * List of inspectable custom properties (used by the Inspector)
  95404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95405. */
  95406. inspectableCustomProperties: IInspectable[];
  95407. private _doNotSerialize;
  95408. /**
  95409. * Gets or sets a boolean used to define if the node must be serialized
  95410. */
  95411. doNotSerialize: boolean;
  95412. /** @hidden */
  95413. _isDisposed: boolean;
  95414. /**
  95415. * Gets a list of Animations associated with the node
  95416. */
  95417. animations: Animation[];
  95418. protected _ranges: {
  95419. [name: string]: Nullable<AnimationRange>;
  95420. };
  95421. /**
  95422. * Callback raised when the node is ready to be used
  95423. */
  95424. onReady: Nullable<(node: Node) => void>;
  95425. private _isEnabled;
  95426. private _isParentEnabled;
  95427. private _isReady;
  95428. /** @hidden */
  95429. _currentRenderId: number;
  95430. private _parentUpdateId;
  95431. /** @hidden */
  95432. _childUpdateId: number;
  95433. /** @hidden */
  95434. _waitingParentId: Nullable<string>;
  95435. /** @hidden */
  95436. _scene: Scene;
  95437. /** @hidden */
  95438. _cache: any;
  95439. private _parentNode;
  95440. private _children;
  95441. /** @hidden */
  95442. _worldMatrix: Matrix;
  95443. /** @hidden */
  95444. _worldMatrixDeterminant: number;
  95445. /** @hidden */
  95446. _worldMatrixDeterminantIsDirty: boolean;
  95447. /** @hidden */
  95448. private _sceneRootNodesIndex;
  95449. /**
  95450. * Gets a boolean indicating if the node has been disposed
  95451. * @returns true if the node was disposed
  95452. */
  95453. isDisposed(): boolean;
  95454. /**
  95455. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95456. * @see https://doc.babylonjs.com/how_to/parenting
  95457. */
  95458. parent: Nullable<Node>;
  95459. /** @hidden */
  95460. _addToSceneRootNodes(): void;
  95461. /** @hidden */
  95462. _removeFromSceneRootNodes(): void;
  95463. private _animationPropertiesOverride;
  95464. /**
  95465. * Gets or sets the animation properties override
  95466. */
  95467. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95468. /**
  95469. * Gets a string idenfifying the name of the class
  95470. * @returns "Node" string
  95471. */
  95472. getClassName(): string;
  95473. /** @hidden */
  95474. readonly _isNode: boolean;
  95475. /**
  95476. * An event triggered when the mesh is disposed
  95477. */
  95478. onDisposeObservable: Observable<Node>;
  95479. private _onDisposeObserver;
  95480. /**
  95481. * Sets a callback that will be raised when the node will be disposed
  95482. */
  95483. onDispose: () => void;
  95484. /**
  95485. * Creates a new Node
  95486. * @param name the name and id to be given to this node
  95487. * @param scene the scene this node will be added to
  95488. */
  95489. constructor(name: string, scene?: Nullable<Scene>);
  95490. /**
  95491. * Gets the scene of the node
  95492. * @returns a scene
  95493. */
  95494. getScene(): Scene;
  95495. /**
  95496. * Gets the engine of the node
  95497. * @returns a Engine
  95498. */
  95499. getEngine(): Engine;
  95500. private _behaviors;
  95501. /**
  95502. * Attach a behavior to the node
  95503. * @see http://doc.babylonjs.com/features/behaviour
  95504. * @param behavior defines the behavior to attach
  95505. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95506. * @returns the current Node
  95507. */
  95508. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95509. /**
  95510. * Remove an attached behavior
  95511. * @see http://doc.babylonjs.com/features/behaviour
  95512. * @param behavior defines the behavior to attach
  95513. * @returns the current Node
  95514. */
  95515. removeBehavior(behavior: Behavior<Node>): Node;
  95516. /**
  95517. * Gets the list of attached behaviors
  95518. * @see http://doc.babylonjs.com/features/behaviour
  95519. */
  95520. readonly behaviors: Behavior<Node>[];
  95521. /**
  95522. * Gets an attached behavior by name
  95523. * @param name defines the name of the behavior to look for
  95524. * @see http://doc.babylonjs.com/features/behaviour
  95525. * @returns null if behavior was not found else the requested behavior
  95526. */
  95527. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95528. /**
  95529. * Returns the latest update of the World matrix
  95530. * @returns a Matrix
  95531. */
  95532. getWorldMatrix(): Matrix;
  95533. /** @hidden */
  95534. _getWorldMatrixDeterminant(): number;
  95535. /**
  95536. * Returns directly the latest state of the mesh World matrix.
  95537. * A Matrix is returned.
  95538. */
  95539. readonly worldMatrixFromCache: Matrix;
  95540. /** @hidden */
  95541. _initCache(): void;
  95542. /** @hidden */
  95543. updateCache(force?: boolean): void;
  95544. /** @hidden */
  95545. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95546. /** @hidden */
  95547. _updateCache(ignoreParentClass?: boolean): void;
  95548. /** @hidden */
  95549. _isSynchronized(): boolean;
  95550. /** @hidden */
  95551. _markSyncedWithParent(): void;
  95552. /** @hidden */
  95553. isSynchronizedWithParent(): boolean;
  95554. /** @hidden */
  95555. isSynchronized(): boolean;
  95556. /**
  95557. * Is this node ready to be used/rendered
  95558. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95559. * @return true if the node is ready
  95560. */
  95561. isReady(completeCheck?: boolean): boolean;
  95562. /**
  95563. * Is this node enabled?
  95564. * 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
  95565. * @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
  95566. * @return whether this node (and its parent) is enabled
  95567. */
  95568. isEnabled(checkAncestors?: boolean): boolean;
  95569. /** @hidden */
  95570. protected _syncParentEnabledState(): void;
  95571. /**
  95572. * Set the enabled state of this node
  95573. * @param value defines the new enabled state
  95574. */
  95575. setEnabled(value: boolean): void;
  95576. /**
  95577. * Is this node a descendant of the given node?
  95578. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95579. * @param ancestor defines the parent node to inspect
  95580. * @returns a boolean indicating if this node is a descendant of the given node
  95581. */
  95582. isDescendantOf(ancestor: Node): boolean;
  95583. /** @hidden */
  95584. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95585. /**
  95586. * Will return all nodes that have this node as ascendant
  95587. * @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
  95588. * @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
  95589. * @return all children nodes of all types
  95590. */
  95591. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95592. /**
  95593. * Get all child-meshes of this node
  95594. * @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)
  95595. * @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
  95596. * @returns an array of AbstractMesh
  95597. */
  95598. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95599. /**
  95600. * Get all direct children of this node
  95601. * @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
  95602. * @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)
  95603. * @returns an array of Node
  95604. */
  95605. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95606. /** @hidden */
  95607. _setReady(state: boolean): void;
  95608. /**
  95609. * Get an animation by name
  95610. * @param name defines the name of the animation to look for
  95611. * @returns null if not found else the requested animation
  95612. */
  95613. getAnimationByName(name: string): Nullable<Animation>;
  95614. /**
  95615. * Creates an animation range for this node
  95616. * @param name defines the name of the range
  95617. * @param from defines the starting key
  95618. * @param to defines the end key
  95619. */
  95620. createAnimationRange(name: string, from: number, to: number): void;
  95621. /**
  95622. * Delete a specific animation range
  95623. * @param name defines the name of the range to delete
  95624. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95625. */
  95626. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95627. /**
  95628. * Get an animation range by name
  95629. * @param name defines the name of the animation range to look for
  95630. * @returns null if not found else the requested animation range
  95631. */
  95632. getAnimationRange(name: string): Nullable<AnimationRange>;
  95633. /**
  95634. * Gets the list of all animation ranges defined on this node
  95635. * @returns an array
  95636. */
  95637. getAnimationRanges(): Nullable<AnimationRange>[];
  95638. /**
  95639. * Will start the animation sequence
  95640. * @param name defines the range frames for animation sequence
  95641. * @param loop defines if the animation should loop (false by default)
  95642. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95643. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95644. * @returns the object created for this animation. If range does not exist, it will return null
  95645. */
  95646. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95647. /**
  95648. * Serialize animation ranges into a JSON compatible object
  95649. * @returns serialization object
  95650. */
  95651. serializeAnimationRanges(): any;
  95652. /**
  95653. * Computes the world matrix of the node
  95654. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95655. * @returns the world matrix
  95656. */
  95657. computeWorldMatrix(force?: boolean): Matrix;
  95658. /**
  95659. * Releases resources associated with this node.
  95660. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95661. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95662. */
  95663. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95664. /**
  95665. * Parse animation range data from a serialization object and store them into a given node
  95666. * @param node defines where to store the animation ranges
  95667. * @param parsedNode defines the serialization object to read data from
  95668. * @param scene defines the hosting scene
  95669. */
  95670. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95671. /**
  95672. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95673. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95674. * @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
  95675. * @returns the new bounding vectors
  95676. */
  95677. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95678. min: Vector3;
  95679. max: Vector3;
  95680. };
  95681. }
  95682. }
  95683. declare module BABYLON {
  95684. /**
  95685. * @hidden
  95686. */
  95687. export class _IAnimationState {
  95688. key: number;
  95689. repeatCount: number;
  95690. workValue?: any;
  95691. loopMode?: number;
  95692. offsetValue?: any;
  95693. highLimitValue?: any;
  95694. }
  95695. /**
  95696. * Class used to store any kind of animation
  95697. */
  95698. export class Animation {
  95699. /**Name of the animation */
  95700. name: string;
  95701. /**Property to animate */
  95702. targetProperty: string;
  95703. /**The frames per second of the animation */
  95704. framePerSecond: number;
  95705. /**The data type of the animation */
  95706. dataType: number;
  95707. /**The loop mode of the animation */
  95708. loopMode?: number | undefined;
  95709. /**Specifies if blending should be enabled */
  95710. enableBlending?: boolean | undefined;
  95711. /**
  95712. * Use matrix interpolation instead of using direct key value when animating matrices
  95713. */
  95714. static AllowMatricesInterpolation: boolean;
  95715. /**
  95716. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95717. */
  95718. static AllowMatrixDecomposeForInterpolation: boolean;
  95719. /**
  95720. * Stores the key frames of the animation
  95721. */
  95722. private _keys;
  95723. /**
  95724. * Stores the easing function of the animation
  95725. */
  95726. private _easingFunction;
  95727. /**
  95728. * @hidden Internal use only
  95729. */
  95730. _runtimeAnimations: RuntimeAnimation[];
  95731. /**
  95732. * The set of event that will be linked to this animation
  95733. */
  95734. private _events;
  95735. /**
  95736. * Stores an array of target property paths
  95737. */
  95738. targetPropertyPath: string[];
  95739. /**
  95740. * Stores the blending speed of the animation
  95741. */
  95742. blendingSpeed: number;
  95743. /**
  95744. * Stores the animation ranges for the animation
  95745. */
  95746. private _ranges;
  95747. /**
  95748. * @hidden Internal use
  95749. */
  95750. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95751. /**
  95752. * Sets up an animation
  95753. * @param property The property to animate
  95754. * @param animationType The animation type to apply
  95755. * @param framePerSecond The frames per second of the animation
  95756. * @param easingFunction The easing function used in the animation
  95757. * @returns The created animation
  95758. */
  95759. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95760. /**
  95761. * Create and start an animation on a node
  95762. * @param name defines the name of the global animation that will be run on all nodes
  95763. * @param node defines the root node where the animation will take place
  95764. * @param targetProperty defines property to animate
  95765. * @param framePerSecond defines the number of frame per second yo use
  95766. * @param totalFrame defines the number of frames in total
  95767. * @param from defines the initial value
  95768. * @param to defines the final value
  95769. * @param loopMode defines which loop mode you want to use (off by default)
  95770. * @param easingFunction defines the easing function to use (linear by default)
  95771. * @param onAnimationEnd defines the callback to call when animation end
  95772. * @returns the animatable created for this animation
  95773. */
  95774. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95775. /**
  95776. * Create and start an animation on a node and its descendants
  95777. * @param name defines the name of the global animation that will be run on all nodes
  95778. * @param node defines the root node where the animation will take place
  95779. * @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
  95780. * @param targetProperty defines property to animate
  95781. * @param framePerSecond defines the number of frame per second to use
  95782. * @param totalFrame defines the number of frames in total
  95783. * @param from defines the initial value
  95784. * @param to defines the final value
  95785. * @param loopMode defines which loop mode you want to use (off by default)
  95786. * @param easingFunction defines the easing function to use (linear by default)
  95787. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95788. * @returns the list of animatables created for all nodes
  95789. * @example https://www.babylonjs-playground.com/#MH0VLI
  95790. */
  95791. 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[]>;
  95792. /**
  95793. * Creates a new animation, merges it with the existing animations and starts it
  95794. * @param name Name of the animation
  95795. * @param node Node which contains the scene that begins the animations
  95796. * @param targetProperty Specifies which property to animate
  95797. * @param framePerSecond The frames per second of the animation
  95798. * @param totalFrame The total number of frames
  95799. * @param from The frame at the beginning of the animation
  95800. * @param to The frame at the end of the animation
  95801. * @param loopMode Specifies the loop mode of the animation
  95802. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95803. * @param onAnimationEnd Callback to run once the animation is complete
  95804. * @returns Nullable animation
  95805. */
  95806. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95807. /**
  95808. * Transition property of an host to the target Value
  95809. * @param property The property to transition
  95810. * @param targetValue The target Value of the property
  95811. * @param host The object where the property to animate belongs
  95812. * @param scene Scene used to run the animation
  95813. * @param frameRate Framerate (in frame/s) to use
  95814. * @param transition The transition type we want to use
  95815. * @param duration The duration of the animation, in milliseconds
  95816. * @param onAnimationEnd Callback trigger at the end of the animation
  95817. * @returns Nullable animation
  95818. */
  95819. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95820. /**
  95821. * Return the array of runtime animations currently using this animation
  95822. */
  95823. readonly runtimeAnimations: RuntimeAnimation[];
  95824. /**
  95825. * Specifies if any of the runtime animations are currently running
  95826. */
  95827. readonly hasRunningRuntimeAnimations: boolean;
  95828. /**
  95829. * Initializes the animation
  95830. * @param name Name of the animation
  95831. * @param targetProperty Property to animate
  95832. * @param framePerSecond The frames per second of the animation
  95833. * @param dataType The data type of the animation
  95834. * @param loopMode The loop mode of the animation
  95835. * @param enableBlending Specifies if blending should be enabled
  95836. */
  95837. constructor(
  95838. /**Name of the animation */
  95839. name: string,
  95840. /**Property to animate */
  95841. targetProperty: string,
  95842. /**The frames per second of the animation */
  95843. framePerSecond: number,
  95844. /**The data type of the animation */
  95845. dataType: number,
  95846. /**The loop mode of the animation */
  95847. loopMode?: number | undefined,
  95848. /**Specifies if blending should be enabled */
  95849. enableBlending?: boolean | undefined);
  95850. /**
  95851. * Converts the animation to a string
  95852. * @param fullDetails support for multiple levels of logging within scene loading
  95853. * @returns String form of the animation
  95854. */
  95855. toString(fullDetails?: boolean): string;
  95856. /**
  95857. * Add an event to this animation
  95858. * @param event Event to add
  95859. */
  95860. addEvent(event: AnimationEvent): void;
  95861. /**
  95862. * Remove all events found at the given frame
  95863. * @param frame The frame to remove events from
  95864. */
  95865. removeEvents(frame: number): void;
  95866. /**
  95867. * Retrieves all the events from the animation
  95868. * @returns Events from the animation
  95869. */
  95870. getEvents(): AnimationEvent[];
  95871. /**
  95872. * Creates an animation range
  95873. * @param name Name of the animation range
  95874. * @param from Starting frame of the animation range
  95875. * @param to Ending frame of the animation
  95876. */
  95877. createRange(name: string, from: number, to: number): void;
  95878. /**
  95879. * Deletes an animation range by name
  95880. * @param name Name of the animation range to delete
  95881. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95882. */
  95883. deleteRange(name: string, deleteFrames?: boolean): void;
  95884. /**
  95885. * Gets the animation range by name, or null if not defined
  95886. * @param name Name of the animation range
  95887. * @returns Nullable animation range
  95888. */
  95889. getRange(name: string): Nullable<AnimationRange>;
  95890. /**
  95891. * Gets the key frames from the animation
  95892. * @returns The key frames of the animation
  95893. */
  95894. getKeys(): Array<IAnimationKey>;
  95895. /**
  95896. * Gets the highest frame rate of the animation
  95897. * @returns Highest frame rate of the animation
  95898. */
  95899. getHighestFrame(): number;
  95900. /**
  95901. * Gets the easing function of the animation
  95902. * @returns Easing function of the animation
  95903. */
  95904. getEasingFunction(): IEasingFunction;
  95905. /**
  95906. * Sets the easing function of the animation
  95907. * @param easingFunction A custom mathematical formula for animation
  95908. */
  95909. setEasingFunction(easingFunction: EasingFunction): void;
  95910. /**
  95911. * Interpolates a scalar linearly
  95912. * @param startValue Start value of the animation curve
  95913. * @param endValue End value of the animation curve
  95914. * @param gradient Scalar amount to interpolate
  95915. * @returns Interpolated scalar value
  95916. */
  95917. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95918. /**
  95919. * Interpolates a scalar cubically
  95920. * @param startValue Start value of the animation curve
  95921. * @param outTangent End tangent of the animation
  95922. * @param endValue End value of the animation curve
  95923. * @param inTangent Start tangent of the animation curve
  95924. * @param gradient Scalar amount to interpolate
  95925. * @returns Interpolated scalar value
  95926. */
  95927. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95928. /**
  95929. * Interpolates a quaternion using a spherical linear interpolation
  95930. * @param startValue Start value of the animation curve
  95931. * @param endValue End value of the animation curve
  95932. * @param gradient Scalar amount to interpolate
  95933. * @returns Interpolated quaternion value
  95934. */
  95935. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95936. /**
  95937. * Interpolates a quaternion cubically
  95938. * @param startValue Start value of the animation curve
  95939. * @param outTangent End tangent of the animation curve
  95940. * @param endValue End value of the animation curve
  95941. * @param inTangent Start tangent of the animation curve
  95942. * @param gradient Scalar amount to interpolate
  95943. * @returns Interpolated quaternion value
  95944. */
  95945. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95946. /**
  95947. * Interpolates a Vector3 linearl
  95948. * @param startValue Start value of the animation curve
  95949. * @param endValue End value of the animation curve
  95950. * @param gradient Scalar amount to interpolate
  95951. * @returns Interpolated scalar value
  95952. */
  95953. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95954. /**
  95955. * Interpolates a Vector3 cubically
  95956. * @param startValue Start value of the animation curve
  95957. * @param outTangent End tangent of the animation
  95958. * @param endValue End value of the animation curve
  95959. * @param inTangent Start tangent of the animation curve
  95960. * @param gradient Scalar amount to interpolate
  95961. * @returns InterpolatedVector3 value
  95962. */
  95963. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95964. /**
  95965. * Interpolates a Vector2 linearly
  95966. * @param startValue Start value of the animation curve
  95967. * @param endValue End value of the animation curve
  95968. * @param gradient Scalar amount to interpolate
  95969. * @returns Interpolated Vector2 value
  95970. */
  95971. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95972. /**
  95973. * Interpolates a Vector2 cubically
  95974. * @param startValue Start value of the animation curve
  95975. * @param outTangent End tangent of the animation
  95976. * @param endValue End value of the animation curve
  95977. * @param inTangent Start tangent of the animation curve
  95978. * @param gradient Scalar amount to interpolate
  95979. * @returns Interpolated Vector2 value
  95980. */
  95981. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95982. /**
  95983. * Interpolates a size linearly
  95984. * @param startValue Start value of the animation curve
  95985. * @param endValue End value of the animation curve
  95986. * @param gradient Scalar amount to interpolate
  95987. * @returns Interpolated Size value
  95988. */
  95989. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95990. /**
  95991. * Interpolates a Color3 linearly
  95992. * @param startValue Start value of the animation curve
  95993. * @param endValue End value of the animation curve
  95994. * @param gradient Scalar amount to interpolate
  95995. * @returns Interpolated Color3 value
  95996. */
  95997. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95998. /**
  95999. * Interpolates a Color4 linearly
  96000. * @param startValue Start value of the animation curve
  96001. * @param endValue End value of the animation curve
  96002. * @param gradient Scalar amount to interpolate
  96003. * @returns Interpolated Color3 value
  96004. */
  96005. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  96006. /**
  96007. * @hidden Internal use only
  96008. */
  96009. _getKeyValue(value: any): any;
  96010. /**
  96011. * @hidden Internal use only
  96012. */
  96013. _interpolate(currentFrame: number, state: _IAnimationState): any;
  96014. /**
  96015. * Defines the function to use to interpolate matrices
  96016. * @param startValue defines the start matrix
  96017. * @param endValue defines the end matrix
  96018. * @param gradient defines the gradient between both matrices
  96019. * @param result defines an optional target matrix where to store the interpolation
  96020. * @returns the interpolated matrix
  96021. */
  96022. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96023. /**
  96024. * Makes a copy of the animation
  96025. * @returns Cloned animation
  96026. */
  96027. clone(): Animation;
  96028. /**
  96029. * Sets the key frames of the animation
  96030. * @param values The animation key frames to set
  96031. */
  96032. setKeys(values: Array<IAnimationKey>): void;
  96033. /**
  96034. * Serializes the animation to an object
  96035. * @returns Serialized object
  96036. */
  96037. serialize(): any;
  96038. /**
  96039. * Float animation type
  96040. */
  96041. static readonly ANIMATIONTYPE_FLOAT: number;
  96042. /**
  96043. * Vector3 animation type
  96044. */
  96045. static readonly ANIMATIONTYPE_VECTOR3: number;
  96046. /**
  96047. * Quaternion animation type
  96048. */
  96049. static readonly ANIMATIONTYPE_QUATERNION: number;
  96050. /**
  96051. * Matrix animation type
  96052. */
  96053. static readonly ANIMATIONTYPE_MATRIX: number;
  96054. /**
  96055. * Color3 animation type
  96056. */
  96057. static readonly ANIMATIONTYPE_COLOR3: number;
  96058. /**
  96059. * Color3 animation type
  96060. */
  96061. static readonly ANIMATIONTYPE_COLOR4: number;
  96062. /**
  96063. * Vector2 animation type
  96064. */
  96065. static readonly ANIMATIONTYPE_VECTOR2: number;
  96066. /**
  96067. * Size animation type
  96068. */
  96069. static readonly ANIMATIONTYPE_SIZE: number;
  96070. /**
  96071. * Relative Loop Mode
  96072. */
  96073. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96074. /**
  96075. * Cycle Loop Mode
  96076. */
  96077. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96078. /**
  96079. * Constant Loop Mode
  96080. */
  96081. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96082. /** @hidden */
  96083. static _UniversalLerp(left: any, right: any, amount: number): any;
  96084. /**
  96085. * Parses an animation object and creates an animation
  96086. * @param parsedAnimation Parsed animation object
  96087. * @returns Animation object
  96088. */
  96089. static Parse(parsedAnimation: any): Animation;
  96090. /**
  96091. * Appends the serialized animations from the source animations
  96092. * @param source Source containing the animations
  96093. * @param destination Target to store the animations
  96094. */
  96095. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96096. }
  96097. }
  96098. declare module BABYLON {
  96099. /**
  96100. * Interface containing an array of animations
  96101. */
  96102. export interface IAnimatable {
  96103. /**
  96104. * Array of animations
  96105. */
  96106. animations: Nullable<Array<Animation>>;
  96107. }
  96108. }
  96109. declare module BABYLON {
  96110. /**
  96111. * This represents all the required information to add a fresnel effect on a material:
  96112. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96113. */
  96114. export class FresnelParameters {
  96115. private _isEnabled;
  96116. /**
  96117. * Define if the fresnel effect is enable or not.
  96118. */
  96119. isEnabled: boolean;
  96120. /**
  96121. * Define the color used on edges (grazing angle)
  96122. */
  96123. leftColor: Color3;
  96124. /**
  96125. * Define the color used on center
  96126. */
  96127. rightColor: Color3;
  96128. /**
  96129. * Define bias applied to computed fresnel term
  96130. */
  96131. bias: number;
  96132. /**
  96133. * Defined the power exponent applied to fresnel term
  96134. */
  96135. power: number;
  96136. /**
  96137. * Clones the current fresnel and its valuues
  96138. * @returns a clone fresnel configuration
  96139. */
  96140. clone(): FresnelParameters;
  96141. /**
  96142. * Serializes the current fresnel parameters to a JSON representation.
  96143. * @return the JSON serialization
  96144. */
  96145. serialize(): any;
  96146. /**
  96147. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96148. * @param parsedFresnelParameters Define the JSON representation
  96149. * @returns the parsed parameters
  96150. */
  96151. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96152. }
  96153. }
  96154. declare module BABYLON {
  96155. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96156. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96157. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96158. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96159. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96160. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96161. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96162. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96163. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96164. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96165. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96166. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96167. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96168. /**
  96169. * Decorator used to define property that can be serialized as reference to a camera
  96170. * @param sourceName defines the name of the property to decorate
  96171. */
  96172. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96173. /**
  96174. * Class used to help serialization objects
  96175. */
  96176. export class SerializationHelper {
  96177. /** @hidden */
  96178. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96179. /** @hidden */
  96180. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96181. /** @hidden */
  96182. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96183. /** @hidden */
  96184. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96185. /**
  96186. * Appends the serialized animations from the source animations
  96187. * @param source Source containing the animations
  96188. * @param destination Target to store the animations
  96189. */
  96190. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96191. /**
  96192. * Static function used to serialized a specific entity
  96193. * @param entity defines the entity to serialize
  96194. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96195. * @returns a JSON compatible object representing the serialization of the entity
  96196. */
  96197. static Serialize<T>(entity: T, serializationObject?: any): any;
  96198. /**
  96199. * Creates a new entity from a serialization data object
  96200. * @param creationFunction defines a function used to instanciated the new entity
  96201. * @param source defines the source serialization data
  96202. * @param scene defines the hosting scene
  96203. * @param rootUrl defines the root url for resources
  96204. * @returns a new entity
  96205. */
  96206. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96207. /**
  96208. * Clones an object
  96209. * @param creationFunction defines the function used to instanciate the new object
  96210. * @param source defines the source object
  96211. * @returns the cloned object
  96212. */
  96213. static Clone<T>(creationFunction: () => T, source: T): T;
  96214. /**
  96215. * Instanciates a new object based on a source one (some data will be shared between both object)
  96216. * @param creationFunction defines the function used to instanciate the new object
  96217. * @param source defines the source object
  96218. * @returns the new object
  96219. */
  96220. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96221. }
  96222. }
  96223. declare module BABYLON {
  96224. /**
  96225. * Class used to manipulate GUIDs
  96226. */
  96227. export class GUID {
  96228. /**
  96229. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96230. * Be aware Math.random() could cause collisions, but:
  96231. * "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"
  96232. * @returns a pseudo random id
  96233. */
  96234. static RandomId(): string;
  96235. }
  96236. }
  96237. declare module BABYLON {
  96238. /**
  96239. * Base class of all the textures in babylon.
  96240. * It groups all the common properties the materials, post process, lights... might need
  96241. * in order to make a correct use of the texture.
  96242. */
  96243. export class BaseTexture implements IAnimatable {
  96244. /**
  96245. * Default anisotropic filtering level for the application.
  96246. * It is set to 4 as a good tradeoff between perf and quality.
  96247. */
  96248. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96249. /**
  96250. * Gets or sets the unique id of the texture
  96251. */
  96252. uniqueId: number;
  96253. /**
  96254. * Define the name of the texture.
  96255. */
  96256. name: string;
  96257. /**
  96258. * Gets or sets an object used to store user defined information.
  96259. */
  96260. metadata: any;
  96261. /**
  96262. * For internal use only. Please do not use.
  96263. */
  96264. reservedDataStore: any;
  96265. private _hasAlpha;
  96266. /**
  96267. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96268. */
  96269. hasAlpha: boolean;
  96270. /**
  96271. * Defines if the alpha value should be determined via the rgb values.
  96272. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96273. */
  96274. getAlphaFromRGB: boolean;
  96275. /**
  96276. * Intensity or strength of the texture.
  96277. * It is commonly used by materials to fine tune the intensity of the texture
  96278. */
  96279. level: number;
  96280. /**
  96281. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96282. * This is part of the texture as textures usually maps to one uv set.
  96283. */
  96284. coordinatesIndex: number;
  96285. private _coordinatesMode;
  96286. /**
  96287. * How a texture is mapped.
  96288. *
  96289. * | Value | Type | Description |
  96290. * | ----- | ----------------------------------- | ----------- |
  96291. * | 0 | EXPLICIT_MODE | |
  96292. * | 1 | SPHERICAL_MODE | |
  96293. * | 2 | PLANAR_MODE | |
  96294. * | 3 | CUBIC_MODE | |
  96295. * | 4 | PROJECTION_MODE | |
  96296. * | 5 | SKYBOX_MODE | |
  96297. * | 6 | INVCUBIC_MODE | |
  96298. * | 7 | EQUIRECTANGULAR_MODE | |
  96299. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96300. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96301. */
  96302. coordinatesMode: number;
  96303. /**
  96304. * | Value | Type | Description |
  96305. * | ----- | ------------------ | ----------- |
  96306. * | 0 | CLAMP_ADDRESSMODE | |
  96307. * | 1 | WRAP_ADDRESSMODE | |
  96308. * | 2 | MIRROR_ADDRESSMODE | |
  96309. */
  96310. wrapU: number;
  96311. /**
  96312. * | Value | Type | Description |
  96313. * | ----- | ------------------ | ----------- |
  96314. * | 0 | CLAMP_ADDRESSMODE | |
  96315. * | 1 | WRAP_ADDRESSMODE | |
  96316. * | 2 | MIRROR_ADDRESSMODE | |
  96317. */
  96318. wrapV: number;
  96319. /**
  96320. * | Value | Type | Description |
  96321. * | ----- | ------------------ | ----------- |
  96322. * | 0 | CLAMP_ADDRESSMODE | |
  96323. * | 1 | WRAP_ADDRESSMODE | |
  96324. * | 2 | MIRROR_ADDRESSMODE | |
  96325. */
  96326. wrapR: number;
  96327. /**
  96328. * With compliant hardware and browser (supporting anisotropic filtering)
  96329. * this defines the level of anisotropic filtering in the texture.
  96330. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96331. */
  96332. anisotropicFilteringLevel: number;
  96333. /**
  96334. * Define if the texture is a cube texture or if false a 2d texture.
  96335. */
  96336. isCube: boolean;
  96337. /**
  96338. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96339. */
  96340. is3D: boolean;
  96341. /**
  96342. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96343. */
  96344. is2DArray: boolean;
  96345. /**
  96346. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96347. * HDR texture are usually stored in linear space.
  96348. * This only impacts the PBR and Background materials
  96349. */
  96350. gammaSpace: boolean;
  96351. /**
  96352. * Gets or sets whether or not the texture contains RGBD data.
  96353. */
  96354. isRGBD: boolean;
  96355. /**
  96356. * Is Z inverted in the texture (useful in a cube texture).
  96357. */
  96358. invertZ: boolean;
  96359. /**
  96360. * Are mip maps generated for this texture or not.
  96361. */
  96362. readonly noMipmap: boolean;
  96363. /**
  96364. * @hidden
  96365. */
  96366. lodLevelInAlpha: boolean;
  96367. /**
  96368. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96369. */
  96370. lodGenerationOffset: number;
  96371. /**
  96372. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96373. */
  96374. lodGenerationScale: number;
  96375. /**
  96376. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96377. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96378. * average roughness values.
  96379. */
  96380. linearSpecularLOD: boolean;
  96381. /**
  96382. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96383. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96384. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96385. */
  96386. irradianceTexture: Nullable<BaseTexture>;
  96387. /**
  96388. * Define if the texture is a render target.
  96389. */
  96390. isRenderTarget: boolean;
  96391. /**
  96392. * Define the unique id of the texture in the scene.
  96393. */
  96394. readonly uid: string;
  96395. /**
  96396. * Return a string representation of the texture.
  96397. * @returns the texture as a string
  96398. */
  96399. toString(): string;
  96400. /**
  96401. * Get the class name of the texture.
  96402. * @returns "BaseTexture"
  96403. */
  96404. getClassName(): string;
  96405. /**
  96406. * Define the list of animation attached to the texture.
  96407. */
  96408. animations: Animation[];
  96409. /**
  96410. * An event triggered when the texture is disposed.
  96411. */
  96412. onDisposeObservable: Observable<BaseTexture>;
  96413. private _onDisposeObserver;
  96414. /**
  96415. * Callback triggered when the texture has been disposed.
  96416. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96417. */
  96418. onDispose: () => void;
  96419. /**
  96420. * Define the current state of the loading sequence when in delayed load mode.
  96421. */
  96422. delayLoadState: number;
  96423. private _scene;
  96424. /** @hidden */
  96425. _texture: Nullable<InternalTexture>;
  96426. private _uid;
  96427. /**
  96428. * Define if the texture is preventinga material to render or not.
  96429. * If not and the texture is not ready, the engine will use a default black texture instead.
  96430. */
  96431. readonly isBlocking: boolean;
  96432. /**
  96433. * Instantiates a new BaseTexture.
  96434. * Base class of all the textures in babylon.
  96435. * It groups all the common properties the materials, post process, lights... might need
  96436. * in order to make a correct use of the texture.
  96437. * @param scene Define the scene the texture blongs to
  96438. */
  96439. constructor(scene: Nullable<Scene>);
  96440. /**
  96441. * Get the scene the texture belongs to.
  96442. * @returns the scene or null if undefined
  96443. */
  96444. getScene(): Nullable<Scene>;
  96445. /**
  96446. * Get the texture transform matrix used to offset tile the texture for istance.
  96447. * @returns the transformation matrix
  96448. */
  96449. getTextureMatrix(): Matrix;
  96450. /**
  96451. * Get the texture reflection matrix used to rotate/transform the reflection.
  96452. * @returns the reflection matrix
  96453. */
  96454. getReflectionTextureMatrix(): Matrix;
  96455. /**
  96456. * Get the underlying lower level texture from Babylon.
  96457. * @returns the insternal texture
  96458. */
  96459. getInternalTexture(): Nullable<InternalTexture>;
  96460. /**
  96461. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96462. * @returns true if ready or not blocking
  96463. */
  96464. isReadyOrNotBlocking(): boolean;
  96465. /**
  96466. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96467. * @returns true if fully ready
  96468. */
  96469. isReady(): boolean;
  96470. private _cachedSize;
  96471. /**
  96472. * Get the size of the texture.
  96473. * @returns the texture size.
  96474. */
  96475. getSize(): ISize;
  96476. /**
  96477. * Get the base size of the texture.
  96478. * It can be different from the size if the texture has been resized for POT for instance
  96479. * @returns the base size
  96480. */
  96481. getBaseSize(): ISize;
  96482. /**
  96483. * Update the sampling mode of the texture.
  96484. * Default is Trilinear mode.
  96485. *
  96486. * | Value | Type | Description |
  96487. * | ----- | ------------------ | ----------- |
  96488. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96489. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96490. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96491. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96492. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96493. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96494. * | 7 | NEAREST_LINEAR | |
  96495. * | 8 | NEAREST_NEAREST | |
  96496. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96497. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96498. * | 11 | LINEAR_LINEAR | |
  96499. * | 12 | LINEAR_NEAREST | |
  96500. *
  96501. * > _mag_: magnification filter (close to the viewer)
  96502. * > _min_: minification filter (far from the viewer)
  96503. * > _mip_: filter used between mip map levels
  96504. *@param samplingMode Define the new sampling mode of the texture
  96505. */
  96506. updateSamplingMode(samplingMode: number): void;
  96507. /**
  96508. * Scales the texture if is `canRescale()`
  96509. * @param ratio the resize factor we want to use to rescale
  96510. */
  96511. scale(ratio: number): void;
  96512. /**
  96513. * Get if the texture can rescale.
  96514. */
  96515. readonly canRescale: boolean;
  96516. /** @hidden */
  96517. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96518. /** @hidden */
  96519. _rebuild(): void;
  96520. /**
  96521. * Triggers the load sequence in delayed load mode.
  96522. */
  96523. delayLoad(): void;
  96524. /**
  96525. * Clones the texture.
  96526. * @returns the cloned texture
  96527. */
  96528. clone(): Nullable<BaseTexture>;
  96529. /**
  96530. * Get the texture underlying type (INT, FLOAT...)
  96531. */
  96532. readonly textureType: number;
  96533. /**
  96534. * Get the texture underlying format (RGB, RGBA...)
  96535. */
  96536. readonly textureFormat: number;
  96537. /**
  96538. * Indicates that textures need to be re-calculated for all materials
  96539. */
  96540. protected _markAllSubMeshesAsTexturesDirty(): void;
  96541. /**
  96542. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96543. * This will returns an RGBA array buffer containing either in values (0-255) or
  96544. * float values (0-1) depending of the underlying buffer type.
  96545. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96546. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96547. * @param buffer defines a user defined buffer to fill with data (can be null)
  96548. * @returns The Array buffer containing the pixels data.
  96549. */
  96550. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96551. /**
  96552. * Release and destroy the underlying lower level texture aka internalTexture.
  96553. */
  96554. releaseInternalTexture(): void;
  96555. /** @hidden */
  96556. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96557. /** @hidden */
  96558. readonly _lodTextureMid: Nullable<BaseTexture>;
  96559. /** @hidden */
  96560. readonly _lodTextureLow: Nullable<BaseTexture>;
  96561. /**
  96562. * Dispose the texture and release its associated resources.
  96563. */
  96564. dispose(): void;
  96565. /**
  96566. * Serialize the texture into a JSON representation that can be parsed later on.
  96567. * @returns the JSON representation of the texture
  96568. */
  96569. serialize(): any;
  96570. /**
  96571. * Helper function to be called back once a list of texture contains only ready textures.
  96572. * @param textures Define the list of textures to wait for
  96573. * @param callback Define the callback triggered once the entire list will be ready
  96574. */
  96575. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96576. }
  96577. }
  96578. declare module BABYLON {
  96579. /**
  96580. * Options to be used when creating an effect.
  96581. */
  96582. export interface IEffectCreationOptions {
  96583. /**
  96584. * Atrributes that will be used in the shader.
  96585. */
  96586. attributes: string[];
  96587. /**
  96588. * Uniform varible names that will be set in the shader.
  96589. */
  96590. uniformsNames: string[];
  96591. /**
  96592. * Uniform buffer variable names that will be set in the shader.
  96593. */
  96594. uniformBuffersNames: string[];
  96595. /**
  96596. * Sampler texture variable names that will be set in the shader.
  96597. */
  96598. samplers: string[];
  96599. /**
  96600. * Define statements that will be set in the shader.
  96601. */
  96602. defines: any;
  96603. /**
  96604. * Possible fallbacks for this effect to improve performance when needed.
  96605. */
  96606. fallbacks: Nullable<IEffectFallbacks>;
  96607. /**
  96608. * Callback that will be called when the shader is compiled.
  96609. */
  96610. onCompiled: Nullable<(effect: Effect) => void>;
  96611. /**
  96612. * Callback that will be called if an error occurs during shader compilation.
  96613. */
  96614. onError: Nullable<(effect: Effect, errors: string) => void>;
  96615. /**
  96616. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96617. */
  96618. indexParameters?: any;
  96619. /**
  96620. * Max number of lights that can be used in the shader.
  96621. */
  96622. maxSimultaneousLights?: number;
  96623. /**
  96624. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96625. */
  96626. transformFeedbackVaryings?: Nullable<string[]>;
  96627. }
  96628. /**
  96629. * Effect containing vertex and fragment shader that can be executed on an object.
  96630. */
  96631. export class Effect implements IDisposable {
  96632. /**
  96633. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96634. */
  96635. static ShadersRepository: string;
  96636. /**
  96637. * Name of the effect.
  96638. */
  96639. name: any;
  96640. /**
  96641. * String container all the define statements that should be set on the shader.
  96642. */
  96643. defines: string;
  96644. /**
  96645. * Callback that will be called when the shader is compiled.
  96646. */
  96647. onCompiled: Nullable<(effect: Effect) => void>;
  96648. /**
  96649. * Callback that will be called if an error occurs during shader compilation.
  96650. */
  96651. onError: Nullable<(effect: Effect, errors: string) => void>;
  96652. /**
  96653. * Callback that will be called when effect is bound.
  96654. */
  96655. onBind: Nullable<(effect: Effect) => void>;
  96656. /**
  96657. * Unique ID of the effect.
  96658. */
  96659. uniqueId: number;
  96660. /**
  96661. * Observable that will be called when the shader is compiled.
  96662. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96663. */
  96664. onCompileObservable: Observable<Effect>;
  96665. /**
  96666. * Observable that will be called if an error occurs during shader compilation.
  96667. */
  96668. onErrorObservable: Observable<Effect>;
  96669. /** @hidden */
  96670. _onBindObservable: Nullable<Observable<Effect>>;
  96671. /**
  96672. * Observable that will be called when effect is bound.
  96673. */
  96674. readonly onBindObservable: Observable<Effect>;
  96675. /** @hidden */
  96676. _bonesComputationForcedToCPU: boolean;
  96677. private static _uniqueIdSeed;
  96678. private _engine;
  96679. private _uniformBuffersNames;
  96680. private _uniformsNames;
  96681. private _samplerList;
  96682. private _samplers;
  96683. private _isReady;
  96684. private _compilationError;
  96685. private _allFallbacksProcessed;
  96686. private _attributesNames;
  96687. private _attributes;
  96688. private _uniforms;
  96689. /**
  96690. * Key for the effect.
  96691. * @hidden
  96692. */
  96693. _key: string;
  96694. private _indexParameters;
  96695. private _fallbacks;
  96696. private _vertexSourceCode;
  96697. private _fragmentSourceCode;
  96698. private _vertexSourceCodeOverride;
  96699. private _fragmentSourceCodeOverride;
  96700. private _transformFeedbackVaryings;
  96701. /**
  96702. * Compiled shader to webGL program.
  96703. * @hidden
  96704. */
  96705. _pipelineContext: Nullable<IPipelineContext>;
  96706. private _valueCache;
  96707. private static _baseCache;
  96708. /**
  96709. * Instantiates an effect.
  96710. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96711. * @param baseName Name of the effect.
  96712. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96713. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96714. * @param samplers List of sampler variables that will be passed to the shader.
  96715. * @param engine Engine to be used to render the effect
  96716. * @param defines Define statements to be added to the shader.
  96717. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96718. * @param onCompiled Callback that will be called when the shader is compiled.
  96719. * @param onError Callback that will be called if an error occurs during shader compilation.
  96720. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96721. */
  96722. 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);
  96723. private _useFinalCode;
  96724. /**
  96725. * Unique key for this effect
  96726. */
  96727. readonly key: string;
  96728. /**
  96729. * If the effect has been compiled and prepared.
  96730. * @returns if the effect is compiled and prepared.
  96731. */
  96732. isReady(): boolean;
  96733. private _isReadyInternal;
  96734. /**
  96735. * The engine the effect was initialized with.
  96736. * @returns the engine.
  96737. */
  96738. getEngine(): Engine;
  96739. /**
  96740. * The pipeline context for this effect
  96741. * @returns the associated pipeline context
  96742. */
  96743. getPipelineContext(): Nullable<IPipelineContext>;
  96744. /**
  96745. * The set of names of attribute variables for the shader.
  96746. * @returns An array of attribute names.
  96747. */
  96748. getAttributesNames(): string[];
  96749. /**
  96750. * Returns the attribute at the given index.
  96751. * @param index The index of the attribute.
  96752. * @returns The location of the attribute.
  96753. */
  96754. getAttributeLocation(index: number): number;
  96755. /**
  96756. * Returns the attribute based on the name of the variable.
  96757. * @param name of the attribute to look up.
  96758. * @returns the attribute location.
  96759. */
  96760. getAttributeLocationByName(name: string): number;
  96761. /**
  96762. * The number of attributes.
  96763. * @returns the numnber of attributes.
  96764. */
  96765. getAttributesCount(): number;
  96766. /**
  96767. * Gets the index of a uniform variable.
  96768. * @param uniformName of the uniform to look up.
  96769. * @returns the index.
  96770. */
  96771. getUniformIndex(uniformName: string): number;
  96772. /**
  96773. * Returns the attribute based on the name of the variable.
  96774. * @param uniformName of the uniform to look up.
  96775. * @returns the location of the uniform.
  96776. */
  96777. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96778. /**
  96779. * Returns an array of sampler variable names
  96780. * @returns The array of sampler variable neames.
  96781. */
  96782. getSamplers(): string[];
  96783. /**
  96784. * The error from the last compilation.
  96785. * @returns the error string.
  96786. */
  96787. getCompilationError(): string;
  96788. /**
  96789. * Gets a boolean indicating that all fallbacks were used during compilation
  96790. * @returns true if all fallbacks were used
  96791. */
  96792. allFallbacksProcessed(): boolean;
  96793. /**
  96794. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96795. * @param func The callback to be used.
  96796. */
  96797. executeWhenCompiled(func: (effect: Effect) => void): void;
  96798. private _checkIsReady;
  96799. private _loadShader;
  96800. /**
  96801. * Recompiles the webGL program
  96802. * @param vertexSourceCode The source code for the vertex shader.
  96803. * @param fragmentSourceCode The source code for the fragment shader.
  96804. * @param onCompiled Callback called when completed.
  96805. * @param onError Callback called on error.
  96806. * @hidden
  96807. */
  96808. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96809. /**
  96810. * Prepares the effect
  96811. * @hidden
  96812. */
  96813. _prepareEffect(): void;
  96814. private _processCompilationErrors;
  96815. /**
  96816. * Checks if the effect is supported. (Must be called after compilation)
  96817. */
  96818. readonly isSupported: boolean;
  96819. /**
  96820. * Binds a texture to the engine to be used as output of the shader.
  96821. * @param channel Name of the output variable.
  96822. * @param texture Texture to bind.
  96823. * @hidden
  96824. */
  96825. _bindTexture(channel: string, texture: InternalTexture): void;
  96826. /**
  96827. * Sets a texture on the engine to be used in the shader.
  96828. * @param channel Name of the sampler variable.
  96829. * @param texture Texture to set.
  96830. */
  96831. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96832. /**
  96833. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96834. * @param channel Name of the sampler variable.
  96835. * @param texture Texture to set.
  96836. */
  96837. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96838. /**
  96839. * Sets an array of textures on the engine to be used in the shader.
  96840. * @param channel Name of the variable.
  96841. * @param textures Textures to set.
  96842. */
  96843. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96844. /**
  96845. * 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)
  96846. * @param channel Name of the sampler variable.
  96847. * @param postProcess Post process to get the input texture from.
  96848. */
  96849. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96850. /**
  96851. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96852. * 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)
  96853. * @param channel Name of the sampler variable.
  96854. * @param postProcess Post process to get the output texture from.
  96855. */
  96856. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96857. /** @hidden */
  96858. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96859. /** @hidden */
  96860. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96861. /** @hidden */
  96862. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96863. /** @hidden */
  96864. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96865. /**
  96866. * Binds a buffer to a uniform.
  96867. * @param buffer Buffer to bind.
  96868. * @param name Name of the uniform variable to bind to.
  96869. */
  96870. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96871. /**
  96872. * Binds block to a uniform.
  96873. * @param blockName Name of the block to bind.
  96874. * @param index Index to bind.
  96875. */
  96876. bindUniformBlock(blockName: string, index: number): void;
  96877. /**
  96878. * Sets an interger value on a uniform variable.
  96879. * @param uniformName Name of the variable.
  96880. * @param value Value to be set.
  96881. * @returns this effect.
  96882. */
  96883. setInt(uniformName: string, value: number): Effect;
  96884. /**
  96885. * Sets an int array on a uniform variable.
  96886. * @param uniformName Name of the variable.
  96887. * @param array array to be set.
  96888. * @returns this effect.
  96889. */
  96890. setIntArray(uniformName: string, array: Int32Array): Effect;
  96891. /**
  96892. * 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)
  96893. * @param uniformName Name of the variable.
  96894. * @param array array to be set.
  96895. * @returns this effect.
  96896. */
  96897. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96898. /**
  96899. * 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)
  96900. * @param uniformName Name of the variable.
  96901. * @param array array to be set.
  96902. * @returns this effect.
  96903. */
  96904. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96905. /**
  96906. * 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)
  96907. * @param uniformName Name of the variable.
  96908. * @param array array to be set.
  96909. * @returns this effect.
  96910. */
  96911. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96912. /**
  96913. * Sets an float array on a uniform variable.
  96914. * @param uniformName Name of the variable.
  96915. * @param array array to be set.
  96916. * @returns this effect.
  96917. */
  96918. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96919. /**
  96920. * 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)
  96921. * @param uniformName Name of the variable.
  96922. * @param array array to be set.
  96923. * @returns this effect.
  96924. */
  96925. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96926. /**
  96927. * 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)
  96928. * @param uniformName Name of the variable.
  96929. * @param array array to be set.
  96930. * @returns this effect.
  96931. */
  96932. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96933. /**
  96934. * 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)
  96935. * @param uniformName Name of the variable.
  96936. * @param array array to be set.
  96937. * @returns this effect.
  96938. */
  96939. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96940. /**
  96941. * Sets an array on a uniform variable.
  96942. * @param uniformName Name of the variable.
  96943. * @param array array to be set.
  96944. * @returns this effect.
  96945. */
  96946. setArray(uniformName: string, array: number[]): Effect;
  96947. /**
  96948. * 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)
  96949. * @param uniformName Name of the variable.
  96950. * @param array array to be set.
  96951. * @returns this effect.
  96952. */
  96953. setArray2(uniformName: string, array: number[]): Effect;
  96954. /**
  96955. * 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)
  96956. * @param uniformName Name of the variable.
  96957. * @param array array to be set.
  96958. * @returns this effect.
  96959. */
  96960. setArray3(uniformName: string, array: number[]): Effect;
  96961. /**
  96962. * 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)
  96963. * @param uniformName Name of the variable.
  96964. * @param array array to be set.
  96965. * @returns this effect.
  96966. */
  96967. setArray4(uniformName: string, array: number[]): Effect;
  96968. /**
  96969. * Sets matrices on a uniform variable.
  96970. * @param uniformName Name of the variable.
  96971. * @param matrices matrices to be set.
  96972. * @returns this effect.
  96973. */
  96974. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96975. /**
  96976. * Sets matrix on a uniform variable.
  96977. * @param uniformName Name of the variable.
  96978. * @param matrix matrix to be set.
  96979. * @returns this effect.
  96980. */
  96981. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96982. /**
  96983. * 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)
  96984. * @param uniformName Name of the variable.
  96985. * @param matrix matrix to be set.
  96986. * @returns this effect.
  96987. */
  96988. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96989. /**
  96990. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96991. * @param uniformName Name of the variable.
  96992. * @param matrix matrix to be set.
  96993. * @returns this effect.
  96994. */
  96995. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96996. /**
  96997. * Sets a float on a uniform variable.
  96998. * @param uniformName Name of the variable.
  96999. * @param value value to be set.
  97000. * @returns this effect.
  97001. */
  97002. setFloat(uniformName: string, value: number): Effect;
  97003. /**
  97004. * Sets a boolean on a uniform variable.
  97005. * @param uniformName Name of the variable.
  97006. * @param bool value to be set.
  97007. * @returns this effect.
  97008. */
  97009. setBool(uniformName: string, bool: boolean): Effect;
  97010. /**
  97011. * Sets a Vector2 on a uniform variable.
  97012. * @param uniformName Name of the variable.
  97013. * @param vector2 vector2 to be set.
  97014. * @returns this effect.
  97015. */
  97016. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  97017. /**
  97018. * Sets a float2 on a uniform variable.
  97019. * @param uniformName Name of the variable.
  97020. * @param x First float in float2.
  97021. * @param y Second float in float2.
  97022. * @returns this effect.
  97023. */
  97024. setFloat2(uniformName: string, x: number, y: number): Effect;
  97025. /**
  97026. * Sets a Vector3 on a uniform variable.
  97027. * @param uniformName Name of the variable.
  97028. * @param vector3 Value to be set.
  97029. * @returns this effect.
  97030. */
  97031. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97032. /**
  97033. * Sets a float3 on a uniform variable.
  97034. * @param uniformName Name of the variable.
  97035. * @param x First float in float3.
  97036. * @param y Second float in float3.
  97037. * @param z Third float in float3.
  97038. * @returns this effect.
  97039. */
  97040. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97041. /**
  97042. * Sets a Vector4 on a uniform variable.
  97043. * @param uniformName Name of the variable.
  97044. * @param vector4 Value to be set.
  97045. * @returns this effect.
  97046. */
  97047. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97048. /**
  97049. * Sets a float4 on a uniform variable.
  97050. * @param uniformName Name of the variable.
  97051. * @param x First float in float4.
  97052. * @param y Second float in float4.
  97053. * @param z Third float in float4.
  97054. * @param w Fourth float in float4.
  97055. * @returns this effect.
  97056. */
  97057. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97058. /**
  97059. * Sets a Color3 on a uniform variable.
  97060. * @param uniformName Name of the variable.
  97061. * @param color3 Value to be set.
  97062. * @returns this effect.
  97063. */
  97064. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97065. /**
  97066. * Sets a Color4 on a uniform variable.
  97067. * @param uniformName Name of the variable.
  97068. * @param color3 Value to be set.
  97069. * @param alpha Alpha value to be set.
  97070. * @returns this effect.
  97071. */
  97072. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97073. /**
  97074. * Sets a Color4 on a uniform variable
  97075. * @param uniformName defines the name of the variable
  97076. * @param color4 defines the value to be set
  97077. * @returns this effect.
  97078. */
  97079. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97080. /** Release all associated resources */
  97081. dispose(): void;
  97082. /**
  97083. * This function will add a new shader to the shader store
  97084. * @param name the name of the shader
  97085. * @param pixelShader optional pixel shader content
  97086. * @param vertexShader optional vertex shader content
  97087. */
  97088. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97089. /**
  97090. * Store of each shader (The can be looked up using effect.key)
  97091. */
  97092. static ShadersStore: {
  97093. [key: string]: string;
  97094. };
  97095. /**
  97096. * Store of each included file for a shader (The can be looked up using effect.key)
  97097. */
  97098. static IncludesShadersStore: {
  97099. [key: string]: string;
  97100. };
  97101. /**
  97102. * Resets the cache of effects.
  97103. */
  97104. static ResetCache(): void;
  97105. }
  97106. }
  97107. declare module BABYLON {
  97108. /**
  97109. * Interface used to describe the capabilities of the engine relatively to the current browser
  97110. */
  97111. export interface EngineCapabilities {
  97112. /** Maximum textures units per fragment shader */
  97113. maxTexturesImageUnits: number;
  97114. /** Maximum texture units per vertex shader */
  97115. maxVertexTextureImageUnits: number;
  97116. /** Maximum textures units in the entire pipeline */
  97117. maxCombinedTexturesImageUnits: number;
  97118. /** Maximum texture size */
  97119. maxTextureSize: number;
  97120. /** Maximum cube texture size */
  97121. maxCubemapTextureSize: number;
  97122. /** Maximum render texture size */
  97123. maxRenderTextureSize: number;
  97124. /** Maximum number of vertex attributes */
  97125. maxVertexAttribs: number;
  97126. /** Maximum number of varyings */
  97127. maxVaryingVectors: number;
  97128. /** Maximum number of uniforms per vertex shader */
  97129. maxVertexUniformVectors: number;
  97130. /** Maximum number of uniforms per fragment shader */
  97131. maxFragmentUniformVectors: number;
  97132. /** Defines if standard derivates (dx/dy) are supported */
  97133. standardDerivatives: boolean;
  97134. /** Defines if s3tc texture compression is supported */
  97135. s3tc?: WEBGL_compressed_texture_s3tc;
  97136. /** Defines if pvrtc texture compression is supported */
  97137. pvrtc: any;
  97138. /** Defines if etc1 texture compression is supported */
  97139. etc1: any;
  97140. /** Defines if etc2 texture compression is supported */
  97141. etc2: any;
  97142. /** Defines if astc texture compression is supported */
  97143. astc: any;
  97144. /** Defines if float textures are supported */
  97145. textureFloat: boolean;
  97146. /** Defines if vertex array objects are supported */
  97147. vertexArrayObject: boolean;
  97148. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97149. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97150. /** Gets the maximum level of anisotropy supported */
  97151. maxAnisotropy: number;
  97152. /** Defines if instancing is supported */
  97153. instancedArrays: boolean;
  97154. /** Defines if 32 bits indices are supported */
  97155. uintIndices: boolean;
  97156. /** Defines if high precision shaders are supported */
  97157. highPrecisionShaderSupported: boolean;
  97158. /** Defines if depth reading in the fragment shader is supported */
  97159. fragmentDepthSupported: boolean;
  97160. /** Defines if float texture linear filtering is supported*/
  97161. textureFloatLinearFiltering: boolean;
  97162. /** Defines if rendering to float textures is supported */
  97163. textureFloatRender: boolean;
  97164. /** Defines if half float textures are supported*/
  97165. textureHalfFloat: boolean;
  97166. /** Defines if half float texture linear filtering is supported*/
  97167. textureHalfFloatLinearFiltering: boolean;
  97168. /** Defines if rendering to half float textures is supported */
  97169. textureHalfFloatRender: boolean;
  97170. /** Defines if textureLOD shader command is supported */
  97171. textureLOD: boolean;
  97172. /** Defines if draw buffers extension is supported */
  97173. drawBuffersExtension: boolean;
  97174. /** Defines if depth textures are supported */
  97175. depthTextureExtension: boolean;
  97176. /** Defines if float color buffer are supported */
  97177. colorBufferFloat: boolean;
  97178. /** Gets disjoint timer query extension (null if not supported) */
  97179. timerQuery?: EXT_disjoint_timer_query;
  97180. /** Defines if timestamp can be used with timer query */
  97181. canUseTimestampForTimerQuery: boolean;
  97182. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97183. multiview?: any;
  97184. /** Function used to let the system compiles shaders in background */
  97185. parallelShaderCompile?: {
  97186. COMPLETION_STATUS_KHR: number;
  97187. };
  97188. /** Max number of texture samples for MSAA */
  97189. maxMSAASamples: number;
  97190. /** Defines if the blend min max extension is supported */
  97191. blendMinMax: boolean;
  97192. }
  97193. }
  97194. declare module BABYLON {
  97195. /**
  97196. * @hidden
  97197. **/
  97198. export class DepthCullingState {
  97199. private _isDepthTestDirty;
  97200. private _isDepthMaskDirty;
  97201. private _isDepthFuncDirty;
  97202. private _isCullFaceDirty;
  97203. private _isCullDirty;
  97204. private _isZOffsetDirty;
  97205. private _isFrontFaceDirty;
  97206. private _depthTest;
  97207. private _depthMask;
  97208. private _depthFunc;
  97209. private _cull;
  97210. private _cullFace;
  97211. private _zOffset;
  97212. private _frontFace;
  97213. /**
  97214. * Initializes the state.
  97215. */
  97216. constructor();
  97217. readonly isDirty: boolean;
  97218. zOffset: number;
  97219. cullFace: Nullable<number>;
  97220. cull: Nullable<boolean>;
  97221. depthFunc: Nullable<number>;
  97222. depthMask: boolean;
  97223. depthTest: boolean;
  97224. frontFace: Nullable<number>;
  97225. reset(): void;
  97226. apply(gl: WebGLRenderingContext): void;
  97227. }
  97228. }
  97229. declare module BABYLON {
  97230. /**
  97231. * @hidden
  97232. **/
  97233. export class StencilState {
  97234. /** 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 */
  97235. static readonly ALWAYS: number;
  97236. /** Passed to stencilOperation to specify that stencil value must be kept */
  97237. static readonly KEEP: number;
  97238. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97239. static readonly REPLACE: number;
  97240. private _isStencilTestDirty;
  97241. private _isStencilMaskDirty;
  97242. private _isStencilFuncDirty;
  97243. private _isStencilOpDirty;
  97244. private _stencilTest;
  97245. private _stencilMask;
  97246. private _stencilFunc;
  97247. private _stencilFuncRef;
  97248. private _stencilFuncMask;
  97249. private _stencilOpStencilFail;
  97250. private _stencilOpDepthFail;
  97251. private _stencilOpStencilDepthPass;
  97252. readonly isDirty: boolean;
  97253. stencilFunc: number;
  97254. stencilFuncRef: number;
  97255. stencilFuncMask: number;
  97256. stencilOpStencilFail: number;
  97257. stencilOpDepthFail: number;
  97258. stencilOpStencilDepthPass: number;
  97259. stencilMask: number;
  97260. stencilTest: boolean;
  97261. constructor();
  97262. reset(): void;
  97263. apply(gl: WebGLRenderingContext): void;
  97264. }
  97265. }
  97266. declare module BABYLON {
  97267. /**
  97268. * @hidden
  97269. **/
  97270. export class AlphaState {
  97271. private _isAlphaBlendDirty;
  97272. private _isBlendFunctionParametersDirty;
  97273. private _isBlendEquationParametersDirty;
  97274. private _isBlendConstantsDirty;
  97275. private _alphaBlend;
  97276. private _blendFunctionParameters;
  97277. private _blendEquationParameters;
  97278. private _blendConstants;
  97279. /**
  97280. * Initializes the state.
  97281. */
  97282. constructor();
  97283. readonly isDirty: boolean;
  97284. alphaBlend: boolean;
  97285. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97286. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97287. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97288. reset(): void;
  97289. apply(gl: WebGLRenderingContext): void;
  97290. }
  97291. }
  97292. declare module BABYLON {
  97293. /** @hidden */
  97294. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97295. attributeProcessor(attribute: string): string;
  97296. varyingProcessor(varying: string, isFragment: boolean): string;
  97297. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97298. }
  97299. }
  97300. declare module BABYLON {
  97301. /**
  97302. * Interface for attribute information associated with buffer instanciation
  97303. */
  97304. export interface InstancingAttributeInfo {
  97305. /**
  97306. * Index/offset of the attribute in the vertex shader
  97307. */
  97308. index: number;
  97309. /**
  97310. * size of the attribute, 1, 2, 3 or 4
  97311. */
  97312. attributeSize: number;
  97313. /**
  97314. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97315. * default is FLOAT
  97316. */
  97317. attributeType: number;
  97318. /**
  97319. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97320. */
  97321. normalized: boolean;
  97322. /**
  97323. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97324. */
  97325. offset: number;
  97326. /**
  97327. * Name of the GLSL attribute, for debugging purpose only
  97328. */
  97329. attributeName: string;
  97330. }
  97331. }
  97332. declare module BABYLON {
  97333. interface ThinEngine {
  97334. /**
  97335. * Update a video texture
  97336. * @param texture defines the texture to update
  97337. * @param video defines the video element to use
  97338. * @param invertY defines if data must be stored with Y axis inverted
  97339. */
  97340. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97341. }
  97342. }
  97343. declare module BABYLON {
  97344. /**
  97345. * Settings for finer control over video usage
  97346. */
  97347. export interface VideoTextureSettings {
  97348. /**
  97349. * Applies `autoplay` to video, if specified
  97350. */
  97351. autoPlay?: boolean;
  97352. /**
  97353. * Applies `loop` to video, if specified
  97354. */
  97355. loop?: boolean;
  97356. /**
  97357. * Automatically updates internal texture from video at every frame in the render loop
  97358. */
  97359. autoUpdateTexture: boolean;
  97360. /**
  97361. * Image src displayed during the video loading or until the user interacts with the video.
  97362. */
  97363. poster?: string;
  97364. }
  97365. /**
  97366. * If you want to display a video in your scene, this is the special texture for that.
  97367. * This special texture works similar to other textures, with the exception of a few parameters.
  97368. * @see https://doc.babylonjs.com/how_to/video_texture
  97369. */
  97370. export class VideoTexture extends Texture {
  97371. /**
  97372. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97373. */
  97374. readonly autoUpdateTexture: boolean;
  97375. /**
  97376. * The video instance used by the texture internally
  97377. */
  97378. readonly video: HTMLVideoElement;
  97379. private _onUserActionRequestedObservable;
  97380. /**
  97381. * Event triggerd when a dom action is required by the user to play the video.
  97382. * This happens due to recent changes in browser policies preventing video to auto start.
  97383. */
  97384. readonly onUserActionRequestedObservable: Observable<Texture>;
  97385. private _generateMipMaps;
  97386. private _engine;
  97387. private _stillImageCaptured;
  97388. private _displayingPosterTexture;
  97389. private _settings;
  97390. private _createInternalTextureOnEvent;
  97391. private _frameId;
  97392. /**
  97393. * Creates a video texture.
  97394. * If you want to display a video in your scene, this is the special texture for that.
  97395. * This special texture works similar to other textures, with the exception of a few parameters.
  97396. * @see https://doc.babylonjs.com/how_to/video_texture
  97397. * @param name optional name, will detect from video source, if not defined
  97398. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97399. * @param scene is obviously the current scene.
  97400. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97401. * @param invertY is false by default but can be used to invert video on Y axis
  97402. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97403. * @param settings allows finer control over video usage
  97404. */
  97405. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97406. private _getName;
  97407. private _getVideo;
  97408. private _createInternalTexture;
  97409. private reset;
  97410. /**
  97411. * @hidden Internal method to initiate `update`.
  97412. */
  97413. _rebuild(): void;
  97414. /**
  97415. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97416. */
  97417. update(): void;
  97418. /**
  97419. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97420. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97421. */
  97422. updateTexture(isVisible: boolean): void;
  97423. protected _updateInternalTexture: () => void;
  97424. /**
  97425. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97426. * @param url New url.
  97427. */
  97428. updateURL(url: string): void;
  97429. /**
  97430. * Dispose the texture and release its associated resources.
  97431. */
  97432. dispose(): void;
  97433. /**
  97434. * Creates a video texture straight from a stream.
  97435. * @param scene Define the scene the texture should be created in
  97436. * @param stream Define the stream the texture should be created from
  97437. * @returns The created video texture as a promise
  97438. */
  97439. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97440. /**
  97441. * Creates a video texture straight from your WebCam video feed.
  97442. * @param scene Define the scene the texture should be created in
  97443. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97444. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97445. * @returns The created video texture as a promise
  97446. */
  97447. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97448. minWidth: number;
  97449. maxWidth: number;
  97450. minHeight: number;
  97451. maxHeight: number;
  97452. deviceId: string;
  97453. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97454. /**
  97455. * Creates a video texture straight from your WebCam video feed.
  97456. * @param scene Define the scene the texture should be created in
  97457. * @param onReady Define a callback to triggered once the texture will be ready
  97458. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97459. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97460. */
  97461. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97462. minWidth: number;
  97463. maxWidth: number;
  97464. minHeight: number;
  97465. maxHeight: number;
  97466. deviceId: string;
  97467. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97468. }
  97469. }
  97470. declare module BABYLON {
  97471. /**
  97472. * Defines the interface used by objects working like Scene
  97473. * @hidden
  97474. */
  97475. interface ISceneLike {
  97476. _addPendingData(data: any): void;
  97477. _removePendingData(data: any): void;
  97478. offlineProvider: IOfflineProvider;
  97479. }
  97480. /** Interface defining initialization parameters for Engine class */
  97481. export interface EngineOptions extends WebGLContextAttributes {
  97482. /**
  97483. * Defines if the engine should no exceed a specified device ratio
  97484. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97485. */
  97486. limitDeviceRatio?: number;
  97487. /**
  97488. * Defines if webvr should be enabled automatically
  97489. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97490. */
  97491. autoEnableWebVR?: boolean;
  97492. /**
  97493. * Defines if webgl2 should be turned off even if supported
  97494. * @see http://doc.babylonjs.com/features/webgl2
  97495. */
  97496. disableWebGL2Support?: boolean;
  97497. /**
  97498. * Defines if webaudio should be initialized as well
  97499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97500. */
  97501. audioEngine?: boolean;
  97502. /**
  97503. * Defines if animations should run using a deterministic lock step
  97504. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97505. */
  97506. deterministicLockstep?: boolean;
  97507. /** Defines the maximum steps to use with deterministic lock step mode */
  97508. lockstepMaxSteps?: number;
  97509. /**
  97510. * Defines that engine should ignore context lost events
  97511. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97512. */
  97513. doNotHandleContextLost?: boolean;
  97514. /**
  97515. * Defines that engine should ignore modifying touch action attribute and style
  97516. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97517. */
  97518. doNotHandleTouchAction?: boolean;
  97519. /**
  97520. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97521. */
  97522. useHighPrecisionFloats?: boolean;
  97523. }
  97524. /**
  97525. * The base engine class (root of all engines)
  97526. */
  97527. export class ThinEngine {
  97528. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97529. static ExceptionList: ({
  97530. key: string;
  97531. capture: string;
  97532. captureConstraint: number;
  97533. targets: string[];
  97534. } | {
  97535. key: string;
  97536. capture: null;
  97537. captureConstraint: null;
  97538. targets: string[];
  97539. })[];
  97540. /** @hidden */
  97541. static _TextureLoaders: IInternalTextureLoader[];
  97542. /**
  97543. * Returns the current npm package of the sdk
  97544. */
  97545. static readonly NpmPackage: string;
  97546. /**
  97547. * Returns the current version of the framework
  97548. */
  97549. static readonly Version: string;
  97550. /**
  97551. * Returns a string describing the current engine
  97552. */
  97553. readonly description: string;
  97554. /**
  97555. * Gets or sets the epsilon value used by collision engine
  97556. */
  97557. static CollisionsEpsilon: number;
  97558. /**
  97559. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97560. */
  97561. static ShadersRepository: string;
  97562. /** @hidden */
  97563. _shaderProcessor: IShaderProcessor;
  97564. /**
  97565. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97566. */
  97567. forcePOTTextures: boolean;
  97568. /**
  97569. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97570. */
  97571. isFullscreen: boolean;
  97572. /**
  97573. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97574. */
  97575. cullBackFaces: boolean;
  97576. /**
  97577. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97578. */
  97579. renderEvenInBackground: boolean;
  97580. /**
  97581. * Gets or sets a boolean indicating that cache can be kept between frames
  97582. */
  97583. preventCacheWipeBetweenFrames: boolean;
  97584. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97585. validateShaderPrograms: boolean;
  97586. /**
  97587. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97588. */
  97589. disableUniformBuffers: boolean;
  97590. /** @hidden */
  97591. _uniformBuffers: UniformBuffer[];
  97592. /**
  97593. * Gets a boolean indicating that the engine supports uniform buffers
  97594. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97595. */
  97596. readonly supportsUniformBuffers: boolean;
  97597. /** @hidden */
  97598. _gl: WebGLRenderingContext;
  97599. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97600. protected _windowIsBackground: boolean;
  97601. protected _webGLVersion: number;
  97602. protected _creationOptions: EngineOptions;
  97603. protected _highPrecisionShadersAllowed: boolean;
  97604. /** @hidden */
  97605. readonly _shouldUseHighPrecisionShader: boolean;
  97606. /**
  97607. * Gets a boolean indicating that only power of 2 textures are supported
  97608. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97609. */
  97610. readonly needPOTTextures: boolean;
  97611. /** @hidden */
  97612. _badOS: boolean;
  97613. /** @hidden */
  97614. _badDesktopOS: boolean;
  97615. private _hardwareScalingLevel;
  97616. /** @hidden */
  97617. _caps: EngineCapabilities;
  97618. private _isStencilEnable;
  97619. protected _colorWrite: boolean;
  97620. private _glVersion;
  97621. private _glRenderer;
  97622. private _glVendor;
  97623. /** @hidden */
  97624. _videoTextureSupported: boolean;
  97625. protected _renderingQueueLaunched: boolean;
  97626. protected _activeRenderLoops: (() => void)[];
  97627. /**
  97628. * Observable signaled when a context lost event is raised
  97629. */
  97630. onContextLostObservable: Observable<ThinEngine>;
  97631. /**
  97632. * Observable signaled when a context restored event is raised
  97633. */
  97634. onContextRestoredObservable: Observable<ThinEngine>;
  97635. private _onContextLost;
  97636. private _onContextRestored;
  97637. protected _contextWasLost: boolean;
  97638. /** @hidden */
  97639. _doNotHandleContextLost: boolean;
  97640. /**
  97641. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97643. */
  97644. doNotHandleContextLost: boolean;
  97645. /**
  97646. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97647. */
  97648. disableVertexArrayObjects: boolean;
  97649. /** @hidden */
  97650. protected _depthCullingState: DepthCullingState;
  97651. /** @hidden */
  97652. protected _stencilState: StencilState;
  97653. /** @hidden */
  97654. protected _alphaState: AlphaState;
  97655. /** @hidden */
  97656. _internalTexturesCache: InternalTexture[];
  97657. /** @hidden */
  97658. protected _activeChannel: number;
  97659. private _currentTextureChannel;
  97660. /** @hidden */
  97661. protected _boundTexturesCache: {
  97662. [key: string]: Nullable<InternalTexture>;
  97663. };
  97664. /** @hidden */
  97665. protected _currentEffect: Nullable<Effect>;
  97666. /** @hidden */
  97667. protected _currentProgram: Nullable<WebGLProgram>;
  97668. private _compiledEffects;
  97669. private _vertexAttribArraysEnabled;
  97670. /** @hidden */
  97671. protected _cachedViewport: Nullable<IViewportLike>;
  97672. private _cachedVertexArrayObject;
  97673. /** @hidden */
  97674. protected _cachedVertexBuffers: any;
  97675. /** @hidden */
  97676. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97677. /** @hidden */
  97678. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97679. /** @hidden */
  97680. _currentRenderTarget: Nullable<InternalTexture>;
  97681. private _uintIndicesCurrentlySet;
  97682. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97683. /** @hidden */
  97684. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97685. private _currentBufferPointers;
  97686. private _currentInstanceLocations;
  97687. private _currentInstanceBuffers;
  97688. private _textureUnits;
  97689. /** @hidden */
  97690. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97691. /** @hidden */
  97692. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97693. /** @hidden */
  97694. _boundRenderFunction: any;
  97695. private _vaoRecordInProgress;
  97696. private _mustWipeVertexAttributes;
  97697. private _emptyTexture;
  97698. private _emptyCubeTexture;
  97699. private _emptyTexture3D;
  97700. private _emptyTexture2DArray;
  97701. /** @hidden */
  97702. _frameHandler: number;
  97703. private _nextFreeTextureSlots;
  97704. private _maxSimultaneousTextures;
  97705. private _activeRequests;
  97706. protected _texturesSupported: string[];
  97707. /** @hidden */
  97708. _textureFormatInUse: Nullable<string>;
  97709. protected readonly _supportsHardwareTextureRescaling: boolean;
  97710. /**
  97711. * Gets the list of texture formats supported
  97712. */
  97713. readonly texturesSupported: Array<string>;
  97714. /**
  97715. * Gets the list of texture formats in use
  97716. */
  97717. readonly textureFormatInUse: Nullable<string>;
  97718. /**
  97719. * Gets the current viewport
  97720. */
  97721. readonly currentViewport: Nullable<IViewportLike>;
  97722. /**
  97723. * Gets the default empty texture
  97724. */
  97725. readonly emptyTexture: InternalTexture;
  97726. /**
  97727. * Gets the default empty 3D texture
  97728. */
  97729. readonly emptyTexture3D: InternalTexture;
  97730. /**
  97731. * Gets the default empty 2D array texture
  97732. */
  97733. readonly emptyTexture2DArray: InternalTexture;
  97734. /**
  97735. * Gets the default empty cube texture
  97736. */
  97737. readonly emptyCubeTexture: InternalTexture;
  97738. /**
  97739. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97740. */
  97741. readonly premultipliedAlpha: boolean;
  97742. /**
  97743. * Observable event triggered before each texture is initialized
  97744. */
  97745. onBeforeTextureInitObservable: Observable<Texture>;
  97746. /**
  97747. * Creates a new engine
  97748. * @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
  97749. * @param antialias defines enable antialiasing (default: false)
  97750. * @param options defines further options to be sent to the getContext() function
  97751. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97752. */
  97753. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97754. private _rebuildInternalTextures;
  97755. private _rebuildEffects;
  97756. /**
  97757. * Gets a boolean indicating if all created effects are ready
  97758. * @returns true if all effects are ready
  97759. */
  97760. areAllEffectsReady(): boolean;
  97761. protected _rebuildBuffers(): void;
  97762. private _initGLContext;
  97763. /**
  97764. * Gets version of the current webGL context
  97765. */
  97766. readonly webGLVersion: number;
  97767. /**
  97768. * Gets a string idenfifying the name of the class
  97769. * @returns "Engine" string
  97770. */
  97771. getClassName(): string;
  97772. /**
  97773. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97774. */
  97775. readonly isStencilEnable: boolean;
  97776. /** @hidden */
  97777. _prepareWorkingCanvas(): void;
  97778. /**
  97779. * Reset the texture cache to empty state
  97780. */
  97781. resetTextureCache(): void;
  97782. /**
  97783. * Gets an object containing information about the current webGL context
  97784. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97785. */
  97786. getGlInfo(): {
  97787. vendor: string;
  97788. renderer: string;
  97789. version: string;
  97790. };
  97791. /**
  97792. * Defines the hardware scaling level.
  97793. * By default the hardware scaling level is computed from the window device ratio.
  97794. * 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.
  97795. * @param level defines the level to use
  97796. */
  97797. setHardwareScalingLevel(level: number): void;
  97798. /**
  97799. * Gets the current hardware scaling level.
  97800. * By default the hardware scaling level is computed from the window device ratio.
  97801. * 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.
  97802. * @returns a number indicating the current hardware scaling level
  97803. */
  97804. getHardwareScalingLevel(): number;
  97805. /**
  97806. * Gets the list of loaded textures
  97807. * @returns an array containing all loaded textures
  97808. */
  97809. getLoadedTexturesCache(): InternalTexture[];
  97810. /**
  97811. * Gets the object containing all engine capabilities
  97812. * @returns the EngineCapabilities object
  97813. */
  97814. getCaps(): EngineCapabilities;
  97815. /**
  97816. * stop executing a render loop function and remove it from the execution array
  97817. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97818. */
  97819. stopRenderLoop(renderFunction?: () => void): void;
  97820. /** @hidden */
  97821. _renderLoop(): void;
  97822. /**
  97823. * Gets the HTML canvas attached with the current webGL context
  97824. * @returns a HTML canvas
  97825. */
  97826. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97827. /**
  97828. * Gets host window
  97829. * @returns the host window object
  97830. */
  97831. getHostWindow(): Nullable<Window>;
  97832. /**
  97833. * Gets the current render width
  97834. * @param useScreen defines if screen size must be used (or the current render target if any)
  97835. * @returns a number defining the current render width
  97836. */
  97837. getRenderWidth(useScreen?: boolean): number;
  97838. /**
  97839. * Gets the current render height
  97840. * @param useScreen defines if screen size must be used (or the current render target if any)
  97841. * @returns a number defining the current render height
  97842. */
  97843. getRenderHeight(useScreen?: boolean): number;
  97844. /**
  97845. * Can be used to override the current requestAnimationFrame requester.
  97846. * @hidden
  97847. */
  97848. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97849. /**
  97850. * Register and execute a render loop. The engine can have more than one render function
  97851. * @param renderFunction defines the function to continuously execute
  97852. */
  97853. runRenderLoop(renderFunction: () => void): void;
  97854. /**
  97855. * Clear the current render buffer or the current render target (if any is set up)
  97856. * @param color defines the color to use
  97857. * @param backBuffer defines if the back buffer must be cleared
  97858. * @param depth defines if the depth buffer must be cleared
  97859. * @param stencil defines if the stencil buffer must be cleared
  97860. */
  97861. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97862. private _viewportCached;
  97863. /** @hidden */
  97864. _viewport(x: number, y: number, width: number, height: number): void;
  97865. /**
  97866. * Set the WebGL's viewport
  97867. * @param viewport defines the viewport element to be used
  97868. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97869. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97870. */
  97871. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97872. /**
  97873. * Begin a new frame
  97874. */
  97875. beginFrame(): void;
  97876. /**
  97877. * Enf the current frame
  97878. */
  97879. endFrame(): void;
  97880. /**
  97881. * Resize the view according to the canvas' size
  97882. */
  97883. resize(): void;
  97884. /**
  97885. * Force a specific size of the canvas
  97886. * @param width defines the new canvas' width
  97887. * @param height defines the new canvas' height
  97888. */
  97889. setSize(width: number, height: number): void;
  97890. /**
  97891. * Binds the frame buffer to the specified texture.
  97892. * @param texture The texture to render to or null for the default canvas
  97893. * @param faceIndex The face of the texture to render to in case of cube texture
  97894. * @param requiredWidth The width of the target to render to
  97895. * @param requiredHeight The height of the target to render to
  97896. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97897. * @param depthStencilTexture The depth stencil texture to use to render
  97898. * @param lodLevel defines le lod level to bind to the frame buffer
  97899. */
  97900. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97901. /** @hidden */
  97902. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97903. /**
  97904. * Unbind the current render target texture from the webGL context
  97905. * @param texture defines the render target texture to unbind
  97906. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97907. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97908. */
  97909. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97910. /**
  97911. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97912. */
  97913. flushFramebuffer(): void;
  97914. /**
  97915. * Unbind the current render target and bind the default framebuffer
  97916. */
  97917. restoreDefaultFramebuffer(): void;
  97918. /** @hidden */
  97919. protected _resetVertexBufferBinding(): void;
  97920. /**
  97921. * Creates a vertex buffer
  97922. * @param data the data for the vertex buffer
  97923. * @returns the new WebGL static buffer
  97924. */
  97925. createVertexBuffer(data: DataArray): DataBuffer;
  97926. private _createVertexBuffer;
  97927. /**
  97928. * Creates a dynamic vertex buffer
  97929. * @param data the data for the dynamic vertex buffer
  97930. * @returns the new WebGL dynamic buffer
  97931. */
  97932. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97933. protected _resetIndexBufferBinding(): void;
  97934. /**
  97935. * Creates a new index buffer
  97936. * @param indices defines the content of the index buffer
  97937. * @param updatable defines if the index buffer must be updatable
  97938. * @returns a new webGL buffer
  97939. */
  97940. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97941. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97942. /**
  97943. * Bind a webGL buffer to the webGL context
  97944. * @param buffer defines the buffer to bind
  97945. */
  97946. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97947. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97948. private bindBuffer;
  97949. /**
  97950. * update the bound buffer with the given data
  97951. * @param data defines the data to update
  97952. */
  97953. updateArrayBuffer(data: Float32Array): void;
  97954. private _vertexAttribPointer;
  97955. private _bindIndexBufferWithCache;
  97956. private _bindVertexBuffersAttributes;
  97957. /**
  97958. * Records a vertex array object
  97959. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97960. * @param vertexBuffers defines the list of vertex buffers to store
  97961. * @param indexBuffer defines the index buffer to store
  97962. * @param effect defines the effect to store
  97963. * @returns the new vertex array object
  97964. */
  97965. recordVertexArrayObject(vertexBuffers: {
  97966. [key: string]: VertexBuffer;
  97967. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97968. /**
  97969. * Bind a specific vertex array object
  97970. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97971. * @param vertexArrayObject defines the vertex array object to bind
  97972. * @param indexBuffer defines the index buffer to bind
  97973. */
  97974. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97975. /**
  97976. * Bind webGl buffers directly to the webGL context
  97977. * @param vertexBuffer defines the vertex buffer to bind
  97978. * @param indexBuffer defines the index buffer to bind
  97979. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97980. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97981. * @param effect defines the effect associated with the vertex buffer
  97982. */
  97983. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97984. private _unbindVertexArrayObject;
  97985. /**
  97986. * Bind a list of vertex buffers to the webGL context
  97987. * @param vertexBuffers defines the list of vertex buffers to bind
  97988. * @param indexBuffer defines the index buffer to bind
  97989. * @param effect defines the effect associated with the vertex buffers
  97990. */
  97991. bindBuffers(vertexBuffers: {
  97992. [key: string]: Nullable<VertexBuffer>;
  97993. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97994. /**
  97995. * Unbind all instance attributes
  97996. */
  97997. unbindInstanceAttributes(): void;
  97998. /**
  97999. * Release and free the memory of a vertex array object
  98000. * @param vao defines the vertex array object to delete
  98001. */
  98002. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  98003. /** @hidden */
  98004. _releaseBuffer(buffer: DataBuffer): boolean;
  98005. protected _deleteBuffer(buffer: DataBuffer): void;
  98006. /**
  98007. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  98008. * @param instancesBuffer defines the webGL buffer to update and bind
  98009. * @param data defines the data to store in the buffer
  98010. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  98011. */
  98012. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  98013. /**
  98014. * Apply all cached states (depth, culling, stencil and alpha)
  98015. */
  98016. applyStates(): void;
  98017. /**
  98018. * Send a draw order
  98019. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98020. * @param indexStart defines the starting index
  98021. * @param indexCount defines the number of index to draw
  98022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98023. */
  98024. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98025. /**
  98026. * Draw a list of points
  98027. * @param verticesStart defines the index of first vertex to draw
  98028. * @param verticesCount defines the count of vertices to draw
  98029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98030. */
  98031. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98032. /**
  98033. * Draw a list of unindexed primitives
  98034. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98035. * @param verticesStart defines the index of first vertex to draw
  98036. * @param verticesCount defines the count of vertices to draw
  98037. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98038. */
  98039. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98040. /**
  98041. * Draw a list of indexed primitives
  98042. * @param fillMode defines the primitive to use
  98043. * @param indexStart defines the starting index
  98044. * @param indexCount defines the number of index to draw
  98045. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98046. */
  98047. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98048. /**
  98049. * Draw a list of unindexed primitives
  98050. * @param fillMode defines the primitive to use
  98051. * @param verticesStart defines the index of first vertex to draw
  98052. * @param verticesCount defines the count of vertices to draw
  98053. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98054. */
  98055. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98056. private _drawMode;
  98057. /** @hidden */
  98058. protected _reportDrawCall(): void;
  98059. /** @hidden */
  98060. _releaseEffect(effect: Effect): void;
  98061. /** @hidden */
  98062. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98063. /**
  98064. * Create a new effect (used to store vertex/fragment shaders)
  98065. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98066. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98067. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98068. * @param samplers defines an array of string used to represent textures
  98069. * @param defines defines the string containing the defines to use to compile the shaders
  98070. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98071. * @param onCompiled defines a function to call when the effect creation is successful
  98072. * @param onError defines a function to call when the effect creation has failed
  98073. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98074. * @returns the new Effect
  98075. */
  98076. 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;
  98077. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98078. private _compileShader;
  98079. private _compileRawShader;
  98080. /**
  98081. * Directly creates a webGL program
  98082. * @param pipelineContext defines the pipeline context to attach to
  98083. * @param vertexCode defines the vertex shader code to use
  98084. * @param fragmentCode defines the fragment shader code to use
  98085. * @param context defines the webGL context to use (if not set, the current one will be used)
  98086. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98087. * @returns the new webGL program
  98088. */
  98089. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98090. /**
  98091. * Creates a webGL program
  98092. * @param pipelineContext defines the pipeline context to attach to
  98093. * @param vertexCode defines the vertex shader code to use
  98094. * @param fragmentCode defines the fragment shader code to use
  98095. * @param defines defines the string containing the defines to use to compile the shaders
  98096. * @param context defines the webGL context to use (if not set, the current one will be used)
  98097. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98098. * @returns the new webGL program
  98099. */
  98100. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98101. /**
  98102. * Creates a new pipeline context
  98103. * @returns the new pipeline
  98104. */
  98105. createPipelineContext(): IPipelineContext;
  98106. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98107. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98108. /** @hidden */
  98109. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98110. /** @hidden */
  98111. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98112. /** @hidden */
  98113. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98114. /**
  98115. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98116. * @param pipelineContext defines the pipeline context to use
  98117. * @param uniformsNames defines the list of uniform names
  98118. * @returns an array of webGL uniform locations
  98119. */
  98120. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98121. /**
  98122. * Gets the lsit of active attributes for a given webGL program
  98123. * @param pipelineContext defines the pipeline context to use
  98124. * @param attributesNames defines the list of attribute names to get
  98125. * @returns an array of indices indicating the offset of each attribute
  98126. */
  98127. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98128. /**
  98129. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98130. * @param effect defines the effect to activate
  98131. */
  98132. enableEffect(effect: Nullable<Effect>): void;
  98133. /**
  98134. * Set the value of an uniform to a number (int)
  98135. * @param uniform defines the webGL uniform location where to store the value
  98136. * @param value defines the int number to store
  98137. */
  98138. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98139. /**
  98140. * Set the value of an uniform to an array of int32
  98141. * @param uniform defines the webGL uniform location where to store the value
  98142. * @param array defines the array of int32 to store
  98143. */
  98144. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98145. /**
  98146. * Set the value of an uniform to an array of int32 (stored as vec2)
  98147. * @param uniform defines the webGL uniform location where to store the value
  98148. * @param array defines the array of int32 to store
  98149. */
  98150. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98151. /**
  98152. * Set the value of an uniform to an array of int32 (stored as vec3)
  98153. * @param uniform defines the webGL uniform location where to store the value
  98154. * @param array defines the array of int32 to store
  98155. */
  98156. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98157. /**
  98158. * Set the value of an uniform to an array of int32 (stored as vec4)
  98159. * @param uniform defines the webGL uniform location where to store the value
  98160. * @param array defines the array of int32 to store
  98161. */
  98162. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98163. /**
  98164. * Set the value of an uniform to an array of number
  98165. * @param uniform defines the webGL uniform location where to store the value
  98166. * @param array defines the array of number to store
  98167. */
  98168. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98169. /**
  98170. * Set the value of an uniform to an array of number (stored as vec2)
  98171. * @param uniform defines the webGL uniform location where to store the value
  98172. * @param array defines the array of number to store
  98173. */
  98174. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98175. /**
  98176. * Set the value of an uniform to an array of number (stored as vec3)
  98177. * @param uniform defines the webGL uniform location where to store the value
  98178. * @param array defines the array of number to store
  98179. */
  98180. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98181. /**
  98182. * Set the value of an uniform to an array of number (stored as vec4)
  98183. * @param uniform defines the webGL uniform location where to store the value
  98184. * @param array defines the array of number to store
  98185. */
  98186. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98187. /**
  98188. * Set the value of an uniform to an array of float32 (stored as matrices)
  98189. * @param uniform defines the webGL uniform location where to store the value
  98190. * @param matrices defines the array of float32 to store
  98191. */
  98192. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98193. /**
  98194. * Set the value of an uniform to a matrix (3x3)
  98195. * @param uniform defines the webGL uniform location where to store the value
  98196. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98197. */
  98198. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98199. /**
  98200. * Set the value of an uniform to a matrix (2x2)
  98201. * @param uniform defines the webGL uniform location where to store the value
  98202. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98203. */
  98204. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98205. /**
  98206. * Set the value of an uniform to a number (float)
  98207. * @param uniform defines the webGL uniform location where to store the value
  98208. * @param value defines the float number to store
  98209. */
  98210. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98211. /**
  98212. * Set the value of an uniform to a vec2
  98213. * @param uniform defines the webGL uniform location where to store the value
  98214. * @param x defines the 1st component of the value
  98215. * @param y defines the 2nd component of the value
  98216. */
  98217. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98218. /**
  98219. * Set the value of an uniform to a vec3
  98220. * @param uniform defines the webGL uniform location where to store the value
  98221. * @param x defines the 1st component of the value
  98222. * @param y defines the 2nd component of the value
  98223. * @param z defines the 3rd component of the value
  98224. */
  98225. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98226. /**
  98227. * Set the value of an uniform to a vec4
  98228. * @param uniform defines the webGL uniform location where to store the value
  98229. * @param x defines the 1st component of the value
  98230. * @param y defines the 2nd component of the value
  98231. * @param z defines the 3rd component of the value
  98232. * @param w defines the 4th component of the value
  98233. */
  98234. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98235. /**
  98236. * Gets the depth culling state manager
  98237. */
  98238. readonly depthCullingState: DepthCullingState;
  98239. /**
  98240. * Gets the alpha state manager
  98241. */
  98242. readonly alphaState: AlphaState;
  98243. /**
  98244. * Gets the stencil state manager
  98245. */
  98246. readonly stencilState: StencilState;
  98247. /**
  98248. * Clears the list of texture accessible through engine.
  98249. * This can help preventing texture load conflict due to name collision.
  98250. */
  98251. clearInternalTexturesCache(): void;
  98252. /**
  98253. * Force the entire cache to be cleared
  98254. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98255. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98256. */
  98257. wipeCaches(bruteForce?: boolean): void;
  98258. /** @hidden */
  98259. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98260. min: number;
  98261. mag: number;
  98262. };
  98263. /** @hidden */
  98264. _createTexture(): WebGLTexture;
  98265. /**
  98266. * Usually called from Texture.ts.
  98267. * Passed information to create a WebGLTexture
  98268. * @param urlArg defines a value which contains one of the following:
  98269. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98270. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98271. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98273. * @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)
  98274. * @param scene needed for loading to the correct scene
  98275. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98276. * @param onLoad optional callback to be called upon successful completion
  98277. * @param onError optional callback to be called upon failure
  98278. * @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
  98279. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98280. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98281. * @param forcedExtension defines the extension to use to pick the right loader
  98282. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98283. * @param mimeType defines an optional mime type
  98284. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98285. */
  98286. 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;
  98287. /**
  98288. * @hidden
  98289. */
  98290. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98291. /**
  98292. * Creates a raw texture
  98293. * @param data defines the data to store in the texture
  98294. * @param width defines the width of the texture
  98295. * @param height defines the height of the texture
  98296. * @param format defines the format of the data
  98297. * @param generateMipMaps defines if the engine should generate the mip levels
  98298. * @param invertY defines if data must be stored with Y axis inverted
  98299. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98300. * @param compression defines the compression used (null by default)
  98301. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98302. * @returns the raw texture inside an InternalTexture
  98303. */
  98304. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98305. /**
  98306. * Creates a new raw cube texture
  98307. * @param data defines the array of data to use to create each face
  98308. * @param size defines the size of the textures
  98309. * @param format defines the format of the data
  98310. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98311. * @param generateMipMaps defines if the engine should generate the mip levels
  98312. * @param invertY defines if data must be stored with Y axis inverted
  98313. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98314. * @param compression defines the compression used (null by default)
  98315. * @returns the cube texture as an InternalTexture
  98316. */
  98317. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98318. /**
  98319. * Creates a new raw 3D texture
  98320. * @param data defines the data used to create the texture
  98321. * @param width defines the width of the texture
  98322. * @param height defines the height of the texture
  98323. * @param depth defines the depth of the texture
  98324. * @param format defines the format of the texture
  98325. * @param generateMipMaps defines if the engine must generate mip levels
  98326. * @param invertY defines if data must be stored with Y axis inverted
  98327. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98328. * @param compression defines the compressed used (can be null)
  98329. * @param textureType defines the compressed used (can be null)
  98330. * @returns a new raw 3D texture (stored in an InternalTexture)
  98331. */
  98332. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98333. /**
  98334. * Creates a new raw 2D array texture
  98335. * @param data defines the data used to create the texture
  98336. * @param width defines the width of the texture
  98337. * @param height defines the height of the texture
  98338. * @param depth defines the number of layers of the texture
  98339. * @param format defines the format of the texture
  98340. * @param generateMipMaps defines if the engine must generate mip levels
  98341. * @param invertY defines if data must be stored with Y axis inverted
  98342. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98343. * @param compression defines the compressed used (can be null)
  98344. * @param textureType defines the compressed used (can be null)
  98345. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98346. */
  98347. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98348. private _unpackFlipYCached;
  98349. /**
  98350. * In case you are sharing the context with other applications, it might
  98351. * be interested to not cache the unpack flip y state to ensure a consistent
  98352. * value would be set.
  98353. */
  98354. enableUnpackFlipYCached: boolean;
  98355. /** @hidden */
  98356. _unpackFlipY(value: boolean): void;
  98357. /** @hidden */
  98358. _getUnpackAlignement(): number;
  98359. /**
  98360. * Update the sampling mode of a given texture
  98361. * @param samplingMode defines the required sampling mode
  98362. * @param texture defines the texture to update
  98363. */
  98364. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98365. /** @hidden */
  98366. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98367. width: number;
  98368. height: number;
  98369. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98370. /** @hidden */
  98371. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98372. /** @hidden */
  98373. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98374. /** @hidden */
  98375. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98376. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98377. private _prepareWebGLTexture;
  98378. /** @hidden */
  98379. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98380. /** @hidden */
  98381. _releaseFramebufferObjects(texture: InternalTexture): void;
  98382. /** @hidden */
  98383. _releaseTexture(texture: InternalTexture): void;
  98384. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98385. protected _setProgram(program: WebGLProgram): void;
  98386. protected _boundUniforms: {
  98387. [key: number]: WebGLUniformLocation;
  98388. };
  98389. /**
  98390. * Binds an effect to the webGL context
  98391. * @param effect defines the effect to bind
  98392. */
  98393. bindSamplers(effect: Effect): void;
  98394. private _activateCurrentTexture;
  98395. /** @hidden */
  98396. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98397. /** @hidden */
  98398. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98399. /**
  98400. * Unbind all textures from the webGL context
  98401. */
  98402. unbindAllTextures(): void;
  98403. /**
  98404. * Sets a texture to the according uniform.
  98405. * @param channel The texture channel
  98406. * @param uniform The uniform to set
  98407. * @param texture The texture to apply
  98408. */
  98409. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98410. private _bindSamplerUniformToChannel;
  98411. private _getTextureWrapMode;
  98412. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98413. /**
  98414. * Sets an array of texture to the webGL context
  98415. * @param channel defines the channel where the texture array must be set
  98416. * @param uniform defines the associated uniform location
  98417. * @param textures defines the array of textures to bind
  98418. */
  98419. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98420. /** @hidden */
  98421. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98422. private _setTextureParameterFloat;
  98423. private _setTextureParameterInteger;
  98424. /**
  98425. * Unbind all vertex attributes from the webGL context
  98426. */
  98427. unbindAllAttributes(): void;
  98428. /**
  98429. * 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
  98430. */
  98431. releaseEffects(): void;
  98432. /**
  98433. * Dispose and release all associated resources
  98434. */
  98435. dispose(): void;
  98436. /**
  98437. * Attach a new callback raised when context lost event is fired
  98438. * @param callback defines the callback to call
  98439. */
  98440. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98441. /**
  98442. * Attach a new callback raised when context restored event is fired
  98443. * @param callback defines the callback to call
  98444. */
  98445. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98446. /**
  98447. * Get the current error code of the webGL context
  98448. * @returns the error code
  98449. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98450. */
  98451. getError(): number;
  98452. private _canRenderToFloatFramebuffer;
  98453. private _canRenderToHalfFloatFramebuffer;
  98454. private _canRenderToFramebuffer;
  98455. /** @hidden */
  98456. _getWebGLTextureType(type: number): number;
  98457. /** @hidden */
  98458. _getInternalFormat(format: number): number;
  98459. /** @hidden */
  98460. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98461. /** @hidden */
  98462. _getRGBAMultiSampleBufferFormat(type: number): number;
  98463. /** @hidden */
  98464. _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;
  98465. /**
  98466. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98467. * @returns true if the engine can be created
  98468. * @ignorenaming
  98469. */
  98470. static isSupported(): boolean;
  98471. /**
  98472. * Find the next highest power of two.
  98473. * @param x Number to start search from.
  98474. * @return Next highest power of two.
  98475. */
  98476. static CeilingPOT(x: number): number;
  98477. /**
  98478. * Find the next lowest power of two.
  98479. * @param x Number to start search from.
  98480. * @return Next lowest power of two.
  98481. */
  98482. static FloorPOT(x: number): number;
  98483. /**
  98484. * Find the nearest power of two.
  98485. * @param x Number to start search from.
  98486. * @return Next nearest power of two.
  98487. */
  98488. static NearestPOT(x: number): number;
  98489. /**
  98490. * Get the closest exponent of two
  98491. * @param value defines the value to approximate
  98492. * @param max defines the maximum value to return
  98493. * @param mode defines how to define the closest value
  98494. * @returns closest exponent of two of the given value
  98495. */
  98496. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98497. /**
  98498. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98499. * @param func - the function to be called
  98500. * @param requester - the object that will request the next frame. Falls back to window.
  98501. * @returns frame number
  98502. */
  98503. static QueueNewFrame(func: () => void, requester?: any): number;
  98504. }
  98505. }
  98506. declare module BABYLON {
  98507. /**
  98508. * Class representing spherical harmonics coefficients to the 3rd degree
  98509. */
  98510. export class SphericalHarmonics {
  98511. /**
  98512. * Defines whether or not the harmonics have been prescaled for rendering.
  98513. */
  98514. preScaled: boolean;
  98515. /**
  98516. * The l0,0 coefficients of the spherical harmonics
  98517. */
  98518. l00: Vector3;
  98519. /**
  98520. * The l1,-1 coefficients of the spherical harmonics
  98521. */
  98522. l1_1: Vector3;
  98523. /**
  98524. * The l1,0 coefficients of the spherical harmonics
  98525. */
  98526. l10: Vector3;
  98527. /**
  98528. * The l1,1 coefficients of the spherical harmonics
  98529. */
  98530. l11: Vector3;
  98531. /**
  98532. * The l2,-2 coefficients of the spherical harmonics
  98533. */
  98534. l2_2: Vector3;
  98535. /**
  98536. * The l2,-1 coefficients of the spherical harmonics
  98537. */
  98538. l2_1: Vector3;
  98539. /**
  98540. * The l2,0 coefficients of the spherical harmonics
  98541. */
  98542. l20: Vector3;
  98543. /**
  98544. * The l2,1 coefficients of the spherical harmonics
  98545. */
  98546. l21: Vector3;
  98547. /**
  98548. * The l2,2 coefficients of the spherical harmonics
  98549. */
  98550. l22: Vector3;
  98551. /**
  98552. * Adds a light to the spherical harmonics
  98553. * @param direction the direction of the light
  98554. * @param color the color of the light
  98555. * @param deltaSolidAngle the delta solid angle of the light
  98556. */
  98557. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98558. /**
  98559. * Scales the spherical harmonics by the given amount
  98560. * @param scale the amount to scale
  98561. */
  98562. scaleInPlace(scale: number): void;
  98563. /**
  98564. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98565. *
  98566. * ```
  98567. * E_lm = A_l * L_lm
  98568. * ```
  98569. *
  98570. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98571. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98572. * the scaling factors are given in equation 9.
  98573. */
  98574. convertIncidentRadianceToIrradiance(): void;
  98575. /**
  98576. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98577. *
  98578. * ```
  98579. * L = (1/pi) * E * rho
  98580. * ```
  98581. *
  98582. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98583. */
  98584. convertIrradianceToLambertianRadiance(): void;
  98585. /**
  98586. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98587. * required operations at run time.
  98588. *
  98589. * This is simply done by scaling back the SH with Ylm constants parameter.
  98590. * The trigonometric part being applied by the shader at run time.
  98591. */
  98592. preScaleForRendering(): void;
  98593. /**
  98594. * Constructs a spherical harmonics from an array.
  98595. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98596. * @returns the spherical harmonics
  98597. */
  98598. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98599. /**
  98600. * Gets the spherical harmonics from polynomial
  98601. * @param polynomial the spherical polynomial
  98602. * @returns the spherical harmonics
  98603. */
  98604. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98605. }
  98606. /**
  98607. * Class representing spherical polynomial coefficients to the 3rd degree
  98608. */
  98609. export class SphericalPolynomial {
  98610. private _harmonics;
  98611. /**
  98612. * The spherical harmonics used to create the polynomials.
  98613. */
  98614. readonly preScaledHarmonics: SphericalHarmonics;
  98615. /**
  98616. * The x coefficients of the spherical polynomial
  98617. */
  98618. x: Vector3;
  98619. /**
  98620. * The y coefficients of the spherical polynomial
  98621. */
  98622. y: Vector3;
  98623. /**
  98624. * The z coefficients of the spherical polynomial
  98625. */
  98626. z: Vector3;
  98627. /**
  98628. * The xx coefficients of the spherical polynomial
  98629. */
  98630. xx: Vector3;
  98631. /**
  98632. * The yy coefficients of the spherical polynomial
  98633. */
  98634. yy: Vector3;
  98635. /**
  98636. * The zz coefficients of the spherical polynomial
  98637. */
  98638. zz: Vector3;
  98639. /**
  98640. * The xy coefficients of the spherical polynomial
  98641. */
  98642. xy: Vector3;
  98643. /**
  98644. * The yz coefficients of the spherical polynomial
  98645. */
  98646. yz: Vector3;
  98647. /**
  98648. * The zx coefficients of the spherical polynomial
  98649. */
  98650. zx: Vector3;
  98651. /**
  98652. * Adds an ambient color to the spherical polynomial
  98653. * @param color the color to add
  98654. */
  98655. addAmbient(color: Color3): void;
  98656. /**
  98657. * Scales the spherical polynomial by the given amount
  98658. * @param scale the amount to scale
  98659. */
  98660. scaleInPlace(scale: number): void;
  98661. /**
  98662. * Gets the spherical polynomial from harmonics
  98663. * @param harmonics the spherical harmonics
  98664. * @returns the spherical polynomial
  98665. */
  98666. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98667. /**
  98668. * Constructs a spherical polynomial from an array.
  98669. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98670. * @returns the spherical polynomial
  98671. */
  98672. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98673. }
  98674. }
  98675. declare module BABYLON {
  98676. /**
  98677. * Defines the source of the internal texture
  98678. */
  98679. export enum InternalTextureSource {
  98680. /**
  98681. * The source of the texture data is unknown
  98682. */
  98683. Unknown = 0,
  98684. /**
  98685. * Texture data comes from an URL
  98686. */
  98687. Url = 1,
  98688. /**
  98689. * Texture data is only used for temporary storage
  98690. */
  98691. Temp = 2,
  98692. /**
  98693. * Texture data comes from raw data (ArrayBuffer)
  98694. */
  98695. Raw = 3,
  98696. /**
  98697. * Texture content is dynamic (video or dynamic texture)
  98698. */
  98699. Dynamic = 4,
  98700. /**
  98701. * Texture content is generated by rendering to it
  98702. */
  98703. RenderTarget = 5,
  98704. /**
  98705. * Texture content is part of a multi render target process
  98706. */
  98707. MultiRenderTarget = 6,
  98708. /**
  98709. * Texture data comes from a cube data file
  98710. */
  98711. Cube = 7,
  98712. /**
  98713. * Texture data comes from a raw cube data
  98714. */
  98715. CubeRaw = 8,
  98716. /**
  98717. * Texture data come from a prefiltered cube data file
  98718. */
  98719. CubePrefiltered = 9,
  98720. /**
  98721. * Texture content is raw 3D data
  98722. */
  98723. Raw3D = 10,
  98724. /**
  98725. * Texture content is raw 2D array data
  98726. */
  98727. Raw2DArray = 11,
  98728. /**
  98729. * Texture content is a depth texture
  98730. */
  98731. Depth = 12,
  98732. /**
  98733. * Texture data comes from a raw cube data encoded with RGBD
  98734. */
  98735. CubeRawRGBD = 13
  98736. }
  98737. /**
  98738. * Class used to store data associated with WebGL texture data for the engine
  98739. * This class should not be used directly
  98740. */
  98741. export class InternalTexture {
  98742. /** @hidden */
  98743. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98744. /**
  98745. * Defines if the texture is ready
  98746. */
  98747. isReady: boolean;
  98748. /**
  98749. * Defines if the texture is a cube texture
  98750. */
  98751. isCube: boolean;
  98752. /**
  98753. * Defines if the texture contains 3D data
  98754. */
  98755. is3D: boolean;
  98756. /**
  98757. * Defines if the texture contains 2D array data
  98758. */
  98759. is2DArray: boolean;
  98760. /**
  98761. * Defines if the texture contains multiview data
  98762. */
  98763. isMultiview: boolean;
  98764. /**
  98765. * Gets the URL used to load this texture
  98766. */
  98767. url: string;
  98768. /**
  98769. * Gets the sampling mode of the texture
  98770. */
  98771. samplingMode: number;
  98772. /**
  98773. * Gets a boolean indicating if the texture needs mipmaps generation
  98774. */
  98775. generateMipMaps: boolean;
  98776. /**
  98777. * Gets the number of samples used by the texture (WebGL2+ only)
  98778. */
  98779. samples: number;
  98780. /**
  98781. * Gets the type of the texture (int, float...)
  98782. */
  98783. type: number;
  98784. /**
  98785. * Gets the format of the texture (RGB, RGBA...)
  98786. */
  98787. format: number;
  98788. /**
  98789. * Observable called when the texture is loaded
  98790. */
  98791. onLoadedObservable: Observable<InternalTexture>;
  98792. /**
  98793. * Gets the width of the texture
  98794. */
  98795. width: number;
  98796. /**
  98797. * Gets the height of the texture
  98798. */
  98799. height: number;
  98800. /**
  98801. * Gets the depth of the texture
  98802. */
  98803. depth: number;
  98804. /**
  98805. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98806. */
  98807. baseWidth: number;
  98808. /**
  98809. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98810. */
  98811. baseHeight: number;
  98812. /**
  98813. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98814. */
  98815. baseDepth: number;
  98816. /**
  98817. * Gets a boolean indicating if the texture is inverted on Y axis
  98818. */
  98819. invertY: boolean;
  98820. /** @hidden */
  98821. _invertVScale: boolean;
  98822. /** @hidden */
  98823. _associatedChannel: number;
  98824. /** @hidden */
  98825. _source: InternalTextureSource;
  98826. /** @hidden */
  98827. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98828. /** @hidden */
  98829. _bufferView: Nullable<ArrayBufferView>;
  98830. /** @hidden */
  98831. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98832. /** @hidden */
  98833. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98834. /** @hidden */
  98835. _size: number;
  98836. /** @hidden */
  98837. _extension: string;
  98838. /** @hidden */
  98839. _files: Nullable<string[]>;
  98840. /** @hidden */
  98841. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98842. /** @hidden */
  98843. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98844. /** @hidden */
  98845. _framebuffer: Nullable<WebGLFramebuffer>;
  98846. /** @hidden */
  98847. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98848. /** @hidden */
  98849. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98850. /** @hidden */
  98851. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98852. /** @hidden */
  98853. _attachments: Nullable<number[]>;
  98854. /** @hidden */
  98855. _cachedCoordinatesMode: Nullable<number>;
  98856. /** @hidden */
  98857. _cachedWrapU: Nullable<number>;
  98858. /** @hidden */
  98859. _cachedWrapV: Nullable<number>;
  98860. /** @hidden */
  98861. _cachedWrapR: Nullable<number>;
  98862. /** @hidden */
  98863. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98864. /** @hidden */
  98865. _isDisabled: boolean;
  98866. /** @hidden */
  98867. _compression: Nullable<string>;
  98868. /** @hidden */
  98869. _generateStencilBuffer: boolean;
  98870. /** @hidden */
  98871. _generateDepthBuffer: boolean;
  98872. /** @hidden */
  98873. _comparisonFunction: number;
  98874. /** @hidden */
  98875. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98876. /** @hidden */
  98877. _lodGenerationScale: number;
  98878. /** @hidden */
  98879. _lodGenerationOffset: number;
  98880. /** @hidden */
  98881. _colorTextureArray: Nullable<WebGLTexture>;
  98882. /** @hidden */
  98883. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98884. /** @hidden */
  98885. _lodTextureHigh: Nullable<BaseTexture>;
  98886. /** @hidden */
  98887. _lodTextureMid: Nullable<BaseTexture>;
  98888. /** @hidden */
  98889. _lodTextureLow: Nullable<BaseTexture>;
  98890. /** @hidden */
  98891. _isRGBD: boolean;
  98892. /** @hidden */
  98893. _linearSpecularLOD: boolean;
  98894. /** @hidden */
  98895. _irradianceTexture: Nullable<BaseTexture>;
  98896. /** @hidden */
  98897. _webGLTexture: Nullable<WebGLTexture>;
  98898. /** @hidden */
  98899. _references: number;
  98900. private _engine;
  98901. /**
  98902. * Gets the Engine the texture belongs to.
  98903. * @returns The babylon engine
  98904. */
  98905. getEngine(): ThinEngine;
  98906. /**
  98907. * Gets the data source type of the texture
  98908. */
  98909. readonly source: InternalTextureSource;
  98910. /**
  98911. * Creates a new InternalTexture
  98912. * @param engine defines the engine to use
  98913. * @param source defines the type of data that will be used
  98914. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98915. */
  98916. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98917. /**
  98918. * Increments the number of references (ie. the number of Texture that point to it)
  98919. */
  98920. incrementReferences(): void;
  98921. /**
  98922. * Change the size of the texture (not the size of the content)
  98923. * @param width defines the new width
  98924. * @param height defines the new height
  98925. * @param depth defines the new depth (1 by default)
  98926. */
  98927. updateSize(width: int, height: int, depth?: int): void;
  98928. /** @hidden */
  98929. _rebuild(): void;
  98930. /** @hidden */
  98931. _swapAndDie(target: InternalTexture): void;
  98932. /**
  98933. * Dispose the current allocated resources
  98934. */
  98935. dispose(): void;
  98936. }
  98937. }
  98938. declare module BABYLON {
  98939. /**
  98940. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98942. */
  98943. export class Analyser {
  98944. /**
  98945. * Gets or sets the smoothing
  98946. * @ignorenaming
  98947. */
  98948. SMOOTHING: number;
  98949. /**
  98950. * Gets or sets the FFT table size
  98951. * @ignorenaming
  98952. */
  98953. FFT_SIZE: number;
  98954. /**
  98955. * Gets or sets the bar graph amplitude
  98956. * @ignorenaming
  98957. */
  98958. BARGRAPHAMPLITUDE: number;
  98959. /**
  98960. * Gets or sets the position of the debug canvas
  98961. * @ignorenaming
  98962. */
  98963. DEBUGCANVASPOS: {
  98964. x: number;
  98965. y: number;
  98966. };
  98967. /**
  98968. * Gets or sets the debug canvas size
  98969. * @ignorenaming
  98970. */
  98971. DEBUGCANVASSIZE: {
  98972. width: number;
  98973. height: number;
  98974. };
  98975. private _byteFreqs;
  98976. private _byteTime;
  98977. private _floatFreqs;
  98978. private _webAudioAnalyser;
  98979. private _debugCanvas;
  98980. private _debugCanvasContext;
  98981. private _scene;
  98982. private _registerFunc;
  98983. private _audioEngine;
  98984. /**
  98985. * Creates a new analyser
  98986. * @param scene defines hosting scene
  98987. */
  98988. constructor(scene: Scene);
  98989. /**
  98990. * Get the number of data values you will have to play with for the visualization
  98991. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98992. * @returns a number
  98993. */
  98994. getFrequencyBinCount(): number;
  98995. /**
  98996. * Gets the current frequency data as a byte array
  98997. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98998. * @returns a Uint8Array
  98999. */
  99000. getByteFrequencyData(): Uint8Array;
  99001. /**
  99002. * Gets the current waveform as a byte array
  99003. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  99004. * @returns a Uint8Array
  99005. */
  99006. getByteTimeDomainData(): Uint8Array;
  99007. /**
  99008. * Gets the current frequency data as a float array
  99009. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99010. * @returns a Float32Array
  99011. */
  99012. getFloatFrequencyData(): Float32Array;
  99013. /**
  99014. * Renders the debug canvas
  99015. */
  99016. drawDebugCanvas(): void;
  99017. /**
  99018. * Stops rendering the debug canvas and removes it
  99019. */
  99020. stopDebugCanvas(): void;
  99021. /**
  99022. * Connects two audio nodes
  99023. * @param inputAudioNode defines first node to connect
  99024. * @param outputAudioNode defines second node to connect
  99025. */
  99026. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99027. /**
  99028. * Releases all associated resources
  99029. */
  99030. dispose(): void;
  99031. }
  99032. }
  99033. declare module BABYLON {
  99034. /**
  99035. * This represents an audio engine and it is responsible
  99036. * to play, synchronize and analyse sounds throughout the application.
  99037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99038. */
  99039. export interface IAudioEngine extends IDisposable {
  99040. /**
  99041. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99042. */
  99043. readonly canUseWebAudio: boolean;
  99044. /**
  99045. * Gets the current AudioContext if available.
  99046. */
  99047. readonly audioContext: Nullable<AudioContext>;
  99048. /**
  99049. * The master gain node defines the global audio volume of your audio engine.
  99050. */
  99051. readonly masterGain: GainNode;
  99052. /**
  99053. * Gets whether or not mp3 are supported by your browser.
  99054. */
  99055. readonly isMP3supported: boolean;
  99056. /**
  99057. * Gets whether or not ogg are supported by your browser.
  99058. */
  99059. readonly isOGGsupported: boolean;
  99060. /**
  99061. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99062. * @ignoreNaming
  99063. */
  99064. WarnedWebAudioUnsupported: boolean;
  99065. /**
  99066. * Defines if the audio engine relies on a custom unlocked button.
  99067. * In this case, the embedded button will not be displayed.
  99068. */
  99069. useCustomUnlockedButton: boolean;
  99070. /**
  99071. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99072. */
  99073. readonly unlocked: boolean;
  99074. /**
  99075. * Event raised when audio has been unlocked on the browser.
  99076. */
  99077. onAudioUnlockedObservable: Observable<AudioEngine>;
  99078. /**
  99079. * Event raised when audio has been locked on the browser.
  99080. */
  99081. onAudioLockedObservable: Observable<AudioEngine>;
  99082. /**
  99083. * Flags the audio engine in Locked state.
  99084. * This happens due to new browser policies preventing audio to autoplay.
  99085. */
  99086. lock(): void;
  99087. /**
  99088. * Unlocks the audio engine once a user action has been done on the dom.
  99089. * This is helpful to resume play once browser policies have been satisfied.
  99090. */
  99091. unlock(): void;
  99092. }
  99093. /**
  99094. * This represents the default audio engine used in babylon.
  99095. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99097. */
  99098. export class AudioEngine implements IAudioEngine {
  99099. private _audioContext;
  99100. private _audioContextInitialized;
  99101. private _muteButton;
  99102. private _hostElement;
  99103. /**
  99104. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99105. */
  99106. canUseWebAudio: boolean;
  99107. /**
  99108. * The master gain node defines the global audio volume of your audio engine.
  99109. */
  99110. masterGain: GainNode;
  99111. /**
  99112. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99113. * @ignoreNaming
  99114. */
  99115. WarnedWebAudioUnsupported: boolean;
  99116. /**
  99117. * Gets whether or not mp3 are supported by your browser.
  99118. */
  99119. isMP3supported: boolean;
  99120. /**
  99121. * Gets whether or not ogg are supported by your browser.
  99122. */
  99123. isOGGsupported: boolean;
  99124. /**
  99125. * Gets whether audio has been unlocked on the device.
  99126. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99127. * a user interaction has happened.
  99128. */
  99129. unlocked: boolean;
  99130. /**
  99131. * Defines if the audio engine relies on a custom unlocked button.
  99132. * In this case, the embedded button will not be displayed.
  99133. */
  99134. useCustomUnlockedButton: boolean;
  99135. /**
  99136. * Event raised when audio has been unlocked on the browser.
  99137. */
  99138. onAudioUnlockedObservable: Observable<AudioEngine>;
  99139. /**
  99140. * Event raised when audio has been locked on the browser.
  99141. */
  99142. onAudioLockedObservable: Observable<AudioEngine>;
  99143. /**
  99144. * Gets the current AudioContext if available.
  99145. */
  99146. readonly audioContext: Nullable<AudioContext>;
  99147. private _connectedAnalyser;
  99148. /**
  99149. * Instantiates a new audio engine.
  99150. *
  99151. * There should be only one per page as some browsers restrict the number
  99152. * of audio contexts you can create.
  99153. * @param hostElement defines the host element where to display the mute icon if necessary
  99154. */
  99155. constructor(hostElement?: Nullable<HTMLElement>);
  99156. /**
  99157. * Flags the audio engine in Locked state.
  99158. * This happens due to new browser policies preventing audio to autoplay.
  99159. */
  99160. lock(): void;
  99161. /**
  99162. * Unlocks the audio engine once a user action has been done on the dom.
  99163. * This is helpful to resume play once browser policies have been satisfied.
  99164. */
  99165. unlock(): void;
  99166. private _resumeAudioContext;
  99167. private _initializeAudioContext;
  99168. private _tryToRun;
  99169. private _triggerRunningState;
  99170. private _triggerSuspendedState;
  99171. private _displayMuteButton;
  99172. private _moveButtonToTopLeft;
  99173. private _onResize;
  99174. private _hideMuteButton;
  99175. /**
  99176. * Destroy and release the resources associated with the audio ccontext.
  99177. */
  99178. dispose(): void;
  99179. /**
  99180. * Gets the global volume sets on the master gain.
  99181. * @returns the global volume if set or -1 otherwise
  99182. */
  99183. getGlobalVolume(): number;
  99184. /**
  99185. * Sets the global volume of your experience (sets on the master gain).
  99186. * @param newVolume Defines the new global volume of the application
  99187. */
  99188. setGlobalVolume(newVolume: number): void;
  99189. /**
  99190. * Connect the audio engine to an audio analyser allowing some amazing
  99191. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99193. * @param analyser The analyser to connect to the engine
  99194. */
  99195. connectToAnalyser(analyser: Analyser): void;
  99196. }
  99197. }
  99198. declare module BABYLON {
  99199. /**
  99200. * Interface used to present a loading screen while loading a scene
  99201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99202. */
  99203. export interface ILoadingScreen {
  99204. /**
  99205. * Function called to display the loading screen
  99206. */
  99207. displayLoadingUI: () => void;
  99208. /**
  99209. * Function called to hide the loading screen
  99210. */
  99211. hideLoadingUI: () => void;
  99212. /**
  99213. * Gets or sets the color to use for the background
  99214. */
  99215. loadingUIBackgroundColor: string;
  99216. /**
  99217. * Gets or sets the text to display while loading
  99218. */
  99219. loadingUIText: string;
  99220. }
  99221. /**
  99222. * Class used for the default loading screen
  99223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99224. */
  99225. export class DefaultLoadingScreen implements ILoadingScreen {
  99226. private _renderingCanvas;
  99227. private _loadingText;
  99228. private _loadingDivBackgroundColor;
  99229. private _loadingDiv;
  99230. private _loadingTextDiv;
  99231. /** Gets or sets the logo url to use for the default loading screen */
  99232. static DefaultLogoUrl: string;
  99233. /** Gets or sets the spinner url to use for the default loading screen */
  99234. static DefaultSpinnerUrl: string;
  99235. /**
  99236. * Creates a new default loading screen
  99237. * @param _renderingCanvas defines the canvas used to render the scene
  99238. * @param _loadingText defines the default text to display
  99239. * @param _loadingDivBackgroundColor defines the default background color
  99240. */
  99241. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99242. /**
  99243. * Function called to display the loading screen
  99244. */
  99245. displayLoadingUI(): void;
  99246. /**
  99247. * Function called to hide the loading screen
  99248. */
  99249. hideLoadingUI(): void;
  99250. /**
  99251. * Gets or sets the text to display while loading
  99252. */
  99253. loadingUIText: string;
  99254. /**
  99255. * Gets or sets the color to use for the background
  99256. */
  99257. loadingUIBackgroundColor: string;
  99258. private _resizeLoadingUI;
  99259. }
  99260. }
  99261. declare module BABYLON {
  99262. /**
  99263. * Interface for any object that can request an animation frame
  99264. */
  99265. export interface ICustomAnimationFrameRequester {
  99266. /**
  99267. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99268. */
  99269. renderFunction?: Function;
  99270. /**
  99271. * Called to request the next frame to render to
  99272. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99273. */
  99274. requestAnimationFrame: Function;
  99275. /**
  99276. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99277. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99278. */
  99279. requestID?: number;
  99280. }
  99281. }
  99282. declare module BABYLON {
  99283. /**
  99284. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99285. */
  99286. export class PerformanceMonitor {
  99287. private _enabled;
  99288. private _rollingFrameTime;
  99289. private _lastFrameTimeMs;
  99290. /**
  99291. * constructor
  99292. * @param frameSampleSize The number of samples required to saturate the sliding window
  99293. */
  99294. constructor(frameSampleSize?: number);
  99295. /**
  99296. * Samples current frame
  99297. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99298. */
  99299. sampleFrame(timeMs?: number): void;
  99300. /**
  99301. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99302. */
  99303. readonly averageFrameTime: number;
  99304. /**
  99305. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99306. */
  99307. readonly averageFrameTimeVariance: number;
  99308. /**
  99309. * Returns the frame time of the most recent frame
  99310. */
  99311. readonly instantaneousFrameTime: number;
  99312. /**
  99313. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99314. */
  99315. readonly averageFPS: number;
  99316. /**
  99317. * Returns the average framerate in frames per second using the most recent frame time
  99318. */
  99319. readonly instantaneousFPS: number;
  99320. /**
  99321. * Returns true if enough samples have been taken to completely fill the sliding window
  99322. */
  99323. readonly isSaturated: boolean;
  99324. /**
  99325. * Enables contributions to the sliding window sample set
  99326. */
  99327. enable(): void;
  99328. /**
  99329. * Disables contributions to the sliding window sample set
  99330. * Samples will not be interpolated over the disabled period
  99331. */
  99332. disable(): void;
  99333. /**
  99334. * Returns true if sampling is enabled
  99335. */
  99336. readonly isEnabled: boolean;
  99337. /**
  99338. * Resets performance monitor
  99339. */
  99340. reset(): void;
  99341. }
  99342. /**
  99343. * RollingAverage
  99344. *
  99345. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99346. */
  99347. export class RollingAverage {
  99348. /**
  99349. * Current average
  99350. */
  99351. average: number;
  99352. /**
  99353. * Current variance
  99354. */
  99355. variance: number;
  99356. protected _samples: Array<number>;
  99357. protected _sampleCount: number;
  99358. protected _pos: number;
  99359. protected _m2: number;
  99360. /**
  99361. * constructor
  99362. * @param length The number of samples required to saturate the sliding window
  99363. */
  99364. constructor(length: number);
  99365. /**
  99366. * Adds a sample to the sample set
  99367. * @param v The sample value
  99368. */
  99369. add(v: number): void;
  99370. /**
  99371. * Returns previously added values or null if outside of history or outside the sliding window domain
  99372. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99373. * @return Value previously recorded with add() or null if outside of range
  99374. */
  99375. history(i: number): number;
  99376. /**
  99377. * Returns true if enough samples have been taken to completely fill the sliding window
  99378. * @return true if sample-set saturated
  99379. */
  99380. isSaturated(): boolean;
  99381. /**
  99382. * Resets the rolling average (equivalent to 0 samples taken so far)
  99383. */
  99384. reset(): void;
  99385. /**
  99386. * Wraps a value around the sample range boundaries
  99387. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99388. * @return Wrapped position in sample range
  99389. */
  99390. protected _wrapPosition(i: number): number;
  99391. }
  99392. }
  99393. declare module BABYLON {
  99394. /**
  99395. * This class is used to track a performance counter which is number based.
  99396. * The user has access to many properties which give statistics of different nature.
  99397. *
  99398. * The implementer can track two kinds of Performance Counter: time and count.
  99399. * 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.
  99400. * 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.
  99401. */
  99402. export class PerfCounter {
  99403. /**
  99404. * Gets or sets a global boolean to turn on and off all the counters
  99405. */
  99406. static Enabled: boolean;
  99407. /**
  99408. * Returns the smallest value ever
  99409. */
  99410. readonly min: number;
  99411. /**
  99412. * Returns the biggest value ever
  99413. */
  99414. readonly max: number;
  99415. /**
  99416. * Returns the average value since the performance counter is running
  99417. */
  99418. readonly average: number;
  99419. /**
  99420. * Returns the average value of the last second the counter was monitored
  99421. */
  99422. readonly lastSecAverage: number;
  99423. /**
  99424. * Returns the current value
  99425. */
  99426. readonly current: number;
  99427. /**
  99428. * Gets the accumulated total
  99429. */
  99430. readonly total: number;
  99431. /**
  99432. * Gets the total value count
  99433. */
  99434. readonly count: number;
  99435. /**
  99436. * Creates a new counter
  99437. */
  99438. constructor();
  99439. /**
  99440. * Call this method to start monitoring a new frame.
  99441. * 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.
  99442. */
  99443. fetchNewFrame(): void;
  99444. /**
  99445. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99446. * @param newCount the count value to add to the monitored count
  99447. * @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.
  99448. */
  99449. addCount(newCount: number, fetchResult: boolean): void;
  99450. /**
  99451. * Start monitoring this performance counter
  99452. */
  99453. beginMonitoring(): void;
  99454. /**
  99455. * Compute the time lapsed since the previous beginMonitoring() call.
  99456. * @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
  99457. */
  99458. endMonitoring(newFrame?: boolean): void;
  99459. private _fetchResult;
  99460. private _startMonitoringTime;
  99461. private _min;
  99462. private _max;
  99463. private _average;
  99464. private _current;
  99465. private _totalValueCount;
  99466. private _totalAccumulated;
  99467. private _lastSecAverage;
  99468. private _lastSecAccumulated;
  99469. private _lastSecTime;
  99470. private _lastSecValueCount;
  99471. }
  99472. }
  99473. declare module BABYLON {
  99474. /**
  99475. * Defines the interface used by display changed events
  99476. */
  99477. export interface IDisplayChangedEventArgs {
  99478. /** Gets the vrDisplay object (if any) */
  99479. vrDisplay: Nullable<any>;
  99480. /** Gets a boolean indicating if webVR is supported */
  99481. vrSupported: boolean;
  99482. }
  99483. /**
  99484. * Defines the interface used by objects containing a viewport (like a camera)
  99485. */
  99486. interface IViewportOwnerLike {
  99487. /**
  99488. * Gets or sets the viewport
  99489. */
  99490. viewport: IViewportLike;
  99491. }
  99492. /**
  99493. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99494. */
  99495. export class Engine extends ThinEngine {
  99496. /** Defines that alpha blending is disabled */
  99497. static readonly ALPHA_DISABLE: number;
  99498. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99499. static readonly ALPHA_ADD: number;
  99500. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99501. static readonly ALPHA_COMBINE: number;
  99502. /** Defines that alpha blending to DEST - SRC * DEST */
  99503. static readonly ALPHA_SUBTRACT: number;
  99504. /** Defines that alpha blending to SRC * DEST */
  99505. static readonly ALPHA_MULTIPLY: number;
  99506. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99507. static readonly ALPHA_MAXIMIZED: number;
  99508. /** Defines that alpha blending to SRC + DEST */
  99509. static readonly ALPHA_ONEONE: number;
  99510. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99511. static readonly ALPHA_PREMULTIPLIED: number;
  99512. /**
  99513. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99514. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99515. */
  99516. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99517. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99518. static readonly ALPHA_INTERPOLATE: number;
  99519. /**
  99520. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99521. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99522. */
  99523. static readonly ALPHA_SCREENMODE: number;
  99524. /** Defines that the ressource is not delayed*/
  99525. static readonly DELAYLOADSTATE_NONE: number;
  99526. /** Defines that the ressource was successfully delay loaded */
  99527. static readonly DELAYLOADSTATE_LOADED: number;
  99528. /** Defines that the ressource is currently delay loading */
  99529. static readonly DELAYLOADSTATE_LOADING: number;
  99530. /** Defines that the ressource is delayed and has not started loading */
  99531. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99532. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99533. static readonly NEVER: number;
  99534. /** 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 */
  99535. static readonly ALWAYS: number;
  99536. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99537. static readonly LESS: number;
  99538. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99539. static readonly EQUAL: number;
  99540. /** 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 */
  99541. static readonly LEQUAL: number;
  99542. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99543. static readonly GREATER: number;
  99544. /** 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 */
  99545. static readonly GEQUAL: number;
  99546. /** 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 */
  99547. static readonly NOTEQUAL: number;
  99548. /** Passed to stencilOperation to specify that stencil value must be kept */
  99549. static readonly KEEP: number;
  99550. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99551. static readonly REPLACE: number;
  99552. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99553. static readonly INCR: number;
  99554. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99555. static readonly DECR: number;
  99556. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99557. static readonly INVERT: number;
  99558. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99559. static readonly INCR_WRAP: number;
  99560. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99561. static readonly DECR_WRAP: number;
  99562. /** Texture is not repeating outside of 0..1 UVs */
  99563. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99564. /** Texture is repeating outside of 0..1 UVs */
  99565. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99566. /** Texture is repeating and mirrored */
  99567. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99568. /** ALPHA */
  99569. static readonly TEXTUREFORMAT_ALPHA: number;
  99570. /** LUMINANCE */
  99571. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99572. /** LUMINANCE_ALPHA */
  99573. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99574. /** RGB */
  99575. static readonly TEXTUREFORMAT_RGB: number;
  99576. /** RGBA */
  99577. static readonly TEXTUREFORMAT_RGBA: number;
  99578. /** RED */
  99579. static readonly TEXTUREFORMAT_RED: number;
  99580. /** RED (2nd reference) */
  99581. static readonly TEXTUREFORMAT_R: number;
  99582. /** RG */
  99583. static readonly TEXTUREFORMAT_RG: number;
  99584. /** RED_INTEGER */
  99585. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99586. /** RED_INTEGER (2nd reference) */
  99587. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99588. /** RG_INTEGER */
  99589. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99590. /** RGB_INTEGER */
  99591. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99592. /** RGBA_INTEGER */
  99593. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99594. /** UNSIGNED_BYTE */
  99595. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99596. /** UNSIGNED_BYTE (2nd reference) */
  99597. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99598. /** FLOAT */
  99599. static readonly TEXTURETYPE_FLOAT: number;
  99600. /** HALF_FLOAT */
  99601. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99602. /** BYTE */
  99603. static readonly TEXTURETYPE_BYTE: number;
  99604. /** SHORT */
  99605. static readonly TEXTURETYPE_SHORT: number;
  99606. /** UNSIGNED_SHORT */
  99607. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99608. /** INT */
  99609. static readonly TEXTURETYPE_INT: number;
  99610. /** UNSIGNED_INT */
  99611. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99612. /** UNSIGNED_SHORT_4_4_4_4 */
  99613. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99614. /** UNSIGNED_SHORT_5_5_5_1 */
  99615. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99616. /** UNSIGNED_SHORT_5_6_5 */
  99617. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99618. /** UNSIGNED_INT_2_10_10_10_REV */
  99619. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99620. /** UNSIGNED_INT_24_8 */
  99621. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99622. /** UNSIGNED_INT_10F_11F_11F_REV */
  99623. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99624. /** UNSIGNED_INT_5_9_9_9_REV */
  99625. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99626. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99627. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99628. /** nearest is mag = nearest and min = nearest and mip = linear */
  99629. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99630. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99631. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99632. /** Trilinear is mag = linear and min = linear and mip = linear */
  99633. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99634. /** nearest is mag = nearest and min = nearest and mip = linear */
  99635. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99636. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99637. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99638. /** Trilinear is mag = linear and min = linear and mip = linear */
  99639. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99640. /** mag = nearest and min = nearest and mip = nearest */
  99641. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99642. /** mag = nearest and min = linear and mip = nearest */
  99643. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99644. /** mag = nearest and min = linear and mip = linear */
  99645. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99646. /** mag = nearest and min = linear and mip = none */
  99647. static readonly TEXTURE_NEAREST_LINEAR: number;
  99648. /** mag = nearest and min = nearest and mip = none */
  99649. static readonly TEXTURE_NEAREST_NEAREST: number;
  99650. /** mag = linear and min = nearest and mip = nearest */
  99651. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99652. /** mag = linear and min = nearest and mip = linear */
  99653. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99654. /** mag = linear and min = linear and mip = none */
  99655. static readonly TEXTURE_LINEAR_LINEAR: number;
  99656. /** mag = linear and min = nearest and mip = none */
  99657. static readonly TEXTURE_LINEAR_NEAREST: number;
  99658. /** Explicit coordinates mode */
  99659. static readonly TEXTURE_EXPLICIT_MODE: number;
  99660. /** Spherical coordinates mode */
  99661. static readonly TEXTURE_SPHERICAL_MODE: number;
  99662. /** Planar coordinates mode */
  99663. static readonly TEXTURE_PLANAR_MODE: number;
  99664. /** Cubic coordinates mode */
  99665. static readonly TEXTURE_CUBIC_MODE: number;
  99666. /** Projection coordinates mode */
  99667. static readonly TEXTURE_PROJECTION_MODE: number;
  99668. /** Skybox coordinates mode */
  99669. static readonly TEXTURE_SKYBOX_MODE: number;
  99670. /** Inverse Cubic coordinates mode */
  99671. static readonly TEXTURE_INVCUBIC_MODE: number;
  99672. /** Equirectangular coordinates mode */
  99673. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99674. /** Equirectangular Fixed coordinates mode */
  99675. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99676. /** Equirectangular Fixed Mirrored coordinates mode */
  99677. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99678. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99679. static readonly SCALEMODE_FLOOR: number;
  99680. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99681. static readonly SCALEMODE_NEAREST: number;
  99682. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99683. static readonly SCALEMODE_CEILING: number;
  99684. /**
  99685. * Returns the current npm package of the sdk
  99686. */
  99687. static readonly NpmPackage: string;
  99688. /**
  99689. * Returns the current version of the framework
  99690. */
  99691. static readonly Version: string;
  99692. /** Gets the list of created engines */
  99693. static readonly Instances: Engine[];
  99694. /**
  99695. * Gets the latest created engine
  99696. */
  99697. static readonly LastCreatedEngine: Nullable<Engine>;
  99698. /**
  99699. * Gets the latest created scene
  99700. */
  99701. static readonly LastCreatedScene: Nullable<Scene>;
  99702. /**
  99703. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99704. * @param flag defines which part of the materials must be marked as dirty
  99705. * @param predicate defines a predicate used to filter which materials should be affected
  99706. */
  99707. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99708. /**
  99709. * Method called to create the default loading screen.
  99710. * This can be overriden in your own app.
  99711. * @param canvas The rendering canvas element
  99712. * @returns The loading screen
  99713. */
  99714. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99715. /**
  99716. * Method called to create the default rescale post process on each engine.
  99717. */
  99718. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99719. /**
  99720. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99721. **/
  99722. enableOfflineSupport: boolean;
  99723. /**
  99724. * 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)
  99725. **/
  99726. disableManifestCheck: boolean;
  99727. /**
  99728. * Gets the list of created scenes
  99729. */
  99730. scenes: Scene[];
  99731. /**
  99732. * Event raised when a new scene is created
  99733. */
  99734. onNewSceneAddedObservable: Observable<Scene>;
  99735. /**
  99736. * Gets the list of created postprocesses
  99737. */
  99738. postProcesses: PostProcess[];
  99739. /**
  99740. * Gets a boolean indicating if the pointer is currently locked
  99741. */
  99742. isPointerLock: boolean;
  99743. /**
  99744. * Observable event triggered each time the rendering canvas is resized
  99745. */
  99746. onResizeObservable: Observable<Engine>;
  99747. /**
  99748. * Observable event triggered each time the canvas loses focus
  99749. */
  99750. onCanvasBlurObservable: Observable<Engine>;
  99751. /**
  99752. * Observable event triggered each time the canvas gains focus
  99753. */
  99754. onCanvasFocusObservable: Observable<Engine>;
  99755. /**
  99756. * Observable event triggered each time the canvas receives pointerout event
  99757. */
  99758. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99759. /**
  99760. * Observable raised when the engine begins a new frame
  99761. */
  99762. onBeginFrameObservable: Observable<Engine>;
  99763. /**
  99764. * If set, will be used to request the next animation frame for the render loop
  99765. */
  99766. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99767. /**
  99768. * Observable raised when the engine ends the current frame
  99769. */
  99770. onEndFrameObservable: Observable<Engine>;
  99771. /**
  99772. * Observable raised when the engine is about to compile a shader
  99773. */
  99774. onBeforeShaderCompilationObservable: Observable<Engine>;
  99775. /**
  99776. * Observable raised when the engine has jsut compiled a shader
  99777. */
  99778. onAfterShaderCompilationObservable: Observable<Engine>;
  99779. /**
  99780. * Gets the audio engine
  99781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99782. * @ignorenaming
  99783. */
  99784. static audioEngine: IAudioEngine;
  99785. /**
  99786. * Default AudioEngine factory responsible of creating the Audio Engine.
  99787. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99788. */
  99789. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99790. /**
  99791. * Default offline support factory responsible of creating a tool used to store data locally.
  99792. * By default, this will create a Database object if the workload has been embedded.
  99793. */
  99794. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99795. private _loadingScreen;
  99796. private _pointerLockRequested;
  99797. private _dummyFramebuffer;
  99798. private _rescalePostProcess;
  99799. /** @hidden */
  99800. protected _alphaMode: number;
  99801. /** @hidden */
  99802. protected _alphaEquation: number;
  99803. private _deterministicLockstep;
  99804. private _lockstepMaxSteps;
  99805. protected readonly _supportsHardwareTextureRescaling: boolean;
  99806. private _fps;
  99807. private _deltaTime;
  99808. /** @hidden */
  99809. _drawCalls: PerfCounter;
  99810. /**
  99811. * Turn this value on if you want to pause FPS computation when in background
  99812. */
  99813. disablePerformanceMonitorInBackground: boolean;
  99814. private _performanceMonitor;
  99815. /**
  99816. * Gets the performance monitor attached to this engine
  99817. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99818. */
  99819. readonly performanceMonitor: PerformanceMonitor;
  99820. private _onFocus;
  99821. private _onBlur;
  99822. private _onCanvasPointerOut;
  99823. private _onCanvasBlur;
  99824. private _onCanvasFocus;
  99825. private _onFullscreenChange;
  99826. private _onPointerLockChange;
  99827. /**
  99828. * Gets the HTML element used to attach event listeners
  99829. * @returns a HTML element
  99830. */
  99831. getInputElement(): Nullable<HTMLElement>;
  99832. /**
  99833. * Creates a new engine
  99834. * @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
  99835. * @param antialias defines enable antialiasing (default: false)
  99836. * @param options defines further options to be sent to the getContext() function
  99837. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99838. */
  99839. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99840. /**
  99841. * Gets current aspect ratio
  99842. * @param viewportOwner defines the camera to use to get the aspect ratio
  99843. * @param useScreen defines if screen size must be used (or the current render target if any)
  99844. * @returns a number defining the aspect ratio
  99845. */
  99846. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99847. /**
  99848. * Gets current screen aspect ratio
  99849. * @returns a number defining the aspect ratio
  99850. */
  99851. getScreenAspectRatio(): number;
  99852. /**
  99853. * Gets host document
  99854. * @returns the host document object
  99855. */
  99856. getHostDocument(): Document;
  99857. /**
  99858. * Gets the client rect of the HTML canvas attached with the current webGL context
  99859. * @returns a client rectanglee
  99860. */
  99861. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99862. /**
  99863. * Gets the client rect of the HTML element used for events
  99864. * @returns a client rectanglee
  99865. */
  99866. getInputElementClientRect(): Nullable<ClientRect>;
  99867. /**
  99868. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99870. * @returns true if engine is in deterministic lock step mode
  99871. */
  99872. isDeterministicLockStep(): boolean;
  99873. /**
  99874. * Gets the max steps when engine is running in deterministic lock step
  99875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99876. * @returns the max steps
  99877. */
  99878. getLockstepMaxSteps(): number;
  99879. /**
  99880. * Force the mipmap generation for the given render target texture
  99881. * @param texture defines the render target texture to use
  99882. */
  99883. generateMipMapsForCubemap(texture: InternalTexture): void;
  99884. /** States */
  99885. /**
  99886. * Set various states to the webGL context
  99887. * @param culling defines backface culling state
  99888. * @param zOffset defines the value to apply to zOffset (0 by default)
  99889. * @param force defines if states must be applied even if cache is up to date
  99890. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99891. */
  99892. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99893. /**
  99894. * Set the z offset to apply to current rendering
  99895. * @param value defines the offset to apply
  99896. */
  99897. setZOffset(value: number): void;
  99898. /**
  99899. * Gets the current value of the zOffset
  99900. * @returns the current zOffset state
  99901. */
  99902. getZOffset(): number;
  99903. /**
  99904. * Enable or disable depth buffering
  99905. * @param enable defines the state to set
  99906. */
  99907. setDepthBuffer(enable: boolean): void;
  99908. /**
  99909. * Gets a boolean indicating if depth writing is enabled
  99910. * @returns the current depth writing state
  99911. */
  99912. getDepthWrite(): boolean;
  99913. /**
  99914. * Enable or disable depth writing
  99915. * @param enable defines the state to set
  99916. */
  99917. setDepthWrite(enable: boolean): void;
  99918. /**
  99919. * Enable or disable color writing
  99920. * @param enable defines the state to set
  99921. */
  99922. setColorWrite(enable: boolean): void;
  99923. /**
  99924. * Gets a boolean indicating if color writing is enabled
  99925. * @returns the current color writing state
  99926. */
  99927. getColorWrite(): boolean;
  99928. /**
  99929. * Sets alpha constants used by some alpha blending modes
  99930. * @param r defines the red component
  99931. * @param g defines the green component
  99932. * @param b defines the blue component
  99933. * @param a defines the alpha component
  99934. */
  99935. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99936. /**
  99937. * Sets the current alpha mode
  99938. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99939. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99940. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99941. */
  99942. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99943. /**
  99944. * Gets the current alpha mode
  99945. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99946. * @returns the current alpha mode
  99947. */
  99948. getAlphaMode(): number;
  99949. /**
  99950. * Sets the current alpha equation
  99951. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99952. */
  99953. setAlphaEquation(equation: number): void;
  99954. /**
  99955. * Gets the current alpha equation.
  99956. * @returns the current alpha equation
  99957. */
  99958. getAlphaEquation(): number;
  99959. /**
  99960. * Gets a boolean indicating if stencil buffer is enabled
  99961. * @returns the current stencil buffer state
  99962. */
  99963. getStencilBuffer(): boolean;
  99964. /**
  99965. * Enable or disable the stencil buffer
  99966. * @param enable defines if the stencil buffer must be enabled or disabled
  99967. */
  99968. setStencilBuffer(enable: boolean): void;
  99969. /**
  99970. * Gets the current stencil mask
  99971. * @returns a number defining the new stencil mask to use
  99972. */
  99973. getStencilMask(): number;
  99974. /**
  99975. * Sets the current stencil mask
  99976. * @param mask defines the new stencil mask to use
  99977. */
  99978. setStencilMask(mask: number): void;
  99979. /**
  99980. * Gets the current stencil function
  99981. * @returns a number defining the stencil function to use
  99982. */
  99983. getStencilFunction(): number;
  99984. /**
  99985. * Gets the current stencil reference value
  99986. * @returns a number defining the stencil reference value to use
  99987. */
  99988. getStencilFunctionReference(): number;
  99989. /**
  99990. * Gets the current stencil mask
  99991. * @returns a number defining the stencil mask to use
  99992. */
  99993. getStencilFunctionMask(): number;
  99994. /**
  99995. * Sets the current stencil function
  99996. * @param stencilFunc defines the new stencil function to use
  99997. */
  99998. setStencilFunction(stencilFunc: number): void;
  99999. /**
  100000. * Sets the current stencil reference
  100001. * @param reference defines the new stencil reference to use
  100002. */
  100003. setStencilFunctionReference(reference: number): void;
  100004. /**
  100005. * Sets the current stencil mask
  100006. * @param mask defines the new stencil mask to use
  100007. */
  100008. setStencilFunctionMask(mask: number): void;
  100009. /**
  100010. * Gets the current stencil operation when stencil fails
  100011. * @returns a number defining stencil operation to use when stencil fails
  100012. */
  100013. getStencilOperationFail(): number;
  100014. /**
  100015. * Gets the current stencil operation when depth fails
  100016. * @returns a number defining stencil operation to use when depth fails
  100017. */
  100018. getStencilOperationDepthFail(): number;
  100019. /**
  100020. * Gets the current stencil operation when stencil passes
  100021. * @returns a number defining stencil operation to use when stencil passes
  100022. */
  100023. getStencilOperationPass(): number;
  100024. /**
  100025. * Sets the stencil operation to use when stencil fails
  100026. * @param operation defines the stencil operation to use when stencil fails
  100027. */
  100028. setStencilOperationFail(operation: number): void;
  100029. /**
  100030. * Sets the stencil operation to use when depth fails
  100031. * @param operation defines the stencil operation to use when depth fails
  100032. */
  100033. setStencilOperationDepthFail(operation: number): void;
  100034. /**
  100035. * Sets the stencil operation to use when stencil passes
  100036. * @param operation defines the stencil operation to use when stencil passes
  100037. */
  100038. setStencilOperationPass(operation: number): void;
  100039. /**
  100040. * Sets a boolean indicating if the dithering state is enabled or disabled
  100041. * @param value defines the dithering state
  100042. */
  100043. setDitheringState(value: boolean): void;
  100044. /**
  100045. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100046. * @param value defines the rasterizer state
  100047. */
  100048. setRasterizerState(value: boolean): void;
  100049. /**
  100050. * Gets the current depth function
  100051. * @returns a number defining the depth function
  100052. */
  100053. getDepthFunction(): Nullable<number>;
  100054. /**
  100055. * Sets the current depth function
  100056. * @param depthFunc defines the function to use
  100057. */
  100058. setDepthFunction(depthFunc: number): void;
  100059. /**
  100060. * Sets the current depth function to GREATER
  100061. */
  100062. setDepthFunctionToGreater(): void;
  100063. /**
  100064. * Sets the current depth function to GEQUAL
  100065. */
  100066. setDepthFunctionToGreaterOrEqual(): void;
  100067. /**
  100068. * Sets the current depth function to LESS
  100069. */
  100070. setDepthFunctionToLess(): void;
  100071. /**
  100072. * Sets the current depth function to LEQUAL
  100073. */
  100074. setDepthFunctionToLessOrEqual(): void;
  100075. private _cachedStencilBuffer;
  100076. private _cachedStencilFunction;
  100077. private _cachedStencilMask;
  100078. private _cachedStencilOperationPass;
  100079. private _cachedStencilOperationFail;
  100080. private _cachedStencilOperationDepthFail;
  100081. private _cachedStencilReference;
  100082. /**
  100083. * Caches the the state of the stencil buffer
  100084. */
  100085. cacheStencilState(): void;
  100086. /**
  100087. * Restores the state of the stencil buffer
  100088. */
  100089. restoreStencilState(): void;
  100090. /**
  100091. * Directly set the WebGL Viewport
  100092. * @param x defines the x coordinate of the viewport (in screen space)
  100093. * @param y defines the y coordinate of the viewport (in screen space)
  100094. * @param width defines the width of the viewport (in screen space)
  100095. * @param height defines the height of the viewport (in screen space)
  100096. * @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
  100097. */
  100098. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100099. /**
  100100. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100101. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100102. * @param y defines the y-coordinate of the corner of the clear rectangle
  100103. * @param width defines the width of the clear rectangle
  100104. * @param height defines the height of the clear rectangle
  100105. * @param clearColor defines the clear color
  100106. */
  100107. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100108. /**
  100109. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100110. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100111. * @param y defines the y-coordinate of the corner of the clear rectangle
  100112. * @param width defines the width of the clear rectangle
  100113. * @param height defines the height of the clear rectangle
  100114. */
  100115. enableScissor(x: number, y: number, width: number, height: number): void;
  100116. /**
  100117. * Disable previously set scissor test rectangle
  100118. */
  100119. disableScissor(): void;
  100120. protected _reportDrawCall(): void;
  100121. /**
  100122. * Initializes a webVR display and starts listening to display change events
  100123. * The onVRDisplayChangedObservable will be notified upon these changes
  100124. * @returns The onVRDisplayChangedObservable
  100125. */
  100126. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100127. /** @hidden */
  100128. _prepareVRComponent(): void;
  100129. /** @hidden */
  100130. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100131. /** @hidden */
  100132. _submitVRFrame(): void;
  100133. /**
  100134. * Call this function to leave webVR mode
  100135. * Will do nothing if webVR is not supported or if there is no webVR device
  100136. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100137. */
  100138. disableVR(): void;
  100139. /**
  100140. * Gets a boolean indicating that the system is in VR mode and is presenting
  100141. * @returns true if VR mode is engaged
  100142. */
  100143. isVRPresenting(): boolean;
  100144. /** @hidden */
  100145. _requestVRFrame(): void;
  100146. /** @hidden */
  100147. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100148. /**
  100149. * Gets the source code of the vertex shader associated with a specific webGL program
  100150. * @param program defines the program to use
  100151. * @returns a string containing the source code of the vertex shader associated with the program
  100152. */
  100153. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100154. /**
  100155. * Gets the source code of the fragment shader associated with a specific webGL program
  100156. * @param program defines the program to use
  100157. * @returns a string containing the source code of the fragment shader associated with the program
  100158. */
  100159. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100160. /**
  100161. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100162. * @param x defines the x coordinate of the rectangle where pixels must be read
  100163. * @param y defines the y coordinate of the rectangle where pixels must be read
  100164. * @param width defines the width of the rectangle where pixels must be read
  100165. * @param height defines the height of the rectangle where pixels must be read
  100166. * @returns a Uint8Array containing RGBA colors
  100167. */
  100168. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100169. /**
  100170. * Sets a depth stencil texture from a render target to the according uniform.
  100171. * @param channel The texture channel
  100172. * @param uniform The uniform to set
  100173. * @param texture The render target texture containing the depth stencil texture to apply
  100174. */
  100175. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100176. /**
  100177. * Sets a texture to the webGL context from a postprocess
  100178. * @param channel defines the channel to use
  100179. * @param postProcess defines the source postprocess
  100180. */
  100181. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100182. /**
  100183. * Binds the output of the passed in post process to the texture channel specified
  100184. * @param channel The channel the texture should be bound to
  100185. * @param postProcess The post process which's output should be bound
  100186. */
  100187. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100188. /** @hidden */
  100189. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100190. protected _rebuildBuffers(): void;
  100191. /** @hidden */
  100192. _renderFrame(): void;
  100193. _renderLoop(): void;
  100194. /** @hidden */
  100195. _renderViews(): boolean;
  100196. /**
  100197. * Toggle full screen mode
  100198. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100199. */
  100200. switchFullscreen(requestPointerLock: boolean): void;
  100201. /**
  100202. * Enters full screen mode
  100203. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100204. */
  100205. enterFullscreen(requestPointerLock: boolean): void;
  100206. /**
  100207. * Exits full screen mode
  100208. */
  100209. exitFullscreen(): void;
  100210. /**
  100211. * Enters Pointerlock mode
  100212. */
  100213. enterPointerlock(): void;
  100214. /**
  100215. * Exits Pointerlock mode
  100216. */
  100217. exitPointerlock(): void;
  100218. /**
  100219. * Begin a new frame
  100220. */
  100221. beginFrame(): void;
  100222. /**
  100223. * Enf the current frame
  100224. */
  100225. endFrame(): void;
  100226. resize(): void;
  100227. /**
  100228. * Set the compressed texture format to use, based on the formats you have, and the formats
  100229. * supported by the hardware / browser.
  100230. *
  100231. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100232. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100233. * to API arguments needed to compressed textures. This puts the burden on the container
  100234. * generator to house the arcane code for determining these for current & future formats.
  100235. *
  100236. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100237. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100238. *
  100239. * Note: The result of this call is not taken into account when a texture is base64.
  100240. *
  100241. * @param formatsAvailable defines the list of those format families you have created
  100242. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100243. *
  100244. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100245. * @returns The extension selected.
  100246. */
  100247. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100248. /**
  100249. * Force a specific size of the canvas
  100250. * @param width defines the new canvas' width
  100251. * @param height defines the new canvas' height
  100252. */
  100253. setSize(width: number, height: number): void;
  100254. /**
  100255. * Updates a dynamic vertex buffer.
  100256. * @param vertexBuffer the vertex buffer to update
  100257. * @param data the data used to update the vertex buffer
  100258. * @param byteOffset the byte offset of the data
  100259. * @param byteLength the byte length of the data
  100260. */
  100261. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100262. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100263. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100264. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100265. _releaseTexture(texture: InternalTexture): void;
  100266. /**
  100267. * @hidden
  100268. * Rescales a texture
  100269. * @param source input texutre
  100270. * @param destination destination texture
  100271. * @param scene scene to use to render the resize
  100272. * @param internalFormat format to use when resizing
  100273. * @param onComplete callback to be called when resize has completed
  100274. */
  100275. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100276. /**
  100277. * Gets the current framerate
  100278. * @returns a number representing the framerate
  100279. */
  100280. getFps(): number;
  100281. /**
  100282. * Gets the time spent between current and previous frame
  100283. * @returns a number representing the delta time in ms
  100284. */
  100285. getDeltaTime(): number;
  100286. private _measureFps;
  100287. /** @hidden */
  100288. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100289. /**
  100290. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100291. * @param renderTarget The render target to set the frame buffer for
  100292. */
  100293. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100294. /**
  100295. * Update a dynamic index buffer
  100296. * @param indexBuffer defines the target index buffer
  100297. * @param indices defines the data to update
  100298. * @param offset defines the offset in the target index buffer where update should start
  100299. */
  100300. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100301. /**
  100302. * Updates the sample count of a render target texture
  100303. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100304. * @param texture defines the texture to update
  100305. * @param samples defines the sample count to set
  100306. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100307. */
  100308. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100309. /**
  100310. * Updates a depth texture Comparison Mode and Function.
  100311. * If the comparison Function is equal to 0, the mode will be set to none.
  100312. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100313. * @param texture The texture to set the comparison function for
  100314. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100315. */
  100316. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100317. /**
  100318. * Creates a webGL buffer to use with instanciation
  100319. * @param capacity defines the size of the buffer
  100320. * @returns the webGL buffer
  100321. */
  100322. createInstancesBuffer(capacity: number): DataBuffer;
  100323. /**
  100324. * Delete a webGL buffer used with instanciation
  100325. * @param buffer defines the webGL buffer to delete
  100326. */
  100327. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100328. /** @hidden */
  100329. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100330. dispose(): void;
  100331. private _disableTouchAction;
  100332. /**
  100333. * Display the loading screen
  100334. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100335. */
  100336. displayLoadingUI(): void;
  100337. /**
  100338. * Hide the loading screen
  100339. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100340. */
  100341. hideLoadingUI(): void;
  100342. /**
  100343. * Gets the current loading screen object
  100344. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100345. */
  100346. /**
  100347. * Sets the current loading screen object
  100348. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100349. */
  100350. loadingScreen: ILoadingScreen;
  100351. /**
  100352. * Sets the current loading screen text
  100353. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100354. */
  100355. loadingUIText: string;
  100356. /**
  100357. * Sets the current loading screen background color
  100358. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100359. */
  100360. loadingUIBackgroundColor: string;
  100361. /** Pointerlock and fullscreen */
  100362. /**
  100363. * Ask the browser to promote the current element to pointerlock mode
  100364. * @param element defines the DOM element to promote
  100365. */
  100366. static _RequestPointerlock(element: HTMLElement): void;
  100367. /**
  100368. * Asks the browser to exit pointerlock mode
  100369. */
  100370. static _ExitPointerlock(): void;
  100371. /**
  100372. * Ask the browser to promote the current element to fullscreen rendering mode
  100373. * @param element defines the DOM element to promote
  100374. */
  100375. static _RequestFullscreen(element: HTMLElement): void;
  100376. /**
  100377. * Asks the browser to exit fullscreen mode
  100378. */
  100379. static _ExitFullscreen(): void;
  100380. }
  100381. }
  100382. declare module BABYLON {
  100383. /**
  100384. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100385. * during the life time of the application.
  100386. */
  100387. export class EngineStore {
  100388. /** Gets the list of created engines */
  100389. static Instances: Engine[];
  100390. /** @hidden */
  100391. static _LastCreatedScene: Nullable<Scene>;
  100392. /**
  100393. * Gets the latest created engine
  100394. */
  100395. static readonly LastCreatedEngine: Nullable<Engine>;
  100396. /**
  100397. * Gets the latest created scene
  100398. */
  100399. static readonly LastCreatedScene: Nullable<Scene>;
  100400. /**
  100401. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100402. * @ignorenaming
  100403. */
  100404. static UseFallbackTexture: boolean;
  100405. /**
  100406. * Texture content used if a texture cannot loaded
  100407. * @ignorenaming
  100408. */
  100409. static FallbackTexture: string;
  100410. }
  100411. }
  100412. declare module BABYLON {
  100413. /**
  100414. * Helper class that provides a small promise polyfill
  100415. */
  100416. export class PromisePolyfill {
  100417. /**
  100418. * Static function used to check if the polyfill is required
  100419. * If this is the case then the function will inject the polyfill to window.Promise
  100420. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100421. */
  100422. static Apply(force?: boolean): void;
  100423. }
  100424. }
  100425. declare module BABYLON {
  100426. /**
  100427. * Interface for screenshot methods with describe argument called `size` as object with options
  100428. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100429. */
  100430. export interface IScreenshotSize {
  100431. /**
  100432. * number in pixels for canvas height
  100433. */
  100434. height?: number;
  100435. /**
  100436. * multiplier allowing render at a higher or lower resolution
  100437. * If value is defined then height and width will be ignored and taken from camera
  100438. */
  100439. precision?: number;
  100440. /**
  100441. * number in pixels for canvas width
  100442. */
  100443. width?: number;
  100444. }
  100445. }
  100446. declare module BABYLON {
  100447. interface IColor4Like {
  100448. r: float;
  100449. g: float;
  100450. b: float;
  100451. a: float;
  100452. }
  100453. /**
  100454. * Class containing a set of static utilities functions
  100455. */
  100456. export class Tools {
  100457. /**
  100458. * Gets or sets the base URL to use to load assets
  100459. */
  100460. static BaseUrl: string;
  100461. /**
  100462. * Enable/Disable Custom HTTP Request Headers globally.
  100463. * default = false
  100464. * @see CustomRequestHeaders
  100465. */
  100466. static UseCustomRequestHeaders: boolean;
  100467. /**
  100468. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100469. * i.e. when loading files, where the server/service expects an Authorization header
  100470. */
  100471. static CustomRequestHeaders: {
  100472. [key: string]: string;
  100473. };
  100474. /**
  100475. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100476. */
  100477. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100478. /**
  100479. * Default behaviour for cors in the application.
  100480. * It can be a string if the expected behavior is identical in the entire app.
  100481. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100482. */
  100483. static CorsBehavior: string | ((url: string | string[]) => string);
  100484. /**
  100485. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100486. * @ignorenaming
  100487. */
  100488. static UseFallbackTexture: boolean;
  100489. /**
  100490. * Use this object to register external classes like custom textures or material
  100491. * to allow the laoders to instantiate them
  100492. */
  100493. static RegisteredExternalClasses: {
  100494. [key: string]: Object;
  100495. };
  100496. /**
  100497. * Texture content used if a texture cannot loaded
  100498. * @ignorenaming
  100499. */
  100500. static fallbackTexture: string;
  100501. /**
  100502. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100503. * @param u defines the coordinate on X axis
  100504. * @param v defines the coordinate on Y axis
  100505. * @param width defines the width of the source data
  100506. * @param height defines the height of the source data
  100507. * @param pixels defines the source byte array
  100508. * @param color defines the output color
  100509. */
  100510. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100511. /**
  100512. * Interpolates between a and b via alpha
  100513. * @param a The lower value (returned when alpha = 0)
  100514. * @param b The upper value (returned when alpha = 1)
  100515. * @param alpha The interpolation-factor
  100516. * @return The mixed value
  100517. */
  100518. static Mix(a: number, b: number, alpha: number): number;
  100519. /**
  100520. * Tries to instantiate a new object from a given class name
  100521. * @param className defines the class name to instantiate
  100522. * @returns the new object or null if the system was not able to do the instantiation
  100523. */
  100524. static Instantiate(className: string): any;
  100525. /**
  100526. * Provides a slice function that will work even on IE
  100527. * @param data defines the array to slice
  100528. * @param start defines the start of the data (optional)
  100529. * @param end defines the end of the data (optional)
  100530. * @returns the new sliced array
  100531. */
  100532. static Slice<T>(data: T, start?: number, end?: number): T;
  100533. /**
  100534. * Polyfill for setImmediate
  100535. * @param action defines the action to execute after the current execution block
  100536. */
  100537. static SetImmediate(action: () => void): void;
  100538. /**
  100539. * Function indicating if a number is an exponent of 2
  100540. * @param value defines the value to test
  100541. * @returns true if the value is an exponent of 2
  100542. */
  100543. static IsExponentOfTwo(value: number): boolean;
  100544. private static _tmpFloatArray;
  100545. /**
  100546. * Returns the nearest 32-bit single precision float representation of a Number
  100547. * @param value A Number. If the parameter is of a different type, it will get converted
  100548. * to a number or to NaN if it cannot be converted
  100549. * @returns number
  100550. */
  100551. static FloatRound(value: number): number;
  100552. /**
  100553. * Extracts the filename from a path
  100554. * @param path defines the path to use
  100555. * @returns the filename
  100556. */
  100557. static GetFilename(path: string): string;
  100558. /**
  100559. * Extracts the "folder" part of a path (everything before the filename).
  100560. * @param uri The URI to extract the info from
  100561. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100562. * @returns The "folder" part of the path
  100563. */
  100564. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100565. /**
  100566. * Extracts text content from a DOM element hierarchy
  100567. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100568. */
  100569. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100570. /**
  100571. * Convert an angle in radians to degrees
  100572. * @param angle defines the angle to convert
  100573. * @returns the angle in degrees
  100574. */
  100575. static ToDegrees(angle: number): number;
  100576. /**
  100577. * Convert an angle in degrees to radians
  100578. * @param angle defines the angle to convert
  100579. * @returns the angle in radians
  100580. */
  100581. static ToRadians(angle: number): number;
  100582. /**
  100583. * Returns an array if obj is not an array
  100584. * @param obj defines the object to evaluate as an array
  100585. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100586. * @returns either obj directly if obj is an array or a new array containing obj
  100587. */
  100588. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100589. /**
  100590. * Gets the pointer prefix to use
  100591. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100592. */
  100593. static GetPointerPrefix(): string;
  100594. /**
  100595. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100596. * @param url define the url we are trying
  100597. * @param element define the dom element where to configure the cors policy
  100598. */
  100599. static SetCorsBehavior(url: string | string[], element: {
  100600. crossOrigin: string | null;
  100601. }): void;
  100602. /**
  100603. * Removes unwanted characters from an url
  100604. * @param url defines the url to clean
  100605. * @returns the cleaned url
  100606. */
  100607. static CleanUrl(url: string): string;
  100608. /**
  100609. * Gets or sets a function used to pre-process url before using them to load assets
  100610. */
  100611. static PreprocessUrl: (url: string) => string;
  100612. /**
  100613. * Loads an image as an HTMLImageElement.
  100614. * @param input url string, ArrayBuffer, or Blob to load
  100615. * @param onLoad callback called when the image successfully loads
  100616. * @param onError callback called when the image fails to load
  100617. * @param offlineProvider offline provider for caching
  100618. * @param mimeType optional mime type
  100619. * @returns the HTMLImageElement of the loaded image
  100620. */
  100621. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100622. /**
  100623. * Loads a file from a url
  100624. * @param url url string, ArrayBuffer, or Blob to load
  100625. * @param onSuccess callback called when the file successfully loads
  100626. * @param onProgress callback called while file is loading (if the server supports this mode)
  100627. * @param offlineProvider defines the offline provider for caching
  100628. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100629. * @param onError callback called when the file fails to load
  100630. * @returns a file request object
  100631. */
  100632. 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;
  100633. /**
  100634. * Loads a file from a url
  100635. * @param url the file url to load
  100636. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100637. */
  100638. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100639. /**
  100640. * Load a script (identified by an url). When the url returns, the
  100641. * content of this file is added into a new script element, attached to the DOM (body element)
  100642. * @param scriptUrl defines the url of the script to laod
  100643. * @param onSuccess defines the callback called when the script is loaded
  100644. * @param onError defines the callback to call if an error occurs
  100645. * @param scriptId defines the id of the script element
  100646. */
  100647. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100648. /**
  100649. * Load an asynchronous script (identified by an url). When the url returns, the
  100650. * content of this file is added into a new script element, attached to the DOM (body element)
  100651. * @param scriptUrl defines the url of the script to laod
  100652. * @param scriptId defines the id of the script element
  100653. * @returns a promise request object
  100654. */
  100655. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100656. /**
  100657. * Loads a file from a blob
  100658. * @param fileToLoad defines the blob to use
  100659. * @param callback defines the callback to call when data is loaded
  100660. * @param progressCallback defines the callback to call during loading process
  100661. * @returns a file request object
  100662. */
  100663. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100664. /**
  100665. * Reads a file from a File object
  100666. * @param file defines the file to load
  100667. * @param onSuccess defines the callback to call when data is loaded
  100668. * @param onProgress defines the callback to call during loading process
  100669. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100670. * @param onError defines the callback to call when an error occurs
  100671. * @returns a file request object
  100672. */
  100673. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100674. /**
  100675. * Creates a data url from a given string content
  100676. * @param content defines the content to convert
  100677. * @returns the new data url link
  100678. */
  100679. static FileAsURL(content: string): string;
  100680. /**
  100681. * Format the given number to a specific decimal format
  100682. * @param value defines the number to format
  100683. * @param decimals defines the number of decimals to use
  100684. * @returns the formatted string
  100685. */
  100686. static Format(value: number, decimals?: number): string;
  100687. /**
  100688. * Tries to copy an object by duplicating every property
  100689. * @param source defines the source object
  100690. * @param destination defines the target object
  100691. * @param doNotCopyList defines a list of properties to avoid
  100692. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100693. */
  100694. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100695. /**
  100696. * Gets a boolean indicating if the given object has no own property
  100697. * @param obj defines the object to test
  100698. * @returns true if object has no own property
  100699. */
  100700. static IsEmpty(obj: any): boolean;
  100701. /**
  100702. * Function used to register events at window level
  100703. * @param windowElement defines the Window object to use
  100704. * @param events defines the events to register
  100705. */
  100706. static RegisterTopRootEvents(windowElement: Window, events: {
  100707. name: string;
  100708. handler: Nullable<(e: FocusEvent) => any>;
  100709. }[]): void;
  100710. /**
  100711. * Function used to unregister events from window level
  100712. * @param windowElement defines the Window object to use
  100713. * @param events defines the events to unregister
  100714. */
  100715. static UnregisterTopRootEvents(windowElement: Window, events: {
  100716. name: string;
  100717. handler: Nullable<(e: FocusEvent) => any>;
  100718. }[]): void;
  100719. /**
  100720. * @ignore
  100721. */
  100722. static _ScreenshotCanvas: HTMLCanvasElement;
  100723. /**
  100724. * Dumps the current bound framebuffer
  100725. * @param width defines the rendering width
  100726. * @param height defines the rendering height
  100727. * @param engine defines the hosting engine
  100728. * @param successCallback defines the callback triggered once the data are available
  100729. * @param mimeType defines the mime type of the result
  100730. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100731. */
  100732. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100733. /**
  100734. * Converts the canvas data to blob.
  100735. * This acts as a polyfill for browsers not supporting the to blob function.
  100736. * @param canvas Defines the canvas to extract the data from
  100737. * @param successCallback Defines the callback triggered once the data are available
  100738. * @param mimeType Defines the mime type of the result
  100739. */
  100740. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100741. /**
  100742. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100743. * @param successCallback defines the callback triggered once the data are available
  100744. * @param mimeType defines the mime type of the result
  100745. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100746. */
  100747. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100748. /**
  100749. * Downloads a blob in the browser
  100750. * @param blob defines the blob to download
  100751. * @param fileName defines the name of the downloaded file
  100752. */
  100753. static Download(blob: Blob, fileName: string): void;
  100754. /**
  100755. * Captures a screenshot of the current rendering
  100756. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100757. * @param engine defines the rendering engine
  100758. * @param camera defines the source camera
  100759. * @param size This parameter can be set to a single number or to an object with the
  100760. * following (optional) properties: precision, width, height. If a single number is passed,
  100761. * it will be used for both width and height. If an object is passed, the screenshot size
  100762. * will be derived from the parameters. The precision property is a multiplier allowing
  100763. * rendering at a higher or lower resolution
  100764. * @param successCallback defines the callback receives a single parameter which contains the
  100765. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100766. * src parameter of an <img> to display it
  100767. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100768. * Check your browser for supported MIME types
  100769. */
  100770. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100771. /**
  100772. * Captures a screenshot of the current rendering
  100773. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100774. * @param engine defines the rendering engine
  100775. * @param camera defines the source camera
  100776. * @param size This parameter can be set to a single number or to an object with the
  100777. * following (optional) properties: precision, width, height. If a single number is passed,
  100778. * it will be used for both width and height. If an object is passed, the screenshot size
  100779. * will be derived from the parameters. The precision property is a multiplier allowing
  100780. * rendering at a higher or lower resolution
  100781. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100782. * Check your browser for supported MIME types
  100783. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100784. * to the src parameter of an <img> to display it
  100785. */
  100786. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100787. /**
  100788. * Generates an image screenshot from the specified camera.
  100789. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100790. * @param engine The engine to use for rendering
  100791. * @param camera The camera to use for rendering
  100792. * @param size This parameter can be set to a single number or to an object with the
  100793. * following (optional) properties: precision, width, height. If a single number is passed,
  100794. * it will be used for both width and height. If an object is passed, the screenshot size
  100795. * will be derived from the parameters. The precision property is a multiplier allowing
  100796. * rendering at a higher or lower resolution
  100797. * @param successCallback The callback receives a single parameter which contains the
  100798. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100799. * src parameter of an <img> to display it
  100800. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100801. * Check your browser for supported MIME types
  100802. * @param samples Texture samples (default: 1)
  100803. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100804. * @param fileName A name for for the downloaded file.
  100805. */
  100806. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100807. /**
  100808. * Generates an image screenshot from the specified camera.
  100809. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100810. * @param engine The engine to use for rendering
  100811. * @param camera The camera to use for rendering
  100812. * @param size This parameter can be set to a single number or to an object with the
  100813. * following (optional) properties: precision, width, height. If a single number is passed,
  100814. * it will be used for both width and height. If an object is passed, the screenshot size
  100815. * will be derived from the parameters. The precision property is a multiplier allowing
  100816. * rendering at a higher or lower resolution
  100817. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100818. * Check your browser for supported MIME types
  100819. * @param samples Texture samples (default: 1)
  100820. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100821. * @param fileName A name for for the downloaded file.
  100822. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100823. * to the src parameter of an <img> to display it
  100824. */
  100825. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100826. /**
  100827. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100828. * Be aware Math.random() could cause collisions, but:
  100829. * "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"
  100830. * @returns a pseudo random id
  100831. */
  100832. static RandomId(): string;
  100833. /**
  100834. * Test if the given uri is a base64 string
  100835. * @param uri The uri to test
  100836. * @return True if the uri is a base64 string or false otherwise
  100837. */
  100838. static IsBase64(uri: string): boolean;
  100839. /**
  100840. * Decode the given base64 uri.
  100841. * @param uri The uri to decode
  100842. * @return The decoded base64 data.
  100843. */
  100844. static DecodeBase64(uri: string): ArrayBuffer;
  100845. /**
  100846. * Gets the absolute url.
  100847. * @param url the input url
  100848. * @return the absolute url
  100849. */
  100850. static GetAbsoluteUrl(url: string): string;
  100851. /**
  100852. * No log
  100853. */
  100854. static readonly NoneLogLevel: number;
  100855. /**
  100856. * Only message logs
  100857. */
  100858. static readonly MessageLogLevel: number;
  100859. /**
  100860. * Only warning logs
  100861. */
  100862. static readonly WarningLogLevel: number;
  100863. /**
  100864. * Only error logs
  100865. */
  100866. static readonly ErrorLogLevel: number;
  100867. /**
  100868. * All logs
  100869. */
  100870. static readonly AllLogLevel: number;
  100871. /**
  100872. * Gets a value indicating the number of loading errors
  100873. * @ignorenaming
  100874. */
  100875. static readonly errorsCount: number;
  100876. /**
  100877. * Callback called when a new log is added
  100878. */
  100879. static OnNewCacheEntry: (entry: string) => void;
  100880. /**
  100881. * Log a message to the console
  100882. * @param message defines the message to log
  100883. */
  100884. static Log(message: string): void;
  100885. /**
  100886. * Write a warning message to the console
  100887. * @param message defines the message to log
  100888. */
  100889. static Warn(message: string): void;
  100890. /**
  100891. * Write an error message to the console
  100892. * @param message defines the message to log
  100893. */
  100894. static Error(message: string): void;
  100895. /**
  100896. * Gets current log cache (list of logs)
  100897. */
  100898. static readonly LogCache: string;
  100899. /**
  100900. * Clears the log cache
  100901. */
  100902. static ClearLogCache(): void;
  100903. /**
  100904. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100905. */
  100906. static LogLevels: number;
  100907. /**
  100908. * Checks if the window object exists
  100909. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100910. */
  100911. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100912. /**
  100913. * No performance log
  100914. */
  100915. static readonly PerformanceNoneLogLevel: number;
  100916. /**
  100917. * Use user marks to log performance
  100918. */
  100919. static readonly PerformanceUserMarkLogLevel: number;
  100920. /**
  100921. * Log performance to the console
  100922. */
  100923. static readonly PerformanceConsoleLogLevel: number;
  100924. private static _performance;
  100925. /**
  100926. * Sets the current performance log level
  100927. */
  100928. static PerformanceLogLevel: number;
  100929. private static _StartPerformanceCounterDisabled;
  100930. private static _EndPerformanceCounterDisabled;
  100931. private static _StartUserMark;
  100932. private static _EndUserMark;
  100933. private static _StartPerformanceConsole;
  100934. private static _EndPerformanceConsole;
  100935. /**
  100936. * Starts a performance counter
  100937. */
  100938. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100939. /**
  100940. * Ends a specific performance coutner
  100941. */
  100942. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100943. /**
  100944. * Gets either window.performance.now() if supported or Date.now() else
  100945. */
  100946. static readonly Now: number;
  100947. /**
  100948. * This method will return the name of the class used to create the instance of the given object.
  100949. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100950. * @param object the object to get the class name from
  100951. * @param isType defines if the object is actually a type
  100952. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100953. */
  100954. static GetClassName(object: any, isType?: boolean): string;
  100955. /**
  100956. * Gets the first element of an array satisfying a given predicate
  100957. * @param array defines the array to browse
  100958. * @param predicate defines the predicate to use
  100959. * @returns null if not found or the element
  100960. */
  100961. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100962. /**
  100963. * This method will return the name of the full name of the class, including its owning module (if any).
  100964. * 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).
  100965. * @param object the object to get the class name from
  100966. * @param isType defines if the object is actually a type
  100967. * @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.
  100968. * @ignorenaming
  100969. */
  100970. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100971. /**
  100972. * Returns a promise that resolves after the given amount of time.
  100973. * @param delay Number of milliseconds to delay
  100974. * @returns Promise that resolves after the given amount of time
  100975. */
  100976. static DelayAsync(delay: number): Promise<void>;
  100977. }
  100978. /**
  100979. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100980. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100981. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100982. * @param name The name of the class, case should be preserved
  100983. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100984. */
  100985. export function className(name: string, module?: string): (target: Object) => void;
  100986. /**
  100987. * An implementation of a loop for asynchronous functions.
  100988. */
  100989. export class AsyncLoop {
  100990. /**
  100991. * Defines the number of iterations for the loop
  100992. */
  100993. iterations: number;
  100994. /**
  100995. * Defines the current index of the loop.
  100996. */
  100997. index: number;
  100998. private _done;
  100999. private _fn;
  101000. private _successCallback;
  101001. /**
  101002. * Constructor.
  101003. * @param iterations the number of iterations.
  101004. * @param func the function to run each iteration
  101005. * @param successCallback the callback that will be called upon succesful execution
  101006. * @param offset starting offset.
  101007. */
  101008. constructor(
  101009. /**
  101010. * Defines the number of iterations for the loop
  101011. */
  101012. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  101013. /**
  101014. * Execute the next iteration. Must be called after the last iteration was finished.
  101015. */
  101016. executeNext(): void;
  101017. /**
  101018. * Break the loop and run the success callback.
  101019. */
  101020. breakLoop(): void;
  101021. /**
  101022. * Create and run an async loop.
  101023. * @param iterations the number of iterations.
  101024. * @param fn the function to run each iteration
  101025. * @param successCallback the callback that will be called upon succesful execution
  101026. * @param offset starting offset.
  101027. * @returns the created async loop object
  101028. */
  101029. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101030. /**
  101031. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101032. * @param iterations total number of iterations
  101033. * @param syncedIterations number of synchronous iterations in each async iteration.
  101034. * @param fn the function to call each iteration.
  101035. * @param callback a success call back that will be called when iterating stops.
  101036. * @param breakFunction a break condition (optional)
  101037. * @param timeout timeout settings for the setTimeout function. default - 0.
  101038. * @returns the created async loop object
  101039. */
  101040. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101041. }
  101042. }
  101043. declare module BABYLON {
  101044. /**
  101045. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101046. * The underlying implementation relies on an associative array to ensure the best performances.
  101047. * The value can be anything including 'null' but except 'undefined'
  101048. */
  101049. export class StringDictionary<T> {
  101050. /**
  101051. * This will clear this dictionary and copy the content from the 'source' one.
  101052. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101053. * @param source the dictionary to take the content from and copy to this dictionary
  101054. */
  101055. copyFrom(source: StringDictionary<T>): void;
  101056. /**
  101057. * Get a value based from its key
  101058. * @param key the given key to get the matching value from
  101059. * @return the value if found, otherwise undefined is returned
  101060. */
  101061. get(key: string): T | undefined;
  101062. /**
  101063. * Get a value from its key or add it if it doesn't exist.
  101064. * This method will ensure you that a given key/data will be present in the dictionary.
  101065. * @param key the given key to get the matching value from
  101066. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101067. * The factory will only be invoked if there's no data for the given key.
  101068. * @return the value corresponding to the key.
  101069. */
  101070. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101071. /**
  101072. * Get a value from its key if present in the dictionary otherwise add it
  101073. * @param key the key to get the value from
  101074. * @param val if there's no such key/value pair in the dictionary add it with this value
  101075. * @return the value corresponding to the key
  101076. */
  101077. getOrAdd(key: string, val: T): T;
  101078. /**
  101079. * Check if there's a given key in the dictionary
  101080. * @param key the key to check for
  101081. * @return true if the key is present, false otherwise
  101082. */
  101083. contains(key: string): boolean;
  101084. /**
  101085. * Add a new key and its corresponding value
  101086. * @param key the key to add
  101087. * @param value the value corresponding to the key
  101088. * @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
  101089. */
  101090. add(key: string, value: T): boolean;
  101091. /**
  101092. * Update a specific value associated to a key
  101093. * @param key defines the key to use
  101094. * @param value defines the value to store
  101095. * @returns true if the value was updated (or false if the key was not found)
  101096. */
  101097. set(key: string, value: T): boolean;
  101098. /**
  101099. * Get the element of the given key and remove it from the dictionary
  101100. * @param key defines the key to search
  101101. * @returns the value associated with the key or null if not found
  101102. */
  101103. getAndRemove(key: string): Nullable<T>;
  101104. /**
  101105. * Remove a key/value from the dictionary.
  101106. * @param key the key to remove
  101107. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101108. */
  101109. remove(key: string): boolean;
  101110. /**
  101111. * Clear the whole content of the dictionary
  101112. */
  101113. clear(): void;
  101114. /**
  101115. * Gets the current count
  101116. */
  101117. readonly count: number;
  101118. /**
  101119. * Execute a callback on each key/val of the dictionary.
  101120. * Note that you can remove any element in this dictionary in the callback implementation
  101121. * @param callback the callback to execute on a given key/value pair
  101122. */
  101123. forEach(callback: (key: string, val: T) => void): void;
  101124. /**
  101125. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101126. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101127. * Note that you can remove any element in this dictionary in the callback implementation
  101128. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101129. * @returns the first item
  101130. */
  101131. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101132. private _count;
  101133. private _data;
  101134. }
  101135. }
  101136. declare module BABYLON {
  101137. /** @hidden */
  101138. export interface ICollisionCoordinator {
  101139. createCollider(): Collider;
  101140. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101141. init(scene: Scene): void;
  101142. }
  101143. /** @hidden */
  101144. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101145. private _scene;
  101146. private _scaledPosition;
  101147. private _scaledVelocity;
  101148. private _finalPosition;
  101149. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101150. createCollider(): Collider;
  101151. init(scene: Scene): void;
  101152. private _collideWithWorld;
  101153. }
  101154. }
  101155. declare module BABYLON {
  101156. /**
  101157. * Class used to manage all inputs for the scene.
  101158. */
  101159. export class InputManager {
  101160. /** The distance in pixel that you have to move to prevent some events */
  101161. static DragMovementThreshold: number;
  101162. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101163. static LongPressDelay: number;
  101164. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101165. static DoubleClickDelay: number;
  101166. /** If you need to check double click without raising a single click at first click, enable this flag */
  101167. static ExclusiveDoubleClickMode: boolean;
  101168. private _wheelEventName;
  101169. private _onPointerMove;
  101170. private _onPointerDown;
  101171. private _onPointerUp;
  101172. private _initClickEvent;
  101173. private _initActionManager;
  101174. private _delayedSimpleClick;
  101175. private _delayedSimpleClickTimeout;
  101176. private _previousDelayedSimpleClickTimeout;
  101177. private _meshPickProceed;
  101178. private _previousButtonPressed;
  101179. private _currentPickResult;
  101180. private _previousPickResult;
  101181. private _totalPointersPressed;
  101182. private _doubleClickOccured;
  101183. private _pointerOverMesh;
  101184. private _pickedDownMesh;
  101185. private _pickedUpMesh;
  101186. private _pointerX;
  101187. private _pointerY;
  101188. private _unTranslatedPointerX;
  101189. private _unTranslatedPointerY;
  101190. private _startingPointerPosition;
  101191. private _previousStartingPointerPosition;
  101192. private _startingPointerTime;
  101193. private _previousStartingPointerTime;
  101194. private _pointerCaptures;
  101195. private _onKeyDown;
  101196. private _onKeyUp;
  101197. private _onCanvasFocusObserver;
  101198. private _onCanvasBlurObserver;
  101199. private _scene;
  101200. /**
  101201. * Creates a new InputManager
  101202. * @param scene defines the hosting scene
  101203. */
  101204. constructor(scene: Scene);
  101205. /**
  101206. * Gets the mesh that is currently under the pointer
  101207. */
  101208. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101209. /**
  101210. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101211. */
  101212. readonly unTranslatedPointer: Vector2;
  101213. /**
  101214. * Gets or sets the current on-screen X position of the pointer
  101215. */
  101216. pointerX: number;
  101217. /**
  101218. * Gets or sets the current on-screen Y position of the pointer
  101219. */
  101220. pointerY: number;
  101221. private _updatePointerPosition;
  101222. private _processPointerMove;
  101223. private _setRayOnPointerInfo;
  101224. private _checkPrePointerObservable;
  101225. /**
  101226. * Use this method to simulate a pointer move on a mesh
  101227. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101228. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101229. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101230. */
  101231. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101232. /**
  101233. * Use this method to simulate a pointer down on a mesh
  101234. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101235. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101236. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101237. */
  101238. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101239. private _processPointerDown;
  101240. /** @hidden */
  101241. _isPointerSwiping(): boolean;
  101242. /**
  101243. * Use this method to simulate a pointer up on a mesh
  101244. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101245. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101246. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101247. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101248. */
  101249. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101250. private _processPointerUp;
  101251. /**
  101252. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101253. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101254. * @returns true if the pointer was captured
  101255. */
  101256. isPointerCaptured(pointerId?: number): boolean;
  101257. /**
  101258. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101259. * @param attachUp defines if you want to attach events to pointerup
  101260. * @param attachDown defines if you want to attach events to pointerdown
  101261. * @param attachMove defines if you want to attach events to pointermove
  101262. */
  101263. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101264. /**
  101265. * Detaches all event handlers
  101266. */
  101267. detachControl(): void;
  101268. /**
  101269. * Force the value of meshUnderPointer
  101270. * @param mesh defines the mesh to use
  101271. */
  101272. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101273. /**
  101274. * Gets the mesh under the pointer
  101275. * @returns a Mesh or null if no mesh is under the pointer
  101276. */
  101277. getPointerOverMesh(): Nullable<AbstractMesh>;
  101278. }
  101279. }
  101280. declare module BABYLON {
  101281. /**
  101282. * Helper class used to generate session unique ID
  101283. */
  101284. export class UniqueIdGenerator {
  101285. private static _UniqueIdCounter;
  101286. /**
  101287. * Gets an unique (relatively to the current scene) Id
  101288. */
  101289. static readonly UniqueId: number;
  101290. }
  101291. }
  101292. declare module BABYLON {
  101293. /**
  101294. * This class defines the direct association between an animation and a target
  101295. */
  101296. export class TargetedAnimation {
  101297. /**
  101298. * Animation to perform
  101299. */
  101300. animation: Animation;
  101301. /**
  101302. * Target to animate
  101303. */
  101304. target: any;
  101305. /**
  101306. * Serialize the object
  101307. * @returns the JSON object representing the current entity
  101308. */
  101309. serialize(): any;
  101310. }
  101311. /**
  101312. * Use this class to create coordinated animations on multiple targets
  101313. */
  101314. export class AnimationGroup implements IDisposable {
  101315. /** The name of the animation group */
  101316. name: string;
  101317. private _scene;
  101318. private _targetedAnimations;
  101319. private _animatables;
  101320. private _from;
  101321. private _to;
  101322. private _isStarted;
  101323. private _isPaused;
  101324. private _speedRatio;
  101325. private _loopAnimation;
  101326. /**
  101327. * Gets or sets the unique id of the node
  101328. */
  101329. uniqueId: number;
  101330. /**
  101331. * This observable will notify when one animation have ended
  101332. */
  101333. onAnimationEndObservable: Observable<TargetedAnimation>;
  101334. /**
  101335. * Observer raised when one animation loops
  101336. */
  101337. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101338. /**
  101339. * Observer raised when all animations have looped
  101340. */
  101341. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101342. /**
  101343. * This observable will notify when all animations have ended.
  101344. */
  101345. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101346. /**
  101347. * This observable will notify when all animations have paused.
  101348. */
  101349. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101350. /**
  101351. * This observable will notify when all animations are playing.
  101352. */
  101353. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101354. /**
  101355. * Gets the first frame
  101356. */
  101357. readonly from: number;
  101358. /**
  101359. * Gets the last frame
  101360. */
  101361. readonly to: number;
  101362. /**
  101363. * Define if the animations are started
  101364. */
  101365. readonly isStarted: boolean;
  101366. /**
  101367. * Gets a value indicating that the current group is playing
  101368. */
  101369. readonly isPlaying: boolean;
  101370. /**
  101371. * Gets or sets the speed ratio to use for all animations
  101372. */
  101373. /**
  101374. * Gets or sets the speed ratio to use for all animations
  101375. */
  101376. speedRatio: number;
  101377. /**
  101378. * Gets or sets if all animations should loop or not
  101379. */
  101380. loopAnimation: boolean;
  101381. /**
  101382. * Gets the targeted animations for this animation group
  101383. */
  101384. readonly targetedAnimations: Array<TargetedAnimation>;
  101385. /**
  101386. * returning the list of animatables controlled by this animation group.
  101387. */
  101388. readonly animatables: Array<Animatable>;
  101389. /**
  101390. * Instantiates a new Animation Group.
  101391. * This helps managing several animations at once.
  101392. * @see http://doc.babylonjs.com/how_to/group
  101393. * @param name Defines the name of the group
  101394. * @param scene Defines the scene the group belongs to
  101395. */
  101396. constructor(
  101397. /** The name of the animation group */
  101398. name: string, scene?: Nullable<Scene>);
  101399. /**
  101400. * Add an animation (with its target) in the group
  101401. * @param animation defines the animation we want to add
  101402. * @param target defines the target of the animation
  101403. * @returns the TargetedAnimation object
  101404. */
  101405. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101406. /**
  101407. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101408. * It can add constant keys at begin or end
  101409. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101410. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101411. * @returns the animation group
  101412. */
  101413. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101414. private _animationLoopCount;
  101415. private _animationLoopFlags;
  101416. private _processLoop;
  101417. /**
  101418. * Start all animations on given targets
  101419. * @param loop defines if animations must loop
  101420. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101421. * @param from defines the from key (optional)
  101422. * @param to defines the to key (optional)
  101423. * @returns the current animation group
  101424. */
  101425. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101426. /**
  101427. * Pause all animations
  101428. * @returns the animation group
  101429. */
  101430. pause(): AnimationGroup;
  101431. /**
  101432. * Play all animations to initial state
  101433. * This function will start() the animations if they were not started or will restart() them if they were paused
  101434. * @param loop defines if animations must loop
  101435. * @returns the animation group
  101436. */
  101437. play(loop?: boolean): AnimationGroup;
  101438. /**
  101439. * Reset all animations to initial state
  101440. * @returns the animation group
  101441. */
  101442. reset(): AnimationGroup;
  101443. /**
  101444. * Restart animations from key 0
  101445. * @returns the animation group
  101446. */
  101447. restart(): AnimationGroup;
  101448. /**
  101449. * Stop all animations
  101450. * @returns the animation group
  101451. */
  101452. stop(): AnimationGroup;
  101453. /**
  101454. * Set animation weight for all animatables
  101455. * @param weight defines the weight to use
  101456. * @return the animationGroup
  101457. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101458. */
  101459. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101460. /**
  101461. * Synchronize and normalize all animatables with a source animatable
  101462. * @param root defines the root animatable to synchronize with
  101463. * @return the animationGroup
  101464. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101465. */
  101466. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101467. /**
  101468. * Goes to a specific frame in this animation group
  101469. * @param frame the frame number to go to
  101470. * @return the animationGroup
  101471. */
  101472. goToFrame(frame: number): AnimationGroup;
  101473. /**
  101474. * Dispose all associated resources
  101475. */
  101476. dispose(): void;
  101477. private _checkAnimationGroupEnded;
  101478. /**
  101479. * Clone the current animation group and returns a copy
  101480. * @param newName defines the name of the new group
  101481. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101482. * @returns the new aniamtion group
  101483. */
  101484. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101485. /**
  101486. * Serializes the animationGroup to an object
  101487. * @returns Serialized object
  101488. */
  101489. serialize(): any;
  101490. /**
  101491. * Returns a new AnimationGroup object parsed from the source provided.
  101492. * @param parsedAnimationGroup defines the source
  101493. * @param scene defines the scene that will receive the animationGroup
  101494. * @returns a new AnimationGroup
  101495. */
  101496. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101497. /**
  101498. * Returns the string "AnimationGroup"
  101499. * @returns "AnimationGroup"
  101500. */
  101501. getClassName(): string;
  101502. /**
  101503. * Creates a detailled string about the object
  101504. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101505. * @returns a string representing the object
  101506. */
  101507. toString(fullDetails?: boolean): string;
  101508. }
  101509. }
  101510. declare module BABYLON {
  101511. /**
  101512. * Define an interface for all classes that will hold resources
  101513. */
  101514. export interface IDisposable {
  101515. /**
  101516. * Releases all held resources
  101517. */
  101518. dispose(): void;
  101519. }
  101520. /** Interface defining initialization parameters for Scene class */
  101521. export interface SceneOptions {
  101522. /**
  101523. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101524. * It will improve performance when the number of geometries becomes important.
  101525. */
  101526. useGeometryUniqueIdsMap?: boolean;
  101527. /**
  101528. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101529. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101530. */
  101531. useMaterialMeshMap?: boolean;
  101532. /**
  101533. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101534. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101535. */
  101536. useClonedMeshhMap?: boolean;
  101537. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101538. virtual?: boolean;
  101539. }
  101540. /**
  101541. * Represents a scene to be rendered by the engine.
  101542. * @see http://doc.babylonjs.com/features/scene
  101543. */
  101544. export class Scene extends AbstractScene implements IAnimatable {
  101545. /** The fog is deactivated */
  101546. static readonly FOGMODE_NONE: number;
  101547. /** The fog density is following an exponential function */
  101548. static readonly FOGMODE_EXP: number;
  101549. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101550. static readonly FOGMODE_EXP2: number;
  101551. /** The fog density is following a linear function. */
  101552. static readonly FOGMODE_LINEAR: number;
  101553. /**
  101554. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101555. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101556. */
  101557. static MinDeltaTime: number;
  101558. /**
  101559. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101561. */
  101562. static MaxDeltaTime: number;
  101563. /**
  101564. * Factory used to create the default material.
  101565. * @param name The name of the material to create
  101566. * @param scene The scene to create the material for
  101567. * @returns The default material
  101568. */
  101569. static DefaultMaterialFactory(scene: Scene): Material;
  101570. /**
  101571. * Factory used to create the a collision coordinator.
  101572. * @returns The collision coordinator
  101573. */
  101574. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101575. /** @hidden */
  101576. _inputManager: InputManager;
  101577. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101578. cameraToUseForPointers: Nullable<Camera>;
  101579. /** @hidden */
  101580. readonly _isScene: boolean;
  101581. /**
  101582. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101583. */
  101584. autoClear: boolean;
  101585. /**
  101586. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101587. */
  101588. autoClearDepthAndStencil: boolean;
  101589. /**
  101590. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101591. */
  101592. clearColor: Color4;
  101593. /**
  101594. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101595. */
  101596. ambientColor: Color3;
  101597. /**
  101598. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101599. * It should only be one of the following (if not the default embedded one):
  101600. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101601. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101602. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101603. * The material properties need to be setup according to the type of texture in use.
  101604. */
  101605. environmentBRDFTexture: BaseTexture;
  101606. /** @hidden */
  101607. protected _environmentTexture: Nullable<BaseTexture>;
  101608. /**
  101609. * Texture used in all pbr material as the reflection texture.
  101610. * As in the majority of the scene they are the same (exception for multi room and so on),
  101611. * this is easier to reference from here than from all the materials.
  101612. */
  101613. /**
  101614. * Texture used in all pbr material as the reflection texture.
  101615. * As in the majority of the scene they are the same (exception for multi room and so on),
  101616. * this is easier to set here than in all the materials.
  101617. */
  101618. environmentTexture: Nullable<BaseTexture>;
  101619. /** @hidden */
  101620. protected _environmentIntensity: number;
  101621. /**
  101622. * Intensity of the environment in all pbr material.
  101623. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101624. * As in the majority of the scene they are the same (exception for multi room and so on),
  101625. * this is easier to reference from here than from all the materials.
  101626. */
  101627. /**
  101628. * Intensity of the environment in all pbr material.
  101629. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101630. * As in the majority of the scene they are the same (exception for multi room and so on),
  101631. * this is easier to set here than in all the materials.
  101632. */
  101633. environmentIntensity: number;
  101634. /** @hidden */
  101635. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101636. /**
  101637. * Default image processing configuration used either in the rendering
  101638. * Forward main pass or through the imageProcessingPostProcess if present.
  101639. * As in the majority of the scene they are the same (exception for multi camera),
  101640. * this is easier to reference from here than from all the materials and post process.
  101641. *
  101642. * No setter as we it is a shared configuration, you can set the values instead.
  101643. */
  101644. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101645. private _forceWireframe;
  101646. /**
  101647. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101648. */
  101649. forceWireframe: boolean;
  101650. private _forcePointsCloud;
  101651. /**
  101652. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101653. */
  101654. forcePointsCloud: boolean;
  101655. /**
  101656. * Gets or sets the active clipplane 1
  101657. */
  101658. clipPlane: Nullable<Plane>;
  101659. /**
  101660. * Gets or sets the active clipplane 2
  101661. */
  101662. clipPlane2: Nullable<Plane>;
  101663. /**
  101664. * Gets or sets the active clipplane 3
  101665. */
  101666. clipPlane3: Nullable<Plane>;
  101667. /**
  101668. * Gets or sets the active clipplane 4
  101669. */
  101670. clipPlane4: Nullable<Plane>;
  101671. /**
  101672. * Gets or sets a boolean indicating if animations are enabled
  101673. */
  101674. animationsEnabled: boolean;
  101675. private _animationPropertiesOverride;
  101676. /**
  101677. * Gets or sets the animation properties override
  101678. */
  101679. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101680. /**
  101681. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101682. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101683. */
  101684. useConstantAnimationDeltaTime: boolean;
  101685. /**
  101686. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101687. * Please note that it requires to run a ray cast through the scene on every frame
  101688. */
  101689. constantlyUpdateMeshUnderPointer: boolean;
  101690. /**
  101691. * Defines the HTML cursor to use when hovering over interactive elements
  101692. */
  101693. hoverCursor: string;
  101694. /**
  101695. * Defines the HTML default cursor to use (empty by default)
  101696. */
  101697. defaultCursor: string;
  101698. /**
  101699. * Defines wether cursors are handled by the scene.
  101700. */
  101701. doNotHandleCursors: boolean;
  101702. /**
  101703. * This is used to call preventDefault() on pointer down
  101704. * in order to block unwanted artifacts like system double clicks
  101705. */
  101706. preventDefaultOnPointerDown: boolean;
  101707. /**
  101708. * This is used to call preventDefault() on pointer up
  101709. * in order to block unwanted artifacts like system double clicks
  101710. */
  101711. preventDefaultOnPointerUp: boolean;
  101712. /**
  101713. * Gets or sets user defined metadata
  101714. */
  101715. metadata: any;
  101716. /**
  101717. * For internal use only. Please do not use.
  101718. */
  101719. reservedDataStore: any;
  101720. /**
  101721. * Gets the name of the plugin used to load this scene (null by default)
  101722. */
  101723. loadingPluginName: string;
  101724. /**
  101725. * Use this array to add regular expressions used to disable offline support for specific urls
  101726. */
  101727. disableOfflineSupportExceptionRules: RegExp[];
  101728. /**
  101729. * An event triggered when the scene is disposed.
  101730. */
  101731. onDisposeObservable: Observable<Scene>;
  101732. private _onDisposeObserver;
  101733. /** Sets a function to be executed when this scene is disposed. */
  101734. onDispose: () => void;
  101735. /**
  101736. * An event triggered before rendering the scene (right after animations and physics)
  101737. */
  101738. onBeforeRenderObservable: Observable<Scene>;
  101739. private _onBeforeRenderObserver;
  101740. /** Sets a function to be executed before rendering this scene */
  101741. beforeRender: Nullable<() => void>;
  101742. /**
  101743. * An event triggered after rendering the scene
  101744. */
  101745. onAfterRenderObservable: Observable<Scene>;
  101746. /**
  101747. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101748. */
  101749. onAfterRenderCameraObservable: Observable<Camera>;
  101750. private _onAfterRenderObserver;
  101751. /** Sets a function to be executed after rendering this scene */
  101752. afterRender: Nullable<() => void>;
  101753. /**
  101754. * An event triggered before animating the scene
  101755. */
  101756. onBeforeAnimationsObservable: Observable<Scene>;
  101757. /**
  101758. * An event triggered after animations processing
  101759. */
  101760. onAfterAnimationsObservable: Observable<Scene>;
  101761. /**
  101762. * An event triggered before draw calls are ready to be sent
  101763. */
  101764. onBeforeDrawPhaseObservable: Observable<Scene>;
  101765. /**
  101766. * An event triggered after draw calls have been sent
  101767. */
  101768. onAfterDrawPhaseObservable: Observable<Scene>;
  101769. /**
  101770. * An event triggered when the scene is ready
  101771. */
  101772. onReadyObservable: Observable<Scene>;
  101773. /**
  101774. * An event triggered before rendering a camera
  101775. */
  101776. onBeforeCameraRenderObservable: Observable<Camera>;
  101777. private _onBeforeCameraRenderObserver;
  101778. /** Sets a function to be executed before rendering a camera*/
  101779. beforeCameraRender: () => void;
  101780. /**
  101781. * An event triggered after rendering a camera
  101782. */
  101783. onAfterCameraRenderObservable: Observable<Camera>;
  101784. private _onAfterCameraRenderObserver;
  101785. /** Sets a function to be executed after rendering a camera*/
  101786. afterCameraRender: () => void;
  101787. /**
  101788. * An event triggered when active meshes evaluation is about to start
  101789. */
  101790. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101791. /**
  101792. * An event triggered when active meshes evaluation is done
  101793. */
  101794. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101795. /**
  101796. * An event triggered when particles rendering is about to start
  101797. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101798. */
  101799. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101800. /**
  101801. * An event triggered when particles rendering is done
  101802. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101803. */
  101804. onAfterParticlesRenderingObservable: Observable<Scene>;
  101805. /**
  101806. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101807. */
  101808. onDataLoadedObservable: Observable<Scene>;
  101809. /**
  101810. * An event triggered when a camera is created
  101811. */
  101812. onNewCameraAddedObservable: Observable<Camera>;
  101813. /**
  101814. * An event triggered when a camera is removed
  101815. */
  101816. onCameraRemovedObservable: Observable<Camera>;
  101817. /**
  101818. * An event triggered when a light is created
  101819. */
  101820. onNewLightAddedObservable: Observable<Light>;
  101821. /**
  101822. * An event triggered when a light is removed
  101823. */
  101824. onLightRemovedObservable: Observable<Light>;
  101825. /**
  101826. * An event triggered when a geometry is created
  101827. */
  101828. onNewGeometryAddedObservable: Observable<Geometry>;
  101829. /**
  101830. * An event triggered when a geometry is removed
  101831. */
  101832. onGeometryRemovedObservable: Observable<Geometry>;
  101833. /**
  101834. * An event triggered when a transform node is created
  101835. */
  101836. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101837. /**
  101838. * An event triggered when a transform node is removed
  101839. */
  101840. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101841. /**
  101842. * An event triggered when a mesh is created
  101843. */
  101844. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101845. /**
  101846. * An event triggered when a mesh is removed
  101847. */
  101848. onMeshRemovedObservable: Observable<AbstractMesh>;
  101849. /**
  101850. * An event triggered when a skeleton is created
  101851. */
  101852. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101853. /**
  101854. * An event triggered when a skeleton is removed
  101855. */
  101856. onSkeletonRemovedObservable: Observable<Skeleton>;
  101857. /**
  101858. * An event triggered when a material is created
  101859. */
  101860. onNewMaterialAddedObservable: Observable<Material>;
  101861. /**
  101862. * An event triggered when a material is removed
  101863. */
  101864. onMaterialRemovedObservable: Observable<Material>;
  101865. /**
  101866. * An event triggered when a texture is created
  101867. */
  101868. onNewTextureAddedObservable: Observable<BaseTexture>;
  101869. /**
  101870. * An event triggered when a texture is removed
  101871. */
  101872. onTextureRemovedObservable: Observable<BaseTexture>;
  101873. /**
  101874. * An event triggered when render targets are about to be rendered
  101875. * Can happen multiple times per frame.
  101876. */
  101877. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101878. /**
  101879. * An event triggered when render targets were rendered.
  101880. * Can happen multiple times per frame.
  101881. */
  101882. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101883. /**
  101884. * An event triggered before calculating deterministic simulation step
  101885. */
  101886. onBeforeStepObservable: Observable<Scene>;
  101887. /**
  101888. * An event triggered after calculating deterministic simulation step
  101889. */
  101890. onAfterStepObservable: Observable<Scene>;
  101891. /**
  101892. * An event triggered when the activeCamera property is updated
  101893. */
  101894. onActiveCameraChanged: Observable<Scene>;
  101895. /**
  101896. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101897. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101898. * 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)
  101899. */
  101900. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101901. /**
  101902. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101903. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101904. * 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)
  101905. */
  101906. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101907. /**
  101908. * This Observable will when a mesh has been imported into the scene.
  101909. */
  101910. onMeshImportedObservable: Observable<AbstractMesh>;
  101911. /**
  101912. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101913. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101914. */
  101915. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101916. /** @hidden */
  101917. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101918. /**
  101919. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101920. */
  101921. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101922. /**
  101923. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101924. */
  101925. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101926. /**
  101927. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101928. */
  101929. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101930. /** Callback called when a pointer move is detected */
  101931. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101932. /** Callback called when a pointer down is detected */
  101933. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101934. /** Callback called when a pointer up is detected */
  101935. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101936. /** Callback called when a pointer pick is detected */
  101937. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101938. /**
  101939. * 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).
  101940. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101941. */
  101942. onPrePointerObservable: Observable<PointerInfoPre>;
  101943. /**
  101944. * Observable event triggered each time an input event is received from the rendering canvas
  101945. */
  101946. onPointerObservable: Observable<PointerInfo>;
  101947. /**
  101948. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101949. */
  101950. readonly unTranslatedPointer: Vector2;
  101951. /**
  101952. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101953. */
  101954. static DragMovementThreshold: number;
  101955. /**
  101956. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101957. */
  101958. static LongPressDelay: number;
  101959. /**
  101960. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101961. */
  101962. static DoubleClickDelay: number;
  101963. /** If you need to check double click without raising a single click at first click, enable this flag */
  101964. static ExclusiveDoubleClickMode: boolean;
  101965. /** @hidden */
  101966. _mirroredCameraPosition: Nullable<Vector3>;
  101967. /**
  101968. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101969. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101970. */
  101971. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101972. /**
  101973. * Observable event triggered each time an keyboard event is received from the hosting window
  101974. */
  101975. onKeyboardObservable: Observable<KeyboardInfo>;
  101976. private _useRightHandedSystem;
  101977. /**
  101978. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101979. */
  101980. useRightHandedSystem: boolean;
  101981. private _timeAccumulator;
  101982. private _currentStepId;
  101983. private _currentInternalStep;
  101984. /**
  101985. * Sets the step Id used by deterministic lock step
  101986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101987. * @param newStepId defines the step Id
  101988. */
  101989. setStepId(newStepId: number): void;
  101990. /**
  101991. * Gets the step Id used by deterministic lock step
  101992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101993. * @returns the step Id
  101994. */
  101995. getStepId(): number;
  101996. /**
  101997. * Gets the internal step used by deterministic lock step
  101998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101999. * @returns the internal step
  102000. */
  102001. getInternalStep(): number;
  102002. private _fogEnabled;
  102003. /**
  102004. * Gets or sets a boolean indicating if fog is enabled on this scene
  102005. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102006. * (Default is true)
  102007. */
  102008. fogEnabled: boolean;
  102009. private _fogMode;
  102010. /**
  102011. * Gets or sets the fog mode to use
  102012. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102013. * | mode | value |
  102014. * | --- | --- |
  102015. * | FOGMODE_NONE | 0 |
  102016. * | FOGMODE_EXP | 1 |
  102017. * | FOGMODE_EXP2 | 2 |
  102018. * | FOGMODE_LINEAR | 3 |
  102019. */
  102020. fogMode: number;
  102021. /**
  102022. * Gets or sets the fog color to use
  102023. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102024. * (Default is Color3(0.2, 0.2, 0.3))
  102025. */
  102026. fogColor: Color3;
  102027. /**
  102028. * Gets or sets the fog density to use
  102029. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102030. * (Default is 0.1)
  102031. */
  102032. fogDensity: number;
  102033. /**
  102034. * Gets or sets the fog start distance to use
  102035. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102036. * (Default is 0)
  102037. */
  102038. fogStart: number;
  102039. /**
  102040. * Gets or sets the fog end distance to use
  102041. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102042. * (Default is 1000)
  102043. */
  102044. fogEnd: number;
  102045. private _shadowsEnabled;
  102046. /**
  102047. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102048. */
  102049. shadowsEnabled: boolean;
  102050. private _lightsEnabled;
  102051. /**
  102052. * Gets or sets a boolean indicating if lights are enabled on this scene
  102053. */
  102054. lightsEnabled: boolean;
  102055. /** All of the active cameras added to this scene. */
  102056. activeCameras: Camera[];
  102057. /** @hidden */
  102058. _activeCamera: Nullable<Camera>;
  102059. /** Gets or sets the current active camera */
  102060. activeCamera: Nullable<Camera>;
  102061. private _defaultMaterial;
  102062. /** The default material used on meshes when no material is affected */
  102063. /** The default material used on meshes when no material is affected */
  102064. defaultMaterial: Material;
  102065. private _texturesEnabled;
  102066. /**
  102067. * Gets or sets a boolean indicating if textures are enabled on this scene
  102068. */
  102069. texturesEnabled: boolean;
  102070. /**
  102071. * Gets or sets a boolean indicating if particles are enabled on this scene
  102072. */
  102073. particlesEnabled: boolean;
  102074. /**
  102075. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102076. */
  102077. spritesEnabled: boolean;
  102078. private _skeletonsEnabled;
  102079. /**
  102080. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102081. */
  102082. skeletonsEnabled: boolean;
  102083. /**
  102084. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102085. */
  102086. lensFlaresEnabled: boolean;
  102087. /**
  102088. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102090. */
  102091. collisionsEnabled: boolean;
  102092. private _collisionCoordinator;
  102093. /** @hidden */
  102094. readonly collisionCoordinator: ICollisionCoordinator;
  102095. /**
  102096. * Defines the gravity applied to this scene (used only for collisions)
  102097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102098. */
  102099. gravity: Vector3;
  102100. /**
  102101. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102102. */
  102103. postProcessesEnabled: boolean;
  102104. /**
  102105. * The list of postprocesses added to the scene
  102106. */
  102107. postProcesses: PostProcess[];
  102108. /**
  102109. * Gets the current postprocess manager
  102110. */
  102111. postProcessManager: PostProcessManager;
  102112. /**
  102113. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102114. */
  102115. renderTargetsEnabled: boolean;
  102116. /**
  102117. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102118. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102119. */
  102120. dumpNextRenderTargets: boolean;
  102121. /**
  102122. * The list of user defined render targets added to the scene
  102123. */
  102124. customRenderTargets: RenderTargetTexture[];
  102125. /**
  102126. * Defines if texture loading must be delayed
  102127. * If true, textures will only be loaded when they need to be rendered
  102128. */
  102129. useDelayedTextureLoading: boolean;
  102130. /**
  102131. * Gets the list of meshes imported to the scene through SceneLoader
  102132. */
  102133. importedMeshesFiles: String[];
  102134. /**
  102135. * Gets or sets a boolean indicating if probes are enabled on this scene
  102136. */
  102137. probesEnabled: boolean;
  102138. /**
  102139. * Gets or sets the current offline provider to use to store scene data
  102140. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102141. */
  102142. offlineProvider: IOfflineProvider;
  102143. /**
  102144. * Gets or sets the action manager associated with the scene
  102145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102146. */
  102147. actionManager: AbstractActionManager;
  102148. private _meshesForIntersections;
  102149. /**
  102150. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102151. */
  102152. proceduralTexturesEnabled: boolean;
  102153. private _engine;
  102154. private _totalVertices;
  102155. /** @hidden */
  102156. _activeIndices: PerfCounter;
  102157. /** @hidden */
  102158. _activeParticles: PerfCounter;
  102159. /** @hidden */
  102160. _activeBones: PerfCounter;
  102161. private _animationRatio;
  102162. /** @hidden */
  102163. _animationTimeLast: number;
  102164. /** @hidden */
  102165. _animationTime: number;
  102166. /**
  102167. * Gets or sets a general scale for animation speed
  102168. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102169. */
  102170. animationTimeScale: number;
  102171. /** @hidden */
  102172. _cachedMaterial: Nullable<Material>;
  102173. /** @hidden */
  102174. _cachedEffect: Nullable<Effect>;
  102175. /** @hidden */
  102176. _cachedVisibility: Nullable<number>;
  102177. private _renderId;
  102178. private _frameId;
  102179. private _executeWhenReadyTimeoutId;
  102180. private _intermediateRendering;
  102181. private _viewUpdateFlag;
  102182. private _projectionUpdateFlag;
  102183. /** @hidden */
  102184. _toBeDisposed: Nullable<IDisposable>[];
  102185. private _activeRequests;
  102186. /** @hidden */
  102187. _pendingData: any[];
  102188. private _isDisposed;
  102189. /**
  102190. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102191. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102192. */
  102193. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102194. private _activeMeshes;
  102195. private _processedMaterials;
  102196. private _renderTargets;
  102197. /** @hidden */
  102198. _activeParticleSystems: SmartArray<IParticleSystem>;
  102199. private _activeSkeletons;
  102200. private _softwareSkinnedMeshes;
  102201. private _renderingManager;
  102202. /** @hidden */
  102203. _activeAnimatables: Animatable[];
  102204. private _transformMatrix;
  102205. private _sceneUbo;
  102206. /** @hidden */
  102207. _viewMatrix: Matrix;
  102208. private _projectionMatrix;
  102209. /** @hidden */
  102210. _forcedViewPosition: Nullable<Vector3>;
  102211. /** @hidden */
  102212. _frustumPlanes: Plane[];
  102213. /**
  102214. * Gets the list of frustum planes (built from the active camera)
  102215. */
  102216. readonly frustumPlanes: Plane[];
  102217. /**
  102218. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102219. * This is useful if there are more lights that the maximum simulteanous authorized
  102220. */
  102221. requireLightSorting: boolean;
  102222. /** @hidden */
  102223. readonly useMaterialMeshMap: boolean;
  102224. /** @hidden */
  102225. readonly useClonedMeshhMap: boolean;
  102226. private _externalData;
  102227. private _uid;
  102228. /**
  102229. * @hidden
  102230. * Backing store of defined scene components.
  102231. */
  102232. _components: ISceneComponent[];
  102233. /**
  102234. * @hidden
  102235. * Backing store of defined scene components.
  102236. */
  102237. _serializableComponents: ISceneSerializableComponent[];
  102238. /**
  102239. * List of components to register on the next registration step.
  102240. */
  102241. private _transientComponents;
  102242. /**
  102243. * Registers the transient components if needed.
  102244. */
  102245. private _registerTransientComponents;
  102246. /**
  102247. * @hidden
  102248. * Add a component to the scene.
  102249. * Note that the ccomponent could be registered on th next frame if this is called after
  102250. * the register component stage.
  102251. * @param component Defines the component to add to the scene
  102252. */
  102253. _addComponent(component: ISceneComponent): void;
  102254. /**
  102255. * @hidden
  102256. * Gets a component from the scene.
  102257. * @param name defines the name of the component to retrieve
  102258. * @returns the component or null if not present
  102259. */
  102260. _getComponent(name: string): Nullable<ISceneComponent>;
  102261. /**
  102262. * @hidden
  102263. * Defines the actions happening before camera updates.
  102264. */
  102265. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102266. /**
  102267. * @hidden
  102268. * Defines the actions happening before clear the canvas.
  102269. */
  102270. _beforeClearStage: Stage<SimpleStageAction>;
  102271. /**
  102272. * @hidden
  102273. * Defines the actions when collecting render targets for the frame.
  102274. */
  102275. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102276. /**
  102277. * @hidden
  102278. * Defines the actions happening for one camera in the frame.
  102279. */
  102280. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102281. /**
  102282. * @hidden
  102283. * Defines the actions happening during the per mesh ready checks.
  102284. */
  102285. _isReadyForMeshStage: Stage<MeshStageAction>;
  102286. /**
  102287. * @hidden
  102288. * Defines the actions happening before evaluate active mesh checks.
  102289. */
  102290. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102291. /**
  102292. * @hidden
  102293. * Defines the actions happening during the evaluate sub mesh checks.
  102294. */
  102295. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102296. /**
  102297. * @hidden
  102298. * Defines the actions happening during the active mesh stage.
  102299. */
  102300. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102301. /**
  102302. * @hidden
  102303. * Defines the actions happening during the per camera render target step.
  102304. */
  102305. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102306. /**
  102307. * @hidden
  102308. * Defines the actions happening just before the active camera is drawing.
  102309. */
  102310. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102311. /**
  102312. * @hidden
  102313. * Defines the actions happening just before a render target is drawing.
  102314. */
  102315. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102316. /**
  102317. * @hidden
  102318. * Defines the actions happening just before a rendering group is drawing.
  102319. */
  102320. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102321. /**
  102322. * @hidden
  102323. * Defines the actions happening just before a mesh is drawing.
  102324. */
  102325. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102326. /**
  102327. * @hidden
  102328. * Defines the actions happening just after a mesh has been drawn.
  102329. */
  102330. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102331. /**
  102332. * @hidden
  102333. * Defines the actions happening just after a rendering group has been drawn.
  102334. */
  102335. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102336. /**
  102337. * @hidden
  102338. * Defines the actions happening just after the active camera has been drawn.
  102339. */
  102340. _afterCameraDrawStage: Stage<CameraStageAction>;
  102341. /**
  102342. * @hidden
  102343. * Defines the actions happening just after a render target has been drawn.
  102344. */
  102345. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102346. /**
  102347. * @hidden
  102348. * Defines the actions happening just after rendering all cameras and computing intersections.
  102349. */
  102350. _afterRenderStage: Stage<SimpleStageAction>;
  102351. /**
  102352. * @hidden
  102353. * Defines the actions happening when a pointer move event happens.
  102354. */
  102355. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102356. /**
  102357. * @hidden
  102358. * Defines the actions happening when a pointer down event happens.
  102359. */
  102360. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102361. /**
  102362. * @hidden
  102363. * Defines the actions happening when a pointer up event happens.
  102364. */
  102365. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102366. /**
  102367. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102368. */
  102369. private geometriesByUniqueId;
  102370. /**
  102371. * Creates a new Scene
  102372. * @param engine defines the engine to use to render this scene
  102373. * @param options defines the scene options
  102374. */
  102375. constructor(engine: Engine, options?: SceneOptions);
  102376. /**
  102377. * Gets a string idenfifying the name of the class
  102378. * @returns "Scene" string
  102379. */
  102380. getClassName(): string;
  102381. private _defaultMeshCandidates;
  102382. /**
  102383. * @hidden
  102384. */
  102385. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102386. private _defaultSubMeshCandidates;
  102387. /**
  102388. * @hidden
  102389. */
  102390. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102391. /**
  102392. * Sets the default candidate providers for the scene.
  102393. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102394. * and getCollidingSubMeshCandidates to their default function
  102395. */
  102396. setDefaultCandidateProviders(): void;
  102397. /**
  102398. * Gets the mesh that is currently under the pointer
  102399. */
  102400. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102401. /**
  102402. * Gets or sets the current on-screen X position of the pointer
  102403. */
  102404. pointerX: number;
  102405. /**
  102406. * Gets or sets the current on-screen Y position of the pointer
  102407. */
  102408. pointerY: number;
  102409. /**
  102410. * Gets the cached material (ie. the latest rendered one)
  102411. * @returns the cached material
  102412. */
  102413. getCachedMaterial(): Nullable<Material>;
  102414. /**
  102415. * Gets the cached effect (ie. the latest rendered one)
  102416. * @returns the cached effect
  102417. */
  102418. getCachedEffect(): Nullable<Effect>;
  102419. /**
  102420. * Gets the cached visibility state (ie. the latest rendered one)
  102421. * @returns the cached visibility state
  102422. */
  102423. getCachedVisibility(): Nullable<number>;
  102424. /**
  102425. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102426. * @param material defines the current material
  102427. * @param effect defines the current effect
  102428. * @param visibility defines the current visibility state
  102429. * @returns true if one parameter is not cached
  102430. */
  102431. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102432. /**
  102433. * Gets the engine associated with the scene
  102434. * @returns an Engine
  102435. */
  102436. getEngine(): Engine;
  102437. /**
  102438. * Gets the total number of vertices rendered per frame
  102439. * @returns the total number of vertices rendered per frame
  102440. */
  102441. getTotalVertices(): number;
  102442. /**
  102443. * Gets the performance counter for total vertices
  102444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102445. */
  102446. readonly totalVerticesPerfCounter: PerfCounter;
  102447. /**
  102448. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102449. * @returns the total number of active indices rendered per frame
  102450. */
  102451. getActiveIndices(): number;
  102452. /**
  102453. * Gets the performance counter for active indices
  102454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102455. */
  102456. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102457. /**
  102458. * Gets the total number of active particles rendered per frame
  102459. * @returns the total number of active particles rendered per frame
  102460. */
  102461. getActiveParticles(): number;
  102462. /**
  102463. * Gets the performance counter for active particles
  102464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102465. */
  102466. readonly activeParticlesPerfCounter: PerfCounter;
  102467. /**
  102468. * Gets the total number of active bones rendered per frame
  102469. * @returns the total number of active bones rendered per frame
  102470. */
  102471. getActiveBones(): number;
  102472. /**
  102473. * Gets the performance counter for active bones
  102474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102475. */
  102476. readonly activeBonesPerfCounter: PerfCounter;
  102477. /**
  102478. * Gets the array of active meshes
  102479. * @returns an array of AbstractMesh
  102480. */
  102481. getActiveMeshes(): SmartArray<AbstractMesh>;
  102482. /**
  102483. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102484. * @returns a number
  102485. */
  102486. getAnimationRatio(): number;
  102487. /**
  102488. * Gets an unique Id for the current render phase
  102489. * @returns a number
  102490. */
  102491. getRenderId(): number;
  102492. /**
  102493. * Gets an unique Id for the current frame
  102494. * @returns a number
  102495. */
  102496. getFrameId(): number;
  102497. /** Call this function if you want to manually increment the render Id*/
  102498. incrementRenderId(): void;
  102499. private _createUbo;
  102500. /**
  102501. * Use this method to simulate a pointer move on a mesh
  102502. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102503. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102504. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102505. * @returns the current scene
  102506. */
  102507. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102508. /**
  102509. * Use this method to simulate a pointer down on a mesh
  102510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102513. * @returns the current scene
  102514. */
  102515. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102516. /**
  102517. * Use this method to simulate a pointer up on a mesh
  102518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102521. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102522. * @returns the current scene
  102523. */
  102524. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102525. /**
  102526. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102527. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102528. * @returns true if the pointer was captured
  102529. */
  102530. isPointerCaptured(pointerId?: number): boolean;
  102531. /**
  102532. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102533. * @param attachUp defines if you want to attach events to pointerup
  102534. * @param attachDown defines if you want to attach events to pointerdown
  102535. * @param attachMove defines if you want to attach events to pointermove
  102536. */
  102537. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102538. /** Detaches all event handlers*/
  102539. detachControl(): void;
  102540. /**
  102541. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102542. * Delay loaded resources are not taking in account
  102543. * @return true if all required resources are ready
  102544. */
  102545. isReady(): boolean;
  102546. /** Resets all cached information relative to material (including effect and visibility) */
  102547. resetCachedMaterial(): void;
  102548. /**
  102549. * Registers a function to be called before every frame render
  102550. * @param func defines the function to register
  102551. */
  102552. registerBeforeRender(func: () => void): void;
  102553. /**
  102554. * Unregisters a function called before every frame render
  102555. * @param func defines the function to unregister
  102556. */
  102557. unregisterBeforeRender(func: () => void): void;
  102558. /**
  102559. * Registers a function to be called after every frame render
  102560. * @param func defines the function to register
  102561. */
  102562. registerAfterRender(func: () => void): void;
  102563. /**
  102564. * Unregisters a function called after every frame render
  102565. * @param func defines the function to unregister
  102566. */
  102567. unregisterAfterRender(func: () => void): void;
  102568. private _executeOnceBeforeRender;
  102569. /**
  102570. * The provided function will run before render once and will be disposed afterwards.
  102571. * A timeout delay can be provided so that the function will be executed in N ms.
  102572. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102573. * @param func The function to be executed.
  102574. * @param timeout optional delay in ms
  102575. */
  102576. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102577. /** @hidden */
  102578. _addPendingData(data: any): void;
  102579. /** @hidden */
  102580. _removePendingData(data: any): void;
  102581. /**
  102582. * Returns the number of items waiting to be loaded
  102583. * @returns the number of items waiting to be loaded
  102584. */
  102585. getWaitingItemsCount(): number;
  102586. /**
  102587. * Returns a boolean indicating if the scene is still loading data
  102588. */
  102589. readonly isLoading: boolean;
  102590. /**
  102591. * Registers a function to be executed when the scene is ready
  102592. * @param {Function} func - the function to be executed
  102593. */
  102594. executeWhenReady(func: () => void): void;
  102595. /**
  102596. * Returns a promise that resolves when the scene is ready
  102597. * @returns A promise that resolves when the scene is ready
  102598. */
  102599. whenReadyAsync(): Promise<void>;
  102600. /** @hidden */
  102601. _checkIsReady(): void;
  102602. /**
  102603. * Gets all animatable attached to the scene
  102604. */
  102605. readonly animatables: Animatable[];
  102606. /**
  102607. * Resets the last animation time frame.
  102608. * Useful to override when animations start running when loading a scene for the first time.
  102609. */
  102610. resetLastAnimationTimeFrame(): void;
  102611. /**
  102612. * Gets the current view matrix
  102613. * @returns a Matrix
  102614. */
  102615. getViewMatrix(): Matrix;
  102616. /**
  102617. * Gets the current projection matrix
  102618. * @returns a Matrix
  102619. */
  102620. getProjectionMatrix(): Matrix;
  102621. /**
  102622. * Gets the current transform matrix
  102623. * @returns a Matrix made of View * Projection
  102624. */
  102625. getTransformMatrix(): Matrix;
  102626. /**
  102627. * Sets the current transform matrix
  102628. * @param viewL defines the View matrix to use
  102629. * @param projectionL defines the Projection matrix to use
  102630. * @param viewR defines the right View matrix to use (if provided)
  102631. * @param projectionR defines the right Projection matrix to use (if provided)
  102632. */
  102633. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102634. /**
  102635. * Gets the uniform buffer used to store scene data
  102636. * @returns a UniformBuffer
  102637. */
  102638. getSceneUniformBuffer(): UniformBuffer;
  102639. /**
  102640. * Gets an unique (relatively to the current scene) Id
  102641. * @returns an unique number for the scene
  102642. */
  102643. getUniqueId(): number;
  102644. /**
  102645. * Add a mesh to the list of scene's meshes
  102646. * @param newMesh defines the mesh to add
  102647. * @param recursive if all child meshes should also be added to the scene
  102648. */
  102649. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102650. /**
  102651. * Remove a mesh for the list of scene's meshes
  102652. * @param toRemove defines the mesh to remove
  102653. * @param recursive if all child meshes should also be removed from the scene
  102654. * @returns the index where the mesh was in the mesh list
  102655. */
  102656. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102657. /**
  102658. * Add a transform node to the list of scene's transform nodes
  102659. * @param newTransformNode defines the transform node to add
  102660. */
  102661. addTransformNode(newTransformNode: TransformNode): void;
  102662. /**
  102663. * Remove a transform node for the list of scene's transform nodes
  102664. * @param toRemove defines the transform node to remove
  102665. * @returns the index where the transform node was in the transform node list
  102666. */
  102667. removeTransformNode(toRemove: TransformNode): number;
  102668. /**
  102669. * Remove a skeleton for the list of scene's skeletons
  102670. * @param toRemove defines the skeleton to remove
  102671. * @returns the index where the skeleton was in the skeleton list
  102672. */
  102673. removeSkeleton(toRemove: Skeleton): number;
  102674. /**
  102675. * Remove a morph target for the list of scene's morph targets
  102676. * @param toRemove defines the morph target to remove
  102677. * @returns the index where the morph target was in the morph target list
  102678. */
  102679. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102680. /**
  102681. * Remove a light for the list of scene's lights
  102682. * @param toRemove defines the light to remove
  102683. * @returns the index where the light was in the light list
  102684. */
  102685. removeLight(toRemove: Light): number;
  102686. /**
  102687. * Remove a camera for the list of scene's cameras
  102688. * @param toRemove defines the camera to remove
  102689. * @returns the index where the camera was in the camera list
  102690. */
  102691. removeCamera(toRemove: Camera): number;
  102692. /**
  102693. * Remove a particle system for the list of scene's particle systems
  102694. * @param toRemove defines the particle system to remove
  102695. * @returns the index where the particle system was in the particle system list
  102696. */
  102697. removeParticleSystem(toRemove: IParticleSystem): number;
  102698. /**
  102699. * Remove a animation for the list of scene's animations
  102700. * @param toRemove defines the animation to remove
  102701. * @returns the index where the animation was in the animation list
  102702. */
  102703. removeAnimation(toRemove: Animation): number;
  102704. /**
  102705. * Will stop the animation of the given target
  102706. * @param target - the target
  102707. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102708. * @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)
  102709. */
  102710. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102711. /**
  102712. * Removes the given animation group from this scene.
  102713. * @param toRemove The animation group to remove
  102714. * @returns The index of the removed animation group
  102715. */
  102716. removeAnimationGroup(toRemove: AnimationGroup): number;
  102717. /**
  102718. * Removes the given multi-material from this scene.
  102719. * @param toRemove The multi-material to remove
  102720. * @returns The index of the removed multi-material
  102721. */
  102722. removeMultiMaterial(toRemove: MultiMaterial): number;
  102723. /**
  102724. * Removes the given material from this scene.
  102725. * @param toRemove The material to remove
  102726. * @returns The index of the removed material
  102727. */
  102728. removeMaterial(toRemove: Material): number;
  102729. /**
  102730. * Removes the given action manager from this scene.
  102731. * @param toRemove The action manager to remove
  102732. * @returns The index of the removed action manager
  102733. */
  102734. removeActionManager(toRemove: AbstractActionManager): number;
  102735. /**
  102736. * Removes the given texture from this scene.
  102737. * @param toRemove The texture to remove
  102738. * @returns The index of the removed texture
  102739. */
  102740. removeTexture(toRemove: BaseTexture): number;
  102741. /**
  102742. * Adds the given light to this scene
  102743. * @param newLight The light to add
  102744. */
  102745. addLight(newLight: Light): void;
  102746. /**
  102747. * Sorts the list list based on light priorities
  102748. */
  102749. sortLightsByPriority(): void;
  102750. /**
  102751. * Adds the given camera to this scene
  102752. * @param newCamera The camera to add
  102753. */
  102754. addCamera(newCamera: Camera): void;
  102755. /**
  102756. * Adds the given skeleton to this scene
  102757. * @param newSkeleton The skeleton to add
  102758. */
  102759. addSkeleton(newSkeleton: Skeleton): void;
  102760. /**
  102761. * Adds the given particle system to this scene
  102762. * @param newParticleSystem The particle system to add
  102763. */
  102764. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102765. /**
  102766. * Adds the given animation to this scene
  102767. * @param newAnimation The animation to add
  102768. */
  102769. addAnimation(newAnimation: Animation): void;
  102770. /**
  102771. * Adds the given animation group to this scene.
  102772. * @param newAnimationGroup The animation group to add
  102773. */
  102774. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102775. /**
  102776. * Adds the given multi-material to this scene
  102777. * @param newMultiMaterial The multi-material to add
  102778. */
  102779. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102780. /**
  102781. * Adds the given material to this scene
  102782. * @param newMaterial The material to add
  102783. */
  102784. addMaterial(newMaterial: Material): void;
  102785. /**
  102786. * Adds the given morph target to this scene
  102787. * @param newMorphTargetManager The morph target to add
  102788. */
  102789. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102790. /**
  102791. * Adds the given geometry to this scene
  102792. * @param newGeometry The geometry to add
  102793. */
  102794. addGeometry(newGeometry: Geometry): void;
  102795. /**
  102796. * Adds the given action manager to this scene
  102797. * @param newActionManager The action manager to add
  102798. */
  102799. addActionManager(newActionManager: AbstractActionManager): void;
  102800. /**
  102801. * Adds the given texture to this scene.
  102802. * @param newTexture The texture to add
  102803. */
  102804. addTexture(newTexture: BaseTexture): void;
  102805. /**
  102806. * Switch active camera
  102807. * @param newCamera defines the new active camera
  102808. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102809. */
  102810. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102811. /**
  102812. * sets the active camera of the scene using its ID
  102813. * @param id defines the camera's ID
  102814. * @return the new active camera or null if none found.
  102815. */
  102816. setActiveCameraByID(id: string): Nullable<Camera>;
  102817. /**
  102818. * sets the active camera of the scene using its name
  102819. * @param name defines the camera's name
  102820. * @returns the new active camera or null if none found.
  102821. */
  102822. setActiveCameraByName(name: string): Nullable<Camera>;
  102823. /**
  102824. * get an animation group using its name
  102825. * @param name defines the material's name
  102826. * @return the animation group or null if none found.
  102827. */
  102828. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102829. /**
  102830. * Get a material using its unique id
  102831. * @param uniqueId defines the material's unique id
  102832. * @return the material or null if none found.
  102833. */
  102834. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102835. /**
  102836. * get a material using its id
  102837. * @param id defines the material's ID
  102838. * @return the material or null if none found.
  102839. */
  102840. getMaterialByID(id: string): Nullable<Material>;
  102841. /**
  102842. * Gets a the last added material using a given id
  102843. * @param id defines the material's ID
  102844. * @return the last material with the given id or null if none found.
  102845. */
  102846. getLastMaterialByID(id: string): Nullable<Material>;
  102847. /**
  102848. * Gets a material using its name
  102849. * @param name defines the material's name
  102850. * @return the material or null if none found.
  102851. */
  102852. getMaterialByName(name: string): Nullable<Material>;
  102853. /**
  102854. * Get a texture using its unique id
  102855. * @param uniqueId defines the texture's unique id
  102856. * @return the texture or null if none found.
  102857. */
  102858. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102859. /**
  102860. * Gets a camera using its id
  102861. * @param id defines the id to look for
  102862. * @returns the camera or null if not found
  102863. */
  102864. getCameraByID(id: string): Nullable<Camera>;
  102865. /**
  102866. * Gets a camera using its unique id
  102867. * @param uniqueId defines the unique id to look for
  102868. * @returns the camera or null if not found
  102869. */
  102870. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102871. /**
  102872. * Gets a camera using its name
  102873. * @param name defines the camera's name
  102874. * @return the camera or null if none found.
  102875. */
  102876. getCameraByName(name: string): Nullable<Camera>;
  102877. /**
  102878. * Gets a bone using its id
  102879. * @param id defines the bone's id
  102880. * @return the bone or null if not found
  102881. */
  102882. getBoneByID(id: string): Nullable<Bone>;
  102883. /**
  102884. * Gets a bone using its id
  102885. * @param name defines the bone's name
  102886. * @return the bone or null if not found
  102887. */
  102888. getBoneByName(name: string): Nullable<Bone>;
  102889. /**
  102890. * Gets a light node using its name
  102891. * @param name defines the the light's name
  102892. * @return the light or null if none found.
  102893. */
  102894. getLightByName(name: string): Nullable<Light>;
  102895. /**
  102896. * Gets a light node using its id
  102897. * @param id defines the light's id
  102898. * @return the light or null if none found.
  102899. */
  102900. getLightByID(id: string): Nullable<Light>;
  102901. /**
  102902. * Gets a light node using its scene-generated unique ID
  102903. * @param uniqueId defines the light's unique id
  102904. * @return the light or null if none found.
  102905. */
  102906. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102907. /**
  102908. * Gets a particle system by id
  102909. * @param id defines the particle system id
  102910. * @return the corresponding system or null if none found
  102911. */
  102912. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102913. /**
  102914. * Gets a geometry using its ID
  102915. * @param id defines the geometry's id
  102916. * @return the geometry or null if none found.
  102917. */
  102918. getGeometryByID(id: string): Nullable<Geometry>;
  102919. private _getGeometryByUniqueID;
  102920. /**
  102921. * Add a new geometry to this scene
  102922. * @param geometry defines the geometry to be added to the scene.
  102923. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102924. * @return a boolean defining if the geometry was added or not
  102925. */
  102926. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102927. /**
  102928. * Removes an existing geometry
  102929. * @param geometry defines the geometry to be removed from the scene
  102930. * @return a boolean defining if the geometry was removed or not
  102931. */
  102932. removeGeometry(geometry: Geometry): boolean;
  102933. /**
  102934. * Gets the list of geometries attached to the scene
  102935. * @returns an array of Geometry
  102936. */
  102937. getGeometries(): Geometry[];
  102938. /**
  102939. * Gets the first added mesh found of a given ID
  102940. * @param id defines the id to search for
  102941. * @return the mesh found or null if not found at all
  102942. */
  102943. getMeshByID(id: string): Nullable<AbstractMesh>;
  102944. /**
  102945. * Gets a list of meshes using their id
  102946. * @param id defines the id to search for
  102947. * @returns a list of meshes
  102948. */
  102949. getMeshesByID(id: string): Array<AbstractMesh>;
  102950. /**
  102951. * Gets the first added transform node found of a given ID
  102952. * @param id defines the id to search for
  102953. * @return the found transform node or null if not found at all.
  102954. */
  102955. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102956. /**
  102957. * Gets a transform node with its auto-generated unique id
  102958. * @param uniqueId efines the unique id to search for
  102959. * @return the found transform node or null if not found at all.
  102960. */
  102961. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102962. /**
  102963. * Gets a list of transform nodes using their id
  102964. * @param id defines the id to search for
  102965. * @returns a list of transform nodes
  102966. */
  102967. getTransformNodesByID(id: string): Array<TransformNode>;
  102968. /**
  102969. * Gets a mesh with its auto-generated unique id
  102970. * @param uniqueId defines the unique id to search for
  102971. * @return the found mesh or null if not found at all.
  102972. */
  102973. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102974. /**
  102975. * Gets a the last added mesh using a given id
  102976. * @param id defines the id to search for
  102977. * @return the found mesh or null if not found at all.
  102978. */
  102979. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102980. /**
  102981. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102982. * @param id defines the id to search for
  102983. * @return the found node or null if not found at all
  102984. */
  102985. getLastEntryByID(id: string): Nullable<Node>;
  102986. /**
  102987. * Gets a node (Mesh, Camera, Light) using a given id
  102988. * @param id defines the id to search for
  102989. * @return the found node or null if not found at all
  102990. */
  102991. getNodeByID(id: string): Nullable<Node>;
  102992. /**
  102993. * Gets a node (Mesh, Camera, Light) using a given name
  102994. * @param name defines the name to search for
  102995. * @return the found node or null if not found at all.
  102996. */
  102997. getNodeByName(name: string): Nullable<Node>;
  102998. /**
  102999. * Gets a mesh using a given name
  103000. * @param name defines the name to search for
  103001. * @return the found mesh or null if not found at all.
  103002. */
  103003. getMeshByName(name: string): Nullable<AbstractMesh>;
  103004. /**
  103005. * Gets a transform node using a given name
  103006. * @param name defines the name to search for
  103007. * @return the found transform node or null if not found at all.
  103008. */
  103009. getTransformNodeByName(name: string): Nullable<TransformNode>;
  103010. /**
  103011. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  103012. * @param id defines the id to search for
  103013. * @return the found skeleton or null if not found at all.
  103014. */
  103015. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  103016. /**
  103017. * Gets a skeleton using a given auto generated unique id
  103018. * @param uniqueId defines the unique id to search for
  103019. * @return the found skeleton or null if not found at all.
  103020. */
  103021. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103022. /**
  103023. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103024. * @param id defines the id to search for
  103025. * @return the found skeleton or null if not found at all.
  103026. */
  103027. getSkeletonById(id: string): Nullable<Skeleton>;
  103028. /**
  103029. * Gets a skeleton using a given name
  103030. * @param name defines the name to search for
  103031. * @return the found skeleton or null if not found at all.
  103032. */
  103033. getSkeletonByName(name: string): Nullable<Skeleton>;
  103034. /**
  103035. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103036. * @param id defines the id to search for
  103037. * @return the found morph target manager or null if not found at all.
  103038. */
  103039. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103040. /**
  103041. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103042. * @param id defines the id to search for
  103043. * @return the found morph target or null if not found at all.
  103044. */
  103045. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103046. /**
  103047. * Gets a boolean indicating if the given mesh is active
  103048. * @param mesh defines the mesh to look for
  103049. * @returns true if the mesh is in the active list
  103050. */
  103051. isActiveMesh(mesh: AbstractMesh): boolean;
  103052. /**
  103053. * Return a unique id as a string which can serve as an identifier for the scene
  103054. */
  103055. readonly uid: string;
  103056. /**
  103057. * Add an externaly attached data from its key.
  103058. * This method call will fail and return false, if such key already exists.
  103059. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103060. * @param key the unique key that identifies the data
  103061. * @param data the data object to associate to the key for this Engine instance
  103062. * @return true if no such key were already present and the data was added successfully, false otherwise
  103063. */
  103064. addExternalData<T>(key: string, data: T): boolean;
  103065. /**
  103066. * Get an externaly attached data from its key
  103067. * @param key the unique key that identifies the data
  103068. * @return the associated data, if present (can be null), or undefined if not present
  103069. */
  103070. getExternalData<T>(key: string): Nullable<T>;
  103071. /**
  103072. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103073. * @param key the unique key that identifies the data
  103074. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103075. * @return the associated data, can be null if the factory returned null.
  103076. */
  103077. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103078. /**
  103079. * Remove an externaly attached data from the Engine instance
  103080. * @param key the unique key that identifies the data
  103081. * @return true if the data was successfully removed, false if it doesn't exist
  103082. */
  103083. removeExternalData(key: string): boolean;
  103084. private _evaluateSubMesh;
  103085. /**
  103086. * Clear the processed materials smart array preventing retention point in material dispose.
  103087. */
  103088. freeProcessedMaterials(): void;
  103089. private _preventFreeActiveMeshesAndRenderingGroups;
  103090. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103091. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103092. * when disposing several meshes in a row or a hierarchy of meshes.
  103093. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103094. */
  103095. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103096. /**
  103097. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103098. */
  103099. freeActiveMeshes(): void;
  103100. /**
  103101. * Clear the info related to rendering groups preventing retention points during dispose.
  103102. */
  103103. freeRenderingGroups(): void;
  103104. /** @hidden */
  103105. _isInIntermediateRendering(): boolean;
  103106. /**
  103107. * Lambda returning the list of potentially active meshes.
  103108. */
  103109. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103110. /**
  103111. * Lambda returning the list of potentially active sub meshes.
  103112. */
  103113. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103114. /**
  103115. * Lambda returning the list of potentially intersecting sub meshes.
  103116. */
  103117. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103118. /**
  103119. * Lambda returning the list of potentially colliding sub meshes.
  103120. */
  103121. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103122. private _activeMeshesFrozen;
  103123. private _skipEvaluateActiveMeshesCompletely;
  103124. /**
  103125. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103126. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103127. * @returns the current scene
  103128. */
  103129. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103130. /**
  103131. * Use this function to restart evaluating active meshes on every frame
  103132. * @returns the current scene
  103133. */
  103134. unfreezeActiveMeshes(): Scene;
  103135. private _evaluateActiveMeshes;
  103136. private _activeMesh;
  103137. /**
  103138. * Update the transform matrix to update from the current active camera
  103139. * @param force defines a boolean used to force the update even if cache is up to date
  103140. */
  103141. updateTransformMatrix(force?: boolean): void;
  103142. private _bindFrameBuffer;
  103143. /** @hidden */
  103144. _allowPostProcessClearColor: boolean;
  103145. /** @hidden */
  103146. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103147. private _processSubCameras;
  103148. private _checkIntersections;
  103149. /** @hidden */
  103150. _advancePhysicsEngineStep(step: number): void;
  103151. /**
  103152. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103153. */
  103154. getDeterministicFrameTime: () => number;
  103155. /** @hidden */
  103156. _animate(): void;
  103157. /** Execute all animations (for a frame) */
  103158. animate(): void;
  103159. /**
  103160. * Render the scene
  103161. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103162. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103163. */
  103164. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103165. /**
  103166. * Freeze all materials
  103167. * A frozen material will not be updatable but should be faster to render
  103168. */
  103169. freezeMaterials(): void;
  103170. /**
  103171. * Unfreeze all materials
  103172. * A frozen material will not be updatable but should be faster to render
  103173. */
  103174. unfreezeMaterials(): void;
  103175. /**
  103176. * Releases all held ressources
  103177. */
  103178. dispose(): void;
  103179. /**
  103180. * Gets if the scene is already disposed
  103181. */
  103182. readonly isDisposed: boolean;
  103183. /**
  103184. * Call this function to reduce memory footprint of the scene.
  103185. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103186. */
  103187. clearCachedVertexData(): void;
  103188. /**
  103189. * This function will remove the local cached buffer data from texture.
  103190. * It will save memory but will prevent the texture from being rebuilt
  103191. */
  103192. cleanCachedTextureBuffer(): void;
  103193. /**
  103194. * Get the world extend vectors with an optional filter
  103195. *
  103196. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103197. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103198. */
  103199. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103200. min: Vector3;
  103201. max: Vector3;
  103202. };
  103203. /**
  103204. * Creates a ray that can be used to pick in the scene
  103205. * @param x defines the x coordinate of the origin (on-screen)
  103206. * @param y defines the y coordinate of the origin (on-screen)
  103207. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103208. * @param camera defines the camera to use for the picking
  103209. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103210. * @returns a Ray
  103211. */
  103212. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103213. /**
  103214. * Creates a ray that can be used to pick in the scene
  103215. * @param x defines the x coordinate of the origin (on-screen)
  103216. * @param y defines the y coordinate of the origin (on-screen)
  103217. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103218. * @param result defines the ray where to store the picking ray
  103219. * @param camera defines the camera to use for the picking
  103220. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103221. * @returns the current scene
  103222. */
  103223. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103224. /**
  103225. * Creates a ray that can be used to pick in the scene
  103226. * @param x defines the x coordinate of the origin (on-screen)
  103227. * @param y defines the y coordinate of the origin (on-screen)
  103228. * @param camera defines the camera to use for the picking
  103229. * @returns a Ray
  103230. */
  103231. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103232. /**
  103233. * Creates a ray that can be used to pick in the scene
  103234. * @param x defines the x coordinate of the origin (on-screen)
  103235. * @param y defines the y coordinate of the origin (on-screen)
  103236. * @param result defines the ray where to store the picking ray
  103237. * @param camera defines the camera to use for the picking
  103238. * @returns the current scene
  103239. */
  103240. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103241. /** Launch a ray to try to pick a mesh in the scene
  103242. * @param x position on screen
  103243. * @param y position on screen
  103244. * @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
  103245. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103246. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103248. * @returns a PickingInfo
  103249. */
  103250. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103251. /** Use the given ray to pick a mesh in the scene
  103252. * @param ray The ray to use to pick meshes
  103253. * @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
  103254. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103255. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103256. * @returns a PickingInfo
  103257. */
  103258. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103259. /**
  103260. * Launch a ray to try to pick a mesh in the scene
  103261. * @param x X position on screen
  103262. * @param y Y position on screen
  103263. * @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
  103264. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103266. * @returns an array of PickingInfo
  103267. */
  103268. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103269. /**
  103270. * Launch a ray to try to pick a mesh in the scene
  103271. * @param ray Ray to use
  103272. * @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
  103273. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103274. * @returns an array of PickingInfo
  103275. */
  103276. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103277. /**
  103278. * Force the value of meshUnderPointer
  103279. * @param mesh defines the mesh to use
  103280. */
  103281. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103282. /**
  103283. * Gets the mesh under the pointer
  103284. * @returns a Mesh or null if no mesh is under the pointer
  103285. */
  103286. getPointerOverMesh(): Nullable<AbstractMesh>;
  103287. /** @hidden */
  103288. _rebuildGeometries(): void;
  103289. /** @hidden */
  103290. _rebuildTextures(): void;
  103291. private _getByTags;
  103292. /**
  103293. * Get a list of meshes by tags
  103294. * @param tagsQuery defines the tags query to use
  103295. * @param forEach defines a predicate used to filter results
  103296. * @returns an array of Mesh
  103297. */
  103298. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103299. /**
  103300. * Get a list of cameras by tags
  103301. * @param tagsQuery defines the tags query to use
  103302. * @param forEach defines a predicate used to filter results
  103303. * @returns an array of Camera
  103304. */
  103305. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103306. /**
  103307. * Get a list of lights by tags
  103308. * @param tagsQuery defines the tags query to use
  103309. * @param forEach defines a predicate used to filter results
  103310. * @returns an array of Light
  103311. */
  103312. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103313. /**
  103314. * Get a list of materials by tags
  103315. * @param tagsQuery defines the tags query to use
  103316. * @param forEach defines a predicate used to filter results
  103317. * @returns an array of Material
  103318. */
  103319. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103320. /**
  103321. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103322. * This allowed control for front to back rendering or reversly depending of the special needs.
  103323. *
  103324. * @param renderingGroupId The rendering group id corresponding to its index
  103325. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103326. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103327. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103328. */
  103329. 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;
  103330. /**
  103331. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103332. *
  103333. * @param renderingGroupId The rendering group id corresponding to its index
  103334. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103335. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103336. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103337. */
  103338. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103339. /**
  103340. * Gets the current auto clear configuration for one rendering group of the rendering
  103341. * manager.
  103342. * @param index the rendering group index to get the information for
  103343. * @returns The auto clear setup for the requested rendering group
  103344. */
  103345. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103346. private _blockMaterialDirtyMechanism;
  103347. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103348. blockMaterialDirtyMechanism: boolean;
  103349. /**
  103350. * Will flag all materials as dirty to trigger new shader compilation
  103351. * @param flag defines the flag used to specify which material part must be marked as dirty
  103352. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103353. */
  103354. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103355. /** @hidden */
  103356. _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;
  103357. /** @hidden */
  103358. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103359. /** @hidden */
  103360. _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;
  103361. /** @hidden */
  103362. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103363. /** @hidden */
  103364. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103365. /** @hidden */
  103366. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * Set of assets to keep when moving a scene into an asset container.
  103372. */
  103373. export class KeepAssets extends AbstractScene {
  103374. }
  103375. /**
  103376. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103377. */
  103378. export class InstantiatedEntries {
  103379. /**
  103380. * List of new root nodes (eg. nodes with no parent)
  103381. */
  103382. rootNodes: TransformNode[];
  103383. /**
  103384. * List of new skeletons
  103385. */
  103386. skeletons: Skeleton[];
  103387. /**
  103388. * List of new animation groups
  103389. */
  103390. animationGroups: AnimationGroup[];
  103391. }
  103392. /**
  103393. * Container with a set of assets that can be added or removed from a scene.
  103394. */
  103395. export class AssetContainer extends AbstractScene {
  103396. /**
  103397. * The scene the AssetContainer belongs to.
  103398. */
  103399. scene: Scene;
  103400. /**
  103401. * Instantiates an AssetContainer.
  103402. * @param scene The scene the AssetContainer belongs to.
  103403. */
  103404. constructor(scene: Scene);
  103405. /**
  103406. * Instantiate or clone all meshes and add the new ones to the scene.
  103407. * Skeletons and animation groups will all be cloned
  103408. * @param nameFunction defines an optional function used to get new names for clones
  103409. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103410. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103411. */
  103412. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103413. /**
  103414. * Adds all the assets from the container to the scene.
  103415. */
  103416. addAllToScene(): void;
  103417. /**
  103418. * Removes all the assets in the container from the scene
  103419. */
  103420. removeAllFromScene(): void;
  103421. /**
  103422. * Disposes all the assets in the container
  103423. */
  103424. dispose(): void;
  103425. private _moveAssets;
  103426. /**
  103427. * Removes all the assets contained in the scene and adds them to the container.
  103428. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103429. */
  103430. moveAllFromScene(keepAssets?: KeepAssets): void;
  103431. /**
  103432. * 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.
  103433. * @returns the root mesh
  103434. */
  103435. createRootMesh(): Mesh;
  103436. }
  103437. }
  103438. declare module BABYLON {
  103439. /**
  103440. * Defines how the parser contract is defined.
  103441. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103442. */
  103443. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103444. /**
  103445. * Defines how the individual parser contract is defined.
  103446. * These parser can parse an individual asset
  103447. */
  103448. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103449. /**
  103450. * Base class of the scene acting as a container for the different elements composing a scene.
  103451. * This class is dynamically extended by the different components of the scene increasing
  103452. * flexibility and reducing coupling
  103453. */
  103454. export abstract class AbstractScene {
  103455. /**
  103456. * Stores the list of available parsers in the application.
  103457. */
  103458. private static _BabylonFileParsers;
  103459. /**
  103460. * Stores the list of available individual parsers in the application.
  103461. */
  103462. private static _IndividualBabylonFileParsers;
  103463. /**
  103464. * Adds a parser in the list of available ones
  103465. * @param name Defines the name of the parser
  103466. * @param parser Defines the parser to add
  103467. */
  103468. static AddParser(name: string, parser: BabylonFileParser): void;
  103469. /**
  103470. * Gets a general parser from the list of avaialble ones
  103471. * @param name Defines the name of the parser
  103472. * @returns the requested parser or null
  103473. */
  103474. static GetParser(name: string): Nullable<BabylonFileParser>;
  103475. /**
  103476. * Adds n individual parser in the list of available ones
  103477. * @param name Defines the name of the parser
  103478. * @param parser Defines the parser to add
  103479. */
  103480. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103481. /**
  103482. * Gets an individual parser from the list of avaialble ones
  103483. * @param name Defines the name of the parser
  103484. * @returns the requested parser or null
  103485. */
  103486. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103487. /**
  103488. * Parser json data and populate both a scene and its associated container object
  103489. * @param jsonData Defines the data to parse
  103490. * @param scene Defines the scene to parse the data for
  103491. * @param container Defines the container attached to the parsing sequence
  103492. * @param rootUrl Defines the root url of the data
  103493. */
  103494. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103495. /**
  103496. * Gets the list of root nodes (ie. nodes with no parent)
  103497. */
  103498. rootNodes: Node[];
  103499. /** All of the cameras added to this scene
  103500. * @see http://doc.babylonjs.com/babylon101/cameras
  103501. */
  103502. cameras: Camera[];
  103503. /**
  103504. * All of the lights added to this scene
  103505. * @see http://doc.babylonjs.com/babylon101/lights
  103506. */
  103507. lights: Light[];
  103508. /**
  103509. * All of the (abstract) meshes added to this scene
  103510. */
  103511. meshes: AbstractMesh[];
  103512. /**
  103513. * The list of skeletons added to the scene
  103514. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103515. */
  103516. skeletons: Skeleton[];
  103517. /**
  103518. * All of the particle systems added to this scene
  103519. * @see http://doc.babylonjs.com/babylon101/particles
  103520. */
  103521. particleSystems: IParticleSystem[];
  103522. /**
  103523. * Gets a list of Animations associated with the scene
  103524. */
  103525. animations: Animation[];
  103526. /**
  103527. * All of the animation groups added to this scene
  103528. * @see http://doc.babylonjs.com/how_to/group
  103529. */
  103530. animationGroups: AnimationGroup[];
  103531. /**
  103532. * All of the multi-materials added to this scene
  103533. * @see http://doc.babylonjs.com/how_to/multi_materials
  103534. */
  103535. multiMaterials: MultiMaterial[];
  103536. /**
  103537. * All of the materials added to this scene
  103538. * In the context of a Scene, it is not supposed to be modified manually.
  103539. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103540. * Note also that the order of the Material within the array is not significant and might change.
  103541. * @see http://doc.babylonjs.com/babylon101/materials
  103542. */
  103543. materials: Material[];
  103544. /**
  103545. * The list of morph target managers added to the scene
  103546. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103547. */
  103548. morphTargetManagers: MorphTargetManager[];
  103549. /**
  103550. * The list of geometries used in the scene.
  103551. */
  103552. geometries: Geometry[];
  103553. /**
  103554. * All of the tranform nodes added to this scene
  103555. * In the context of a Scene, it is not supposed to be modified manually.
  103556. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103557. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103558. * @see http://doc.babylonjs.com/how_to/transformnode
  103559. */
  103560. transformNodes: TransformNode[];
  103561. /**
  103562. * ActionManagers available on the scene.
  103563. */
  103564. actionManagers: AbstractActionManager[];
  103565. /**
  103566. * Textures to keep.
  103567. */
  103568. textures: BaseTexture[];
  103569. /**
  103570. * Environment texture for the scene
  103571. */
  103572. environmentTexture: Nullable<BaseTexture>;
  103573. }
  103574. }
  103575. declare module BABYLON {
  103576. /**
  103577. * Interface used to define options for Sound class
  103578. */
  103579. export interface ISoundOptions {
  103580. /**
  103581. * Does the sound autoplay once loaded.
  103582. */
  103583. autoplay?: boolean;
  103584. /**
  103585. * Does the sound loop after it finishes playing once.
  103586. */
  103587. loop?: boolean;
  103588. /**
  103589. * Sound's volume
  103590. */
  103591. volume?: number;
  103592. /**
  103593. * Is it a spatial sound?
  103594. */
  103595. spatialSound?: boolean;
  103596. /**
  103597. * Maximum distance to hear that sound
  103598. */
  103599. maxDistance?: number;
  103600. /**
  103601. * Uses user defined attenuation function
  103602. */
  103603. useCustomAttenuation?: boolean;
  103604. /**
  103605. * Define the roll off factor of spatial sounds.
  103606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103607. */
  103608. rolloffFactor?: number;
  103609. /**
  103610. * Define the reference distance the sound should be heard perfectly.
  103611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103612. */
  103613. refDistance?: number;
  103614. /**
  103615. * Define the distance attenuation model the sound will follow.
  103616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103617. */
  103618. distanceModel?: string;
  103619. /**
  103620. * Defines the playback speed (1 by default)
  103621. */
  103622. playbackRate?: number;
  103623. /**
  103624. * Defines if the sound is from a streaming source
  103625. */
  103626. streaming?: boolean;
  103627. /**
  103628. * Defines an optional length (in seconds) inside the sound file
  103629. */
  103630. length?: number;
  103631. /**
  103632. * Defines an optional offset (in seconds) inside the sound file
  103633. */
  103634. offset?: number;
  103635. /**
  103636. * If true, URLs will not be required to state the audio file codec to use.
  103637. */
  103638. skipCodecCheck?: boolean;
  103639. }
  103640. /**
  103641. * Defines a sound that can be played in the application.
  103642. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103644. */
  103645. export class Sound {
  103646. /**
  103647. * The name of the sound in the scene.
  103648. */
  103649. name: string;
  103650. /**
  103651. * Does the sound autoplay once loaded.
  103652. */
  103653. autoplay: boolean;
  103654. /**
  103655. * Does the sound loop after it finishes playing once.
  103656. */
  103657. loop: boolean;
  103658. /**
  103659. * Does the sound use a custom attenuation curve to simulate the falloff
  103660. * happening when the source gets further away from the camera.
  103661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103662. */
  103663. useCustomAttenuation: boolean;
  103664. /**
  103665. * The sound track id this sound belongs to.
  103666. */
  103667. soundTrackId: number;
  103668. /**
  103669. * Is this sound currently played.
  103670. */
  103671. isPlaying: boolean;
  103672. /**
  103673. * Is this sound currently paused.
  103674. */
  103675. isPaused: boolean;
  103676. /**
  103677. * Does this sound enables spatial sound.
  103678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103679. */
  103680. spatialSound: boolean;
  103681. /**
  103682. * Define the reference distance the sound should be heard perfectly.
  103683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103684. */
  103685. refDistance: number;
  103686. /**
  103687. * Define the roll off factor of spatial sounds.
  103688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103689. */
  103690. rolloffFactor: number;
  103691. /**
  103692. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103694. */
  103695. maxDistance: number;
  103696. /**
  103697. * Define the distance attenuation model the sound will follow.
  103698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103699. */
  103700. distanceModel: string;
  103701. /**
  103702. * @hidden
  103703. * Back Compat
  103704. **/
  103705. onended: () => any;
  103706. /**
  103707. * Observable event when the current playing sound finishes.
  103708. */
  103709. onEndedObservable: Observable<Sound>;
  103710. private _panningModel;
  103711. private _playbackRate;
  103712. private _streaming;
  103713. private _startTime;
  103714. private _startOffset;
  103715. private _position;
  103716. /** @hidden */
  103717. _positionInEmitterSpace: boolean;
  103718. private _localDirection;
  103719. private _volume;
  103720. private _isReadyToPlay;
  103721. private _isDirectional;
  103722. private _readyToPlayCallback;
  103723. private _audioBuffer;
  103724. private _soundSource;
  103725. private _streamingSource;
  103726. private _soundPanner;
  103727. private _soundGain;
  103728. private _inputAudioNode;
  103729. private _outputAudioNode;
  103730. private _coneInnerAngle;
  103731. private _coneOuterAngle;
  103732. private _coneOuterGain;
  103733. private _scene;
  103734. private _connectedTransformNode;
  103735. private _customAttenuationFunction;
  103736. private _registerFunc;
  103737. private _isOutputConnected;
  103738. private _htmlAudioElement;
  103739. private _urlType;
  103740. private _length?;
  103741. private _offset?;
  103742. /** @hidden */
  103743. static _SceneComponentInitialization: (scene: Scene) => void;
  103744. /**
  103745. * Create a sound and attach it to a scene
  103746. * @param name Name of your sound
  103747. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103748. * @param scene defines the scene the sound belongs to
  103749. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103750. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103751. */
  103752. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103753. /**
  103754. * Release the sound and its associated resources
  103755. */
  103756. dispose(): void;
  103757. /**
  103758. * Gets if the sounds is ready to be played or not.
  103759. * @returns true if ready, otherwise false
  103760. */
  103761. isReady(): boolean;
  103762. private _soundLoaded;
  103763. /**
  103764. * Sets the data of the sound from an audiobuffer
  103765. * @param audioBuffer The audioBuffer containing the data
  103766. */
  103767. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103768. /**
  103769. * Updates the current sounds options such as maxdistance, loop...
  103770. * @param options A JSON object containing values named as the object properties
  103771. */
  103772. updateOptions(options: ISoundOptions): void;
  103773. private _createSpatialParameters;
  103774. private _updateSpatialParameters;
  103775. /**
  103776. * Switch the panning model to HRTF:
  103777. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103779. */
  103780. switchPanningModelToHRTF(): void;
  103781. /**
  103782. * Switch the panning model to Equal Power:
  103783. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103785. */
  103786. switchPanningModelToEqualPower(): void;
  103787. private _switchPanningModel;
  103788. /**
  103789. * Connect this sound to a sound track audio node like gain...
  103790. * @param soundTrackAudioNode the sound track audio node to connect to
  103791. */
  103792. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103793. /**
  103794. * Transform this sound into a directional source
  103795. * @param coneInnerAngle Size of the inner cone in degree
  103796. * @param coneOuterAngle Size of the outer cone in degree
  103797. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103798. */
  103799. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103800. /**
  103801. * Gets or sets the inner angle for the directional cone.
  103802. */
  103803. /**
  103804. * Gets or sets the inner angle for the directional cone.
  103805. */
  103806. directionalConeInnerAngle: number;
  103807. /**
  103808. * Gets or sets the outer angle for the directional cone.
  103809. */
  103810. /**
  103811. * Gets or sets the outer angle for the directional cone.
  103812. */
  103813. directionalConeOuterAngle: number;
  103814. /**
  103815. * Sets the position of the emitter if spatial sound is enabled
  103816. * @param newPosition Defines the new posisiton
  103817. */
  103818. setPosition(newPosition: Vector3): void;
  103819. /**
  103820. * Sets the local direction of the emitter if spatial sound is enabled
  103821. * @param newLocalDirection Defines the new local direction
  103822. */
  103823. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103824. private _updateDirection;
  103825. /** @hidden */
  103826. updateDistanceFromListener(): void;
  103827. /**
  103828. * Sets a new custom attenuation function for the sound.
  103829. * @param callback Defines the function used for the attenuation
  103830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103831. */
  103832. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103833. /**
  103834. * Play the sound
  103835. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103836. * @param offset (optional) Start the sound at a specific time in seconds
  103837. * @param length (optional) Sound duration (in seconds)
  103838. */
  103839. play(time?: number, offset?: number, length?: number): void;
  103840. private _onended;
  103841. /**
  103842. * Stop the sound
  103843. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103844. */
  103845. stop(time?: number): void;
  103846. /**
  103847. * Put the sound in pause
  103848. */
  103849. pause(): void;
  103850. /**
  103851. * Sets a dedicated volume for this sounds
  103852. * @param newVolume Define the new volume of the sound
  103853. * @param time Define time for gradual change to new volume
  103854. */
  103855. setVolume(newVolume: number, time?: number): void;
  103856. /**
  103857. * Set the sound play back rate
  103858. * @param newPlaybackRate Define the playback rate the sound should be played at
  103859. */
  103860. setPlaybackRate(newPlaybackRate: number): void;
  103861. /**
  103862. * Gets the volume of the sound.
  103863. * @returns the volume of the sound
  103864. */
  103865. getVolume(): number;
  103866. /**
  103867. * Attach the sound to a dedicated mesh
  103868. * @param transformNode The transform node to connect the sound with
  103869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103870. */
  103871. attachToMesh(transformNode: TransformNode): void;
  103872. /**
  103873. * Detach the sound from the previously attached mesh
  103874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103875. */
  103876. detachFromMesh(): void;
  103877. private _onRegisterAfterWorldMatrixUpdate;
  103878. /**
  103879. * Clone the current sound in the scene.
  103880. * @returns the new sound clone
  103881. */
  103882. clone(): Nullable<Sound>;
  103883. /**
  103884. * Gets the current underlying audio buffer containing the data
  103885. * @returns the audio buffer
  103886. */
  103887. getAudioBuffer(): Nullable<AudioBuffer>;
  103888. /**
  103889. * Serializes the Sound in a JSON representation
  103890. * @returns the JSON representation of the sound
  103891. */
  103892. serialize(): any;
  103893. /**
  103894. * Parse a JSON representation of a sound to innstantiate in a given scene
  103895. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103896. * @param scene Define the scene the new parsed sound should be created in
  103897. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103898. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103899. * @returns the newly parsed sound
  103900. */
  103901. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103902. }
  103903. }
  103904. declare module BABYLON {
  103905. /**
  103906. * This defines an action helpful to play a defined sound on a triggered action.
  103907. */
  103908. export class PlaySoundAction extends Action {
  103909. private _sound;
  103910. /**
  103911. * Instantiate the action
  103912. * @param triggerOptions defines the trigger options
  103913. * @param sound defines the sound to play
  103914. * @param condition defines the trigger related conditions
  103915. */
  103916. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103917. /** @hidden */
  103918. _prepare(): void;
  103919. /**
  103920. * Execute the action and play the sound.
  103921. */
  103922. execute(): void;
  103923. /**
  103924. * Serializes the actions and its related information.
  103925. * @param parent defines the object to serialize in
  103926. * @returns the serialized object
  103927. */
  103928. serialize(parent: any): any;
  103929. }
  103930. /**
  103931. * This defines an action helpful to stop a defined sound on a triggered action.
  103932. */
  103933. export class StopSoundAction extends Action {
  103934. private _sound;
  103935. /**
  103936. * Instantiate the action
  103937. * @param triggerOptions defines the trigger options
  103938. * @param sound defines the sound to stop
  103939. * @param condition defines the trigger related conditions
  103940. */
  103941. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103942. /** @hidden */
  103943. _prepare(): void;
  103944. /**
  103945. * Execute the action and stop the sound.
  103946. */
  103947. execute(): void;
  103948. /**
  103949. * Serializes the actions and its related information.
  103950. * @param parent defines the object to serialize in
  103951. * @returns the serialized object
  103952. */
  103953. serialize(parent: any): any;
  103954. }
  103955. }
  103956. declare module BABYLON {
  103957. /**
  103958. * This defines an action responsible to change the value of a property
  103959. * by interpolating between its current value and the newly set one once triggered.
  103960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103961. */
  103962. export class InterpolateValueAction extends Action {
  103963. /**
  103964. * Defines the path of the property where the value should be interpolated
  103965. */
  103966. propertyPath: string;
  103967. /**
  103968. * Defines the target value at the end of the interpolation.
  103969. */
  103970. value: any;
  103971. /**
  103972. * Defines the time it will take for the property to interpolate to the value.
  103973. */
  103974. duration: number;
  103975. /**
  103976. * Defines if the other scene animations should be stopped when the action has been triggered
  103977. */
  103978. stopOtherAnimations?: boolean;
  103979. /**
  103980. * Defines a callback raised once the interpolation animation has been done.
  103981. */
  103982. onInterpolationDone?: () => void;
  103983. /**
  103984. * Observable triggered once the interpolation animation has been done.
  103985. */
  103986. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103987. private _target;
  103988. private _effectiveTarget;
  103989. private _property;
  103990. /**
  103991. * Instantiate the action
  103992. * @param triggerOptions defines the trigger options
  103993. * @param target defines the object containing the value to interpolate
  103994. * @param propertyPath defines the path to the property in the target object
  103995. * @param value defines the target value at the end of the interpolation
  103996. * @param duration deines the time it will take for the property to interpolate to the value.
  103997. * @param condition defines the trigger related conditions
  103998. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103999. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  104000. */
  104001. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  104002. /** @hidden */
  104003. _prepare(): void;
  104004. /**
  104005. * Execute the action starts the value interpolation.
  104006. */
  104007. execute(): void;
  104008. /**
  104009. * Serializes the actions and its related information.
  104010. * @param parent defines the object to serialize in
  104011. * @returns the serialized object
  104012. */
  104013. serialize(parent: any): any;
  104014. }
  104015. }
  104016. declare module BABYLON {
  104017. /**
  104018. * Options allowed during the creation of a sound track.
  104019. */
  104020. export interface ISoundTrackOptions {
  104021. /**
  104022. * The volume the sound track should take during creation
  104023. */
  104024. volume?: number;
  104025. /**
  104026. * Define if the sound track is the main sound track of the scene
  104027. */
  104028. mainTrack?: boolean;
  104029. }
  104030. /**
  104031. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104032. * It will be also used in a future release to apply effects on a specific track.
  104033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104034. */
  104035. export class SoundTrack {
  104036. /**
  104037. * The unique identifier of the sound track in the scene.
  104038. */
  104039. id: number;
  104040. /**
  104041. * The list of sounds included in the sound track.
  104042. */
  104043. soundCollection: Array<Sound>;
  104044. private _outputAudioNode;
  104045. private _scene;
  104046. private _connectedAnalyser;
  104047. private _options;
  104048. private _isInitialized;
  104049. /**
  104050. * Creates a new sound track.
  104051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104052. * @param scene Define the scene the sound track belongs to
  104053. * @param options
  104054. */
  104055. constructor(scene: Scene, options?: ISoundTrackOptions);
  104056. private _initializeSoundTrackAudioGraph;
  104057. /**
  104058. * Release the sound track and its associated resources
  104059. */
  104060. dispose(): void;
  104061. /**
  104062. * Adds a sound to this sound track
  104063. * @param sound define the cound to add
  104064. * @ignoreNaming
  104065. */
  104066. AddSound(sound: Sound): void;
  104067. /**
  104068. * Removes a sound to this sound track
  104069. * @param sound define the cound to remove
  104070. * @ignoreNaming
  104071. */
  104072. RemoveSound(sound: Sound): void;
  104073. /**
  104074. * Set a global volume for the full sound track.
  104075. * @param newVolume Define the new volume of the sound track
  104076. */
  104077. setVolume(newVolume: number): void;
  104078. /**
  104079. * Switch the panning model to HRTF:
  104080. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104082. */
  104083. switchPanningModelToHRTF(): void;
  104084. /**
  104085. * Switch the panning model to Equal Power:
  104086. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104088. */
  104089. switchPanningModelToEqualPower(): void;
  104090. /**
  104091. * Connect the sound track to an audio analyser allowing some amazing
  104092. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104094. * @param analyser The analyser to connect to the engine
  104095. */
  104096. connectToAnalyser(analyser: Analyser): void;
  104097. }
  104098. }
  104099. declare module BABYLON {
  104100. interface AbstractScene {
  104101. /**
  104102. * The list of sounds used in the scene.
  104103. */
  104104. sounds: Nullable<Array<Sound>>;
  104105. }
  104106. interface Scene {
  104107. /**
  104108. * @hidden
  104109. * Backing field
  104110. */
  104111. _mainSoundTrack: SoundTrack;
  104112. /**
  104113. * The main sound track played by the scene.
  104114. * It cotains your primary collection of sounds.
  104115. */
  104116. mainSoundTrack: SoundTrack;
  104117. /**
  104118. * The list of sound tracks added to the scene
  104119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104120. */
  104121. soundTracks: Nullable<Array<SoundTrack>>;
  104122. /**
  104123. * Gets a sound using a given name
  104124. * @param name defines the name to search for
  104125. * @return the found sound or null if not found at all.
  104126. */
  104127. getSoundByName(name: string): Nullable<Sound>;
  104128. /**
  104129. * Gets or sets if audio support is enabled
  104130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104131. */
  104132. audioEnabled: boolean;
  104133. /**
  104134. * Gets or sets if audio will be output to headphones
  104135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104136. */
  104137. headphone: boolean;
  104138. /**
  104139. * Gets or sets custom audio listener position provider
  104140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104141. */
  104142. audioListenerPositionProvider: Nullable<() => Vector3>;
  104143. /**
  104144. * Gets or sets a refresh rate when using 3D audio positioning
  104145. */
  104146. audioPositioningRefreshRate: number;
  104147. }
  104148. /**
  104149. * Defines the sound scene component responsible to manage any sounds
  104150. * in a given scene.
  104151. */
  104152. export class AudioSceneComponent implements ISceneSerializableComponent {
  104153. /**
  104154. * The component name helpfull to identify the component in the list of scene components.
  104155. */
  104156. readonly name: string;
  104157. /**
  104158. * The scene the component belongs to.
  104159. */
  104160. scene: Scene;
  104161. private _audioEnabled;
  104162. /**
  104163. * Gets whether audio is enabled or not.
  104164. * Please use related enable/disable method to switch state.
  104165. */
  104166. readonly audioEnabled: boolean;
  104167. private _headphone;
  104168. /**
  104169. * Gets whether audio is outputing to headphone or not.
  104170. * Please use the according Switch methods to change output.
  104171. */
  104172. readonly headphone: boolean;
  104173. /**
  104174. * Gets or sets a refresh rate when using 3D audio positioning
  104175. */
  104176. audioPositioningRefreshRate: number;
  104177. private _audioListenerPositionProvider;
  104178. /**
  104179. * Gets the current audio listener position provider
  104180. */
  104181. /**
  104182. * Sets a custom listener position for all sounds in the scene
  104183. * By default, this is the position of the first active camera
  104184. */
  104185. audioListenerPositionProvider: Nullable<() => Vector3>;
  104186. /**
  104187. * Creates a new instance of the component for the given scene
  104188. * @param scene Defines the scene to register the component in
  104189. */
  104190. constructor(scene: Scene);
  104191. /**
  104192. * Registers the component in a given scene
  104193. */
  104194. register(): void;
  104195. /**
  104196. * Rebuilds the elements related to this component in case of
  104197. * context lost for instance.
  104198. */
  104199. rebuild(): void;
  104200. /**
  104201. * Serializes the component data to the specified json object
  104202. * @param serializationObject The object to serialize to
  104203. */
  104204. serialize(serializationObject: any): void;
  104205. /**
  104206. * Adds all the elements from the container to the scene
  104207. * @param container the container holding the elements
  104208. */
  104209. addFromContainer(container: AbstractScene): void;
  104210. /**
  104211. * Removes all the elements in the container from the scene
  104212. * @param container contains the elements to remove
  104213. * @param dispose if the removed element should be disposed (default: false)
  104214. */
  104215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104216. /**
  104217. * Disposes the component and the associated ressources.
  104218. */
  104219. dispose(): void;
  104220. /**
  104221. * Disables audio in the associated scene.
  104222. */
  104223. disableAudio(): void;
  104224. /**
  104225. * Enables audio in the associated scene.
  104226. */
  104227. enableAudio(): void;
  104228. /**
  104229. * Switch audio to headphone output.
  104230. */
  104231. switchAudioModeForHeadphones(): void;
  104232. /**
  104233. * Switch audio to normal speakers.
  104234. */
  104235. switchAudioModeForNormalSpeakers(): void;
  104236. private _cachedCameraDirection;
  104237. private _cachedCameraPosition;
  104238. private _lastCheck;
  104239. private _afterRender;
  104240. }
  104241. }
  104242. declare module BABYLON {
  104243. /**
  104244. * Wraps one or more Sound objects and selects one with random weight for playback.
  104245. */
  104246. export class WeightedSound {
  104247. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104248. loop: boolean;
  104249. private _coneInnerAngle;
  104250. private _coneOuterAngle;
  104251. private _volume;
  104252. /** A Sound is currently playing. */
  104253. isPlaying: boolean;
  104254. /** A Sound is currently paused. */
  104255. isPaused: boolean;
  104256. private _sounds;
  104257. private _weights;
  104258. private _currentIndex?;
  104259. /**
  104260. * Creates a new WeightedSound from the list of sounds given.
  104261. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104262. * @param sounds Array of Sounds that will be selected from.
  104263. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104264. */
  104265. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104266. /**
  104267. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104268. */
  104269. /**
  104270. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104271. */
  104272. directionalConeInnerAngle: number;
  104273. /**
  104274. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104275. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104276. */
  104277. /**
  104278. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104279. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104280. */
  104281. directionalConeOuterAngle: number;
  104282. /**
  104283. * Playback volume.
  104284. */
  104285. /**
  104286. * Playback volume.
  104287. */
  104288. volume: number;
  104289. private _onended;
  104290. /**
  104291. * Suspend playback
  104292. */
  104293. pause(): void;
  104294. /**
  104295. * Stop playback
  104296. */
  104297. stop(): void;
  104298. /**
  104299. * Start playback.
  104300. * @param startOffset Position the clip head at a specific time in seconds.
  104301. */
  104302. play(startOffset?: number): void;
  104303. }
  104304. }
  104305. declare module BABYLON {
  104306. /**
  104307. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104309. */
  104310. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104311. /**
  104312. * Gets the name of the behavior.
  104313. */
  104314. readonly name: string;
  104315. /**
  104316. * The easing function used by animations
  104317. */
  104318. static EasingFunction: BackEase;
  104319. /**
  104320. * The easing mode used by animations
  104321. */
  104322. static EasingMode: number;
  104323. /**
  104324. * The duration of the animation, in milliseconds
  104325. */
  104326. transitionDuration: number;
  104327. /**
  104328. * Length of the distance animated by the transition when lower radius is reached
  104329. */
  104330. lowerRadiusTransitionRange: number;
  104331. /**
  104332. * Length of the distance animated by the transition when upper radius is reached
  104333. */
  104334. upperRadiusTransitionRange: number;
  104335. private _autoTransitionRange;
  104336. /**
  104337. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104338. */
  104339. /**
  104340. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104341. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104342. */
  104343. autoTransitionRange: boolean;
  104344. private _attachedCamera;
  104345. private _onAfterCheckInputsObserver;
  104346. private _onMeshTargetChangedObserver;
  104347. /**
  104348. * Initializes the behavior.
  104349. */
  104350. init(): void;
  104351. /**
  104352. * Attaches the behavior to its arc rotate camera.
  104353. * @param camera Defines the camera to attach the behavior to
  104354. */
  104355. attach(camera: ArcRotateCamera): void;
  104356. /**
  104357. * Detaches the behavior from its current arc rotate camera.
  104358. */
  104359. detach(): void;
  104360. private _radiusIsAnimating;
  104361. private _radiusBounceTransition;
  104362. private _animatables;
  104363. private _cachedWheelPrecision;
  104364. /**
  104365. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104366. * @param radiusLimit The limit to check against.
  104367. * @return Bool to indicate if at limit.
  104368. */
  104369. private _isRadiusAtLimit;
  104370. /**
  104371. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104372. * @param radiusDelta The delta by which to animate to. Can be negative.
  104373. */
  104374. private _applyBoundRadiusAnimation;
  104375. /**
  104376. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104377. */
  104378. protected _clearAnimationLocks(): void;
  104379. /**
  104380. * Stops and removes all animations that have been applied to the camera
  104381. */
  104382. stopAllAnimations(): void;
  104383. }
  104384. }
  104385. declare module BABYLON {
  104386. /**
  104387. * 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.
  104388. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104389. */
  104390. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104391. /**
  104392. * Gets the name of the behavior.
  104393. */
  104394. readonly name: string;
  104395. private _mode;
  104396. private _radiusScale;
  104397. private _positionScale;
  104398. private _defaultElevation;
  104399. private _elevationReturnTime;
  104400. private _elevationReturnWaitTime;
  104401. private _zoomStopsAnimation;
  104402. private _framingTime;
  104403. /**
  104404. * The easing function used by animations
  104405. */
  104406. static EasingFunction: ExponentialEase;
  104407. /**
  104408. * The easing mode used by animations
  104409. */
  104410. static EasingMode: number;
  104411. /**
  104412. * Sets the current mode used by the behavior
  104413. */
  104414. /**
  104415. * Gets current mode used by the behavior.
  104416. */
  104417. mode: number;
  104418. /**
  104419. * Sets the scale applied to the radius (1 by default)
  104420. */
  104421. /**
  104422. * Gets the scale applied to the radius
  104423. */
  104424. radiusScale: number;
  104425. /**
  104426. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104427. */
  104428. /**
  104429. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104430. */
  104431. positionScale: number;
  104432. /**
  104433. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104434. * behaviour is triggered, in radians.
  104435. */
  104436. /**
  104437. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104438. * behaviour is triggered, in radians.
  104439. */
  104440. defaultElevation: number;
  104441. /**
  104442. * Sets the time (in milliseconds) taken to return to the default beta position.
  104443. * Negative value indicates camera should not return to default.
  104444. */
  104445. /**
  104446. * Gets the time (in milliseconds) taken to return to the default beta position.
  104447. * Negative value indicates camera should not return to default.
  104448. */
  104449. elevationReturnTime: number;
  104450. /**
  104451. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104452. */
  104453. /**
  104454. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104455. */
  104456. elevationReturnWaitTime: number;
  104457. /**
  104458. * Sets the flag that indicates if user zooming should stop animation.
  104459. */
  104460. /**
  104461. * Gets the flag that indicates if user zooming should stop animation.
  104462. */
  104463. zoomStopsAnimation: boolean;
  104464. /**
  104465. * Sets the transition time when framing the mesh, in milliseconds
  104466. */
  104467. /**
  104468. * Gets the transition time when framing the mesh, in milliseconds
  104469. */
  104470. framingTime: number;
  104471. /**
  104472. * Define if the behavior should automatically change the configured
  104473. * camera limits and sensibilities.
  104474. */
  104475. autoCorrectCameraLimitsAndSensibility: boolean;
  104476. private _onPrePointerObservableObserver;
  104477. private _onAfterCheckInputsObserver;
  104478. private _onMeshTargetChangedObserver;
  104479. private _attachedCamera;
  104480. private _isPointerDown;
  104481. private _lastInteractionTime;
  104482. /**
  104483. * Initializes the behavior.
  104484. */
  104485. init(): void;
  104486. /**
  104487. * Attaches the behavior to its arc rotate camera.
  104488. * @param camera Defines the camera to attach the behavior to
  104489. */
  104490. attach(camera: ArcRotateCamera): void;
  104491. /**
  104492. * Detaches the behavior from its current arc rotate camera.
  104493. */
  104494. detach(): void;
  104495. private _animatables;
  104496. private _betaIsAnimating;
  104497. private _betaTransition;
  104498. private _radiusTransition;
  104499. private _vectorTransition;
  104500. /**
  104501. * Targets the given mesh and updates zoom level accordingly.
  104502. * @param mesh The mesh to target.
  104503. * @param radius Optional. If a cached radius position already exists, overrides default.
  104504. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104505. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104506. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104507. */
  104508. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104509. /**
  104510. * Targets the given mesh with its children and updates zoom level accordingly.
  104511. * @param mesh The mesh to target.
  104512. * @param radius Optional. If a cached radius position already exists, overrides default.
  104513. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104514. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104515. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104516. */
  104517. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104518. /**
  104519. * Targets the given meshes with their children and updates zoom level accordingly.
  104520. * @param meshes The mesh to target.
  104521. * @param radius Optional. If a cached radius position already exists, overrides default.
  104522. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104523. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104524. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104525. */
  104526. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104527. /**
  104528. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104529. * @param minimumWorld Determines the smaller position of the bounding box extend
  104530. * @param maximumWorld Determines the bigger position of the bounding box extend
  104531. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104532. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104533. */
  104534. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104535. /**
  104536. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104537. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104538. * frustum width.
  104539. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104540. * to fully enclose the mesh in the viewing frustum.
  104541. */
  104542. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104543. /**
  104544. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104545. * is automatically returned to its default position (expected to be above ground plane).
  104546. */
  104547. private _maintainCameraAboveGround;
  104548. /**
  104549. * Returns the frustum slope based on the canvas ratio and camera FOV
  104550. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104551. */
  104552. private _getFrustumSlope;
  104553. /**
  104554. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104555. */
  104556. private _clearAnimationLocks;
  104557. /**
  104558. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104559. */
  104560. private _applyUserInteraction;
  104561. /**
  104562. * Stops and removes all animations that have been applied to the camera
  104563. */
  104564. stopAllAnimations(): void;
  104565. /**
  104566. * Gets a value indicating if the user is moving the camera
  104567. */
  104568. readonly isUserIsMoving: boolean;
  104569. /**
  104570. * The camera can move all the way towards the mesh.
  104571. */
  104572. static IgnoreBoundsSizeMode: number;
  104573. /**
  104574. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104575. */
  104576. static FitFrustumSidesMode: number;
  104577. }
  104578. }
  104579. declare module BABYLON {
  104580. /**
  104581. * Base class for Camera Pointer Inputs.
  104582. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104583. * for example usage.
  104584. */
  104585. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104586. /**
  104587. * Defines the camera the input is attached to.
  104588. */
  104589. abstract camera: Camera;
  104590. /**
  104591. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104592. */
  104593. protected _altKey: boolean;
  104594. protected _ctrlKey: boolean;
  104595. protected _metaKey: boolean;
  104596. protected _shiftKey: boolean;
  104597. /**
  104598. * Which mouse buttons were pressed at time of last mouse event.
  104599. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104600. */
  104601. protected _buttonsPressed: number;
  104602. /**
  104603. * Defines the buttons associated with the input to handle camera move.
  104604. */
  104605. buttons: number[];
  104606. /**
  104607. * Attach the input controls to a specific dom element to get the input from.
  104608. * @param element Defines the element the controls should be listened from
  104609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104610. */
  104611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104612. /**
  104613. * Detach the current controls from the specified dom element.
  104614. * @param element Defines the element to stop listening the inputs from
  104615. */
  104616. detachControl(element: Nullable<HTMLElement>): void;
  104617. /**
  104618. * Gets the class name of the current input.
  104619. * @returns the class name
  104620. */
  104621. getClassName(): string;
  104622. /**
  104623. * Get the friendly name associated with the input class.
  104624. * @returns the input friendly name
  104625. */
  104626. getSimpleName(): string;
  104627. /**
  104628. * Called on pointer POINTERDOUBLETAP event.
  104629. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104630. */
  104631. protected onDoubleTap(type: string): void;
  104632. /**
  104633. * Called on pointer POINTERMOVE event if only a single touch is active.
  104634. * Override this method to provide functionality.
  104635. */
  104636. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104637. /**
  104638. * Called on pointer POINTERMOVE event if multiple touches are active.
  104639. * Override this method to provide functionality.
  104640. */
  104641. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104642. /**
  104643. * Called on JS contextmenu event.
  104644. * Override this method to provide functionality.
  104645. */
  104646. protected onContextMenu(evt: PointerEvent): void;
  104647. /**
  104648. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104649. * press.
  104650. * Override this method to provide functionality.
  104651. */
  104652. protected onButtonDown(evt: PointerEvent): void;
  104653. /**
  104654. * Called each time a new POINTERUP event occurs. Ie, for each button
  104655. * release.
  104656. * Override this method to provide functionality.
  104657. */
  104658. protected onButtonUp(evt: PointerEvent): void;
  104659. /**
  104660. * Called when window becomes inactive.
  104661. * Override this method to provide functionality.
  104662. */
  104663. protected onLostFocus(): void;
  104664. private _pointerInput;
  104665. private _observer;
  104666. private _onLostFocus;
  104667. private pointA;
  104668. private pointB;
  104669. }
  104670. }
  104671. declare module BABYLON {
  104672. /**
  104673. * Manage the pointers inputs to control an arc rotate camera.
  104674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104675. */
  104676. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104677. /**
  104678. * Defines the camera the input is attached to.
  104679. */
  104680. camera: ArcRotateCamera;
  104681. /**
  104682. * Gets the class name of the current input.
  104683. * @returns the class name
  104684. */
  104685. getClassName(): string;
  104686. /**
  104687. * Defines the buttons associated with the input to handle camera move.
  104688. */
  104689. buttons: number[];
  104690. /**
  104691. * Defines the pointer angular sensibility along the X axis or how fast is
  104692. * the camera rotating.
  104693. */
  104694. angularSensibilityX: number;
  104695. /**
  104696. * Defines the pointer angular sensibility along the Y axis or how fast is
  104697. * the camera rotating.
  104698. */
  104699. angularSensibilityY: number;
  104700. /**
  104701. * Defines the pointer pinch precision or how fast is the camera zooming.
  104702. */
  104703. pinchPrecision: number;
  104704. /**
  104705. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104706. * from 0.
  104707. * It defines the percentage of current camera.radius to use as delta when
  104708. * pinch zoom is used.
  104709. */
  104710. pinchDeltaPercentage: number;
  104711. /**
  104712. * Defines the pointer panning sensibility or how fast is the camera moving.
  104713. */
  104714. panningSensibility: number;
  104715. /**
  104716. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104717. */
  104718. multiTouchPanning: boolean;
  104719. /**
  104720. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104721. * zoom (pinch) through multitouch.
  104722. */
  104723. multiTouchPanAndZoom: boolean;
  104724. /**
  104725. * Revers pinch action direction.
  104726. */
  104727. pinchInwards: boolean;
  104728. private _isPanClick;
  104729. private _twoFingerActivityCount;
  104730. private _isPinching;
  104731. /**
  104732. * Called on pointer POINTERMOVE event if only a single touch is active.
  104733. */
  104734. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104735. /**
  104736. * Called on pointer POINTERDOUBLETAP event.
  104737. */
  104738. protected onDoubleTap(type: string): void;
  104739. /**
  104740. * Called on pointer POINTERMOVE event if multiple touches are active.
  104741. */
  104742. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104743. /**
  104744. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104745. * press.
  104746. */
  104747. protected onButtonDown(evt: PointerEvent): void;
  104748. /**
  104749. * Called each time a new POINTERUP event occurs. Ie, for each button
  104750. * release.
  104751. */
  104752. protected onButtonUp(evt: PointerEvent): void;
  104753. /**
  104754. * Called when window becomes inactive.
  104755. */
  104756. protected onLostFocus(): void;
  104757. }
  104758. }
  104759. declare module BABYLON {
  104760. /**
  104761. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104763. */
  104764. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104765. /**
  104766. * Defines the camera the input is attached to.
  104767. */
  104768. camera: ArcRotateCamera;
  104769. /**
  104770. * Defines the list of key codes associated with the up action (increase alpha)
  104771. */
  104772. keysUp: number[];
  104773. /**
  104774. * Defines the list of key codes associated with the down action (decrease alpha)
  104775. */
  104776. keysDown: number[];
  104777. /**
  104778. * Defines the list of key codes associated with the left action (increase beta)
  104779. */
  104780. keysLeft: number[];
  104781. /**
  104782. * Defines the list of key codes associated with the right action (decrease beta)
  104783. */
  104784. keysRight: number[];
  104785. /**
  104786. * Defines the list of key codes associated with the reset action.
  104787. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104788. */
  104789. keysReset: number[];
  104790. /**
  104791. * Defines the panning sensibility of the inputs.
  104792. * (How fast is the camera paning)
  104793. */
  104794. panningSensibility: number;
  104795. /**
  104796. * Defines the zooming sensibility of the inputs.
  104797. * (How fast is the camera zooming)
  104798. */
  104799. zoomingSensibility: number;
  104800. /**
  104801. * Defines wether maintaining the alt key down switch the movement mode from
  104802. * orientation to zoom.
  104803. */
  104804. useAltToZoom: boolean;
  104805. /**
  104806. * Rotation speed of the camera
  104807. */
  104808. angularSpeed: number;
  104809. private _keys;
  104810. private _ctrlPressed;
  104811. private _altPressed;
  104812. private _onCanvasBlurObserver;
  104813. private _onKeyboardObserver;
  104814. private _engine;
  104815. private _scene;
  104816. /**
  104817. * Attach the input controls to a specific dom element to get the input from.
  104818. * @param element Defines the element the controls should be listened from
  104819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104820. */
  104821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104822. /**
  104823. * Detach the current controls from the specified dom element.
  104824. * @param element Defines the element to stop listening the inputs from
  104825. */
  104826. detachControl(element: Nullable<HTMLElement>): void;
  104827. /**
  104828. * Update the current camera state depending on the inputs that have been used this frame.
  104829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104830. */
  104831. checkInputs(): void;
  104832. /**
  104833. * Gets the class name of the current intput.
  104834. * @returns the class name
  104835. */
  104836. getClassName(): string;
  104837. /**
  104838. * Get the friendly name associated with the input class.
  104839. * @returns the input friendly name
  104840. */
  104841. getSimpleName(): string;
  104842. }
  104843. }
  104844. declare module BABYLON {
  104845. /**
  104846. * Manage the mouse wheel inputs to control an arc rotate camera.
  104847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104848. */
  104849. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104850. /**
  104851. * Defines the camera the input is attached to.
  104852. */
  104853. camera: ArcRotateCamera;
  104854. /**
  104855. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104856. */
  104857. wheelPrecision: number;
  104858. /**
  104859. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104860. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104861. */
  104862. wheelDeltaPercentage: number;
  104863. private _wheel;
  104864. private _observer;
  104865. private computeDeltaFromMouseWheelLegacyEvent;
  104866. /**
  104867. * Attach the input controls to a specific dom element to get the input from.
  104868. * @param element Defines the element the controls should be listened from
  104869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104870. */
  104871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104872. /**
  104873. * Detach the current controls from the specified dom element.
  104874. * @param element Defines the element to stop listening the inputs from
  104875. */
  104876. detachControl(element: Nullable<HTMLElement>): void;
  104877. /**
  104878. * Gets the class name of the current intput.
  104879. * @returns the class name
  104880. */
  104881. getClassName(): string;
  104882. /**
  104883. * Get the friendly name associated with the input class.
  104884. * @returns the input friendly name
  104885. */
  104886. getSimpleName(): string;
  104887. }
  104888. }
  104889. declare module BABYLON {
  104890. /**
  104891. * Default Inputs manager for the ArcRotateCamera.
  104892. * It groups all the default supported inputs for ease of use.
  104893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104894. */
  104895. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104896. /**
  104897. * Instantiates a new ArcRotateCameraInputsManager.
  104898. * @param camera Defines the camera the inputs belong to
  104899. */
  104900. constructor(camera: ArcRotateCamera);
  104901. /**
  104902. * Add mouse wheel input support to the input manager.
  104903. * @returns the current input manager
  104904. */
  104905. addMouseWheel(): ArcRotateCameraInputsManager;
  104906. /**
  104907. * Add pointers input support to the input manager.
  104908. * @returns the current input manager
  104909. */
  104910. addPointers(): ArcRotateCameraInputsManager;
  104911. /**
  104912. * Add keyboard input support to the input manager.
  104913. * @returns the current input manager
  104914. */
  104915. addKeyboard(): ArcRotateCameraInputsManager;
  104916. }
  104917. }
  104918. declare module BABYLON {
  104919. /**
  104920. * This represents an orbital type of camera.
  104921. *
  104922. * 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.
  104923. * 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.
  104924. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104925. */
  104926. export class ArcRotateCamera extends TargetCamera {
  104927. /**
  104928. * Defines the rotation angle of the camera along the longitudinal axis.
  104929. */
  104930. alpha: number;
  104931. /**
  104932. * Defines the rotation angle of the camera along the latitudinal axis.
  104933. */
  104934. beta: number;
  104935. /**
  104936. * Defines the radius of the camera from it s target point.
  104937. */
  104938. radius: number;
  104939. protected _target: Vector3;
  104940. protected _targetHost: Nullable<AbstractMesh>;
  104941. /**
  104942. * Defines the target point of the camera.
  104943. * The camera looks towards it form the radius distance.
  104944. */
  104945. target: Vector3;
  104946. /**
  104947. * Define the current local position of the camera in the scene
  104948. */
  104949. position: Vector3;
  104950. protected _upVector: Vector3;
  104951. protected _upToYMatrix: Matrix;
  104952. protected _YToUpMatrix: Matrix;
  104953. /**
  104954. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104955. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104956. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104957. */
  104958. upVector: Vector3;
  104959. /**
  104960. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104961. */
  104962. setMatUp(): void;
  104963. /**
  104964. * Current inertia value on the longitudinal axis.
  104965. * The bigger this number the longer it will take for the camera to stop.
  104966. */
  104967. inertialAlphaOffset: number;
  104968. /**
  104969. * Current inertia value on the latitudinal axis.
  104970. * The bigger this number the longer it will take for the camera to stop.
  104971. */
  104972. inertialBetaOffset: number;
  104973. /**
  104974. * Current inertia value on the radius axis.
  104975. * The bigger this number the longer it will take for the camera to stop.
  104976. */
  104977. inertialRadiusOffset: number;
  104978. /**
  104979. * Minimum allowed angle on the longitudinal axis.
  104980. * This can help limiting how the Camera is able to move in the scene.
  104981. */
  104982. lowerAlphaLimit: Nullable<number>;
  104983. /**
  104984. * Maximum allowed angle on the longitudinal axis.
  104985. * This can help limiting how the Camera is able to move in the scene.
  104986. */
  104987. upperAlphaLimit: Nullable<number>;
  104988. /**
  104989. * Minimum allowed angle on the latitudinal axis.
  104990. * This can help limiting how the Camera is able to move in the scene.
  104991. */
  104992. lowerBetaLimit: number;
  104993. /**
  104994. * Maximum allowed angle on the latitudinal axis.
  104995. * This can help limiting how the Camera is able to move in the scene.
  104996. */
  104997. upperBetaLimit: number;
  104998. /**
  104999. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  105000. * This can help limiting how the Camera is able to move in the scene.
  105001. */
  105002. lowerRadiusLimit: Nullable<number>;
  105003. /**
  105004. * Maximum allowed distance of the camera to the target (The camera can not get further).
  105005. * This can help limiting how the Camera is able to move in the scene.
  105006. */
  105007. upperRadiusLimit: Nullable<number>;
  105008. /**
  105009. * Defines the current inertia value used during panning of the camera along the X axis.
  105010. */
  105011. inertialPanningX: number;
  105012. /**
  105013. * Defines the current inertia value used during panning of the camera along the Y axis.
  105014. */
  105015. inertialPanningY: number;
  105016. /**
  105017. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105018. * Basically if your fingers moves away from more than this distance you will be considered
  105019. * in pinch mode.
  105020. */
  105021. pinchToPanMaxDistance: number;
  105022. /**
  105023. * Defines the maximum distance the camera can pan.
  105024. * This could help keeping the cammera always in your scene.
  105025. */
  105026. panningDistanceLimit: Nullable<number>;
  105027. /**
  105028. * Defines the target of the camera before paning.
  105029. */
  105030. panningOriginTarget: Vector3;
  105031. /**
  105032. * Defines the value of the inertia used during panning.
  105033. * 0 would mean stop inertia and one would mean no decelleration at all.
  105034. */
  105035. panningInertia: number;
  105036. /**
  105037. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105038. */
  105039. angularSensibilityX: number;
  105040. /**
  105041. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105042. */
  105043. angularSensibilityY: number;
  105044. /**
  105045. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105046. */
  105047. pinchPrecision: number;
  105048. /**
  105049. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105050. * It will be used instead of pinchDeltaPrecision if different from 0.
  105051. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105052. */
  105053. pinchDeltaPercentage: number;
  105054. /**
  105055. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105056. */
  105057. panningSensibility: number;
  105058. /**
  105059. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105060. */
  105061. keysUp: number[];
  105062. /**
  105063. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105064. */
  105065. keysDown: number[];
  105066. /**
  105067. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105068. */
  105069. keysLeft: number[];
  105070. /**
  105071. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105072. */
  105073. keysRight: number[];
  105074. /**
  105075. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105076. */
  105077. wheelPrecision: number;
  105078. /**
  105079. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105080. * It will be used instead of pinchDeltaPrecision if different from 0.
  105081. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105082. */
  105083. wheelDeltaPercentage: number;
  105084. /**
  105085. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105086. */
  105087. zoomOnFactor: number;
  105088. /**
  105089. * Defines a screen offset for the camera position.
  105090. */
  105091. targetScreenOffset: Vector2;
  105092. /**
  105093. * Allows the camera to be completely reversed.
  105094. * If false the camera can not arrive upside down.
  105095. */
  105096. allowUpsideDown: boolean;
  105097. /**
  105098. * Define if double tap/click is used to restore the previously saved state of the camera.
  105099. */
  105100. useInputToRestoreState: boolean;
  105101. /** @hidden */
  105102. _viewMatrix: Matrix;
  105103. /** @hidden */
  105104. _useCtrlForPanning: boolean;
  105105. /** @hidden */
  105106. _panningMouseButton: number;
  105107. /**
  105108. * Defines the input associated to the camera.
  105109. */
  105110. inputs: ArcRotateCameraInputsManager;
  105111. /** @hidden */
  105112. _reset: () => void;
  105113. /**
  105114. * Defines the allowed panning axis.
  105115. */
  105116. panningAxis: Vector3;
  105117. protected _localDirection: Vector3;
  105118. protected _transformedDirection: Vector3;
  105119. private _bouncingBehavior;
  105120. /**
  105121. * Gets the bouncing behavior of the camera if it has been enabled.
  105122. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105123. */
  105124. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105125. /**
  105126. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105128. */
  105129. useBouncingBehavior: boolean;
  105130. private _framingBehavior;
  105131. /**
  105132. * Gets the framing behavior of the camera if it has been enabled.
  105133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105134. */
  105135. readonly framingBehavior: Nullable<FramingBehavior>;
  105136. /**
  105137. * Defines if the framing behavior of the camera is enabled on the camera.
  105138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105139. */
  105140. useFramingBehavior: boolean;
  105141. private _autoRotationBehavior;
  105142. /**
  105143. * Gets the auto rotation behavior of the camera if it has been enabled.
  105144. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105145. */
  105146. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105147. /**
  105148. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105150. */
  105151. useAutoRotationBehavior: boolean;
  105152. /**
  105153. * Observable triggered when the mesh target has been changed on the camera.
  105154. */
  105155. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105156. /**
  105157. * Event raised when the camera is colliding with a mesh.
  105158. */
  105159. onCollide: (collidedMesh: AbstractMesh) => void;
  105160. /**
  105161. * Defines whether the camera should check collision with the objects oh the scene.
  105162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105163. */
  105164. checkCollisions: boolean;
  105165. /**
  105166. * Defines the collision radius of the camera.
  105167. * This simulates a sphere around the camera.
  105168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105169. */
  105170. collisionRadius: Vector3;
  105171. protected _collider: Collider;
  105172. protected _previousPosition: Vector3;
  105173. protected _collisionVelocity: Vector3;
  105174. protected _newPosition: Vector3;
  105175. protected _previousAlpha: number;
  105176. protected _previousBeta: number;
  105177. protected _previousRadius: number;
  105178. protected _collisionTriggered: boolean;
  105179. protected _targetBoundingCenter: Nullable<Vector3>;
  105180. private _computationVector;
  105181. /**
  105182. * Instantiates a new ArcRotateCamera in a given scene
  105183. * @param name Defines the name of the camera
  105184. * @param alpha Defines the camera rotation along the logitudinal axis
  105185. * @param beta Defines the camera rotation along the latitudinal axis
  105186. * @param radius Defines the camera distance from its target
  105187. * @param target Defines the camera target
  105188. * @param scene Defines the scene the camera belongs to
  105189. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105190. */
  105191. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105192. /** @hidden */
  105193. _initCache(): void;
  105194. /** @hidden */
  105195. _updateCache(ignoreParentClass?: boolean): void;
  105196. protected _getTargetPosition(): Vector3;
  105197. private _storedAlpha;
  105198. private _storedBeta;
  105199. private _storedRadius;
  105200. private _storedTarget;
  105201. private _storedTargetScreenOffset;
  105202. /**
  105203. * Stores the current state of the camera (alpha, beta, radius and target)
  105204. * @returns the camera itself
  105205. */
  105206. storeState(): Camera;
  105207. /**
  105208. * @hidden
  105209. * Restored camera state. You must call storeState() first
  105210. */
  105211. _restoreStateValues(): boolean;
  105212. /** @hidden */
  105213. _isSynchronizedViewMatrix(): boolean;
  105214. /**
  105215. * Attached controls to the current camera.
  105216. * @param element Defines the element the controls should be listened from
  105217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105218. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105219. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105220. */
  105221. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105222. /**
  105223. * Detach the current controls from the camera.
  105224. * The camera will stop reacting to inputs.
  105225. * @param element Defines the element to stop listening the inputs from
  105226. */
  105227. detachControl(element: HTMLElement): void;
  105228. /** @hidden */
  105229. _checkInputs(): void;
  105230. protected _checkLimits(): void;
  105231. /**
  105232. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105233. */
  105234. rebuildAnglesAndRadius(): void;
  105235. /**
  105236. * Use a position to define the current camera related information like alpha, beta and radius
  105237. * @param position Defines the position to set the camera at
  105238. */
  105239. setPosition(position: Vector3): void;
  105240. /**
  105241. * Defines the target the camera should look at.
  105242. * This will automatically adapt alpha beta and radius to fit within the new target.
  105243. * @param target Defines the new target as a Vector or a mesh
  105244. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105245. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105246. */
  105247. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105248. /** @hidden */
  105249. _getViewMatrix(): Matrix;
  105250. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105251. /**
  105252. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105253. * @param meshes Defines the mesh to zoom on
  105254. * @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)
  105255. */
  105256. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105257. /**
  105258. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105259. * The target will be changed but the radius
  105260. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105261. * @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)
  105262. */
  105263. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105264. min: Vector3;
  105265. max: Vector3;
  105266. distance: number;
  105267. }, doNotUpdateMaxZ?: boolean): void;
  105268. /**
  105269. * @override
  105270. * Override Camera.createRigCamera
  105271. */
  105272. createRigCamera(name: string, cameraIndex: number): Camera;
  105273. /**
  105274. * @hidden
  105275. * @override
  105276. * Override Camera._updateRigCameras
  105277. */
  105278. _updateRigCameras(): void;
  105279. /**
  105280. * Destroy the camera and release the current resources hold by it.
  105281. */
  105282. dispose(): void;
  105283. /**
  105284. * Gets the current object class name.
  105285. * @return the class name
  105286. */
  105287. getClassName(): string;
  105288. }
  105289. }
  105290. declare module BABYLON {
  105291. /**
  105292. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105294. */
  105295. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105296. /**
  105297. * Gets the name of the behavior.
  105298. */
  105299. readonly name: string;
  105300. private _zoomStopsAnimation;
  105301. private _idleRotationSpeed;
  105302. private _idleRotationWaitTime;
  105303. private _idleRotationSpinupTime;
  105304. /**
  105305. * Sets the flag that indicates if user zooming should stop animation.
  105306. */
  105307. /**
  105308. * Gets the flag that indicates if user zooming should stop animation.
  105309. */
  105310. zoomStopsAnimation: boolean;
  105311. /**
  105312. * Sets the default speed at which the camera rotates around the model.
  105313. */
  105314. /**
  105315. * Gets the default speed at which the camera rotates around the model.
  105316. */
  105317. idleRotationSpeed: number;
  105318. /**
  105319. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105320. */
  105321. /**
  105322. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105323. */
  105324. idleRotationWaitTime: number;
  105325. /**
  105326. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105327. */
  105328. /**
  105329. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105330. */
  105331. idleRotationSpinupTime: number;
  105332. /**
  105333. * Gets a value indicating if the camera is currently rotating because of this behavior
  105334. */
  105335. readonly rotationInProgress: boolean;
  105336. private _onPrePointerObservableObserver;
  105337. private _onAfterCheckInputsObserver;
  105338. private _attachedCamera;
  105339. private _isPointerDown;
  105340. private _lastFrameTime;
  105341. private _lastInteractionTime;
  105342. private _cameraRotationSpeed;
  105343. /**
  105344. * Initializes the behavior.
  105345. */
  105346. init(): void;
  105347. /**
  105348. * Attaches the behavior to its arc rotate camera.
  105349. * @param camera Defines the camera to attach the behavior to
  105350. */
  105351. attach(camera: ArcRotateCamera): void;
  105352. /**
  105353. * Detaches the behavior from its current arc rotate camera.
  105354. */
  105355. detach(): void;
  105356. /**
  105357. * Returns true if user is scrolling.
  105358. * @return true if user is scrolling.
  105359. */
  105360. private _userIsZooming;
  105361. private _lastFrameRadius;
  105362. private _shouldAnimationStopForInteraction;
  105363. /**
  105364. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105365. */
  105366. private _applyUserInteraction;
  105367. private _userIsMoving;
  105368. }
  105369. }
  105370. declare module BABYLON {
  105371. /**
  105372. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105373. */
  105374. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105375. private ui;
  105376. /**
  105377. * The name of the behavior
  105378. */
  105379. name: string;
  105380. /**
  105381. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105382. */
  105383. distanceAwayFromFace: number;
  105384. /**
  105385. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105386. */
  105387. distanceAwayFromBottomOfFace: number;
  105388. private _faceVectors;
  105389. private _target;
  105390. private _scene;
  105391. private _onRenderObserver;
  105392. private _tmpMatrix;
  105393. private _tmpVector;
  105394. /**
  105395. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105396. * @param ui The transform node that should be attched to the mesh
  105397. */
  105398. constructor(ui: TransformNode);
  105399. /**
  105400. * Initializes the behavior
  105401. */
  105402. init(): void;
  105403. private _closestFace;
  105404. private _zeroVector;
  105405. private _lookAtTmpMatrix;
  105406. private _lookAtToRef;
  105407. /**
  105408. * Attaches the AttachToBoxBehavior to the passed in mesh
  105409. * @param target The mesh that the specified node will be attached to
  105410. */
  105411. attach(target: Mesh): void;
  105412. /**
  105413. * Detaches the behavior from the mesh
  105414. */
  105415. detach(): void;
  105416. }
  105417. }
  105418. declare module BABYLON {
  105419. /**
  105420. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105421. */
  105422. export class FadeInOutBehavior implements Behavior<Mesh> {
  105423. /**
  105424. * Time in milliseconds to delay before fading in (Default: 0)
  105425. */
  105426. delay: number;
  105427. /**
  105428. * Time in milliseconds for the mesh to fade in (Default: 300)
  105429. */
  105430. fadeInTime: number;
  105431. private _millisecondsPerFrame;
  105432. private _hovered;
  105433. private _hoverValue;
  105434. private _ownerNode;
  105435. /**
  105436. * Instatiates the FadeInOutBehavior
  105437. */
  105438. constructor();
  105439. /**
  105440. * The name of the behavior
  105441. */
  105442. readonly name: string;
  105443. /**
  105444. * Initializes the behavior
  105445. */
  105446. init(): void;
  105447. /**
  105448. * Attaches the fade behavior on the passed in mesh
  105449. * @param ownerNode The mesh that will be faded in/out once attached
  105450. */
  105451. attach(ownerNode: Mesh): void;
  105452. /**
  105453. * Detaches the behavior from the mesh
  105454. */
  105455. detach(): void;
  105456. /**
  105457. * Triggers the mesh to begin fading in or out
  105458. * @param value if the object should fade in or out (true to fade in)
  105459. */
  105460. fadeIn(value: boolean): void;
  105461. private _update;
  105462. private _setAllVisibility;
  105463. }
  105464. }
  105465. declare module BABYLON {
  105466. /**
  105467. * Class containing a set of static utilities functions for managing Pivots
  105468. * @hidden
  105469. */
  105470. export class PivotTools {
  105471. private static _PivotCached;
  105472. private static _OldPivotPoint;
  105473. private static _PivotTranslation;
  105474. private static _PivotTmpVector;
  105475. /** @hidden */
  105476. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105477. /** @hidden */
  105478. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105479. }
  105480. }
  105481. declare module BABYLON {
  105482. /**
  105483. * Class containing static functions to help procedurally build meshes
  105484. */
  105485. export class PlaneBuilder {
  105486. /**
  105487. * Creates a plane mesh
  105488. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105489. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105490. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105494. * @param name defines the name of the mesh
  105495. * @param options defines the options used to create the mesh
  105496. * @param scene defines the hosting scene
  105497. * @returns the plane mesh
  105498. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105499. */
  105500. static CreatePlane(name: string, options: {
  105501. size?: number;
  105502. width?: number;
  105503. height?: number;
  105504. sideOrientation?: number;
  105505. frontUVs?: Vector4;
  105506. backUVs?: Vector4;
  105507. updatable?: boolean;
  105508. sourcePlane?: Plane;
  105509. }, scene?: Nullable<Scene>): Mesh;
  105510. }
  105511. }
  105512. declare module BABYLON {
  105513. /**
  105514. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105515. */
  105516. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105517. private static _AnyMouseID;
  105518. /**
  105519. * Abstract mesh the behavior is set on
  105520. */
  105521. attachedNode: AbstractMesh;
  105522. private _dragPlane;
  105523. private _scene;
  105524. private _pointerObserver;
  105525. private _beforeRenderObserver;
  105526. private static _planeScene;
  105527. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105528. /**
  105529. * 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)
  105530. */
  105531. maxDragAngle: number;
  105532. /**
  105533. * @hidden
  105534. */
  105535. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105536. /**
  105537. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105538. */
  105539. currentDraggingPointerID: number;
  105540. /**
  105541. * The last position where the pointer hit the drag plane in world space
  105542. */
  105543. lastDragPosition: Vector3;
  105544. /**
  105545. * If the behavior is currently in a dragging state
  105546. */
  105547. dragging: boolean;
  105548. /**
  105549. * 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)
  105550. */
  105551. dragDeltaRatio: number;
  105552. /**
  105553. * If the drag plane orientation should be updated during the dragging (Default: true)
  105554. */
  105555. updateDragPlane: boolean;
  105556. private _debugMode;
  105557. private _moving;
  105558. /**
  105559. * Fires each time the attached mesh is dragged with the pointer
  105560. * * delta between last drag position and current drag position in world space
  105561. * * dragDistance along the drag axis
  105562. * * dragPlaneNormal normal of the current drag plane used during the drag
  105563. * * dragPlanePoint in world space where the drag intersects the drag plane
  105564. */
  105565. onDragObservable: Observable<{
  105566. delta: Vector3;
  105567. dragPlanePoint: Vector3;
  105568. dragPlaneNormal: Vector3;
  105569. dragDistance: number;
  105570. pointerId: number;
  105571. }>;
  105572. /**
  105573. * Fires each time a drag begins (eg. mouse down on mesh)
  105574. */
  105575. onDragStartObservable: Observable<{
  105576. dragPlanePoint: Vector3;
  105577. pointerId: number;
  105578. }>;
  105579. /**
  105580. * Fires each time a drag ends (eg. mouse release after drag)
  105581. */
  105582. onDragEndObservable: Observable<{
  105583. dragPlanePoint: Vector3;
  105584. pointerId: number;
  105585. }>;
  105586. /**
  105587. * If the attached mesh should be moved when dragged
  105588. */
  105589. moveAttached: boolean;
  105590. /**
  105591. * If the drag behavior will react to drag events (Default: true)
  105592. */
  105593. enabled: boolean;
  105594. /**
  105595. * If pointer events should start and release the drag (Default: true)
  105596. */
  105597. startAndReleaseDragOnPointerEvents: boolean;
  105598. /**
  105599. * If camera controls should be detached during the drag
  105600. */
  105601. detachCameraControls: boolean;
  105602. /**
  105603. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105604. */
  105605. useObjectOrienationForDragging: boolean;
  105606. private _options;
  105607. /**
  105608. * Creates a pointer drag behavior that can be attached to a mesh
  105609. * @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)
  105610. */
  105611. constructor(options?: {
  105612. dragAxis?: Vector3;
  105613. dragPlaneNormal?: Vector3;
  105614. });
  105615. /**
  105616. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105617. */
  105618. validateDrag: (targetPosition: Vector3) => boolean;
  105619. /**
  105620. * The name of the behavior
  105621. */
  105622. readonly name: string;
  105623. /**
  105624. * Initializes the behavior
  105625. */
  105626. init(): void;
  105627. private _tmpVector;
  105628. private _alternatePickedPoint;
  105629. private _worldDragAxis;
  105630. private _targetPosition;
  105631. private _attachedElement;
  105632. /**
  105633. * Attaches the drag behavior the passed in mesh
  105634. * @param ownerNode The mesh that will be dragged around once attached
  105635. * @param predicate Predicate to use for pick filtering
  105636. */
  105637. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105638. /**
  105639. * Force relase the drag action by code.
  105640. */
  105641. releaseDrag(): void;
  105642. private _startDragRay;
  105643. private _lastPointerRay;
  105644. /**
  105645. * Simulates the start of a pointer drag event on the behavior
  105646. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105647. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105648. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105649. */
  105650. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105651. private _startDrag;
  105652. private _dragDelta;
  105653. private _moveDrag;
  105654. private _pickWithRayOnDragPlane;
  105655. private _pointA;
  105656. private _pointB;
  105657. private _pointC;
  105658. private _lineA;
  105659. private _lineB;
  105660. private _localAxis;
  105661. private _lookAt;
  105662. private _updateDragPlanePosition;
  105663. /**
  105664. * Detaches the behavior from the mesh
  105665. */
  105666. detach(): void;
  105667. }
  105668. }
  105669. declare module BABYLON {
  105670. /**
  105671. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105672. */
  105673. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105674. private _dragBehaviorA;
  105675. private _dragBehaviorB;
  105676. private _startDistance;
  105677. private _initialScale;
  105678. private _targetScale;
  105679. private _ownerNode;
  105680. private _sceneRenderObserver;
  105681. /**
  105682. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105683. */
  105684. constructor();
  105685. /**
  105686. * The name of the behavior
  105687. */
  105688. readonly name: string;
  105689. /**
  105690. * Initializes the behavior
  105691. */
  105692. init(): void;
  105693. private _getCurrentDistance;
  105694. /**
  105695. * Attaches the scale behavior the passed in mesh
  105696. * @param ownerNode The mesh that will be scaled around once attached
  105697. */
  105698. attach(ownerNode: Mesh): void;
  105699. /**
  105700. * Detaches the behavior from the mesh
  105701. */
  105702. detach(): void;
  105703. }
  105704. }
  105705. declare module BABYLON {
  105706. /**
  105707. * 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
  105708. */
  105709. export class SixDofDragBehavior implements Behavior<Mesh> {
  105710. private static _virtualScene;
  105711. private _ownerNode;
  105712. private _sceneRenderObserver;
  105713. private _scene;
  105714. private _targetPosition;
  105715. private _virtualOriginMesh;
  105716. private _virtualDragMesh;
  105717. private _pointerObserver;
  105718. private _moving;
  105719. private _startingOrientation;
  105720. /**
  105721. * 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)
  105722. */
  105723. private zDragFactor;
  105724. /**
  105725. * If the object should rotate to face the drag origin
  105726. */
  105727. rotateDraggedObject: boolean;
  105728. /**
  105729. * If the behavior is currently in a dragging state
  105730. */
  105731. dragging: boolean;
  105732. /**
  105733. * 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)
  105734. */
  105735. dragDeltaRatio: number;
  105736. /**
  105737. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105738. */
  105739. currentDraggingPointerID: number;
  105740. /**
  105741. * If camera controls should be detached during the drag
  105742. */
  105743. detachCameraControls: boolean;
  105744. /**
  105745. * Fires each time a drag starts
  105746. */
  105747. onDragStartObservable: Observable<{}>;
  105748. /**
  105749. * Fires each time a drag ends (eg. mouse release after drag)
  105750. */
  105751. onDragEndObservable: Observable<{}>;
  105752. /**
  105753. * 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
  105754. */
  105755. constructor();
  105756. /**
  105757. * The name of the behavior
  105758. */
  105759. readonly name: string;
  105760. /**
  105761. * Initializes the behavior
  105762. */
  105763. init(): void;
  105764. /**
  105765. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105766. */
  105767. private readonly _pointerCamera;
  105768. /**
  105769. * Attaches the scale behavior the passed in mesh
  105770. * @param ownerNode The mesh that will be scaled around once attached
  105771. */
  105772. attach(ownerNode: Mesh): void;
  105773. /**
  105774. * Detaches the behavior from the mesh
  105775. */
  105776. detach(): void;
  105777. }
  105778. }
  105779. declare module BABYLON {
  105780. /**
  105781. * Class used to apply inverse kinematics to bones
  105782. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105783. */
  105784. export class BoneIKController {
  105785. private static _tmpVecs;
  105786. private static _tmpQuat;
  105787. private static _tmpMats;
  105788. /**
  105789. * Gets or sets the target mesh
  105790. */
  105791. targetMesh: AbstractMesh;
  105792. /** Gets or sets the mesh used as pole */
  105793. poleTargetMesh: AbstractMesh;
  105794. /**
  105795. * Gets or sets the bone used as pole
  105796. */
  105797. poleTargetBone: Nullable<Bone>;
  105798. /**
  105799. * Gets or sets the target position
  105800. */
  105801. targetPosition: Vector3;
  105802. /**
  105803. * Gets or sets the pole target position
  105804. */
  105805. poleTargetPosition: Vector3;
  105806. /**
  105807. * Gets or sets the pole target local offset
  105808. */
  105809. poleTargetLocalOffset: Vector3;
  105810. /**
  105811. * Gets or sets the pole angle
  105812. */
  105813. poleAngle: number;
  105814. /**
  105815. * Gets or sets the mesh associated with the controller
  105816. */
  105817. mesh: AbstractMesh;
  105818. /**
  105819. * 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)
  105820. */
  105821. slerpAmount: number;
  105822. private _bone1Quat;
  105823. private _bone1Mat;
  105824. private _bone2Ang;
  105825. private _bone1;
  105826. private _bone2;
  105827. private _bone1Length;
  105828. private _bone2Length;
  105829. private _maxAngle;
  105830. private _maxReach;
  105831. private _rightHandedSystem;
  105832. private _bendAxis;
  105833. private _slerping;
  105834. private _adjustRoll;
  105835. /**
  105836. * Gets or sets maximum allowed angle
  105837. */
  105838. maxAngle: number;
  105839. /**
  105840. * Creates a new BoneIKController
  105841. * @param mesh defines the mesh to control
  105842. * @param bone defines the bone to control
  105843. * @param options defines options to set up the controller
  105844. */
  105845. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105846. targetMesh?: AbstractMesh;
  105847. poleTargetMesh?: AbstractMesh;
  105848. poleTargetBone?: Bone;
  105849. poleTargetLocalOffset?: Vector3;
  105850. poleAngle?: number;
  105851. bendAxis?: Vector3;
  105852. maxAngle?: number;
  105853. slerpAmount?: number;
  105854. });
  105855. private _setMaxAngle;
  105856. /**
  105857. * Force the controller to update the bones
  105858. */
  105859. update(): void;
  105860. }
  105861. }
  105862. declare module BABYLON {
  105863. /**
  105864. * Class used to make a bone look toward a point in space
  105865. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105866. */
  105867. export class BoneLookController {
  105868. private static _tmpVecs;
  105869. private static _tmpQuat;
  105870. private static _tmpMats;
  105871. /**
  105872. * The target Vector3 that the bone will look at
  105873. */
  105874. target: Vector3;
  105875. /**
  105876. * The mesh that the bone is attached to
  105877. */
  105878. mesh: AbstractMesh;
  105879. /**
  105880. * The bone that will be looking to the target
  105881. */
  105882. bone: Bone;
  105883. /**
  105884. * The up axis of the coordinate system that is used when the bone is rotated
  105885. */
  105886. upAxis: Vector3;
  105887. /**
  105888. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105889. */
  105890. upAxisSpace: Space;
  105891. /**
  105892. * Used to make an adjustment to the yaw of the bone
  105893. */
  105894. adjustYaw: number;
  105895. /**
  105896. * Used to make an adjustment to the pitch of the bone
  105897. */
  105898. adjustPitch: number;
  105899. /**
  105900. * Used to make an adjustment to the roll of the bone
  105901. */
  105902. adjustRoll: number;
  105903. /**
  105904. * 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)
  105905. */
  105906. slerpAmount: number;
  105907. private _minYaw;
  105908. private _maxYaw;
  105909. private _minPitch;
  105910. private _maxPitch;
  105911. private _minYawSin;
  105912. private _minYawCos;
  105913. private _maxYawSin;
  105914. private _maxYawCos;
  105915. private _midYawConstraint;
  105916. private _minPitchTan;
  105917. private _maxPitchTan;
  105918. private _boneQuat;
  105919. private _slerping;
  105920. private _transformYawPitch;
  105921. private _transformYawPitchInv;
  105922. private _firstFrameSkipped;
  105923. private _yawRange;
  105924. private _fowardAxis;
  105925. /**
  105926. * Gets or sets the minimum yaw angle that the bone can look to
  105927. */
  105928. minYaw: number;
  105929. /**
  105930. * Gets or sets the maximum yaw angle that the bone can look to
  105931. */
  105932. maxYaw: number;
  105933. /**
  105934. * Gets or sets the minimum pitch angle that the bone can look to
  105935. */
  105936. minPitch: number;
  105937. /**
  105938. * Gets or sets the maximum pitch angle that the bone can look to
  105939. */
  105940. maxPitch: number;
  105941. /**
  105942. * Create a BoneLookController
  105943. * @param mesh the mesh that the bone belongs to
  105944. * @param bone the bone that will be looking to the target
  105945. * @param target the target Vector3 to look at
  105946. * @param options optional settings:
  105947. * * maxYaw: the maximum angle the bone will yaw to
  105948. * * minYaw: the minimum angle the bone will yaw to
  105949. * * maxPitch: the maximum angle the bone will pitch to
  105950. * * minPitch: the minimum angle the bone will yaw to
  105951. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105952. * * upAxis: the up axis of the coordinate system
  105953. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105954. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105955. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105956. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105957. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105958. * * adjustRoll: used to make an adjustment to the roll of the bone
  105959. **/
  105960. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105961. maxYaw?: number;
  105962. minYaw?: number;
  105963. maxPitch?: number;
  105964. minPitch?: number;
  105965. slerpAmount?: number;
  105966. upAxis?: Vector3;
  105967. upAxisSpace?: Space;
  105968. yawAxis?: Vector3;
  105969. pitchAxis?: Vector3;
  105970. adjustYaw?: number;
  105971. adjustPitch?: number;
  105972. adjustRoll?: number;
  105973. });
  105974. /**
  105975. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105976. */
  105977. update(): void;
  105978. private _getAngleDiff;
  105979. private _getAngleBetween;
  105980. private _isAngleBetween;
  105981. }
  105982. }
  105983. declare module BABYLON {
  105984. /**
  105985. * Manage the gamepad inputs to control an arc rotate camera.
  105986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105987. */
  105988. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105989. /**
  105990. * Defines the camera the input is attached to.
  105991. */
  105992. camera: ArcRotateCamera;
  105993. /**
  105994. * Defines the gamepad the input is gathering event from.
  105995. */
  105996. gamepad: Nullable<Gamepad>;
  105997. /**
  105998. * Defines the gamepad rotation sensiblity.
  105999. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106000. */
  106001. gamepadRotationSensibility: number;
  106002. /**
  106003. * Defines the gamepad move sensiblity.
  106004. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106005. */
  106006. gamepadMoveSensibility: number;
  106007. private _yAxisScale;
  106008. /**
  106009. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106010. */
  106011. invertYAxis: boolean;
  106012. private _onGamepadConnectedObserver;
  106013. private _onGamepadDisconnectedObserver;
  106014. /**
  106015. * Attach the input controls to a specific dom element to get the input from.
  106016. * @param element Defines the element the controls should be listened from
  106017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106018. */
  106019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106020. /**
  106021. * Detach the current controls from the specified dom element.
  106022. * @param element Defines the element to stop listening the inputs from
  106023. */
  106024. detachControl(element: Nullable<HTMLElement>): void;
  106025. /**
  106026. * Update the current camera state depending on the inputs that have been used this frame.
  106027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106028. */
  106029. checkInputs(): void;
  106030. /**
  106031. * Gets the class name of the current intput.
  106032. * @returns the class name
  106033. */
  106034. getClassName(): string;
  106035. /**
  106036. * Get the friendly name associated with the input class.
  106037. * @returns the input friendly name
  106038. */
  106039. getSimpleName(): string;
  106040. }
  106041. }
  106042. declare module BABYLON {
  106043. interface ArcRotateCameraInputsManager {
  106044. /**
  106045. * Add orientation input support to the input manager.
  106046. * @returns the current input manager
  106047. */
  106048. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106049. }
  106050. /**
  106051. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106053. */
  106054. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106055. /**
  106056. * Defines the camera the input is attached to.
  106057. */
  106058. camera: ArcRotateCamera;
  106059. /**
  106060. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106061. */
  106062. alphaCorrection: number;
  106063. /**
  106064. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106065. */
  106066. gammaCorrection: number;
  106067. private _alpha;
  106068. private _gamma;
  106069. private _dirty;
  106070. private _deviceOrientationHandler;
  106071. /**
  106072. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106073. */
  106074. constructor();
  106075. /**
  106076. * Attach the input controls to a specific dom element to get the input from.
  106077. * @param element Defines the element the controls should be listened from
  106078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106079. */
  106080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106081. /** @hidden */
  106082. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106083. /**
  106084. * Update the current camera state depending on the inputs that have been used this frame.
  106085. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106086. */
  106087. checkInputs(): void;
  106088. /**
  106089. * Detach the current controls from the specified dom element.
  106090. * @param element Defines the element to stop listening the inputs from
  106091. */
  106092. detachControl(element: Nullable<HTMLElement>): void;
  106093. /**
  106094. * Gets the class name of the current intput.
  106095. * @returns the class name
  106096. */
  106097. getClassName(): string;
  106098. /**
  106099. * Get the friendly name associated with the input class.
  106100. * @returns the input friendly name
  106101. */
  106102. getSimpleName(): string;
  106103. }
  106104. }
  106105. declare module BABYLON {
  106106. /**
  106107. * Listen to mouse events to control the camera.
  106108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106109. */
  106110. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106111. /**
  106112. * Defines the camera the input is attached to.
  106113. */
  106114. camera: FlyCamera;
  106115. /**
  106116. * Defines if touch is enabled. (Default is true.)
  106117. */
  106118. touchEnabled: boolean;
  106119. /**
  106120. * Defines the buttons associated with the input to handle camera rotation.
  106121. */
  106122. buttons: number[];
  106123. /**
  106124. * Assign buttons for Yaw control.
  106125. */
  106126. buttonsYaw: number[];
  106127. /**
  106128. * Assign buttons for Pitch control.
  106129. */
  106130. buttonsPitch: number[];
  106131. /**
  106132. * Assign buttons for Roll control.
  106133. */
  106134. buttonsRoll: number[];
  106135. /**
  106136. * Detect if any button is being pressed while mouse is moved.
  106137. * -1 = Mouse locked.
  106138. * 0 = Left button.
  106139. * 1 = Middle Button.
  106140. * 2 = Right Button.
  106141. */
  106142. activeButton: number;
  106143. /**
  106144. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106145. * Higher values reduce its sensitivity.
  106146. */
  106147. angularSensibility: number;
  106148. private _mousemoveCallback;
  106149. private _observer;
  106150. private _rollObserver;
  106151. private previousPosition;
  106152. private noPreventDefault;
  106153. private element;
  106154. /**
  106155. * Listen to mouse events to control the camera.
  106156. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106158. */
  106159. constructor(touchEnabled?: boolean);
  106160. /**
  106161. * Attach the mouse control to the HTML DOM element.
  106162. * @param element Defines the element that listens to the input events.
  106163. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106164. */
  106165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106166. /**
  106167. * Detach the current controls from the specified dom element.
  106168. * @param element Defines the element to stop listening the inputs from
  106169. */
  106170. detachControl(element: Nullable<HTMLElement>): void;
  106171. /**
  106172. * Gets the class name of the current input.
  106173. * @returns the class name.
  106174. */
  106175. getClassName(): string;
  106176. /**
  106177. * Get the friendly name associated with the input class.
  106178. * @returns the input's friendly name.
  106179. */
  106180. getSimpleName(): string;
  106181. private _pointerInput;
  106182. private _onMouseMove;
  106183. /**
  106184. * Rotate camera by mouse offset.
  106185. */
  106186. private rotateCamera;
  106187. }
  106188. }
  106189. declare module BABYLON {
  106190. /**
  106191. * Default Inputs manager for the FlyCamera.
  106192. * It groups all the default supported inputs for ease of use.
  106193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106194. */
  106195. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106196. /**
  106197. * Instantiates a new FlyCameraInputsManager.
  106198. * @param camera Defines the camera the inputs belong to.
  106199. */
  106200. constructor(camera: FlyCamera);
  106201. /**
  106202. * Add keyboard input support to the input manager.
  106203. * @returns the new FlyCameraKeyboardMoveInput().
  106204. */
  106205. addKeyboard(): FlyCameraInputsManager;
  106206. /**
  106207. * Add mouse input support to the input manager.
  106208. * @param touchEnabled Enable touch screen support.
  106209. * @returns the new FlyCameraMouseInput().
  106210. */
  106211. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106212. }
  106213. }
  106214. declare module BABYLON {
  106215. /**
  106216. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106217. * such as in a 3D Space Shooter or a Flight Simulator.
  106218. */
  106219. export class FlyCamera extends TargetCamera {
  106220. /**
  106221. * Define the collision ellipsoid of the camera.
  106222. * This is helpful for simulating a camera body, like a player's body.
  106223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106224. */
  106225. ellipsoid: Vector3;
  106226. /**
  106227. * Define an offset for the position of the ellipsoid around the camera.
  106228. * This can be helpful if the camera is attached away from the player's body center,
  106229. * such as at its head.
  106230. */
  106231. ellipsoidOffset: Vector3;
  106232. /**
  106233. * Enable or disable collisions of the camera with the rest of the scene objects.
  106234. */
  106235. checkCollisions: boolean;
  106236. /**
  106237. * Enable or disable gravity on the camera.
  106238. */
  106239. applyGravity: boolean;
  106240. /**
  106241. * Define the current direction the camera is moving to.
  106242. */
  106243. cameraDirection: Vector3;
  106244. /**
  106245. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106246. * This overrides and empties cameraRotation.
  106247. */
  106248. rotationQuaternion: Quaternion;
  106249. /**
  106250. * Track Roll to maintain the wanted Rolling when looking around.
  106251. */
  106252. _trackRoll: number;
  106253. /**
  106254. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106255. */
  106256. rollCorrect: number;
  106257. /**
  106258. * Mimic a banked turn, Rolling the camera when Yawing.
  106259. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106260. */
  106261. bankedTurn: boolean;
  106262. /**
  106263. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106264. */
  106265. bankedTurnLimit: number;
  106266. /**
  106267. * Value of 0 disables the banked Roll.
  106268. * Value of 1 is equal to the Yaw angle in radians.
  106269. */
  106270. bankedTurnMultiplier: number;
  106271. /**
  106272. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106273. */
  106274. inputs: FlyCameraInputsManager;
  106275. /**
  106276. * Gets the input sensibility for mouse input.
  106277. * Higher values reduce sensitivity.
  106278. */
  106279. /**
  106280. * Sets the input sensibility for a mouse input.
  106281. * Higher values reduce sensitivity.
  106282. */
  106283. angularSensibility: number;
  106284. /**
  106285. * Get the keys for camera movement forward.
  106286. */
  106287. /**
  106288. * Set the keys for camera movement forward.
  106289. */
  106290. keysForward: number[];
  106291. /**
  106292. * Get the keys for camera movement backward.
  106293. */
  106294. keysBackward: number[];
  106295. /**
  106296. * Get the keys for camera movement up.
  106297. */
  106298. /**
  106299. * Set the keys for camera movement up.
  106300. */
  106301. keysUp: number[];
  106302. /**
  106303. * Get the keys for camera movement down.
  106304. */
  106305. /**
  106306. * Set the keys for camera movement down.
  106307. */
  106308. keysDown: number[];
  106309. /**
  106310. * Get the keys for camera movement left.
  106311. */
  106312. /**
  106313. * Set the keys for camera movement left.
  106314. */
  106315. keysLeft: number[];
  106316. /**
  106317. * Set the keys for camera movement right.
  106318. */
  106319. /**
  106320. * Set the keys for camera movement right.
  106321. */
  106322. keysRight: number[];
  106323. /**
  106324. * Event raised when the camera collides with a mesh in the scene.
  106325. */
  106326. onCollide: (collidedMesh: AbstractMesh) => void;
  106327. private _collider;
  106328. private _needMoveForGravity;
  106329. private _oldPosition;
  106330. private _diffPosition;
  106331. private _newPosition;
  106332. /** @hidden */
  106333. _localDirection: Vector3;
  106334. /** @hidden */
  106335. _transformedDirection: Vector3;
  106336. /**
  106337. * Instantiates a FlyCamera.
  106338. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106339. * such as in a 3D Space Shooter or a Flight Simulator.
  106340. * @param name Define the name of the camera in the scene.
  106341. * @param position Define the starting position of the camera in the scene.
  106342. * @param scene Define the scene the camera belongs to.
  106343. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106344. */
  106345. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106346. /**
  106347. * Attach a control to the HTML DOM element.
  106348. * @param element Defines the element that listens to the input events.
  106349. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106350. */
  106351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106352. /**
  106353. * Detach a control from the HTML DOM element.
  106354. * The camera will stop reacting to that input.
  106355. * @param element Defines the element that listens to the input events.
  106356. */
  106357. detachControl(element: HTMLElement): void;
  106358. private _collisionMask;
  106359. /**
  106360. * Get the mask that the camera ignores in collision events.
  106361. */
  106362. /**
  106363. * Set the mask that the camera ignores in collision events.
  106364. */
  106365. collisionMask: number;
  106366. /** @hidden */
  106367. _collideWithWorld(displacement: Vector3): void;
  106368. /** @hidden */
  106369. private _onCollisionPositionChange;
  106370. /** @hidden */
  106371. _checkInputs(): void;
  106372. /** @hidden */
  106373. _decideIfNeedsToMove(): boolean;
  106374. /** @hidden */
  106375. _updatePosition(): void;
  106376. /**
  106377. * Restore the Roll to its target value at the rate specified.
  106378. * @param rate - Higher means slower restoring.
  106379. * @hidden
  106380. */
  106381. restoreRoll(rate: number): void;
  106382. /**
  106383. * Destroy the camera and release the current resources held by it.
  106384. */
  106385. dispose(): void;
  106386. /**
  106387. * Get the current object class name.
  106388. * @returns the class name.
  106389. */
  106390. getClassName(): string;
  106391. }
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * Listen to keyboard events to control the camera.
  106396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106397. */
  106398. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106399. /**
  106400. * Defines the camera the input is attached to.
  106401. */
  106402. camera: FlyCamera;
  106403. /**
  106404. * The list of keyboard keys used to control the forward move of the camera.
  106405. */
  106406. keysForward: number[];
  106407. /**
  106408. * The list of keyboard keys used to control the backward move of the camera.
  106409. */
  106410. keysBackward: number[];
  106411. /**
  106412. * The list of keyboard keys used to control the forward move of the camera.
  106413. */
  106414. keysUp: number[];
  106415. /**
  106416. * The list of keyboard keys used to control the backward move of the camera.
  106417. */
  106418. keysDown: number[];
  106419. /**
  106420. * The list of keyboard keys used to control the right strafe move of the camera.
  106421. */
  106422. keysRight: number[];
  106423. /**
  106424. * The list of keyboard keys used to control the left strafe move of the camera.
  106425. */
  106426. keysLeft: number[];
  106427. private _keys;
  106428. private _onCanvasBlurObserver;
  106429. private _onKeyboardObserver;
  106430. private _engine;
  106431. private _scene;
  106432. /**
  106433. * Attach the input controls to a specific dom element to get the input from.
  106434. * @param element Defines the element the controls should be listened from
  106435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106436. */
  106437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106438. /**
  106439. * Detach the current controls from the specified dom element.
  106440. * @param element Defines the element to stop listening the inputs from
  106441. */
  106442. detachControl(element: Nullable<HTMLElement>): void;
  106443. /**
  106444. * Gets the class name of the current intput.
  106445. * @returns the class name
  106446. */
  106447. getClassName(): string;
  106448. /** @hidden */
  106449. _onLostFocus(e: FocusEvent): void;
  106450. /**
  106451. * Get the friendly name associated with the input class.
  106452. * @returns the input friendly name
  106453. */
  106454. getSimpleName(): string;
  106455. /**
  106456. * Update the current camera state depending on the inputs that have been used this frame.
  106457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106458. */
  106459. checkInputs(): void;
  106460. }
  106461. }
  106462. declare module BABYLON {
  106463. /**
  106464. * Manage the mouse wheel inputs to control a follow camera.
  106465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106466. */
  106467. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106468. /**
  106469. * Defines the camera the input is attached to.
  106470. */
  106471. camera: FollowCamera;
  106472. /**
  106473. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106474. */
  106475. axisControlRadius: boolean;
  106476. /**
  106477. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106478. */
  106479. axisControlHeight: boolean;
  106480. /**
  106481. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106482. */
  106483. axisControlRotation: boolean;
  106484. /**
  106485. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106486. * relation to mouseWheel events.
  106487. */
  106488. wheelPrecision: number;
  106489. /**
  106490. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106491. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106492. */
  106493. wheelDeltaPercentage: number;
  106494. private _wheel;
  106495. private _observer;
  106496. /**
  106497. * Attach the input controls to a specific dom element to get the input from.
  106498. * @param element Defines the element the controls should be listened from
  106499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106500. */
  106501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106502. /**
  106503. * Detach the current controls from the specified dom element.
  106504. * @param element Defines the element to stop listening the inputs from
  106505. */
  106506. detachControl(element: Nullable<HTMLElement>): void;
  106507. /**
  106508. * Gets the class name of the current intput.
  106509. * @returns the class name
  106510. */
  106511. getClassName(): string;
  106512. /**
  106513. * Get the friendly name associated with the input class.
  106514. * @returns the input friendly name
  106515. */
  106516. getSimpleName(): string;
  106517. }
  106518. }
  106519. declare module BABYLON {
  106520. /**
  106521. * Manage the pointers inputs to control an follow camera.
  106522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106523. */
  106524. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106525. /**
  106526. * Defines the camera the input is attached to.
  106527. */
  106528. camera: FollowCamera;
  106529. /**
  106530. * Gets the class name of the current input.
  106531. * @returns the class name
  106532. */
  106533. getClassName(): string;
  106534. /**
  106535. * Defines the pointer angular sensibility along the X axis or how fast is
  106536. * the camera rotating.
  106537. * A negative number will reverse the axis direction.
  106538. */
  106539. angularSensibilityX: number;
  106540. /**
  106541. * Defines the pointer angular sensibility along the Y axis or how fast is
  106542. * the camera rotating.
  106543. * A negative number will reverse the axis direction.
  106544. */
  106545. angularSensibilityY: number;
  106546. /**
  106547. * Defines the pointer pinch precision or how fast is the camera zooming.
  106548. * A negative number will reverse the axis direction.
  106549. */
  106550. pinchPrecision: number;
  106551. /**
  106552. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106553. * from 0.
  106554. * It defines the percentage of current camera.radius to use as delta when
  106555. * pinch zoom is used.
  106556. */
  106557. pinchDeltaPercentage: number;
  106558. /**
  106559. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106560. */
  106561. axisXControlRadius: boolean;
  106562. /**
  106563. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106564. */
  106565. axisXControlHeight: boolean;
  106566. /**
  106567. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106568. */
  106569. axisXControlRotation: boolean;
  106570. /**
  106571. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106572. */
  106573. axisYControlRadius: boolean;
  106574. /**
  106575. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106576. */
  106577. axisYControlHeight: boolean;
  106578. /**
  106579. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106580. */
  106581. axisYControlRotation: boolean;
  106582. /**
  106583. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106584. */
  106585. axisPinchControlRadius: boolean;
  106586. /**
  106587. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106588. */
  106589. axisPinchControlHeight: boolean;
  106590. /**
  106591. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106592. */
  106593. axisPinchControlRotation: boolean;
  106594. /**
  106595. * Log error messages if basic misconfiguration has occurred.
  106596. */
  106597. warningEnable: boolean;
  106598. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106599. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106600. private _warningCounter;
  106601. private _warning;
  106602. }
  106603. }
  106604. declare module BABYLON {
  106605. /**
  106606. * Default Inputs manager for the FollowCamera.
  106607. * It groups all the default supported inputs for ease of use.
  106608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106609. */
  106610. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106611. /**
  106612. * Instantiates a new FollowCameraInputsManager.
  106613. * @param camera Defines the camera the inputs belong to
  106614. */
  106615. constructor(camera: FollowCamera);
  106616. /**
  106617. * Add keyboard input support to the input manager.
  106618. * @returns the current input manager
  106619. */
  106620. addKeyboard(): FollowCameraInputsManager;
  106621. /**
  106622. * Add mouse wheel input support to the input manager.
  106623. * @returns the current input manager
  106624. */
  106625. addMouseWheel(): FollowCameraInputsManager;
  106626. /**
  106627. * Add pointers input support to the input manager.
  106628. * @returns the current input manager
  106629. */
  106630. addPointers(): FollowCameraInputsManager;
  106631. /**
  106632. * Add orientation input support to the input manager.
  106633. * @returns the current input manager
  106634. */
  106635. addVRDeviceOrientation(): FollowCameraInputsManager;
  106636. }
  106637. }
  106638. declare module BABYLON {
  106639. /**
  106640. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106641. * an arc rotate version arcFollowCamera are available.
  106642. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106643. */
  106644. export class FollowCamera extends TargetCamera {
  106645. /**
  106646. * Distance the follow camera should follow an object at
  106647. */
  106648. radius: number;
  106649. /**
  106650. * Minimum allowed distance of the camera to the axis of rotation
  106651. * (The camera can not get closer).
  106652. * This can help limiting how the Camera is able to move in the scene.
  106653. */
  106654. lowerRadiusLimit: Nullable<number>;
  106655. /**
  106656. * Maximum allowed distance of the camera to the axis of rotation
  106657. * (The camera can not get further).
  106658. * This can help limiting how the Camera is able to move in the scene.
  106659. */
  106660. upperRadiusLimit: Nullable<number>;
  106661. /**
  106662. * Define a rotation offset between the camera and the object it follows
  106663. */
  106664. rotationOffset: number;
  106665. /**
  106666. * Minimum allowed angle to camera position relative to target object.
  106667. * This can help limiting how the Camera is able to move in the scene.
  106668. */
  106669. lowerRotationOffsetLimit: Nullable<number>;
  106670. /**
  106671. * Maximum allowed angle to camera position relative to target object.
  106672. * This can help limiting how the Camera is able to move in the scene.
  106673. */
  106674. upperRotationOffsetLimit: Nullable<number>;
  106675. /**
  106676. * Define a height offset between the camera and the object it follows.
  106677. * It can help following an object from the top (like a car chaing a plane)
  106678. */
  106679. heightOffset: number;
  106680. /**
  106681. * Minimum allowed height of camera position relative to target object.
  106682. * This can help limiting how the Camera is able to move in the scene.
  106683. */
  106684. lowerHeightOffsetLimit: Nullable<number>;
  106685. /**
  106686. * Maximum allowed height of camera position relative to target object.
  106687. * This can help limiting how the Camera is able to move in the scene.
  106688. */
  106689. upperHeightOffsetLimit: Nullable<number>;
  106690. /**
  106691. * Define how fast the camera can accelerate to follow it s target.
  106692. */
  106693. cameraAcceleration: number;
  106694. /**
  106695. * Define the speed limit of the camera following an object.
  106696. */
  106697. maxCameraSpeed: number;
  106698. /**
  106699. * Define the target of the camera.
  106700. */
  106701. lockedTarget: Nullable<AbstractMesh>;
  106702. /**
  106703. * Defines the input associated with the camera.
  106704. */
  106705. inputs: FollowCameraInputsManager;
  106706. /**
  106707. * Instantiates the follow camera.
  106708. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106709. * @param name Define the name of the camera in the scene
  106710. * @param position Define the position of the camera
  106711. * @param scene Define the scene the camera belong to
  106712. * @param lockedTarget Define the target of the camera
  106713. */
  106714. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106715. private _follow;
  106716. /**
  106717. * Attached controls to the current camera.
  106718. * @param element Defines the element the controls should be listened from
  106719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106720. */
  106721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106722. /**
  106723. * Detach the current controls from the camera.
  106724. * The camera will stop reacting to inputs.
  106725. * @param element Defines the element to stop listening the inputs from
  106726. */
  106727. detachControl(element: HTMLElement): void;
  106728. /** @hidden */
  106729. _checkInputs(): void;
  106730. private _checkLimits;
  106731. /**
  106732. * Gets the camera class name.
  106733. * @returns the class name
  106734. */
  106735. getClassName(): string;
  106736. }
  106737. /**
  106738. * Arc Rotate version of the follow camera.
  106739. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106740. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106741. */
  106742. export class ArcFollowCamera extends TargetCamera {
  106743. /** The longitudinal angle of the camera */
  106744. alpha: number;
  106745. /** The latitudinal angle of the camera */
  106746. beta: number;
  106747. /** The radius of the camera from its target */
  106748. radius: number;
  106749. /** Define the camera target (the messh it should follow) */
  106750. target: Nullable<AbstractMesh>;
  106751. private _cartesianCoordinates;
  106752. /**
  106753. * Instantiates a new ArcFollowCamera
  106754. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106755. * @param name Define the name of the camera
  106756. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106757. * @param beta Define the rotation angle of the camera around the elevation axis
  106758. * @param radius Define the radius of the camera from its target point
  106759. * @param target Define the target of the camera
  106760. * @param scene Define the scene the camera belongs to
  106761. */
  106762. constructor(name: string,
  106763. /** The longitudinal angle of the camera */
  106764. alpha: number,
  106765. /** The latitudinal angle of the camera */
  106766. beta: number,
  106767. /** The radius of the camera from its target */
  106768. radius: number,
  106769. /** Define the camera target (the messh it should follow) */
  106770. target: Nullable<AbstractMesh>, scene: Scene);
  106771. private _follow;
  106772. /** @hidden */
  106773. _checkInputs(): void;
  106774. /**
  106775. * Returns the class name of the object.
  106776. * It is mostly used internally for serialization purposes.
  106777. */
  106778. getClassName(): string;
  106779. }
  106780. }
  106781. declare module BABYLON {
  106782. /**
  106783. * Manage the keyboard inputs to control the movement of a follow camera.
  106784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106785. */
  106786. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106787. /**
  106788. * Defines the camera the input is attached to.
  106789. */
  106790. camera: FollowCamera;
  106791. /**
  106792. * Defines the list of key codes associated with the up action (increase heightOffset)
  106793. */
  106794. keysHeightOffsetIncr: number[];
  106795. /**
  106796. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106797. */
  106798. keysHeightOffsetDecr: number[];
  106799. /**
  106800. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106801. */
  106802. keysHeightOffsetModifierAlt: boolean;
  106803. /**
  106804. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106805. */
  106806. keysHeightOffsetModifierCtrl: boolean;
  106807. /**
  106808. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106809. */
  106810. keysHeightOffsetModifierShift: boolean;
  106811. /**
  106812. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106813. */
  106814. keysRotationOffsetIncr: number[];
  106815. /**
  106816. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106817. */
  106818. keysRotationOffsetDecr: number[];
  106819. /**
  106820. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106821. */
  106822. keysRotationOffsetModifierAlt: boolean;
  106823. /**
  106824. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106825. */
  106826. keysRotationOffsetModifierCtrl: boolean;
  106827. /**
  106828. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106829. */
  106830. keysRotationOffsetModifierShift: boolean;
  106831. /**
  106832. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106833. */
  106834. keysRadiusIncr: number[];
  106835. /**
  106836. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106837. */
  106838. keysRadiusDecr: number[];
  106839. /**
  106840. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106841. */
  106842. keysRadiusModifierAlt: boolean;
  106843. /**
  106844. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106845. */
  106846. keysRadiusModifierCtrl: boolean;
  106847. /**
  106848. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106849. */
  106850. keysRadiusModifierShift: boolean;
  106851. /**
  106852. * Defines the rate of change of heightOffset.
  106853. */
  106854. heightSensibility: number;
  106855. /**
  106856. * Defines the rate of change of rotationOffset.
  106857. */
  106858. rotationSensibility: number;
  106859. /**
  106860. * Defines the rate of change of radius.
  106861. */
  106862. radiusSensibility: number;
  106863. private _keys;
  106864. private _ctrlPressed;
  106865. private _altPressed;
  106866. private _shiftPressed;
  106867. private _onCanvasBlurObserver;
  106868. private _onKeyboardObserver;
  106869. private _engine;
  106870. private _scene;
  106871. /**
  106872. * Attach the input controls to a specific dom element to get the input from.
  106873. * @param element Defines the element the controls should be listened from
  106874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106875. */
  106876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106877. /**
  106878. * Detach the current controls from the specified dom element.
  106879. * @param element Defines the element to stop listening the inputs from
  106880. */
  106881. detachControl(element: Nullable<HTMLElement>): void;
  106882. /**
  106883. * Update the current camera state depending on the inputs that have been used this frame.
  106884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106885. */
  106886. checkInputs(): void;
  106887. /**
  106888. * Gets the class name of the current input.
  106889. * @returns the class name
  106890. */
  106891. getClassName(): string;
  106892. /**
  106893. * Get the friendly name associated with the input class.
  106894. * @returns the input friendly name
  106895. */
  106896. getSimpleName(): string;
  106897. /**
  106898. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106899. * allow modification of the heightOffset value.
  106900. */
  106901. private _modifierHeightOffset;
  106902. /**
  106903. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106904. * allow modification of the rotationOffset value.
  106905. */
  106906. private _modifierRotationOffset;
  106907. /**
  106908. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106909. * allow modification of the radius value.
  106910. */
  106911. private _modifierRadius;
  106912. }
  106913. }
  106914. declare module BABYLON {
  106915. interface FreeCameraInputsManager {
  106916. /**
  106917. * @hidden
  106918. */
  106919. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106920. /**
  106921. * Add orientation input support to the input manager.
  106922. * @returns the current input manager
  106923. */
  106924. addDeviceOrientation(): FreeCameraInputsManager;
  106925. }
  106926. /**
  106927. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106928. * Screen rotation is taken into account.
  106929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106930. */
  106931. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106932. private _camera;
  106933. private _screenOrientationAngle;
  106934. private _constantTranform;
  106935. private _screenQuaternion;
  106936. private _alpha;
  106937. private _beta;
  106938. private _gamma;
  106939. /**
  106940. * Can be used to detect if a device orientation sensor is availible on a device
  106941. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106942. * @returns a promise that will resolve on orientation change
  106943. */
  106944. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106945. /**
  106946. * @hidden
  106947. */
  106948. _onDeviceOrientationChangedObservable: Observable<void>;
  106949. /**
  106950. * Instantiates a new input
  106951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106952. */
  106953. constructor();
  106954. /**
  106955. * Define the camera controlled by the input.
  106956. */
  106957. camera: FreeCamera;
  106958. /**
  106959. * Attach the input controls to a specific dom element to get the input from.
  106960. * @param element Defines the element the controls should be listened from
  106961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106962. */
  106963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106964. private _orientationChanged;
  106965. private _deviceOrientation;
  106966. /**
  106967. * Detach the current controls from the specified dom element.
  106968. * @param element Defines the element to stop listening the inputs from
  106969. */
  106970. detachControl(element: Nullable<HTMLElement>): void;
  106971. /**
  106972. * Update the current camera state depending on the inputs that have been used this frame.
  106973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106974. */
  106975. checkInputs(): void;
  106976. /**
  106977. * Gets the class name of the current intput.
  106978. * @returns the class name
  106979. */
  106980. getClassName(): string;
  106981. /**
  106982. * Get the friendly name associated with the input class.
  106983. * @returns the input friendly name
  106984. */
  106985. getSimpleName(): string;
  106986. }
  106987. }
  106988. declare module BABYLON {
  106989. /**
  106990. * Manage the gamepad inputs to control a free camera.
  106991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106992. */
  106993. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106994. /**
  106995. * Define the camera the input is attached to.
  106996. */
  106997. camera: FreeCamera;
  106998. /**
  106999. * Define the Gamepad controlling the input
  107000. */
  107001. gamepad: Nullable<Gamepad>;
  107002. /**
  107003. * Defines the gamepad rotation sensiblity.
  107004. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107005. */
  107006. gamepadAngularSensibility: number;
  107007. /**
  107008. * Defines the gamepad move sensiblity.
  107009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107010. */
  107011. gamepadMoveSensibility: number;
  107012. private _yAxisScale;
  107013. /**
  107014. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107015. */
  107016. invertYAxis: boolean;
  107017. private _onGamepadConnectedObserver;
  107018. private _onGamepadDisconnectedObserver;
  107019. private _cameraTransform;
  107020. private _deltaTransform;
  107021. private _vector3;
  107022. private _vector2;
  107023. /**
  107024. * Attach the input controls to a specific dom element to get the input from.
  107025. * @param element Defines the element the controls should be listened from
  107026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107027. */
  107028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107029. /**
  107030. * Detach the current controls from the specified dom element.
  107031. * @param element Defines the element to stop listening the inputs from
  107032. */
  107033. detachControl(element: Nullable<HTMLElement>): void;
  107034. /**
  107035. * Update the current camera state depending on the inputs that have been used this frame.
  107036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107037. */
  107038. checkInputs(): void;
  107039. /**
  107040. * Gets the class name of the current intput.
  107041. * @returns the class name
  107042. */
  107043. getClassName(): string;
  107044. /**
  107045. * Get the friendly name associated with the input class.
  107046. * @returns the input friendly name
  107047. */
  107048. getSimpleName(): string;
  107049. }
  107050. }
  107051. declare module BABYLON {
  107052. /**
  107053. * Defines the potential axis of a Joystick
  107054. */
  107055. export enum JoystickAxis {
  107056. /** X axis */
  107057. X = 0,
  107058. /** Y axis */
  107059. Y = 1,
  107060. /** Z axis */
  107061. Z = 2
  107062. }
  107063. /**
  107064. * Class used to define virtual joystick (used in touch mode)
  107065. */
  107066. export class VirtualJoystick {
  107067. /**
  107068. * Gets or sets a boolean indicating that left and right values must be inverted
  107069. */
  107070. reverseLeftRight: boolean;
  107071. /**
  107072. * Gets or sets a boolean indicating that up and down values must be inverted
  107073. */
  107074. reverseUpDown: boolean;
  107075. /**
  107076. * Gets the offset value for the position (ie. the change of the position value)
  107077. */
  107078. deltaPosition: Vector3;
  107079. /**
  107080. * Gets a boolean indicating if the virtual joystick was pressed
  107081. */
  107082. pressed: boolean;
  107083. /**
  107084. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107085. */
  107086. static Canvas: Nullable<HTMLCanvasElement>;
  107087. private static _globalJoystickIndex;
  107088. private static vjCanvasContext;
  107089. private static vjCanvasWidth;
  107090. private static vjCanvasHeight;
  107091. private static halfWidth;
  107092. private _action;
  107093. private _axisTargetedByLeftAndRight;
  107094. private _axisTargetedByUpAndDown;
  107095. private _joystickSensibility;
  107096. private _inversedSensibility;
  107097. private _joystickPointerID;
  107098. private _joystickColor;
  107099. private _joystickPointerPos;
  107100. private _joystickPreviousPointerPos;
  107101. private _joystickPointerStartPos;
  107102. private _deltaJoystickVector;
  107103. private _leftJoystick;
  107104. private _touches;
  107105. private _onPointerDownHandlerRef;
  107106. private _onPointerMoveHandlerRef;
  107107. private _onPointerUpHandlerRef;
  107108. private _onResize;
  107109. /**
  107110. * Creates a new virtual joystick
  107111. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107112. */
  107113. constructor(leftJoystick?: boolean);
  107114. /**
  107115. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107116. * @param newJoystickSensibility defines the new sensibility
  107117. */
  107118. setJoystickSensibility(newJoystickSensibility: number): void;
  107119. private _onPointerDown;
  107120. private _onPointerMove;
  107121. private _onPointerUp;
  107122. /**
  107123. * Change the color of the virtual joystick
  107124. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107125. */
  107126. setJoystickColor(newColor: string): void;
  107127. /**
  107128. * Defines a callback to call when the joystick is touched
  107129. * @param action defines the callback
  107130. */
  107131. setActionOnTouch(action: () => any): void;
  107132. /**
  107133. * Defines which axis you'd like to control for left & right
  107134. * @param axis defines the axis to use
  107135. */
  107136. setAxisForLeftRight(axis: JoystickAxis): void;
  107137. /**
  107138. * Defines which axis you'd like to control for up & down
  107139. * @param axis defines the axis to use
  107140. */
  107141. setAxisForUpDown(axis: JoystickAxis): void;
  107142. private _drawVirtualJoystick;
  107143. /**
  107144. * Release internal HTML canvas
  107145. */
  107146. releaseCanvas(): void;
  107147. }
  107148. }
  107149. declare module BABYLON {
  107150. interface FreeCameraInputsManager {
  107151. /**
  107152. * Add virtual joystick input support to the input manager.
  107153. * @returns the current input manager
  107154. */
  107155. addVirtualJoystick(): FreeCameraInputsManager;
  107156. }
  107157. /**
  107158. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107160. */
  107161. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107162. /**
  107163. * Defines the camera the input is attached to.
  107164. */
  107165. camera: FreeCamera;
  107166. private _leftjoystick;
  107167. private _rightjoystick;
  107168. /**
  107169. * Gets the left stick of the virtual joystick.
  107170. * @returns The virtual Joystick
  107171. */
  107172. getLeftJoystick(): VirtualJoystick;
  107173. /**
  107174. * Gets the right stick of the virtual joystick.
  107175. * @returns The virtual Joystick
  107176. */
  107177. getRightJoystick(): VirtualJoystick;
  107178. /**
  107179. * Update the current camera state depending on the inputs that have been used this frame.
  107180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107181. */
  107182. checkInputs(): void;
  107183. /**
  107184. * Attach the input controls to a specific dom element to get the input from.
  107185. * @param element Defines the element the controls should be listened from
  107186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107187. */
  107188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107189. /**
  107190. * Detach the current controls from the specified dom element.
  107191. * @param element Defines the element to stop listening the inputs from
  107192. */
  107193. detachControl(element: Nullable<HTMLElement>): void;
  107194. /**
  107195. * Gets the class name of the current intput.
  107196. * @returns the class name
  107197. */
  107198. getClassName(): string;
  107199. /**
  107200. * Get the friendly name associated with the input class.
  107201. * @returns the input friendly name
  107202. */
  107203. getSimpleName(): string;
  107204. }
  107205. }
  107206. declare module BABYLON {
  107207. /**
  107208. * This represents a FPS type of camera controlled by touch.
  107209. * This is like a universal camera minus the Gamepad controls.
  107210. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107211. */
  107212. export class TouchCamera extends FreeCamera {
  107213. /**
  107214. * Defines the touch sensibility for rotation.
  107215. * The higher the faster.
  107216. */
  107217. touchAngularSensibility: number;
  107218. /**
  107219. * Defines the touch sensibility for move.
  107220. * The higher the faster.
  107221. */
  107222. touchMoveSensibility: number;
  107223. /**
  107224. * Instantiates a new touch camera.
  107225. * This represents a FPS type of camera controlled by touch.
  107226. * This is like a universal camera minus the Gamepad controls.
  107227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107228. * @param name Define the name of the camera in the scene
  107229. * @param position Define the start position of the camera in the scene
  107230. * @param scene Define the scene the camera belongs to
  107231. */
  107232. constructor(name: string, position: Vector3, scene: Scene);
  107233. /**
  107234. * Gets the current object class name.
  107235. * @return the class name
  107236. */
  107237. getClassName(): string;
  107238. /** @hidden */
  107239. _setupInputs(): void;
  107240. }
  107241. }
  107242. declare module BABYLON {
  107243. /**
  107244. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107245. * being tilted forward or back and left or right.
  107246. */
  107247. export class DeviceOrientationCamera extends FreeCamera {
  107248. private _initialQuaternion;
  107249. private _quaternionCache;
  107250. private _tmpDragQuaternion;
  107251. private _disablePointerInputWhenUsingDeviceOrientation;
  107252. /**
  107253. * Creates a new device orientation camera
  107254. * @param name The name of the camera
  107255. * @param position The start position camera
  107256. * @param scene The scene the camera belongs to
  107257. */
  107258. constructor(name: string, position: Vector3, scene: Scene);
  107259. /**
  107260. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107261. */
  107262. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107263. private _dragFactor;
  107264. /**
  107265. * Enabled turning on the y axis when the orientation sensor is active
  107266. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107267. */
  107268. enableHorizontalDragging(dragFactor?: number): void;
  107269. /**
  107270. * Gets the current instance class name ("DeviceOrientationCamera").
  107271. * This helps avoiding instanceof at run time.
  107272. * @returns the class name
  107273. */
  107274. getClassName(): string;
  107275. /**
  107276. * @hidden
  107277. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107278. */
  107279. _checkInputs(): void;
  107280. /**
  107281. * Reset the camera to its default orientation on the specified axis only.
  107282. * @param axis The axis to reset
  107283. */
  107284. resetToCurrentRotation(axis?: Axis): void;
  107285. }
  107286. }
  107287. declare module BABYLON {
  107288. /**
  107289. * Defines supported buttons for XBox360 compatible gamepads
  107290. */
  107291. export enum Xbox360Button {
  107292. /** A */
  107293. A = 0,
  107294. /** B */
  107295. B = 1,
  107296. /** X */
  107297. X = 2,
  107298. /** Y */
  107299. Y = 3,
  107300. /** Start */
  107301. Start = 4,
  107302. /** Back */
  107303. Back = 5,
  107304. /** Left button */
  107305. LB = 6,
  107306. /** Right button */
  107307. RB = 7,
  107308. /** Left stick */
  107309. LeftStick = 8,
  107310. /** Right stick */
  107311. RightStick = 9
  107312. }
  107313. /** Defines values for XBox360 DPad */
  107314. export enum Xbox360Dpad {
  107315. /** Up */
  107316. Up = 0,
  107317. /** Down */
  107318. Down = 1,
  107319. /** Left */
  107320. Left = 2,
  107321. /** Right */
  107322. Right = 3
  107323. }
  107324. /**
  107325. * Defines a XBox360 gamepad
  107326. */
  107327. export class Xbox360Pad extends Gamepad {
  107328. private _leftTrigger;
  107329. private _rightTrigger;
  107330. private _onlefttriggerchanged;
  107331. private _onrighttriggerchanged;
  107332. private _onbuttondown;
  107333. private _onbuttonup;
  107334. private _ondpaddown;
  107335. private _ondpadup;
  107336. /** Observable raised when a button is pressed */
  107337. onButtonDownObservable: Observable<Xbox360Button>;
  107338. /** Observable raised when a button is released */
  107339. onButtonUpObservable: Observable<Xbox360Button>;
  107340. /** Observable raised when a pad is pressed */
  107341. onPadDownObservable: Observable<Xbox360Dpad>;
  107342. /** Observable raised when a pad is released */
  107343. onPadUpObservable: Observable<Xbox360Dpad>;
  107344. private _buttonA;
  107345. private _buttonB;
  107346. private _buttonX;
  107347. private _buttonY;
  107348. private _buttonBack;
  107349. private _buttonStart;
  107350. private _buttonLB;
  107351. private _buttonRB;
  107352. private _buttonLeftStick;
  107353. private _buttonRightStick;
  107354. private _dPadUp;
  107355. private _dPadDown;
  107356. private _dPadLeft;
  107357. private _dPadRight;
  107358. private _isXboxOnePad;
  107359. /**
  107360. * Creates a new XBox360 gamepad object
  107361. * @param id defines the id of this gamepad
  107362. * @param index defines its index
  107363. * @param gamepad defines the internal HTML gamepad object
  107364. * @param xboxOne defines if it is a XBox One gamepad
  107365. */
  107366. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107367. /**
  107368. * Defines the callback to call when left trigger is pressed
  107369. * @param callback defines the callback to use
  107370. */
  107371. onlefttriggerchanged(callback: (value: number) => void): void;
  107372. /**
  107373. * Defines the callback to call when right trigger is pressed
  107374. * @param callback defines the callback to use
  107375. */
  107376. onrighttriggerchanged(callback: (value: number) => void): void;
  107377. /**
  107378. * Gets the left trigger value
  107379. */
  107380. /**
  107381. * Sets the left trigger value
  107382. */
  107383. leftTrigger: number;
  107384. /**
  107385. * Gets the right trigger value
  107386. */
  107387. /**
  107388. * Sets the right trigger value
  107389. */
  107390. rightTrigger: number;
  107391. /**
  107392. * Defines the callback to call when a button is pressed
  107393. * @param callback defines the callback to use
  107394. */
  107395. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107396. /**
  107397. * Defines the callback to call when a button is released
  107398. * @param callback defines the callback to use
  107399. */
  107400. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107401. /**
  107402. * Defines the callback to call when a pad is pressed
  107403. * @param callback defines the callback to use
  107404. */
  107405. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107406. /**
  107407. * Defines the callback to call when a pad is released
  107408. * @param callback defines the callback to use
  107409. */
  107410. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107411. private _setButtonValue;
  107412. private _setDPadValue;
  107413. /**
  107414. * Gets the value of the `A` button
  107415. */
  107416. /**
  107417. * Sets the value of the `A` button
  107418. */
  107419. buttonA: number;
  107420. /**
  107421. * Gets the value of the `B` button
  107422. */
  107423. /**
  107424. * Sets the value of the `B` button
  107425. */
  107426. buttonB: number;
  107427. /**
  107428. * Gets the value of the `X` button
  107429. */
  107430. /**
  107431. * Sets the value of the `X` button
  107432. */
  107433. buttonX: number;
  107434. /**
  107435. * Gets the value of the `Y` button
  107436. */
  107437. /**
  107438. * Sets the value of the `Y` button
  107439. */
  107440. buttonY: number;
  107441. /**
  107442. * Gets the value of the `Start` button
  107443. */
  107444. /**
  107445. * Sets the value of the `Start` button
  107446. */
  107447. buttonStart: number;
  107448. /**
  107449. * Gets the value of the `Back` button
  107450. */
  107451. /**
  107452. * Sets the value of the `Back` button
  107453. */
  107454. buttonBack: number;
  107455. /**
  107456. * Gets the value of the `Left` button
  107457. */
  107458. /**
  107459. * Sets the value of the `Left` button
  107460. */
  107461. buttonLB: number;
  107462. /**
  107463. * Gets the value of the `Right` button
  107464. */
  107465. /**
  107466. * Sets the value of the `Right` button
  107467. */
  107468. buttonRB: number;
  107469. /**
  107470. * Gets the value of the Left joystick
  107471. */
  107472. /**
  107473. * Sets the value of the Left joystick
  107474. */
  107475. buttonLeftStick: number;
  107476. /**
  107477. * Gets the value of the Right joystick
  107478. */
  107479. /**
  107480. * Sets the value of the Right joystick
  107481. */
  107482. buttonRightStick: number;
  107483. /**
  107484. * Gets the value of D-pad up
  107485. */
  107486. /**
  107487. * Sets the value of D-pad up
  107488. */
  107489. dPadUp: number;
  107490. /**
  107491. * Gets the value of D-pad down
  107492. */
  107493. /**
  107494. * Sets the value of D-pad down
  107495. */
  107496. dPadDown: number;
  107497. /**
  107498. * Gets the value of D-pad left
  107499. */
  107500. /**
  107501. * Sets the value of D-pad left
  107502. */
  107503. dPadLeft: number;
  107504. /**
  107505. * Gets the value of D-pad right
  107506. */
  107507. /**
  107508. * Sets the value of D-pad right
  107509. */
  107510. dPadRight: number;
  107511. /**
  107512. * Force the gamepad to synchronize with device values
  107513. */
  107514. update(): void;
  107515. /**
  107516. * Disposes the gamepad
  107517. */
  107518. dispose(): void;
  107519. }
  107520. }
  107521. declare module BABYLON {
  107522. /**
  107523. * Defines supported buttons for DualShock compatible gamepads
  107524. */
  107525. export enum DualShockButton {
  107526. /** Cross */
  107527. Cross = 0,
  107528. /** Circle */
  107529. Circle = 1,
  107530. /** Square */
  107531. Square = 2,
  107532. /** Triangle */
  107533. Triangle = 3,
  107534. /** Options */
  107535. Options = 4,
  107536. /** Share */
  107537. Share = 5,
  107538. /** L1 */
  107539. L1 = 6,
  107540. /** R1 */
  107541. R1 = 7,
  107542. /** Left stick */
  107543. LeftStick = 8,
  107544. /** Right stick */
  107545. RightStick = 9
  107546. }
  107547. /** Defines values for DualShock DPad */
  107548. export enum DualShockDpad {
  107549. /** Up */
  107550. Up = 0,
  107551. /** Down */
  107552. Down = 1,
  107553. /** Left */
  107554. Left = 2,
  107555. /** Right */
  107556. Right = 3
  107557. }
  107558. /**
  107559. * Defines a DualShock gamepad
  107560. */
  107561. export class DualShockPad extends Gamepad {
  107562. private _leftTrigger;
  107563. private _rightTrigger;
  107564. private _onlefttriggerchanged;
  107565. private _onrighttriggerchanged;
  107566. private _onbuttondown;
  107567. private _onbuttonup;
  107568. private _ondpaddown;
  107569. private _ondpadup;
  107570. /** Observable raised when a button is pressed */
  107571. onButtonDownObservable: Observable<DualShockButton>;
  107572. /** Observable raised when a button is released */
  107573. onButtonUpObservable: Observable<DualShockButton>;
  107574. /** Observable raised when a pad is pressed */
  107575. onPadDownObservable: Observable<DualShockDpad>;
  107576. /** Observable raised when a pad is released */
  107577. onPadUpObservable: Observable<DualShockDpad>;
  107578. private _buttonCross;
  107579. private _buttonCircle;
  107580. private _buttonSquare;
  107581. private _buttonTriangle;
  107582. private _buttonShare;
  107583. private _buttonOptions;
  107584. private _buttonL1;
  107585. private _buttonR1;
  107586. private _buttonLeftStick;
  107587. private _buttonRightStick;
  107588. private _dPadUp;
  107589. private _dPadDown;
  107590. private _dPadLeft;
  107591. private _dPadRight;
  107592. /**
  107593. * Creates a new DualShock gamepad object
  107594. * @param id defines the id of this gamepad
  107595. * @param index defines its index
  107596. * @param gamepad defines the internal HTML gamepad object
  107597. */
  107598. constructor(id: string, index: number, gamepad: any);
  107599. /**
  107600. * Defines the callback to call when left trigger is pressed
  107601. * @param callback defines the callback to use
  107602. */
  107603. onlefttriggerchanged(callback: (value: number) => void): void;
  107604. /**
  107605. * Defines the callback to call when right trigger is pressed
  107606. * @param callback defines the callback to use
  107607. */
  107608. onrighttriggerchanged(callback: (value: number) => void): void;
  107609. /**
  107610. * Gets the left trigger value
  107611. */
  107612. /**
  107613. * Sets the left trigger value
  107614. */
  107615. leftTrigger: number;
  107616. /**
  107617. * Gets the right trigger value
  107618. */
  107619. /**
  107620. * Sets the right trigger value
  107621. */
  107622. rightTrigger: number;
  107623. /**
  107624. * Defines the callback to call when a button is pressed
  107625. * @param callback defines the callback to use
  107626. */
  107627. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107628. /**
  107629. * Defines the callback to call when a button is released
  107630. * @param callback defines the callback to use
  107631. */
  107632. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107633. /**
  107634. * Defines the callback to call when a pad is pressed
  107635. * @param callback defines the callback to use
  107636. */
  107637. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107638. /**
  107639. * Defines the callback to call when a pad is released
  107640. * @param callback defines the callback to use
  107641. */
  107642. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107643. private _setButtonValue;
  107644. private _setDPadValue;
  107645. /**
  107646. * Gets the value of the `Cross` button
  107647. */
  107648. /**
  107649. * Sets the value of the `Cross` button
  107650. */
  107651. buttonCross: number;
  107652. /**
  107653. * Gets the value of the `Circle` button
  107654. */
  107655. /**
  107656. * Sets the value of the `Circle` button
  107657. */
  107658. buttonCircle: number;
  107659. /**
  107660. * Gets the value of the `Square` button
  107661. */
  107662. /**
  107663. * Sets the value of the `Square` button
  107664. */
  107665. buttonSquare: number;
  107666. /**
  107667. * Gets the value of the `Triangle` button
  107668. */
  107669. /**
  107670. * Sets the value of the `Triangle` button
  107671. */
  107672. buttonTriangle: number;
  107673. /**
  107674. * Gets the value of the `Options` button
  107675. */
  107676. /**
  107677. * Sets the value of the `Options` button
  107678. */
  107679. buttonOptions: number;
  107680. /**
  107681. * Gets the value of the `Share` button
  107682. */
  107683. /**
  107684. * Sets the value of the `Share` button
  107685. */
  107686. buttonShare: number;
  107687. /**
  107688. * Gets the value of the `L1` button
  107689. */
  107690. /**
  107691. * Sets the value of the `L1` button
  107692. */
  107693. buttonL1: number;
  107694. /**
  107695. * Gets the value of the `R1` button
  107696. */
  107697. /**
  107698. * Sets the value of the `R1` button
  107699. */
  107700. buttonR1: number;
  107701. /**
  107702. * Gets the value of the Left joystick
  107703. */
  107704. /**
  107705. * Sets the value of the Left joystick
  107706. */
  107707. buttonLeftStick: number;
  107708. /**
  107709. * Gets the value of the Right joystick
  107710. */
  107711. /**
  107712. * Sets the value of the Right joystick
  107713. */
  107714. buttonRightStick: number;
  107715. /**
  107716. * Gets the value of D-pad up
  107717. */
  107718. /**
  107719. * Sets the value of D-pad up
  107720. */
  107721. dPadUp: number;
  107722. /**
  107723. * Gets the value of D-pad down
  107724. */
  107725. /**
  107726. * Sets the value of D-pad down
  107727. */
  107728. dPadDown: number;
  107729. /**
  107730. * Gets the value of D-pad left
  107731. */
  107732. /**
  107733. * Sets the value of D-pad left
  107734. */
  107735. dPadLeft: number;
  107736. /**
  107737. * Gets the value of D-pad right
  107738. */
  107739. /**
  107740. * Sets the value of D-pad right
  107741. */
  107742. dPadRight: number;
  107743. /**
  107744. * Force the gamepad to synchronize with device values
  107745. */
  107746. update(): void;
  107747. /**
  107748. * Disposes the gamepad
  107749. */
  107750. dispose(): void;
  107751. }
  107752. }
  107753. declare module BABYLON {
  107754. /**
  107755. * Manager for handling gamepads
  107756. */
  107757. export class GamepadManager {
  107758. private _scene?;
  107759. private _babylonGamepads;
  107760. private _oneGamepadConnected;
  107761. /** @hidden */
  107762. _isMonitoring: boolean;
  107763. private _gamepadEventSupported;
  107764. private _gamepadSupport;
  107765. /**
  107766. * observable to be triggered when the gamepad controller has been connected
  107767. */
  107768. onGamepadConnectedObservable: Observable<Gamepad>;
  107769. /**
  107770. * observable to be triggered when the gamepad controller has been disconnected
  107771. */
  107772. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107773. private _onGamepadConnectedEvent;
  107774. private _onGamepadDisconnectedEvent;
  107775. /**
  107776. * Initializes the gamepad manager
  107777. * @param _scene BabylonJS scene
  107778. */
  107779. constructor(_scene?: Scene | undefined);
  107780. /**
  107781. * The gamepads in the game pad manager
  107782. */
  107783. readonly gamepads: Gamepad[];
  107784. /**
  107785. * Get the gamepad controllers based on type
  107786. * @param type The type of gamepad controller
  107787. * @returns Nullable gamepad
  107788. */
  107789. getGamepadByType(type?: number): Nullable<Gamepad>;
  107790. /**
  107791. * Disposes the gamepad manager
  107792. */
  107793. dispose(): void;
  107794. private _addNewGamepad;
  107795. private _startMonitoringGamepads;
  107796. private _stopMonitoringGamepads;
  107797. /** @hidden */
  107798. _checkGamepadsStatus(): void;
  107799. private _updateGamepadObjects;
  107800. }
  107801. }
  107802. declare module BABYLON {
  107803. interface Scene {
  107804. /** @hidden */
  107805. _gamepadManager: Nullable<GamepadManager>;
  107806. /**
  107807. * Gets the gamepad manager associated with the scene
  107808. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107809. */
  107810. gamepadManager: GamepadManager;
  107811. }
  107812. /**
  107813. * Interface representing a free camera inputs manager
  107814. */
  107815. interface FreeCameraInputsManager {
  107816. /**
  107817. * Adds gamepad input support to the FreeCameraInputsManager.
  107818. * @returns the FreeCameraInputsManager
  107819. */
  107820. addGamepad(): FreeCameraInputsManager;
  107821. }
  107822. /**
  107823. * Interface representing an arc rotate camera inputs manager
  107824. */
  107825. interface ArcRotateCameraInputsManager {
  107826. /**
  107827. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107828. * @returns the camera inputs manager
  107829. */
  107830. addGamepad(): ArcRotateCameraInputsManager;
  107831. }
  107832. /**
  107833. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107834. */
  107835. export class GamepadSystemSceneComponent implements ISceneComponent {
  107836. /**
  107837. * The component name helpfull to identify the component in the list of scene components.
  107838. */
  107839. readonly name: string;
  107840. /**
  107841. * The scene the component belongs to.
  107842. */
  107843. scene: Scene;
  107844. /**
  107845. * Creates a new instance of the component for the given scene
  107846. * @param scene Defines the scene to register the component in
  107847. */
  107848. constructor(scene: Scene);
  107849. /**
  107850. * Registers the component in a given scene
  107851. */
  107852. register(): void;
  107853. /**
  107854. * Rebuilds the elements related to this component in case of
  107855. * context lost for instance.
  107856. */
  107857. rebuild(): void;
  107858. /**
  107859. * Disposes the component and the associated ressources
  107860. */
  107861. dispose(): void;
  107862. private _beforeCameraUpdate;
  107863. }
  107864. }
  107865. declare module BABYLON {
  107866. /**
  107867. * 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,
  107868. * which still works and will still be found in many Playgrounds.
  107869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107870. */
  107871. export class UniversalCamera extends TouchCamera {
  107872. /**
  107873. * Defines the gamepad rotation sensiblity.
  107874. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107875. */
  107876. gamepadAngularSensibility: number;
  107877. /**
  107878. * Defines the gamepad move sensiblity.
  107879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107880. */
  107881. gamepadMoveSensibility: number;
  107882. /**
  107883. * 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,
  107884. * which still works and will still be found in many Playgrounds.
  107885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107886. * @param name Define the name of the camera in the scene
  107887. * @param position Define the start position of the camera in the scene
  107888. * @param scene Define the scene the camera belongs to
  107889. */
  107890. constructor(name: string, position: Vector3, scene: Scene);
  107891. /**
  107892. * Gets the current object class name.
  107893. * @return the class name
  107894. */
  107895. getClassName(): string;
  107896. }
  107897. }
  107898. declare module BABYLON {
  107899. /**
  107900. * This represents a FPS type of camera. This is only here for back compat purpose.
  107901. * Please use the UniversalCamera instead as both are identical.
  107902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107903. */
  107904. export class GamepadCamera extends UniversalCamera {
  107905. /**
  107906. * Instantiates a new Gamepad Camera
  107907. * This represents a FPS type of camera. This is only here for back compat purpose.
  107908. * Please use the UniversalCamera instead as both are identical.
  107909. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107910. * @param name Define the name of the camera in the scene
  107911. * @param position Define the start position of the camera in the scene
  107912. * @param scene Define the scene the camera belongs to
  107913. */
  107914. constructor(name: string, position: Vector3, scene: Scene);
  107915. /**
  107916. * Gets the current object class name.
  107917. * @return the class name
  107918. */
  107919. getClassName(): string;
  107920. }
  107921. }
  107922. declare module BABYLON {
  107923. /** @hidden */
  107924. export var passPixelShader: {
  107925. name: string;
  107926. shader: string;
  107927. };
  107928. }
  107929. declare module BABYLON {
  107930. /** @hidden */
  107931. export var passCubePixelShader: {
  107932. name: string;
  107933. shader: string;
  107934. };
  107935. }
  107936. declare module BABYLON {
  107937. /**
  107938. * PassPostProcess which produces an output the same as it's input
  107939. */
  107940. export class PassPostProcess extends PostProcess {
  107941. /**
  107942. * Creates the PassPostProcess
  107943. * @param name The name of the effect.
  107944. * @param options The required width/height ratio to downsize to before computing the render pass.
  107945. * @param camera The camera to apply the render pass to.
  107946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107947. * @param engine The engine which the post process will be applied. (default: current engine)
  107948. * @param reusable If the post process can be reused on the same frame. (default: false)
  107949. * @param textureType The type of texture to be used when performing the post processing.
  107950. * @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)
  107951. */
  107952. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107953. }
  107954. /**
  107955. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107956. */
  107957. export class PassCubePostProcess extends PostProcess {
  107958. private _face;
  107959. /**
  107960. * Gets or sets the cube face to display.
  107961. * * 0 is +X
  107962. * * 1 is -X
  107963. * * 2 is +Y
  107964. * * 3 is -Y
  107965. * * 4 is +Z
  107966. * * 5 is -Z
  107967. */
  107968. face: number;
  107969. /**
  107970. * Creates the PassCubePostProcess
  107971. * @param name The name of the effect.
  107972. * @param options The required width/height ratio to downsize to before computing the render pass.
  107973. * @param camera The camera to apply the render pass to.
  107974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107975. * @param engine The engine which the post process will be applied. (default: current engine)
  107976. * @param reusable If the post process can be reused on the same frame. (default: false)
  107977. * @param textureType The type of texture to be used when performing the post processing.
  107978. * @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)
  107979. */
  107980. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107981. }
  107982. }
  107983. declare module BABYLON {
  107984. /** @hidden */
  107985. export var anaglyphPixelShader: {
  107986. name: string;
  107987. shader: string;
  107988. };
  107989. }
  107990. declare module BABYLON {
  107991. /**
  107992. * Postprocess used to generate anaglyphic rendering
  107993. */
  107994. export class AnaglyphPostProcess extends PostProcess {
  107995. private _passedProcess;
  107996. /**
  107997. * Creates a new AnaglyphPostProcess
  107998. * @param name defines postprocess name
  107999. * @param options defines creation options or target ratio scale
  108000. * @param rigCameras defines cameras using this postprocess
  108001. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  108002. * @param engine defines hosting engine
  108003. * @param reusable defines if the postprocess will be reused multiple times per frame
  108004. */
  108005. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  108006. }
  108007. }
  108008. declare module BABYLON {
  108009. /**
  108010. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  108011. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108012. */
  108013. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  108014. /**
  108015. * Creates a new AnaglyphArcRotateCamera
  108016. * @param name defines camera name
  108017. * @param alpha defines alpha angle (in radians)
  108018. * @param beta defines beta angle (in radians)
  108019. * @param radius defines radius
  108020. * @param target defines camera target
  108021. * @param interaxialDistance defines distance between each color axis
  108022. * @param scene defines the hosting scene
  108023. */
  108024. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108025. /**
  108026. * Gets camera class name
  108027. * @returns AnaglyphArcRotateCamera
  108028. */
  108029. getClassName(): string;
  108030. }
  108031. }
  108032. declare module BABYLON {
  108033. /**
  108034. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108035. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108036. */
  108037. export class AnaglyphFreeCamera extends FreeCamera {
  108038. /**
  108039. * Creates a new AnaglyphFreeCamera
  108040. * @param name defines camera name
  108041. * @param position defines initial position
  108042. * @param interaxialDistance defines distance between each color axis
  108043. * @param scene defines the hosting scene
  108044. */
  108045. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108046. /**
  108047. * Gets camera class name
  108048. * @returns AnaglyphFreeCamera
  108049. */
  108050. getClassName(): string;
  108051. }
  108052. }
  108053. declare module BABYLON {
  108054. /**
  108055. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108056. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108057. */
  108058. export class AnaglyphGamepadCamera extends GamepadCamera {
  108059. /**
  108060. * Creates a new AnaglyphGamepadCamera
  108061. * @param name defines camera name
  108062. * @param position defines initial position
  108063. * @param interaxialDistance defines distance between each color axis
  108064. * @param scene defines the hosting scene
  108065. */
  108066. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108067. /**
  108068. * Gets camera class name
  108069. * @returns AnaglyphGamepadCamera
  108070. */
  108071. getClassName(): string;
  108072. }
  108073. }
  108074. declare module BABYLON {
  108075. /**
  108076. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108077. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108078. */
  108079. export class AnaglyphUniversalCamera extends UniversalCamera {
  108080. /**
  108081. * Creates a new AnaglyphUniversalCamera
  108082. * @param name defines camera name
  108083. * @param position defines initial position
  108084. * @param interaxialDistance defines distance between each color axis
  108085. * @param scene defines the hosting scene
  108086. */
  108087. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108088. /**
  108089. * Gets camera class name
  108090. * @returns AnaglyphUniversalCamera
  108091. */
  108092. getClassName(): string;
  108093. }
  108094. }
  108095. declare module BABYLON {
  108096. /** @hidden */
  108097. export var stereoscopicInterlacePixelShader: {
  108098. name: string;
  108099. shader: string;
  108100. };
  108101. }
  108102. declare module BABYLON {
  108103. /**
  108104. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108105. */
  108106. export class StereoscopicInterlacePostProcess extends PostProcess {
  108107. private _stepSize;
  108108. private _passedProcess;
  108109. /**
  108110. * Initializes a StereoscopicInterlacePostProcess
  108111. * @param name The name of the effect.
  108112. * @param rigCameras The rig cameras to be appled to the post process
  108113. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108115. * @param engine The engine which the post process will be applied. (default: current engine)
  108116. * @param reusable If the post process can be reused on the same frame. (default: false)
  108117. */
  108118. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108119. }
  108120. }
  108121. declare module BABYLON {
  108122. /**
  108123. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108124. * @see http://doc.babylonjs.com/features/cameras
  108125. */
  108126. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108127. /**
  108128. * Creates a new StereoscopicArcRotateCamera
  108129. * @param name defines camera name
  108130. * @param alpha defines alpha angle (in radians)
  108131. * @param beta defines beta angle (in radians)
  108132. * @param radius defines radius
  108133. * @param target defines camera target
  108134. * @param interaxialDistance defines distance between each color axis
  108135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108136. * @param scene defines the hosting scene
  108137. */
  108138. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108139. /**
  108140. * Gets camera class name
  108141. * @returns StereoscopicArcRotateCamera
  108142. */
  108143. getClassName(): string;
  108144. }
  108145. }
  108146. declare module BABYLON {
  108147. /**
  108148. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108149. * @see http://doc.babylonjs.com/features/cameras
  108150. */
  108151. export class StereoscopicFreeCamera extends FreeCamera {
  108152. /**
  108153. * Creates a new StereoscopicFreeCamera
  108154. * @param name defines camera name
  108155. * @param position defines initial position
  108156. * @param interaxialDistance defines distance between each color axis
  108157. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108158. * @param scene defines the hosting scene
  108159. */
  108160. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108161. /**
  108162. * Gets camera class name
  108163. * @returns StereoscopicFreeCamera
  108164. */
  108165. getClassName(): string;
  108166. }
  108167. }
  108168. declare module BABYLON {
  108169. /**
  108170. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108171. * @see http://doc.babylonjs.com/features/cameras
  108172. */
  108173. export class StereoscopicGamepadCamera extends GamepadCamera {
  108174. /**
  108175. * Creates a new StereoscopicGamepadCamera
  108176. * @param name defines camera name
  108177. * @param position defines initial position
  108178. * @param interaxialDistance defines distance between each color axis
  108179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108180. * @param scene defines the hosting scene
  108181. */
  108182. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108183. /**
  108184. * Gets camera class name
  108185. * @returns StereoscopicGamepadCamera
  108186. */
  108187. getClassName(): string;
  108188. }
  108189. }
  108190. declare module BABYLON {
  108191. /**
  108192. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108193. * @see http://doc.babylonjs.com/features/cameras
  108194. */
  108195. export class StereoscopicUniversalCamera extends UniversalCamera {
  108196. /**
  108197. * Creates a new StereoscopicUniversalCamera
  108198. * @param name defines camera name
  108199. * @param position defines initial position
  108200. * @param interaxialDistance defines distance between each color axis
  108201. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108202. * @param scene defines the hosting scene
  108203. */
  108204. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108205. /**
  108206. * Gets camera class name
  108207. * @returns StereoscopicUniversalCamera
  108208. */
  108209. getClassName(): string;
  108210. }
  108211. }
  108212. declare module BABYLON {
  108213. /**
  108214. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108215. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108216. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108217. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108218. */
  108219. export class VirtualJoysticksCamera extends FreeCamera {
  108220. /**
  108221. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108222. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108223. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108224. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108225. * @param name Define the name of the camera in the scene
  108226. * @param position Define the start position of the camera in the scene
  108227. * @param scene Define the scene the camera belongs to
  108228. */
  108229. constructor(name: string, position: Vector3, scene: Scene);
  108230. /**
  108231. * Gets the current object class name.
  108232. * @return the class name
  108233. */
  108234. getClassName(): string;
  108235. }
  108236. }
  108237. declare module BABYLON {
  108238. /**
  108239. * This represents all the required metrics to create a VR camera.
  108240. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108241. */
  108242. export class VRCameraMetrics {
  108243. /**
  108244. * Define the horizontal resolution off the screen.
  108245. */
  108246. hResolution: number;
  108247. /**
  108248. * Define the vertical resolution off the screen.
  108249. */
  108250. vResolution: number;
  108251. /**
  108252. * Define the horizontal screen size.
  108253. */
  108254. hScreenSize: number;
  108255. /**
  108256. * Define the vertical screen size.
  108257. */
  108258. vScreenSize: number;
  108259. /**
  108260. * Define the vertical screen center position.
  108261. */
  108262. vScreenCenter: number;
  108263. /**
  108264. * Define the distance of the eyes to the screen.
  108265. */
  108266. eyeToScreenDistance: number;
  108267. /**
  108268. * Define the distance between both lenses
  108269. */
  108270. lensSeparationDistance: number;
  108271. /**
  108272. * Define the distance between both viewer's eyes.
  108273. */
  108274. interpupillaryDistance: number;
  108275. /**
  108276. * Define the distortion factor of the VR postprocess.
  108277. * Please, touch with care.
  108278. */
  108279. distortionK: number[];
  108280. /**
  108281. * Define the chromatic aberration correction factors for the VR post process.
  108282. */
  108283. chromaAbCorrection: number[];
  108284. /**
  108285. * Define the scale factor of the post process.
  108286. * The smaller the better but the slower.
  108287. */
  108288. postProcessScaleFactor: number;
  108289. /**
  108290. * Define an offset for the lens center.
  108291. */
  108292. lensCenterOffset: number;
  108293. /**
  108294. * Define if the current vr camera should compensate the distortion of the lense or not.
  108295. */
  108296. compensateDistortion: boolean;
  108297. /**
  108298. * Defines if multiview should be enabled when rendering (Default: false)
  108299. */
  108300. multiviewEnabled: boolean;
  108301. /**
  108302. * Gets the rendering aspect ratio based on the provided resolutions.
  108303. */
  108304. readonly aspectRatio: number;
  108305. /**
  108306. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108307. */
  108308. readonly aspectRatioFov: number;
  108309. /**
  108310. * @hidden
  108311. */
  108312. readonly leftHMatrix: Matrix;
  108313. /**
  108314. * @hidden
  108315. */
  108316. readonly rightHMatrix: Matrix;
  108317. /**
  108318. * @hidden
  108319. */
  108320. readonly leftPreViewMatrix: Matrix;
  108321. /**
  108322. * @hidden
  108323. */
  108324. readonly rightPreViewMatrix: Matrix;
  108325. /**
  108326. * Get the default VRMetrics based on the most generic setup.
  108327. * @returns the default vr metrics
  108328. */
  108329. static GetDefault(): VRCameraMetrics;
  108330. }
  108331. }
  108332. declare module BABYLON {
  108333. /** @hidden */
  108334. export var vrDistortionCorrectionPixelShader: {
  108335. name: string;
  108336. shader: string;
  108337. };
  108338. }
  108339. declare module BABYLON {
  108340. /**
  108341. * VRDistortionCorrectionPostProcess used for mobile VR
  108342. */
  108343. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108344. private _isRightEye;
  108345. private _distortionFactors;
  108346. private _postProcessScaleFactor;
  108347. private _lensCenterOffset;
  108348. private _scaleIn;
  108349. private _scaleFactor;
  108350. private _lensCenter;
  108351. /**
  108352. * Initializes the VRDistortionCorrectionPostProcess
  108353. * @param name The name of the effect.
  108354. * @param camera The camera to apply the render pass to.
  108355. * @param isRightEye If this is for the right eye distortion
  108356. * @param vrMetrics All the required metrics for the VR camera
  108357. */
  108358. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108359. }
  108360. }
  108361. declare module BABYLON {
  108362. /**
  108363. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108364. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108365. */
  108366. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108367. /**
  108368. * Creates a new VRDeviceOrientationArcRotateCamera
  108369. * @param name defines camera name
  108370. * @param alpha defines the camera rotation along the logitudinal axis
  108371. * @param beta defines the camera rotation along the latitudinal axis
  108372. * @param radius defines the camera distance from its target
  108373. * @param target defines the camera target
  108374. * @param scene defines the scene the camera belongs to
  108375. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108376. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108377. */
  108378. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108379. /**
  108380. * Gets camera class name
  108381. * @returns VRDeviceOrientationArcRotateCamera
  108382. */
  108383. getClassName(): string;
  108384. }
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * Camera used to simulate VR rendering (based on FreeCamera)
  108389. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108390. */
  108391. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108392. /**
  108393. * Creates a new VRDeviceOrientationFreeCamera
  108394. * @param name defines camera name
  108395. * @param position defines the start position of the camera
  108396. * @param scene defines the scene the camera belongs to
  108397. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108398. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108399. */
  108400. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108401. /**
  108402. * Gets camera class name
  108403. * @returns VRDeviceOrientationFreeCamera
  108404. */
  108405. getClassName(): string;
  108406. }
  108407. }
  108408. declare module BABYLON {
  108409. /**
  108410. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108411. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108412. */
  108413. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108414. /**
  108415. * Creates a new VRDeviceOrientationGamepadCamera
  108416. * @param name defines camera name
  108417. * @param position defines the start position of the camera
  108418. * @param scene defines the scene the camera belongs to
  108419. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108420. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108421. */
  108422. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108423. /**
  108424. * Gets camera class name
  108425. * @returns VRDeviceOrientationGamepadCamera
  108426. */
  108427. getClassName(): string;
  108428. }
  108429. }
  108430. declare module BABYLON {
  108431. /**
  108432. * Base class of materials working in push mode in babylon JS
  108433. * @hidden
  108434. */
  108435. export class PushMaterial extends Material {
  108436. protected _activeEffect: Effect;
  108437. protected _normalMatrix: Matrix;
  108438. /**
  108439. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108440. * This means that the material can keep using a previous shader while a new one is being compiled.
  108441. * This is mostly used when shader parallel compilation is supported (true by default)
  108442. */
  108443. allowShaderHotSwapping: boolean;
  108444. constructor(name: string, scene: Scene);
  108445. getEffect(): Effect;
  108446. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108447. /**
  108448. * Binds the given world matrix to the active effect
  108449. *
  108450. * @param world the matrix to bind
  108451. */
  108452. bindOnlyWorldMatrix(world: Matrix): void;
  108453. /**
  108454. * Binds the given normal matrix to the active effect
  108455. *
  108456. * @param normalMatrix the matrix to bind
  108457. */
  108458. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108459. bind(world: Matrix, mesh?: Mesh): void;
  108460. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108461. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108462. }
  108463. }
  108464. declare module BABYLON {
  108465. /**
  108466. * This groups all the flags used to control the materials channel.
  108467. */
  108468. export class MaterialFlags {
  108469. private static _DiffuseTextureEnabled;
  108470. /**
  108471. * Are diffuse textures enabled in the application.
  108472. */
  108473. static DiffuseTextureEnabled: boolean;
  108474. private static _AmbientTextureEnabled;
  108475. /**
  108476. * Are ambient textures enabled in the application.
  108477. */
  108478. static AmbientTextureEnabled: boolean;
  108479. private static _OpacityTextureEnabled;
  108480. /**
  108481. * Are opacity textures enabled in the application.
  108482. */
  108483. static OpacityTextureEnabled: boolean;
  108484. private static _ReflectionTextureEnabled;
  108485. /**
  108486. * Are reflection textures enabled in the application.
  108487. */
  108488. static ReflectionTextureEnabled: boolean;
  108489. private static _EmissiveTextureEnabled;
  108490. /**
  108491. * Are emissive textures enabled in the application.
  108492. */
  108493. static EmissiveTextureEnabled: boolean;
  108494. private static _SpecularTextureEnabled;
  108495. /**
  108496. * Are specular textures enabled in the application.
  108497. */
  108498. static SpecularTextureEnabled: boolean;
  108499. private static _BumpTextureEnabled;
  108500. /**
  108501. * Are bump textures enabled in the application.
  108502. */
  108503. static BumpTextureEnabled: boolean;
  108504. private static _LightmapTextureEnabled;
  108505. /**
  108506. * Are lightmap textures enabled in the application.
  108507. */
  108508. static LightmapTextureEnabled: boolean;
  108509. private static _RefractionTextureEnabled;
  108510. /**
  108511. * Are refraction textures enabled in the application.
  108512. */
  108513. static RefractionTextureEnabled: boolean;
  108514. private static _ColorGradingTextureEnabled;
  108515. /**
  108516. * Are color grading textures enabled in the application.
  108517. */
  108518. static ColorGradingTextureEnabled: boolean;
  108519. private static _FresnelEnabled;
  108520. /**
  108521. * Are fresnels enabled in the application.
  108522. */
  108523. static FresnelEnabled: boolean;
  108524. private static _ClearCoatTextureEnabled;
  108525. /**
  108526. * Are clear coat textures enabled in the application.
  108527. */
  108528. static ClearCoatTextureEnabled: boolean;
  108529. private static _ClearCoatBumpTextureEnabled;
  108530. /**
  108531. * Are clear coat bump textures enabled in the application.
  108532. */
  108533. static ClearCoatBumpTextureEnabled: boolean;
  108534. private static _ClearCoatTintTextureEnabled;
  108535. /**
  108536. * Are clear coat tint textures enabled in the application.
  108537. */
  108538. static ClearCoatTintTextureEnabled: boolean;
  108539. private static _SheenTextureEnabled;
  108540. /**
  108541. * Are sheen textures enabled in the application.
  108542. */
  108543. static SheenTextureEnabled: boolean;
  108544. private static _AnisotropicTextureEnabled;
  108545. /**
  108546. * Are anisotropic textures enabled in the application.
  108547. */
  108548. static AnisotropicTextureEnabled: boolean;
  108549. private static _ThicknessTextureEnabled;
  108550. /**
  108551. * Are thickness textures enabled in the application.
  108552. */
  108553. static ThicknessTextureEnabled: boolean;
  108554. }
  108555. }
  108556. declare module BABYLON {
  108557. /** @hidden */
  108558. export var defaultFragmentDeclaration: {
  108559. name: string;
  108560. shader: string;
  108561. };
  108562. }
  108563. declare module BABYLON {
  108564. /** @hidden */
  108565. export var defaultUboDeclaration: {
  108566. name: string;
  108567. shader: string;
  108568. };
  108569. }
  108570. declare module BABYLON {
  108571. /** @hidden */
  108572. export var lightFragmentDeclaration: {
  108573. name: string;
  108574. shader: string;
  108575. };
  108576. }
  108577. declare module BABYLON {
  108578. /** @hidden */
  108579. export var lightUboDeclaration: {
  108580. name: string;
  108581. shader: string;
  108582. };
  108583. }
  108584. declare module BABYLON {
  108585. /** @hidden */
  108586. export var lightsFragmentFunctions: {
  108587. name: string;
  108588. shader: string;
  108589. };
  108590. }
  108591. declare module BABYLON {
  108592. /** @hidden */
  108593. export var shadowsFragmentFunctions: {
  108594. name: string;
  108595. shader: string;
  108596. };
  108597. }
  108598. declare module BABYLON {
  108599. /** @hidden */
  108600. export var fresnelFunction: {
  108601. name: string;
  108602. shader: string;
  108603. };
  108604. }
  108605. declare module BABYLON {
  108606. /** @hidden */
  108607. export var reflectionFunction: {
  108608. name: string;
  108609. shader: string;
  108610. };
  108611. }
  108612. declare module BABYLON {
  108613. /** @hidden */
  108614. export var bumpFragmentFunctions: {
  108615. name: string;
  108616. shader: string;
  108617. };
  108618. }
  108619. declare module BABYLON {
  108620. /** @hidden */
  108621. export var logDepthDeclaration: {
  108622. name: string;
  108623. shader: string;
  108624. };
  108625. }
  108626. declare module BABYLON {
  108627. /** @hidden */
  108628. export var bumpFragment: {
  108629. name: string;
  108630. shader: string;
  108631. };
  108632. }
  108633. declare module BABYLON {
  108634. /** @hidden */
  108635. export var depthPrePass: {
  108636. name: string;
  108637. shader: string;
  108638. };
  108639. }
  108640. declare module BABYLON {
  108641. /** @hidden */
  108642. export var lightFragment: {
  108643. name: string;
  108644. shader: string;
  108645. };
  108646. }
  108647. declare module BABYLON {
  108648. /** @hidden */
  108649. export var logDepthFragment: {
  108650. name: string;
  108651. shader: string;
  108652. };
  108653. }
  108654. declare module BABYLON {
  108655. /** @hidden */
  108656. export var defaultPixelShader: {
  108657. name: string;
  108658. shader: string;
  108659. };
  108660. }
  108661. declare module BABYLON {
  108662. /** @hidden */
  108663. export var defaultVertexDeclaration: {
  108664. name: string;
  108665. shader: string;
  108666. };
  108667. }
  108668. declare module BABYLON {
  108669. /** @hidden */
  108670. export var bumpVertexDeclaration: {
  108671. name: string;
  108672. shader: string;
  108673. };
  108674. }
  108675. declare module BABYLON {
  108676. /** @hidden */
  108677. export var bumpVertex: {
  108678. name: string;
  108679. shader: string;
  108680. };
  108681. }
  108682. declare module BABYLON {
  108683. /** @hidden */
  108684. export var fogVertex: {
  108685. name: string;
  108686. shader: string;
  108687. };
  108688. }
  108689. declare module BABYLON {
  108690. /** @hidden */
  108691. export var shadowsVertex: {
  108692. name: string;
  108693. shader: string;
  108694. };
  108695. }
  108696. declare module BABYLON {
  108697. /** @hidden */
  108698. export var pointCloudVertex: {
  108699. name: string;
  108700. shader: string;
  108701. };
  108702. }
  108703. declare module BABYLON {
  108704. /** @hidden */
  108705. export var logDepthVertex: {
  108706. name: string;
  108707. shader: string;
  108708. };
  108709. }
  108710. declare module BABYLON {
  108711. /** @hidden */
  108712. export var defaultVertexShader: {
  108713. name: string;
  108714. shader: string;
  108715. };
  108716. }
  108717. declare module BABYLON {
  108718. /** @hidden */
  108719. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108720. MAINUV1: boolean;
  108721. MAINUV2: boolean;
  108722. DIFFUSE: boolean;
  108723. DIFFUSEDIRECTUV: number;
  108724. AMBIENT: boolean;
  108725. AMBIENTDIRECTUV: number;
  108726. OPACITY: boolean;
  108727. OPACITYDIRECTUV: number;
  108728. OPACITYRGB: boolean;
  108729. REFLECTION: boolean;
  108730. EMISSIVE: boolean;
  108731. EMISSIVEDIRECTUV: number;
  108732. SPECULAR: boolean;
  108733. SPECULARDIRECTUV: number;
  108734. BUMP: boolean;
  108735. BUMPDIRECTUV: number;
  108736. PARALLAX: boolean;
  108737. PARALLAXOCCLUSION: boolean;
  108738. SPECULAROVERALPHA: boolean;
  108739. CLIPPLANE: boolean;
  108740. CLIPPLANE2: boolean;
  108741. CLIPPLANE3: boolean;
  108742. CLIPPLANE4: boolean;
  108743. ALPHATEST: boolean;
  108744. DEPTHPREPASS: boolean;
  108745. ALPHAFROMDIFFUSE: boolean;
  108746. POINTSIZE: boolean;
  108747. FOG: boolean;
  108748. SPECULARTERM: boolean;
  108749. DIFFUSEFRESNEL: boolean;
  108750. OPACITYFRESNEL: boolean;
  108751. REFLECTIONFRESNEL: boolean;
  108752. REFRACTIONFRESNEL: boolean;
  108753. EMISSIVEFRESNEL: boolean;
  108754. FRESNEL: boolean;
  108755. NORMAL: boolean;
  108756. UV1: boolean;
  108757. UV2: boolean;
  108758. VERTEXCOLOR: boolean;
  108759. VERTEXALPHA: boolean;
  108760. NUM_BONE_INFLUENCERS: number;
  108761. BonesPerMesh: number;
  108762. BONETEXTURE: boolean;
  108763. INSTANCES: boolean;
  108764. GLOSSINESS: boolean;
  108765. ROUGHNESS: boolean;
  108766. EMISSIVEASILLUMINATION: boolean;
  108767. LINKEMISSIVEWITHDIFFUSE: boolean;
  108768. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108769. LIGHTMAP: boolean;
  108770. LIGHTMAPDIRECTUV: number;
  108771. OBJECTSPACE_NORMALMAP: boolean;
  108772. USELIGHTMAPASSHADOWMAP: boolean;
  108773. REFLECTIONMAP_3D: boolean;
  108774. REFLECTIONMAP_SPHERICAL: boolean;
  108775. REFLECTIONMAP_PLANAR: boolean;
  108776. REFLECTIONMAP_CUBIC: boolean;
  108777. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108778. REFLECTIONMAP_PROJECTION: boolean;
  108779. REFLECTIONMAP_SKYBOX: boolean;
  108780. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108781. REFLECTIONMAP_EXPLICIT: boolean;
  108782. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108783. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108784. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108785. INVERTCUBICMAP: boolean;
  108786. LOGARITHMICDEPTH: boolean;
  108787. REFRACTION: boolean;
  108788. REFRACTIONMAP_3D: boolean;
  108789. REFLECTIONOVERALPHA: boolean;
  108790. TWOSIDEDLIGHTING: boolean;
  108791. SHADOWFLOAT: boolean;
  108792. MORPHTARGETS: boolean;
  108793. MORPHTARGETS_NORMAL: boolean;
  108794. MORPHTARGETS_TANGENT: boolean;
  108795. MORPHTARGETS_UV: boolean;
  108796. NUM_MORPH_INFLUENCERS: number;
  108797. NONUNIFORMSCALING: boolean;
  108798. PREMULTIPLYALPHA: boolean;
  108799. IMAGEPROCESSING: boolean;
  108800. VIGNETTE: boolean;
  108801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108802. VIGNETTEBLENDMODEOPAQUE: boolean;
  108803. TONEMAPPING: boolean;
  108804. TONEMAPPING_ACES: boolean;
  108805. CONTRAST: boolean;
  108806. COLORCURVES: boolean;
  108807. COLORGRADING: boolean;
  108808. COLORGRADING3D: boolean;
  108809. SAMPLER3DGREENDEPTH: boolean;
  108810. SAMPLER3DBGRMAP: boolean;
  108811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108812. MULTIVIEW: boolean;
  108813. /**
  108814. * If the reflection texture on this material is in linear color space
  108815. * @hidden
  108816. */
  108817. IS_REFLECTION_LINEAR: boolean;
  108818. /**
  108819. * If the refraction texture on this material is in linear color space
  108820. * @hidden
  108821. */
  108822. IS_REFRACTION_LINEAR: boolean;
  108823. EXPOSURE: boolean;
  108824. constructor();
  108825. setReflectionMode(modeToEnable: string): void;
  108826. }
  108827. /**
  108828. * This is the default material used in Babylon. It is the best trade off between quality
  108829. * and performances.
  108830. * @see http://doc.babylonjs.com/babylon101/materials
  108831. */
  108832. export class StandardMaterial extends PushMaterial {
  108833. private _diffuseTexture;
  108834. /**
  108835. * The basic texture of the material as viewed under a light.
  108836. */
  108837. diffuseTexture: Nullable<BaseTexture>;
  108838. private _ambientTexture;
  108839. /**
  108840. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108841. */
  108842. ambientTexture: Nullable<BaseTexture>;
  108843. private _opacityTexture;
  108844. /**
  108845. * Define the transparency of the material from a texture.
  108846. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108847. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108848. */
  108849. opacityTexture: Nullable<BaseTexture>;
  108850. private _reflectionTexture;
  108851. /**
  108852. * Define the texture used to display the reflection.
  108853. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108854. */
  108855. reflectionTexture: Nullable<BaseTexture>;
  108856. private _emissiveTexture;
  108857. /**
  108858. * Define texture of the material as if self lit.
  108859. * This will be mixed in the final result even in the absence of light.
  108860. */
  108861. emissiveTexture: Nullable<BaseTexture>;
  108862. private _specularTexture;
  108863. /**
  108864. * Define how the color and intensity of the highlight given by the light in the material.
  108865. */
  108866. specularTexture: Nullable<BaseTexture>;
  108867. private _bumpTexture;
  108868. /**
  108869. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108870. * 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.
  108871. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108872. */
  108873. bumpTexture: Nullable<BaseTexture>;
  108874. private _lightmapTexture;
  108875. /**
  108876. * Complex lighting can be computationally expensive to compute at runtime.
  108877. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108878. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108879. */
  108880. lightmapTexture: Nullable<BaseTexture>;
  108881. private _refractionTexture;
  108882. /**
  108883. * Define the texture used to display the refraction.
  108884. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108885. */
  108886. refractionTexture: Nullable<BaseTexture>;
  108887. /**
  108888. * The color of the material lit by the environmental background lighting.
  108889. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108890. */
  108891. ambientColor: Color3;
  108892. /**
  108893. * The basic color of the material as viewed under a light.
  108894. */
  108895. diffuseColor: Color3;
  108896. /**
  108897. * Define how the color and intensity of the highlight given by the light in the material.
  108898. */
  108899. specularColor: Color3;
  108900. /**
  108901. * Define the color of the material as if self lit.
  108902. * This will be mixed in the final result even in the absence of light.
  108903. */
  108904. emissiveColor: Color3;
  108905. /**
  108906. * Defines how sharp are the highlights in the material.
  108907. * The bigger the value the sharper giving a more glossy feeling to the result.
  108908. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108909. */
  108910. specularPower: number;
  108911. private _useAlphaFromDiffuseTexture;
  108912. /**
  108913. * Does the transparency come from the diffuse texture alpha channel.
  108914. */
  108915. useAlphaFromDiffuseTexture: boolean;
  108916. private _useEmissiveAsIllumination;
  108917. /**
  108918. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108919. */
  108920. useEmissiveAsIllumination: boolean;
  108921. private _linkEmissiveWithDiffuse;
  108922. /**
  108923. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108924. * the emissive level when the final color is close to one.
  108925. */
  108926. linkEmissiveWithDiffuse: boolean;
  108927. private _useSpecularOverAlpha;
  108928. /**
  108929. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108931. */
  108932. useSpecularOverAlpha: boolean;
  108933. private _useReflectionOverAlpha;
  108934. /**
  108935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108937. */
  108938. useReflectionOverAlpha: boolean;
  108939. private _disableLighting;
  108940. /**
  108941. * Does lights from the scene impacts this material.
  108942. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108943. */
  108944. disableLighting: boolean;
  108945. private _useObjectSpaceNormalMap;
  108946. /**
  108947. * Allows using an object space normal map (instead of tangent space).
  108948. */
  108949. useObjectSpaceNormalMap: boolean;
  108950. private _useParallax;
  108951. /**
  108952. * Is parallax enabled or not.
  108953. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108954. */
  108955. useParallax: boolean;
  108956. private _useParallaxOcclusion;
  108957. /**
  108958. * Is parallax occlusion enabled or not.
  108959. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108960. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108961. */
  108962. useParallaxOcclusion: boolean;
  108963. /**
  108964. * 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.
  108965. */
  108966. parallaxScaleBias: number;
  108967. private _roughness;
  108968. /**
  108969. * Helps to define how blurry the reflections should appears in the material.
  108970. */
  108971. roughness: number;
  108972. /**
  108973. * In case of refraction, define the value of the index of refraction.
  108974. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108975. */
  108976. indexOfRefraction: number;
  108977. /**
  108978. * Invert the refraction texture alongside the y axis.
  108979. * It can be useful with procedural textures or probe for instance.
  108980. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108981. */
  108982. invertRefractionY: boolean;
  108983. /**
  108984. * Defines the alpha limits in alpha test mode.
  108985. */
  108986. alphaCutOff: number;
  108987. private _useLightmapAsShadowmap;
  108988. /**
  108989. * In case of light mapping, define whether the map contains light or shadow informations.
  108990. */
  108991. useLightmapAsShadowmap: boolean;
  108992. private _diffuseFresnelParameters;
  108993. /**
  108994. * Define the diffuse fresnel parameters of the material.
  108995. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108996. */
  108997. diffuseFresnelParameters: FresnelParameters;
  108998. private _opacityFresnelParameters;
  108999. /**
  109000. * Define the opacity fresnel parameters of the material.
  109001. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109002. */
  109003. opacityFresnelParameters: FresnelParameters;
  109004. private _reflectionFresnelParameters;
  109005. /**
  109006. * Define the reflection fresnel parameters of the material.
  109007. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109008. */
  109009. reflectionFresnelParameters: FresnelParameters;
  109010. private _refractionFresnelParameters;
  109011. /**
  109012. * Define the refraction fresnel parameters of the material.
  109013. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109014. */
  109015. refractionFresnelParameters: FresnelParameters;
  109016. private _emissiveFresnelParameters;
  109017. /**
  109018. * Define the emissive fresnel parameters of the material.
  109019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109020. */
  109021. emissiveFresnelParameters: FresnelParameters;
  109022. private _useReflectionFresnelFromSpecular;
  109023. /**
  109024. * If true automatically deducts the fresnels values from the material specularity.
  109025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109026. */
  109027. useReflectionFresnelFromSpecular: boolean;
  109028. private _useGlossinessFromSpecularMapAlpha;
  109029. /**
  109030. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109031. */
  109032. useGlossinessFromSpecularMapAlpha: boolean;
  109033. private _maxSimultaneousLights;
  109034. /**
  109035. * Defines the maximum number of lights that can be used in the material
  109036. */
  109037. maxSimultaneousLights: number;
  109038. private _invertNormalMapX;
  109039. /**
  109040. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109041. */
  109042. invertNormalMapX: boolean;
  109043. private _invertNormalMapY;
  109044. /**
  109045. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109046. */
  109047. invertNormalMapY: boolean;
  109048. private _twoSidedLighting;
  109049. /**
  109050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109051. */
  109052. twoSidedLighting: boolean;
  109053. /**
  109054. * Default configuration related to image processing available in the standard Material.
  109055. */
  109056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109057. /**
  109058. * Gets the image processing configuration used either in this material.
  109059. */
  109060. /**
  109061. * Sets the Default image processing configuration used either in the this material.
  109062. *
  109063. * If sets to null, the scene one is in use.
  109064. */
  109065. imageProcessingConfiguration: ImageProcessingConfiguration;
  109066. /**
  109067. * Keep track of the image processing observer to allow dispose and replace.
  109068. */
  109069. private _imageProcessingObserver;
  109070. /**
  109071. * Attaches a new image processing configuration to the Standard Material.
  109072. * @param configuration
  109073. */
  109074. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109075. /**
  109076. * Gets wether the color curves effect is enabled.
  109077. */
  109078. /**
  109079. * Sets wether the color curves effect is enabled.
  109080. */
  109081. cameraColorCurvesEnabled: boolean;
  109082. /**
  109083. * Gets wether the color grading effect is enabled.
  109084. */
  109085. /**
  109086. * Gets wether the color grading effect is enabled.
  109087. */
  109088. cameraColorGradingEnabled: boolean;
  109089. /**
  109090. * Gets wether tonemapping is enabled or not.
  109091. */
  109092. /**
  109093. * Sets wether tonemapping is enabled or not
  109094. */
  109095. cameraToneMappingEnabled: boolean;
  109096. /**
  109097. * The camera exposure used on this material.
  109098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109099. * This corresponds to a photographic exposure.
  109100. */
  109101. /**
  109102. * The camera exposure used on this material.
  109103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109104. * This corresponds to a photographic exposure.
  109105. */
  109106. cameraExposure: number;
  109107. /**
  109108. * Gets The camera contrast used on this material.
  109109. */
  109110. /**
  109111. * Sets The camera contrast used on this material.
  109112. */
  109113. cameraContrast: number;
  109114. /**
  109115. * Gets the Color Grading 2D Lookup Texture.
  109116. */
  109117. /**
  109118. * Sets the Color Grading 2D Lookup Texture.
  109119. */
  109120. cameraColorGradingTexture: Nullable<BaseTexture>;
  109121. /**
  109122. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109123. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109124. * 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;
  109125. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109126. */
  109127. /**
  109128. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109129. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109130. * 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;
  109131. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109132. */
  109133. cameraColorCurves: Nullable<ColorCurves>;
  109134. /**
  109135. * Custom callback helping to override the default shader used in the material.
  109136. */
  109137. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109138. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109139. protected _worldViewProjectionMatrix: Matrix;
  109140. protected _globalAmbientColor: Color3;
  109141. protected _useLogarithmicDepth: boolean;
  109142. protected _rebuildInParallel: boolean;
  109143. /**
  109144. * Instantiates a new standard material.
  109145. * This is the default material used in Babylon. It is the best trade off between quality
  109146. * and performances.
  109147. * @see http://doc.babylonjs.com/babylon101/materials
  109148. * @param name Define the name of the material in the scene
  109149. * @param scene Define the scene the material belong to
  109150. */
  109151. constructor(name: string, scene: Scene);
  109152. /**
  109153. * Gets a boolean indicating that current material needs to register RTT
  109154. */
  109155. readonly hasRenderTargetTextures: boolean;
  109156. /**
  109157. * Gets the current class name of the material e.g. "StandardMaterial"
  109158. * Mainly use in serialization.
  109159. * @returns the class name
  109160. */
  109161. getClassName(): string;
  109162. /**
  109163. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109164. * You can try switching to logarithmic depth.
  109165. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109166. */
  109167. useLogarithmicDepth: boolean;
  109168. /**
  109169. * Specifies if the material will require alpha blending
  109170. * @returns a boolean specifying if alpha blending is needed
  109171. */
  109172. needAlphaBlending(): boolean;
  109173. /**
  109174. * Specifies if this material should be rendered in alpha test mode
  109175. * @returns a boolean specifying if an alpha test is needed.
  109176. */
  109177. needAlphaTesting(): boolean;
  109178. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109179. /**
  109180. * Get the texture used for alpha test purpose.
  109181. * @returns the diffuse texture in case of the standard material.
  109182. */
  109183. getAlphaTestTexture(): Nullable<BaseTexture>;
  109184. /**
  109185. * Get if the submesh is ready to be used and all its information available.
  109186. * Child classes can use it to update shaders
  109187. * @param mesh defines the mesh to check
  109188. * @param subMesh defines which submesh to check
  109189. * @param useInstances specifies that instances should be used
  109190. * @returns a boolean indicating that the submesh is ready or not
  109191. */
  109192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109193. /**
  109194. * Builds the material UBO layouts.
  109195. * Used internally during the effect preparation.
  109196. */
  109197. buildUniformLayout(): void;
  109198. /**
  109199. * Unbinds the material from the mesh
  109200. */
  109201. unbind(): void;
  109202. /**
  109203. * Binds the submesh to this material by preparing the effect and shader to draw
  109204. * @param world defines the world transformation matrix
  109205. * @param mesh defines the mesh containing the submesh
  109206. * @param subMesh defines the submesh to bind the material to
  109207. */
  109208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109209. /**
  109210. * Get the list of animatables in the material.
  109211. * @returns the list of animatables object used in the material
  109212. */
  109213. getAnimatables(): IAnimatable[];
  109214. /**
  109215. * Gets the active textures from the material
  109216. * @returns an array of textures
  109217. */
  109218. getActiveTextures(): BaseTexture[];
  109219. /**
  109220. * Specifies if the material uses a texture
  109221. * @param texture defines the texture to check against the material
  109222. * @returns a boolean specifying if the material uses the texture
  109223. */
  109224. hasTexture(texture: BaseTexture): boolean;
  109225. /**
  109226. * Disposes the material
  109227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109229. */
  109230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109231. /**
  109232. * Makes a duplicate of the material, and gives it a new name
  109233. * @param name defines the new name for the duplicated material
  109234. * @returns the cloned material
  109235. */
  109236. clone(name: string): StandardMaterial;
  109237. /**
  109238. * Serializes this material in a JSON representation
  109239. * @returns the serialized material object
  109240. */
  109241. serialize(): any;
  109242. /**
  109243. * Creates a standard material from parsed material data
  109244. * @param source defines the JSON representation of the material
  109245. * @param scene defines the hosting scene
  109246. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109247. * @returns a new standard material
  109248. */
  109249. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109250. /**
  109251. * Are diffuse textures enabled in the application.
  109252. */
  109253. static DiffuseTextureEnabled: boolean;
  109254. /**
  109255. * Are ambient textures enabled in the application.
  109256. */
  109257. static AmbientTextureEnabled: boolean;
  109258. /**
  109259. * Are opacity textures enabled in the application.
  109260. */
  109261. static OpacityTextureEnabled: boolean;
  109262. /**
  109263. * Are reflection textures enabled in the application.
  109264. */
  109265. static ReflectionTextureEnabled: boolean;
  109266. /**
  109267. * Are emissive textures enabled in the application.
  109268. */
  109269. static EmissiveTextureEnabled: boolean;
  109270. /**
  109271. * Are specular textures enabled in the application.
  109272. */
  109273. static SpecularTextureEnabled: boolean;
  109274. /**
  109275. * Are bump textures enabled in the application.
  109276. */
  109277. static BumpTextureEnabled: boolean;
  109278. /**
  109279. * Are lightmap textures enabled in the application.
  109280. */
  109281. static LightmapTextureEnabled: boolean;
  109282. /**
  109283. * Are refraction textures enabled in the application.
  109284. */
  109285. static RefractionTextureEnabled: boolean;
  109286. /**
  109287. * Are color grading textures enabled in the application.
  109288. */
  109289. static ColorGradingTextureEnabled: boolean;
  109290. /**
  109291. * Are fresnels enabled in the application.
  109292. */
  109293. static FresnelEnabled: boolean;
  109294. }
  109295. }
  109296. declare module BABYLON {
  109297. /** @hidden */
  109298. export var imageProcessingPixelShader: {
  109299. name: string;
  109300. shader: string;
  109301. };
  109302. }
  109303. declare module BABYLON {
  109304. /**
  109305. * ImageProcessingPostProcess
  109306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109307. */
  109308. export class ImageProcessingPostProcess extends PostProcess {
  109309. /**
  109310. * Default configuration related to image processing available in the PBR Material.
  109311. */
  109312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109313. /**
  109314. * Gets the image processing configuration used either in this material.
  109315. */
  109316. /**
  109317. * Sets the Default image processing configuration used either in the this material.
  109318. *
  109319. * If sets to null, the scene one is in use.
  109320. */
  109321. imageProcessingConfiguration: ImageProcessingConfiguration;
  109322. /**
  109323. * Keep track of the image processing observer to allow dispose and replace.
  109324. */
  109325. private _imageProcessingObserver;
  109326. /**
  109327. * Attaches a new image processing configuration to the PBR Material.
  109328. * @param configuration
  109329. */
  109330. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109331. /**
  109332. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109333. */
  109334. /**
  109335. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109336. */
  109337. colorCurves: Nullable<ColorCurves>;
  109338. /**
  109339. * Gets wether the color curves effect is enabled.
  109340. */
  109341. /**
  109342. * Sets wether the color curves effect is enabled.
  109343. */
  109344. colorCurvesEnabled: boolean;
  109345. /**
  109346. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109347. */
  109348. /**
  109349. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109350. */
  109351. colorGradingTexture: Nullable<BaseTexture>;
  109352. /**
  109353. * Gets wether the color grading effect is enabled.
  109354. */
  109355. /**
  109356. * Gets wether the color grading effect is enabled.
  109357. */
  109358. colorGradingEnabled: boolean;
  109359. /**
  109360. * Gets exposure used in the effect.
  109361. */
  109362. /**
  109363. * Sets exposure used in the effect.
  109364. */
  109365. exposure: number;
  109366. /**
  109367. * Gets wether tonemapping is enabled or not.
  109368. */
  109369. /**
  109370. * Sets wether tonemapping is enabled or not
  109371. */
  109372. toneMappingEnabled: boolean;
  109373. /**
  109374. * Gets the type of tone mapping effect.
  109375. */
  109376. /**
  109377. * Sets the type of tone mapping effect.
  109378. */
  109379. toneMappingType: number;
  109380. /**
  109381. * Gets contrast used in the effect.
  109382. */
  109383. /**
  109384. * Sets contrast used in the effect.
  109385. */
  109386. contrast: number;
  109387. /**
  109388. * Gets Vignette stretch size.
  109389. */
  109390. /**
  109391. * Sets Vignette stretch size.
  109392. */
  109393. vignetteStretch: number;
  109394. /**
  109395. * Gets Vignette centre X Offset.
  109396. */
  109397. /**
  109398. * Sets Vignette centre X Offset.
  109399. */
  109400. vignetteCentreX: number;
  109401. /**
  109402. * Gets Vignette centre Y Offset.
  109403. */
  109404. /**
  109405. * Sets Vignette centre Y Offset.
  109406. */
  109407. vignetteCentreY: number;
  109408. /**
  109409. * Gets Vignette weight or intensity of the vignette effect.
  109410. */
  109411. /**
  109412. * Sets Vignette weight or intensity of the vignette effect.
  109413. */
  109414. vignetteWeight: number;
  109415. /**
  109416. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109417. * if vignetteEnabled is set to true.
  109418. */
  109419. /**
  109420. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109421. * if vignetteEnabled is set to true.
  109422. */
  109423. vignetteColor: Color4;
  109424. /**
  109425. * Gets Camera field of view used by the Vignette effect.
  109426. */
  109427. /**
  109428. * Sets Camera field of view used by the Vignette effect.
  109429. */
  109430. vignetteCameraFov: number;
  109431. /**
  109432. * Gets the vignette blend mode allowing different kind of effect.
  109433. */
  109434. /**
  109435. * Sets the vignette blend mode allowing different kind of effect.
  109436. */
  109437. vignetteBlendMode: number;
  109438. /**
  109439. * Gets wether the vignette effect is enabled.
  109440. */
  109441. /**
  109442. * Sets wether the vignette effect is enabled.
  109443. */
  109444. vignetteEnabled: boolean;
  109445. private _fromLinearSpace;
  109446. /**
  109447. * Gets wether the input of the processing is in Gamma or Linear Space.
  109448. */
  109449. /**
  109450. * Sets wether the input of the processing is in Gamma or Linear Space.
  109451. */
  109452. fromLinearSpace: boolean;
  109453. /**
  109454. * Defines cache preventing GC.
  109455. */
  109456. private _defines;
  109457. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109458. /**
  109459. * "ImageProcessingPostProcess"
  109460. * @returns "ImageProcessingPostProcess"
  109461. */
  109462. getClassName(): string;
  109463. protected _updateParameters(): void;
  109464. dispose(camera?: Camera): void;
  109465. }
  109466. }
  109467. declare module BABYLON {
  109468. /**
  109469. * Class containing static functions to help procedurally build meshes
  109470. */
  109471. export class GroundBuilder {
  109472. /**
  109473. * Creates a ground mesh
  109474. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109475. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109477. * @param name defines the name of the mesh
  109478. * @param options defines the options used to create the mesh
  109479. * @param scene defines the hosting scene
  109480. * @returns the ground mesh
  109481. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109482. */
  109483. static CreateGround(name: string, options: {
  109484. width?: number;
  109485. height?: number;
  109486. subdivisions?: number;
  109487. subdivisionsX?: number;
  109488. subdivisionsY?: number;
  109489. updatable?: boolean;
  109490. }, scene: any): Mesh;
  109491. /**
  109492. * Creates a tiled ground mesh
  109493. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109494. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109495. * * 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
  109496. * * 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
  109497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109498. * @param name defines the name of the mesh
  109499. * @param options defines the options used to create the mesh
  109500. * @param scene defines the hosting scene
  109501. * @returns the tiled ground mesh
  109502. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109503. */
  109504. static CreateTiledGround(name: string, options: {
  109505. xmin: number;
  109506. zmin: number;
  109507. xmax: number;
  109508. zmax: number;
  109509. subdivisions?: {
  109510. w: number;
  109511. h: number;
  109512. };
  109513. precision?: {
  109514. w: number;
  109515. h: number;
  109516. };
  109517. updatable?: boolean;
  109518. }, scene?: Nullable<Scene>): Mesh;
  109519. /**
  109520. * Creates a ground mesh from a height map
  109521. * * The parameter `url` sets the URL of the height map image resource.
  109522. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109523. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109524. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109525. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109526. * * 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.
  109527. * * 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).
  109528. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109530. * @param name defines the name of the mesh
  109531. * @param url defines the url to the height map
  109532. * @param options defines the options used to create the mesh
  109533. * @param scene defines the hosting scene
  109534. * @returns the ground mesh
  109535. * @see https://doc.babylonjs.com/babylon101/height_map
  109536. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109537. */
  109538. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109539. width?: number;
  109540. height?: number;
  109541. subdivisions?: number;
  109542. minHeight?: number;
  109543. maxHeight?: number;
  109544. colorFilter?: Color3;
  109545. alphaFilter?: number;
  109546. updatable?: boolean;
  109547. onReady?: (mesh: GroundMesh) => void;
  109548. }, scene?: Nullable<Scene>): GroundMesh;
  109549. }
  109550. }
  109551. declare module BABYLON {
  109552. /**
  109553. * Class containing static functions to help procedurally build meshes
  109554. */
  109555. export class TorusBuilder {
  109556. /**
  109557. * Creates a torus mesh
  109558. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109559. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109560. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109564. * @param name defines the name of the mesh
  109565. * @param options defines the options used to create the mesh
  109566. * @param scene defines the hosting scene
  109567. * @returns the torus mesh
  109568. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109569. */
  109570. static CreateTorus(name: string, options: {
  109571. diameter?: number;
  109572. thickness?: number;
  109573. tessellation?: number;
  109574. updatable?: boolean;
  109575. sideOrientation?: number;
  109576. frontUVs?: Vector4;
  109577. backUVs?: Vector4;
  109578. }, scene: any): Mesh;
  109579. }
  109580. }
  109581. declare module BABYLON {
  109582. /**
  109583. * Class containing static functions to help procedurally build meshes
  109584. */
  109585. export class CylinderBuilder {
  109586. /**
  109587. * Creates a cylinder or a cone mesh
  109588. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109589. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109590. * * 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.
  109591. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109592. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109593. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109594. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109595. * * 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).
  109596. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109597. * * 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).
  109598. * * 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
  109599. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109600. * * 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
  109601. * * 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.
  109602. * * If `enclose` is false, a ring surface is one element.
  109603. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109604. * * 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
  109605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109608. * @param name defines the name of the mesh
  109609. * @param options defines the options used to create the mesh
  109610. * @param scene defines the hosting scene
  109611. * @returns the cylinder mesh
  109612. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109613. */
  109614. static CreateCylinder(name: string, options: {
  109615. height?: number;
  109616. diameterTop?: number;
  109617. diameterBottom?: number;
  109618. diameter?: number;
  109619. tessellation?: number;
  109620. subdivisions?: number;
  109621. arc?: number;
  109622. faceColors?: Color4[];
  109623. faceUV?: Vector4[];
  109624. updatable?: boolean;
  109625. hasRings?: boolean;
  109626. enclose?: boolean;
  109627. cap?: number;
  109628. sideOrientation?: number;
  109629. frontUVs?: Vector4;
  109630. backUVs?: Vector4;
  109631. }, scene: any): Mesh;
  109632. }
  109633. }
  109634. declare module BABYLON {
  109635. /**
  109636. * Options to modify the vr teleportation behavior.
  109637. */
  109638. export interface VRTeleportationOptions {
  109639. /**
  109640. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109641. */
  109642. floorMeshName?: string;
  109643. /**
  109644. * A list of meshes to be used as the teleportation floor. (default: empty)
  109645. */
  109646. floorMeshes?: Mesh[];
  109647. }
  109648. /**
  109649. * Options to modify the vr experience helper's behavior.
  109650. */
  109651. export interface VRExperienceHelperOptions extends WebVROptions {
  109652. /**
  109653. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109654. */
  109655. createDeviceOrientationCamera?: boolean;
  109656. /**
  109657. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109658. */
  109659. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109660. /**
  109661. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109662. */
  109663. laserToggle?: boolean;
  109664. /**
  109665. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109666. */
  109667. floorMeshes?: Mesh[];
  109668. /**
  109669. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109670. */
  109671. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109672. }
  109673. /**
  109674. * Event containing information after VR has been entered
  109675. */
  109676. export class OnAfterEnteringVRObservableEvent {
  109677. /**
  109678. * If entering vr was successful
  109679. */
  109680. success: boolean;
  109681. }
  109682. /**
  109683. * Helps to quickly add VR support to an existing scene.
  109684. * See http://doc.babylonjs.com/how_to/webvr_helper
  109685. */
  109686. export class VRExperienceHelper {
  109687. /** Options to modify the vr experience helper's behavior. */
  109688. webVROptions: VRExperienceHelperOptions;
  109689. private _scene;
  109690. private _position;
  109691. private _btnVR;
  109692. private _btnVRDisplayed;
  109693. private _webVRsupported;
  109694. private _webVRready;
  109695. private _webVRrequesting;
  109696. private _webVRpresenting;
  109697. private _hasEnteredVR;
  109698. private _fullscreenVRpresenting;
  109699. private _inputElement;
  109700. private _webVRCamera;
  109701. private _vrDeviceOrientationCamera;
  109702. private _deviceOrientationCamera;
  109703. private _existingCamera;
  109704. private _onKeyDown;
  109705. private _onVrDisplayPresentChange;
  109706. private _onVRDisplayChanged;
  109707. private _onVRRequestPresentStart;
  109708. private _onVRRequestPresentComplete;
  109709. /**
  109710. * 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)
  109711. */
  109712. enableGazeEvenWhenNoPointerLock: boolean;
  109713. /**
  109714. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109715. */
  109716. exitVROnDoubleTap: boolean;
  109717. /**
  109718. * Observable raised right before entering VR.
  109719. */
  109720. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109721. /**
  109722. * Observable raised when entering VR has completed.
  109723. */
  109724. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109725. /**
  109726. * Observable raised when exiting VR.
  109727. */
  109728. onExitingVRObservable: Observable<VRExperienceHelper>;
  109729. /**
  109730. * Observable raised when controller mesh is loaded.
  109731. */
  109732. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109733. /** Return this.onEnteringVRObservable
  109734. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109735. */
  109736. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109737. /** Return this.onExitingVRObservable
  109738. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109739. */
  109740. readonly onExitingVR: Observable<VRExperienceHelper>;
  109741. /** Return this.onControllerMeshLoadedObservable
  109742. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109743. */
  109744. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109745. private _rayLength;
  109746. private _useCustomVRButton;
  109747. private _teleportationRequested;
  109748. private _teleportActive;
  109749. private _floorMeshName;
  109750. private _floorMeshesCollection;
  109751. private _rotationAllowed;
  109752. private _teleportBackwardsVector;
  109753. private _teleportationTarget;
  109754. private _isDefaultTeleportationTarget;
  109755. private _postProcessMove;
  109756. private _teleportationFillColor;
  109757. private _teleportationBorderColor;
  109758. private _rotationAngle;
  109759. private _haloCenter;
  109760. private _cameraGazer;
  109761. private _padSensibilityUp;
  109762. private _padSensibilityDown;
  109763. private _leftController;
  109764. private _rightController;
  109765. /**
  109766. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109767. */
  109768. onNewMeshSelected: Observable<AbstractMesh>;
  109769. /**
  109770. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109771. * This observable will provide the mesh and the controller used to select the mesh
  109772. */
  109773. onMeshSelectedWithController: Observable<{
  109774. mesh: AbstractMesh;
  109775. controller: WebVRController;
  109776. }>;
  109777. /**
  109778. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109779. */
  109780. onNewMeshPicked: Observable<PickingInfo>;
  109781. private _circleEase;
  109782. /**
  109783. * Observable raised before camera teleportation
  109784. */
  109785. onBeforeCameraTeleport: Observable<Vector3>;
  109786. /**
  109787. * Observable raised after camera teleportation
  109788. */
  109789. onAfterCameraTeleport: Observable<Vector3>;
  109790. /**
  109791. * Observable raised when current selected mesh gets unselected
  109792. */
  109793. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109794. private _raySelectionPredicate;
  109795. /**
  109796. * To be optionaly changed by user to define custom ray selection
  109797. */
  109798. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109799. /**
  109800. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109801. */
  109802. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109803. /**
  109804. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109805. */
  109806. teleportationEnabled: boolean;
  109807. private _defaultHeight;
  109808. private _teleportationInitialized;
  109809. private _interactionsEnabled;
  109810. private _interactionsRequested;
  109811. private _displayGaze;
  109812. private _displayLaserPointer;
  109813. /**
  109814. * The mesh used to display where the user is going to teleport.
  109815. */
  109816. /**
  109817. * Sets the mesh to be used to display where the user is going to teleport.
  109818. */
  109819. teleportationTarget: Mesh;
  109820. /**
  109821. * 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
  109822. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109823. * See http://doc.babylonjs.com/resources/baking_transformations
  109824. */
  109825. gazeTrackerMesh: Mesh;
  109826. /**
  109827. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109828. */
  109829. updateGazeTrackerScale: boolean;
  109830. /**
  109831. * If the gaze trackers color should be updated when selecting meshes
  109832. */
  109833. updateGazeTrackerColor: boolean;
  109834. /**
  109835. * If the controller laser color should be updated when selecting meshes
  109836. */
  109837. updateControllerLaserColor: boolean;
  109838. /**
  109839. * The gaze tracking mesh corresponding to the left controller
  109840. */
  109841. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109842. /**
  109843. * The gaze tracking mesh corresponding to the right controller
  109844. */
  109845. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109846. /**
  109847. * If the ray of the gaze should be displayed.
  109848. */
  109849. /**
  109850. * Sets if the ray of the gaze should be displayed.
  109851. */
  109852. displayGaze: boolean;
  109853. /**
  109854. * If the ray of the LaserPointer should be displayed.
  109855. */
  109856. /**
  109857. * Sets if the ray of the LaserPointer should be displayed.
  109858. */
  109859. displayLaserPointer: boolean;
  109860. /**
  109861. * The deviceOrientationCamera used as the camera when not in VR.
  109862. */
  109863. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109864. /**
  109865. * Based on the current WebVR support, returns the current VR camera used.
  109866. */
  109867. readonly currentVRCamera: Nullable<Camera>;
  109868. /**
  109869. * The webVRCamera which is used when in VR.
  109870. */
  109871. readonly webVRCamera: WebVRFreeCamera;
  109872. /**
  109873. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109874. */
  109875. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109876. /**
  109877. * The html button that is used to trigger entering into VR.
  109878. */
  109879. readonly vrButton: Nullable<HTMLButtonElement>;
  109880. private readonly _teleportationRequestInitiated;
  109881. /**
  109882. * Defines wether or not Pointer lock should be requested when switching to
  109883. * full screen.
  109884. */
  109885. requestPointerLockOnFullScreen: boolean;
  109886. /**
  109887. * Instantiates a VRExperienceHelper.
  109888. * Helps to quickly add VR support to an existing scene.
  109889. * @param scene The scene the VRExperienceHelper belongs to.
  109890. * @param webVROptions Options to modify the vr experience helper's behavior.
  109891. */
  109892. constructor(scene: Scene,
  109893. /** Options to modify the vr experience helper's behavior. */
  109894. webVROptions?: VRExperienceHelperOptions);
  109895. private _onDefaultMeshLoaded;
  109896. private _onResize;
  109897. private _onFullscreenChange;
  109898. /**
  109899. * Gets a value indicating if we are currently in VR mode.
  109900. */
  109901. readonly isInVRMode: boolean;
  109902. private onVrDisplayPresentChange;
  109903. private onVRDisplayChanged;
  109904. private moveButtonToBottomRight;
  109905. private displayVRButton;
  109906. private updateButtonVisibility;
  109907. private _cachedAngularSensibility;
  109908. /**
  109909. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109910. * Otherwise, will use the fullscreen API.
  109911. */
  109912. enterVR(): void;
  109913. /**
  109914. * Attempt to exit VR, or fullscreen.
  109915. */
  109916. exitVR(): void;
  109917. /**
  109918. * The position of the vr experience helper.
  109919. */
  109920. /**
  109921. * Sets the position of the vr experience helper.
  109922. */
  109923. position: Vector3;
  109924. /**
  109925. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109926. */
  109927. enableInteractions(): void;
  109928. private readonly _noControllerIsActive;
  109929. private beforeRender;
  109930. private _isTeleportationFloor;
  109931. /**
  109932. * Adds a floor mesh to be used for teleportation.
  109933. * @param floorMesh the mesh to be used for teleportation.
  109934. */
  109935. addFloorMesh(floorMesh: Mesh): void;
  109936. /**
  109937. * Removes a floor mesh from being used for teleportation.
  109938. * @param floorMesh the mesh to be removed.
  109939. */
  109940. removeFloorMesh(floorMesh: Mesh): void;
  109941. /**
  109942. * Enables interactions and teleportation using the VR controllers and gaze.
  109943. * @param vrTeleportationOptions options to modify teleportation behavior.
  109944. */
  109945. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109946. private _onNewGamepadConnected;
  109947. private _tryEnableInteractionOnController;
  109948. private _onNewGamepadDisconnected;
  109949. private _enableInteractionOnController;
  109950. private _checkTeleportWithRay;
  109951. private _checkRotate;
  109952. private _checkTeleportBackwards;
  109953. private _enableTeleportationOnController;
  109954. private _createTeleportationCircles;
  109955. private _displayTeleportationTarget;
  109956. private _hideTeleportationTarget;
  109957. private _rotateCamera;
  109958. private _moveTeleportationSelectorTo;
  109959. private _workingVector;
  109960. private _workingQuaternion;
  109961. private _workingMatrix;
  109962. /**
  109963. * Teleports the users feet to the desired location
  109964. * @param location The location where the user's feet should be placed
  109965. */
  109966. teleportCamera(location: Vector3): void;
  109967. private _convertNormalToDirectionOfRay;
  109968. private _castRayAndSelectObject;
  109969. private _notifySelectedMeshUnselected;
  109970. /**
  109971. * Sets the color of the laser ray from the vr controllers.
  109972. * @param color new color for the ray.
  109973. */
  109974. changeLaserColor(color: Color3): void;
  109975. /**
  109976. * Sets the color of the ray from the vr headsets gaze.
  109977. * @param color new color for the ray.
  109978. */
  109979. changeGazeColor(color: Color3): void;
  109980. /**
  109981. * Exits VR and disposes of the vr experience helper
  109982. */
  109983. dispose(): void;
  109984. /**
  109985. * Gets the name of the VRExperienceHelper class
  109986. * @returns "VRExperienceHelper"
  109987. */
  109988. getClassName(): string;
  109989. }
  109990. }
  109991. declare module BABYLON {
  109992. /**
  109993. * States of the webXR experience
  109994. */
  109995. export enum WebXRState {
  109996. /**
  109997. * Transitioning to being in XR mode
  109998. */
  109999. ENTERING_XR = 0,
  110000. /**
  110001. * Transitioning to non XR mode
  110002. */
  110003. EXITING_XR = 1,
  110004. /**
  110005. * In XR mode and presenting
  110006. */
  110007. IN_XR = 2,
  110008. /**
  110009. * Not entered XR mode
  110010. */
  110011. NOT_IN_XR = 3
  110012. }
  110013. /**
  110014. * Abstraction of the XR render target
  110015. */
  110016. export interface WebXRRenderTarget extends IDisposable {
  110017. /**
  110018. * xrpresent context of the canvas which can be used to display/mirror xr content
  110019. */
  110020. canvasContext: WebGLRenderingContext;
  110021. /**
  110022. * xr layer for the canvas
  110023. */
  110024. xrLayer: Nullable<XRWebGLLayer>;
  110025. /**
  110026. * Initializes the xr layer for the session
  110027. * @param xrSession xr session
  110028. * @returns a promise that will resolve once the XR Layer has been created
  110029. */
  110030. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110031. }
  110032. }
  110033. declare module BABYLON {
  110034. /**
  110035. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110036. */
  110037. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110038. private _engine;
  110039. private _canvas;
  110040. /**
  110041. * xrpresent context of the canvas which can be used to display/mirror xr content
  110042. */
  110043. canvasContext: WebGLRenderingContext;
  110044. /**
  110045. * xr layer for the canvas
  110046. */
  110047. xrLayer: Nullable<XRWebGLLayer>;
  110048. /**
  110049. * Initializes the xr layer for the session
  110050. * @param xrSession xr session
  110051. * @returns a promise that will resolve once the XR Layer has been created
  110052. */
  110053. initializeXRLayerAsync(xrSession: any): any;
  110054. /**
  110055. * Initializes the canvas to be added/removed upon entering/exiting xr
  110056. * @param engine the Babylon engine
  110057. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110058. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110059. */
  110060. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  110061. /**
  110062. * Disposes of the object
  110063. */
  110064. dispose(): void;
  110065. private _setManagedOutputCanvas;
  110066. private _addCanvas;
  110067. private _removeCanvas;
  110068. }
  110069. }
  110070. declare module BABYLON {
  110071. /**
  110072. * Manages an XRSession to work with Babylon's engine
  110073. * @see https://doc.babylonjs.com/how_to/webxr
  110074. */
  110075. export class WebXRSessionManager implements IDisposable {
  110076. private scene;
  110077. /**
  110078. * Fires every time a new xrFrame arrives which can be used to update the camera
  110079. */
  110080. onXRFrameObservable: Observable<any>;
  110081. /**
  110082. * Fires when the xr session is ended either by the device or manually done
  110083. */
  110084. onXRSessionEnded: Observable<any>;
  110085. /**
  110086. * Underlying xr session
  110087. */
  110088. session: XRSession;
  110089. /**
  110090. * Type of reference space used when creating the session
  110091. */
  110092. referenceSpace: XRReferenceSpace;
  110093. /**
  110094. * Current XR frame
  110095. */
  110096. currentFrame: Nullable<XRFrame>;
  110097. private _xrNavigator;
  110098. private baseLayer;
  110099. private _rttProvider;
  110100. private _sessionEnded;
  110101. /**
  110102. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110103. * @param scene The scene which the session should be created for
  110104. */
  110105. constructor(scene: Scene);
  110106. /**
  110107. * Initializes the manager
  110108. * After initialization enterXR can be called to start an XR session
  110109. * @returns Promise which resolves after it is initialized
  110110. */
  110111. initializeAsync(): Promise<void>;
  110112. /**
  110113. * Initializes an xr session
  110114. * @param xrSessionMode mode to initialize
  110115. * @param optionalFeatures defines optional values to pass to the session builder
  110116. * @returns a promise which will resolve once the session has been initialized
  110117. */
  110118. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  110119. /**
  110120. * Sets the reference space on the xr session
  110121. * @param referenceSpace space to set
  110122. * @returns a promise that will resolve once the reference space has been set
  110123. */
  110124. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110125. /**
  110126. * Updates the render state of the session
  110127. * @param state state to set
  110128. * @returns a promise that resolves once the render state has been updated
  110129. */
  110130. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110131. /**
  110132. * Starts rendering to the xr layer
  110133. * @returns a promise that will resolve once rendering has started
  110134. */
  110135. startRenderingToXRAsync(): Promise<void>;
  110136. /**
  110137. * Gets the correct render target texture to be rendered this frame for this eye
  110138. * @param eye the eye for which to get the render target
  110139. * @returns the render target for the specified eye
  110140. */
  110141. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110142. /**
  110143. * Stops the xrSession and restores the renderloop
  110144. * @returns Promise which resolves after it exits XR
  110145. */
  110146. exitXRAsync(): Promise<void>;
  110147. /**
  110148. * Checks if a session would be supported for the creation options specified
  110149. * @param sessionMode session mode to check if supported eg. immersive-vr
  110150. * @returns true if supported
  110151. */
  110152. supportsSessionAsync(sessionMode: XRSessionMode): any;
  110153. /**
  110154. * Creates a WebXRRenderTarget object for the XR session
  110155. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110156. * @returns a WebXR render target to which the session can render
  110157. */
  110158. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  110159. /**
  110160. * @hidden
  110161. * Converts the render layer of xrSession to a render target
  110162. * @param session session to create render target for
  110163. * @param scene scene the new render target should be created for
  110164. */
  110165. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110166. /**
  110167. * Disposes of the session manager
  110168. */
  110169. dispose(): void;
  110170. }
  110171. }
  110172. declare module BABYLON {
  110173. /**
  110174. * WebXR Camera which holds the views for the xrSession
  110175. * @see https://doc.babylonjs.com/how_to/webxr
  110176. */
  110177. export class WebXRCamera extends FreeCamera {
  110178. private static _TmpMatrix;
  110179. /**
  110180. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110181. * @param name the name of the camera
  110182. * @param scene the scene to add the camera to
  110183. */
  110184. constructor(name: string, scene: Scene);
  110185. private _updateNumberOfRigCameras;
  110186. /** @hidden */
  110187. _updateForDualEyeDebugging(): void;
  110188. /**
  110189. * Updates the cameras position from the current pose information of the XR session
  110190. * @param xrSessionManager the session containing pose information
  110191. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110192. */
  110193. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110194. }
  110195. }
  110196. declare module BABYLON {
  110197. /**
  110198. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110199. * @see https://doc.babylonjs.com/how_to/webxr
  110200. */
  110201. export class WebXRExperienceHelper implements IDisposable {
  110202. private scene;
  110203. /**
  110204. * 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
  110205. */
  110206. container: AbstractMesh;
  110207. /**
  110208. * Camera used to render xr content
  110209. */
  110210. camera: WebXRCamera;
  110211. /**
  110212. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110213. */
  110214. state: WebXRState;
  110215. private _setState;
  110216. private static _TmpVector;
  110217. /**
  110218. * Fires when the state of the experience helper has changed
  110219. */
  110220. onStateChangedObservable: Observable<WebXRState>;
  110221. /** Session manager used to keep track of xr session */
  110222. sessionManager: WebXRSessionManager;
  110223. private _nonVRCamera;
  110224. private _originalSceneAutoClear;
  110225. private _supported;
  110226. /**
  110227. * Creates the experience helper
  110228. * @param scene the scene to attach the experience helper to
  110229. * @returns a promise for the experience helper
  110230. */
  110231. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110232. /**
  110233. * Creates a WebXRExperienceHelper
  110234. * @param scene The scene the helper should be created in
  110235. */
  110236. private constructor();
  110237. /**
  110238. * Exits XR mode and returns the scene to its original state
  110239. * @returns promise that resolves after xr mode has exited
  110240. */
  110241. exitXRAsync(): Promise<void>;
  110242. /**
  110243. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110244. * @param sessionMode options for the XR session
  110245. * @param referenceSpaceType frame of reference of the XR session
  110246. * @param renderTarget the output canvas that will be used to enter XR mode
  110247. * @returns promise that resolves after xr mode has entered
  110248. */
  110249. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110250. /**
  110251. * Updates the global position of the camera by moving the camera's container
  110252. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110253. * @param position The desired global position of the camera
  110254. */
  110255. setPositionOfCameraUsingContainer(position: Vector3): void;
  110256. /**
  110257. * Rotates the xr camera by rotating the camera's container around the camera's position
  110258. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110259. * @param rotation the desired quaternion rotation to apply to the camera
  110260. */
  110261. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110262. /**
  110263. * Disposes of the experience helper
  110264. */
  110265. dispose(): void;
  110266. }
  110267. }
  110268. declare module BABYLON {
  110269. /**
  110270. * Button which can be used to enter a different mode of XR
  110271. */
  110272. export class WebXREnterExitUIButton {
  110273. /** button element */
  110274. element: HTMLElement;
  110275. /** XR initialization options for the button */
  110276. sessionMode: XRSessionMode;
  110277. /** Reference space type */
  110278. referenceSpaceType: XRReferenceSpaceType;
  110279. /**
  110280. * Creates a WebXREnterExitUIButton
  110281. * @param element button element
  110282. * @param sessionMode XR initialization session mode
  110283. * @param referenceSpaceType the type of reference space to be used
  110284. */
  110285. constructor(
  110286. /** button element */
  110287. element: HTMLElement,
  110288. /** XR initialization options for the button */
  110289. sessionMode: XRSessionMode,
  110290. /** Reference space type */
  110291. referenceSpaceType: XRReferenceSpaceType);
  110292. /**
  110293. * Overwritable function which can be used to update the button's visuals when the state changes
  110294. * @param activeButton the current active button in the UI
  110295. */
  110296. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110297. }
  110298. /**
  110299. * Options to create the webXR UI
  110300. */
  110301. export class WebXREnterExitUIOptions {
  110302. /**
  110303. * Context to enter xr with
  110304. */
  110305. renderTarget?: Nullable<WebXRRenderTarget>;
  110306. /**
  110307. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110308. */
  110309. customButtons?: Array<WebXREnterExitUIButton>;
  110310. }
  110311. /**
  110312. * UI to allow the user to enter/exit XR mode
  110313. */
  110314. export class WebXREnterExitUI implements IDisposable {
  110315. private scene;
  110316. private _overlay;
  110317. private _buttons;
  110318. private _activeButton;
  110319. /**
  110320. * Fired every time the active button is changed.
  110321. *
  110322. * When xr is entered via a button that launches xr that button will be the callback parameter
  110323. *
  110324. * When exiting xr the callback parameter will be null)
  110325. */
  110326. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110327. /**
  110328. * Creates UI to allow the user to enter/exit XR mode
  110329. * @param scene the scene to add the ui to
  110330. * @param helper the xr experience helper to enter/exit xr with
  110331. * @param options options to configure the UI
  110332. * @returns the created ui
  110333. */
  110334. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110335. private constructor();
  110336. private _updateButtons;
  110337. /**
  110338. * Disposes of the object
  110339. */
  110340. dispose(): void;
  110341. }
  110342. }
  110343. declare module BABYLON {
  110344. /**
  110345. * Represents an XR input
  110346. */
  110347. export class WebXRController {
  110348. private scene;
  110349. /** The underlying input source for the controller */
  110350. inputSource: XRInputSource;
  110351. private parentContainer;
  110352. /**
  110353. * 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
  110354. */
  110355. grip?: AbstractMesh;
  110356. /**
  110357. * Pointer which can be used to select objects or attach a visible laser to
  110358. */
  110359. pointer: AbstractMesh;
  110360. private _gamepadMode;
  110361. /**
  110362. * If available, this is the gamepad object related to this controller.
  110363. * Using this object it is possible to get click events and trackpad changes of the
  110364. * webxr controller that is currently being used.
  110365. */
  110366. gamepadController?: WebVRController;
  110367. /**
  110368. * Event that fires when the controller is removed/disposed
  110369. */
  110370. onDisposeObservable: Observable<{}>;
  110371. private _tmpMatrix;
  110372. private _tmpQuaternion;
  110373. private _tmpVector;
  110374. /**
  110375. * Creates the controller
  110376. * @see https://doc.babylonjs.com/how_to/webxr
  110377. * @param scene the scene which the controller should be associated to
  110378. * @param inputSource the underlying input source for the controller
  110379. * @param parentContainer parent that the controller meshes should be children of
  110380. */
  110381. constructor(scene: Scene,
  110382. /** The underlying input source for the controller */
  110383. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110384. /**
  110385. * Updates the controller pose based on the given XRFrame
  110386. * @param xrFrame xr frame to update the pose with
  110387. * @param referenceSpace reference space to use
  110388. */
  110389. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110390. /**
  110391. * Gets a world space ray coming from the controller
  110392. * @param result the resulting ray
  110393. */
  110394. getWorldPointerRayToRef(result: Ray): void;
  110395. /**
  110396. * Get the scene associated with this controller
  110397. * @returns the scene object
  110398. */
  110399. getScene(): Scene;
  110400. /**
  110401. * Disposes of the object
  110402. */
  110403. dispose(): void;
  110404. }
  110405. }
  110406. declare module BABYLON {
  110407. /**
  110408. * XR input used to track XR inputs such as controllers/rays
  110409. */
  110410. export class WebXRInput implements IDisposable {
  110411. /**
  110412. * Base experience the input listens to
  110413. */
  110414. baseExperience: WebXRExperienceHelper;
  110415. /**
  110416. * XR controllers being tracked
  110417. */
  110418. controllers: Array<WebXRController>;
  110419. private _frameObserver;
  110420. private _stateObserver;
  110421. /**
  110422. * Event when a controller has been connected/added
  110423. */
  110424. onControllerAddedObservable: Observable<WebXRController>;
  110425. /**
  110426. * Event when a controller has been removed/disconnected
  110427. */
  110428. onControllerRemovedObservable: Observable<WebXRController>;
  110429. /**
  110430. * Initializes the WebXRInput
  110431. * @param baseExperience experience helper which the input should be created for
  110432. */
  110433. constructor(
  110434. /**
  110435. * Base experience the input listens to
  110436. */
  110437. baseExperience: WebXRExperienceHelper);
  110438. private _onInputSourcesChange;
  110439. private _addAndRemoveControllers;
  110440. /**
  110441. * Disposes of the object
  110442. */
  110443. dispose(): void;
  110444. }
  110445. }
  110446. declare module BABYLON {
  110447. /**
  110448. * Enables teleportation
  110449. */
  110450. export class WebXRControllerTeleportation {
  110451. private _teleportationFillColor;
  110452. private _teleportationBorderColor;
  110453. private _tmpRay;
  110454. private _tmpVector;
  110455. /**
  110456. * Creates a WebXRControllerTeleportation
  110457. * @param input input manager to add teleportation to
  110458. * @param floorMeshes floormeshes which can be teleported to
  110459. */
  110460. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110461. }
  110462. }
  110463. declare module BABYLON {
  110464. /**
  110465. * Handles pointer input automatically for the pointer of XR controllers
  110466. */
  110467. export class WebXRControllerPointerSelection {
  110468. private static _idCounter;
  110469. private _tmpRay;
  110470. /**
  110471. * Creates a WebXRControllerPointerSelection
  110472. * @param input input manager to setup pointer selection
  110473. */
  110474. constructor(input: WebXRInput);
  110475. private _convertNormalToDirectionOfRay;
  110476. private _updatePointerDistance;
  110477. }
  110478. }
  110479. declare module BABYLON {
  110480. /**
  110481. * Class used to represent data loading progression
  110482. */
  110483. export class SceneLoaderProgressEvent {
  110484. /** defines if data length to load can be evaluated */
  110485. readonly lengthComputable: boolean;
  110486. /** defines the loaded data length */
  110487. readonly loaded: number;
  110488. /** defines the data length to load */
  110489. readonly total: number;
  110490. /**
  110491. * Create a new progress event
  110492. * @param lengthComputable defines if data length to load can be evaluated
  110493. * @param loaded defines the loaded data length
  110494. * @param total defines the data length to load
  110495. */
  110496. constructor(
  110497. /** defines if data length to load can be evaluated */
  110498. lengthComputable: boolean,
  110499. /** defines the loaded data length */
  110500. loaded: number,
  110501. /** defines the data length to load */
  110502. total: number);
  110503. /**
  110504. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110505. * @param event defines the source event
  110506. * @returns a new SceneLoaderProgressEvent
  110507. */
  110508. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110509. }
  110510. /**
  110511. * Interface used by SceneLoader plugins to define supported file extensions
  110512. */
  110513. export interface ISceneLoaderPluginExtensions {
  110514. /**
  110515. * Defines the list of supported extensions
  110516. */
  110517. [extension: string]: {
  110518. isBinary: boolean;
  110519. };
  110520. }
  110521. /**
  110522. * Interface used by SceneLoader plugin factory
  110523. */
  110524. export interface ISceneLoaderPluginFactory {
  110525. /**
  110526. * Defines the name of the factory
  110527. */
  110528. name: string;
  110529. /**
  110530. * Function called to create a new plugin
  110531. * @return the new plugin
  110532. */
  110533. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110534. /**
  110535. * The callback that returns true if the data can be directly loaded.
  110536. * @param data string containing the file data
  110537. * @returns if the data can be loaded directly
  110538. */
  110539. canDirectLoad?(data: string): boolean;
  110540. }
  110541. /**
  110542. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110543. */
  110544. export interface ISceneLoaderPluginBase {
  110545. /**
  110546. * The friendly name of this plugin.
  110547. */
  110548. name: string;
  110549. /**
  110550. * The file extensions supported by this plugin.
  110551. */
  110552. extensions: string | ISceneLoaderPluginExtensions;
  110553. /**
  110554. * The callback called when loading from a url.
  110555. * @param scene scene loading this url
  110556. * @param url url to load
  110557. * @param onSuccess callback called when the file successfully loads
  110558. * @param onProgress callback called while file is loading (if the server supports this mode)
  110559. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110560. * @param onError callback called when the file fails to load
  110561. * @returns a file request object
  110562. */
  110563. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110564. /**
  110565. * The callback called when loading from a file object.
  110566. * @param scene scene loading this file
  110567. * @param file defines the file to load
  110568. * @param onSuccess defines the callback to call when data is loaded
  110569. * @param onProgress defines the callback to call during loading process
  110570. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110571. * @param onError defines the callback to call when an error occurs
  110572. * @returns a file request object
  110573. */
  110574. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110575. /**
  110576. * The callback that returns true if the data can be directly loaded.
  110577. * @param data string containing the file data
  110578. * @returns if the data can be loaded directly
  110579. */
  110580. canDirectLoad?(data: string): boolean;
  110581. /**
  110582. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110583. * @param scene scene loading this data
  110584. * @param data string containing the data
  110585. * @returns data to pass to the plugin
  110586. */
  110587. directLoad?(scene: Scene, data: string): any;
  110588. /**
  110589. * The callback that allows custom handling of the root url based on the response url.
  110590. * @param rootUrl the original root url
  110591. * @param responseURL the response url if available
  110592. * @returns the new root url
  110593. */
  110594. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110595. }
  110596. /**
  110597. * Interface used to define a SceneLoader plugin
  110598. */
  110599. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110600. /**
  110601. * Import meshes into a scene.
  110602. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110603. * @param scene The scene to import into
  110604. * @param data The data to import
  110605. * @param rootUrl The root url for scene and resources
  110606. * @param meshes The meshes array to import into
  110607. * @param particleSystems The particle systems array to import into
  110608. * @param skeletons The skeletons array to import into
  110609. * @param onError The callback when import fails
  110610. * @returns True if successful or false otherwise
  110611. */
  110612. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110613. /**
  110614. * Load into a scene.
  110615. * @param scene The scene to load into
  110616. * @param data The data to import
  110617. * @param rootUrl The root url for scene and resources
  110618. * @param onError The callback when import fails
  110619. * @returns True if successful or false otherwise
  110620. */
  110621. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110622. /**
  110623. * Load into an asset container.
  110624. * @param scene The scene to load into
  110625. * @param data The data to import
  110626. * @param rootUrl The root url for scene and resources
  110627. * @param onError The callback when import fails
  110628. * @returns The loaded asset container
  110629. */
  110630. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110631. }
  110632. /**
  110633. * Interface used to define an async SceneLoader plugin
  110634. */
  110635. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110636. /**
  110637. * Import meshes into a scene.
  110638. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110639. * @param scene The scene to import into
  110640. * @param data The data to import
  110641. * @param rootUrl The root url for scene and resources
  110642. * @param onProgress The callback when the load progresses
  110643. * @param fileName Defines the name of the file to load
  110644. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110645. */
  110646. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110647. meshes: AbstractMesh[];
  110648. particleSystems: IParticleSystem[];
  110649. skeletons: Skeleton[];
  110650. animationGroups: AnimationGroup[];
  110651. }>;
  110652. /**
  110653. * Load into a scene.
  110654. * @param scene The scene to load into
  110655. * @param data The data to import
  110656. * @param rootUrl The root url for scene and resources
  110657. * @param onProgress The callback when the load progresses
  110658. * @param fileName Defines the name of the file to load
  110659. * @returns Nothing
  110660. */
  110661. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110662. /**
  110663. * Load into an asset container.
  110664. * @param scene The scene to load into
  110665. * @param data The data to import
  110666. * @param rootUrl The root url for scene and resources
  110667. * @param onProgress The callback when the load progresses
  110668. * @param fileName Defines the name of the file to load
  110669. * @returns The loaded asset container
  110670. */
  110671. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110672. }
  110673. /**
  110674. * Class used to load scene from various file formats using registered plugins
  110675. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110676. */
  110677. export class SceneLoader {
  110678. /**
  110679. * No logging while loading
  110680. */
  110681. static readonly NO_LOGGING: number;
  110682. /**
  110683. * Minimal logging while loading
  110684. */
  110685. static readonly MINIMAL_LOGGING: number;
  110686. /**
  110687. * Summary logging while loading
  110688. */
  110689. static readonly SUMMARY_LOGGING: number;
  110690. /**
  110691. * Detailled logging while loading
  110692. */
  110693. static readonly DETAILED_LOGGING: number;
  110694. /**
  110695. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110696. */
  110697. static ForceFullSceneLoadingForIncremental: boolean;
  110698. /**
  110699. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110700. */
  110701. static ShowLoadingScreen: boolean;
  110702. /**
  110703. * Defines the current logging level (while loading the scene)
  110704. * @ignorenaming
  110705. */
  110706. static loggingLevel: number;
  110707. /**
  110708. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110709. */
  110710. static CleanBoneMatrixWeights: boolean;
  110711. /**
  110712. * Event raised when a plugin is used to load a scene
  110713. */
  110714. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110715. private static _registeredPlugins;
  110716. private static _getDefaultPlugin;
  110717. private static _getPluginForExtension;
  110718. private static _getPluginForDirectLoad;
  110719. private static _getPluginForFilename;
  110720. private static _getDirectLoad;
  110721. private static _loadData;
  110722. private static _getFileInfo;
  110723. /**
  110724. * Gets a plugin that can load the given extension
  110725. * @param extension defines the extension to load
  110726. * @returns a plugin or null if none works
  110727. */
  110728. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110729. /**
  110730. * Gets a boolean indicating that the given extension can be loaded
  110731. * @param extension defines the extension to load
  110732. * @returns true if the extension is supported
  110733. */
  110734. static IsPluginForExtensionAvailable(extension: string): boolean;
  110735. /**
  110736. * Adds a new plugin to the list of registered plugins
  110737. * @param plugin defines the plugin to add
  110738. */
  110739. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110740. /**
  110741. * Import meshes into a scene
  110742. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110743. * @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)
  110744. * @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)
  110745. * @param scene the instance of BABYLON.Scene to append to
  110746. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110747. * @param onProgress a callback with a progress event for each file being loaded
  110748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110749. * @param pluginExtension the extension used to determine the plugin
  110750. * @returns The loaded plugin
  110751. */
  110752. 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>;
  110753. /**
  110754. * Import meshes into a scene
  110755. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110756. * @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)
  110757. * @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)
  110758. * @param scene the instance of BABYLON.Scene to append to
  110759. * @param onProgress a callback with a progress event for each file being loaded
  110760. * @param pluginExtension the extension used to determine the plugin
  110761. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110762. */
  110763. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110764. meshes: AbstractMesh[];
  110765. particleSystems: IParticleSystem[];
  110766. skeletons: Skeleton[];
  110767. animationGroups: AnimationGroup[];
  110768. }>;
  110769. /**
  110770. * Load a scene
  110771. * @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)
  110772. * @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)
  110773. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110774. * @param onSuccess a callback with the scene when import succeeds
  110775. * @param onProgress a callback with a progress event for each file being loaded
  110776. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110777. * @param pluginExtension the extension used to determine the plugin
  110778. * @returns The loaded plugin
  110779. */
  110780. 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>;
  110781. /**
  110782. * Load a scene
  110783. * @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)
  110784. * @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)
  110785. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110786. * @param onProgress a callback with a progress event for each file being loaded
  110787. * @param pluginExtension the extension used to determine the plugin
  110788. * @returns The loaded scene
  110789. */
  110790. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110791. /**
  110792. * Append a scene
  110793. * @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)
  110794. * @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)
  110795. * @param scene is the instance of BABYLON.Scene to append to
  110796. * @param onSuccess a callback with the scene when import succeeds
  110797. * @param onProgress a callback with a progress event for each file being loaded
  110798. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110799. * @param pluginExtension the extension used to determine the plugin
  110800. * @returns The loaded plugin
  110801. */
  110802. 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>;
  110803. /**
  110804. * Append a scene
  110805. * @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)
  110806. * @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)
  110807. * @param scene is the instance of BABYLON.Scene to append to
  110808. * @param onProgress a callback with a progress event for each file being loaded
  110809. * @param pluginExtension the extension used to determine the plugin
  110810. * @returns The given scene
  110811. */
  110812. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110813. /**
  110814. * Load a scene into an asset container
  110815. * @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)
  110816. * @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)
  110817. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110818. * @param onSuccess a callback with the scene when import succeeds
  110819. * @param onProgress a callback with a progress event for each file being loaded
  110820. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110821. * @param pluginExtension the extension used to determine the plugin
  110822. * @returns The loaded plugin
  110823. */
  110824. 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>;
  110825. /**
  110826. * Load a scene into an asset container
  110827. * @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)
  110828. * @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)
  110829. * @param scene is the instance of Scene to append to
  110830. * @param onProgress a callback with a progress event for each file being loaded
  110831. * @param pluginExtension the extension used to determine the plugin
  110832. * @returns The loaded asset container
  110833. */
  110834. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110835. }
  110836. }
  110837. declare module BABYLON {
  110838. /**
  110839. * Generic Controller
  110840. */
  110841. export class GenericController extends WebVRController {
  110842. /**
  110843. * Base Url for the controller model.
  110844. */
  110845. static readonly MODEL_BASE_URL: string;
  110846. /**
  110847. * File name for the controller model.
  110848. */
  110849. static readonly MODEL_FILENAME: string;
  110850. /**
  110851. * Creates a new GenericController from a gamepad
  110852. * @param vrGamepad the gamepad that the controller should be created from
  110853. */
  110854. constructor(vrGamepad: any);
  110855. /**
  110856. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110857. * @param scene scene in which to add meshes
  110858. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110859. */
  110860. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110861. /**
  110862. * Called once for each button that changed state since the last frame
  110863. * @param buttonIdx Which button index changed
  110864. * @param state New state of the button
  110865. * @param changes Which properties on the state changed since last frame
  110866. */
  110867. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110868. }
  110869. }
  110870. declare module BABYLON {
  110871. /**
  110872. * Defines the WindowsMotionController object that the state of the windows motion controller
  110873. */
  110874. export class WindowsMotionController extends WebVRController {
  110875. /**
  110876. * The base url used to load the left and right controller models
  110877. */
  110878. static MODEL_BASE_URL: string;
  110879. /**
  110880. * The name of the left controller model file
  110881. */
  110882. static MODEL_LEFT_FILENAME: string;
  110883. /**
  110884. * The name of the right controller model file
  110885. */
  110886. static MODEL_RIGHT_FILENAME: string;
  110887. /**
  110888. * The controller name prefix for this controller type
  110889. */
  110890. static readonly GAMEPAD_ID_PREFIX: string;
  110891. /**
  110892. * The controller id pattern for this controller type
  110893. */
  110894. private static readonly GAMEPAD_ID_PATTERN;
  110895. private _loadedMeshInfo;
  110896. private readonly _mapping;
  110897. /**
  110898. * Fired when the trackpad on this controller is clicked
  110899. */
  110900. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110901. /**
  110902. * Fired when the trackpad on this controller is modified
  110903. */
  110904. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110905. /**
  110906. * The current x and y values of this controller's trackpad
  110907. */
  110908. trackpad: StickValues;
  110909. /**
  110910. * Creates a new WindowsMotionController from a gamepad
  110911. * @param vrGamepad the gamepad that the controller should be created from
  110912. */
  110913. constructor(vrGamepad: any);
  110914. /**
  110915. * Fired when the trigger on this controller is modified
  110916. */
  110917. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110918. /**
  110919. * Fired when the menu button on this controller is modified
  110920. */
  110921. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110922. /**
  110923. * Fired when the grip button on this controller is modified
  110924. */
  110925. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110926. /**
  110927. * Fired when the thumbstick button on this controller is modified
  110928. */
  110929. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110930. /**
  110931. * Fired when the touchpad button on this controller is modified
  110932. */
  110933. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110934. /**
  110935. * Fired when the touchpad values on this controller are modified
  110936. */
  110937. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110938. private _updateTrackpad;
  110939. /**
  110940. * Called once per frame by the engine.
  110941. */
  110942. update(): void;
  110943. /**
  110944. * Called once for each button that changed state since the last frame
  110945. * @param buttonIdx Which button index changed
  110946. * @param state New state of the button
  110947. * @param changes Which properties on the state changed since last frame
  110948. */
  110949. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110950. /**
  110951. * Moves the buttons on the controller mesh based on their current state
  110952. * @param buttonName the name of the button to move
  110953. * @param buttonValue the value of the button which determines the buttons new position
  110954. */
  110955. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110956. /**
  110957. * Moves the axis on the controller mesh based on its current state
  110958. * @param axis the index of the axis
  110959. * @param axisValue the value of the axis which determines the meshes new position
  110960. * @hidden
  110961. */
  110962. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110963. /**
  110964. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110965. * @param scene scene in which to add meshes
  110966. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110967. */
  110968. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110969. /**
  110970. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110971. * can be transformed by button presses and axes values, based on this._mapping.
  110972. *
  110973. * @param scene scene in which the meshes exist
  110974. * @param meshes list of meshes that make up the controller model to process
  110975. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110976. */
  110977. private processModel;
  110978. private createMeshInfo;
  110979. /**
  110980. * Gets the ray of the controller in the direction the controller is pointing
  110981. * @param length the length the resulting ray should be
  110982. * @returns a ray in the direction the controller is pointing
  110983. */
  110984. getForwardRay(length?: number): Ray;
  110985. /**
  110986. * Disposes of the controller
  110987. */
  110988. dispose(): void;
  110989. }
  110990. }
  110991. declare module BABYLON {
  110992. /**
  110993. * Oculus Touch Controller
  110994. */
  110995. export class OculusTouchController extends WebVRController {
  110996. /**
  110997. * Base Url for the controller model.
  110998. */
  110999. static MODEL_BASE_URL: string;
  111000. /**
  111001. * File name for the left controller model.
  111002. */
  111003. static MODEL_LEFT_FILENAME: string;
  111004. /**
  111005. * File name for the right controller model.
  111006. */
  111007. static MODEL_RIGHT_FILENAME: string;
  111008. /**
  111009. * Base Url for the Quest controller model.
  111010. */
  111011. static QUEST_MODEL_BASE_URL: string;
  111012. /**
  111013. * @hidden
  111014. * If the controllers are running on a device that needs the updated Quest controller models
  111015. */
  111016. static _IsQuest: boolean;
  111017. /**
  111018. * Fired when the secondary trigger on this controller is modified
  111019. */
  111020. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111021. /**
  111022. * Fired when the thumb rest on this controller is modified
  111023. */
  111024. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111025. /**
  111026. * Creates a new OculusTouchController from a gamepad
  111027. * @param vrGamepad the gamepad that the controller should be created from
  111028. */
  111029. constructor(vrGamepad: any);
  111030. /**
  111031. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111032. * @param scene scene in which to add meshes
  111033. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111034. */
  111035. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111036. /**
  111037. * Fired when the A button on this controller is modified
  111038. */
  111039. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111040. /**
  111041. * Fired when the B button on this controller is modified
  111042. */
  111043. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111044. /**
  111045. * Fired when the X button on this controller is modified
  111046. */
  111047. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111048. /**
  111049. * Fired when the Y button on this controller is modified
  111050. */
  111051. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111052. /**
  111053. * Called once for each button that changed state since the last frame
  111054. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111055. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111056. * 2) secondary trigger (same)
  111057. * 3) A (right) X (left), touch, pressed = value
  111058. * 4) B / Y
  111059. * 5) thumb rest
  111060. * @param buttonIdx Which button index changed
  111061. * @param state New state of the button
  111062. * @param changes Which properties on the state changed since last frame
  111063. */
  111064. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111065. }
  111066. }
  111067. declare module BABYLON {
  111068. /**
  111069. * Vive Controller
  111070. */
  111071. export class ViveController extends WebVRController {
  111072. /**
  111073. * Base Url for the controller model.
  111074. */
  111075. static MODEL_BASE_URL: string;
  111076. /**
  111077. * File name for the controller model.
  111078. */
  111079. static MODEL_FILENAME: string;
  111080. /**
  111081. * Creates a new ViveController from a gamepad
  111082. * @param vrGamepad the gamepad that the controller should be created from
  111083. */
  111084. constructor(vrGamepad: any);
  111085. /**
  111086. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111087. * @param scene scene in which to add meshes
  111088. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111089. */
  111090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111091. /**
  111092. * Fired when the left button on this controller is modified
  111093. */
  111094. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111095. /**
  111096. * Fired when the right button on this controller is modified
  111097. */
  111098. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111099. /**
  111100. * Fired when the menu button on this controller is modified
  111101. */
  111102. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111103. /**
  111104. * Called once for each button that changed state since the last frame
  111105. * Vive mapping:
  111106. * 0: touchpad
  111107. * 1: trigger
  111108. * 2: left AND right buttons
  111109. * 3: menu button
  111110. * @param buttonIdx Which button index changed
  111111. * @param state New state of the button
  111112. * @param changes Which properties on the state changed since last frame
  111113. */
  111114. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111115. }
  111116. }
  111117. declare module BABYLON {
  111118. /**
  111119. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111120. */
  111121. export class WebXRControllerModelLoader {
  111122. /**
  111123. * Creates the WebXRControllerModelLoader
  111124. * @param input xr input that creates the controllers
  111125. */
  111126. constructor(input: WebXRInput);
  111127. }
  111128. }
  111129. declare module BABYLON {
  111130. /**
  111131. * Contains an array of blocks representing the octree
  111132. */
  111133. export interface IOctreeContainer<T> {
  111134. /**
  111135. * Blocks within the octree
  111136. */
  111137. blocks: Array<OctreeBlock<T>>;
  111138. }
  111139. /**
  111140. * Class used to store a cell in an octree
  111141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111142. */
  111143. export class OctreeBlock<T> {
  111144. /**
  111145. * Gets the content of the current block
  111146. */
  111147. entries: T[];
  111148. /**
  111149. * Gets the list of block children
  111150. */
  111151. blocks: Array<OctreeBlock<T>>;
  111152. private _depth;
  111153. private _maxDepth;
  111154. private _capacity;
  111155. private _minPoint;
  111156. private _maxPoint;
  111157. private _boundingVectors;
  111158. private _creationFunc;
  111159. /**
  111160. * Creates a new block
  111161. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111162. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111163. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111164. * @param depth defines the current depth of this block in the octree
  111165. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111166. * @param creationFunc defines a callback to call when an element is added to the block
  111167. */
  111168. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111169. /**
  111170. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111171. */
  111172. readonly capacity: number;
  111173. /**
  111174. * Gets the minimum vector (in world space) of the block's bounding box
  111175. */
  111176. readonly minPoint: Vector3;
  111177. /**
  111178. * Gets the maximum vector (in world space) of the block's bounding box
  111179. */
  111180. readonly maxPoint: Vector3;
  111181. /**
  111182. * Add a new element to this block
  111183. * @param entry defines the element to add
  111184. */
  111185. addEntry(entry: T): void;
  111186. /**
  111187. * Remove an element from this block
  111188. * @param entry defines the element to remove
  111189. */
  111190. removeEntry(entry: T): void;
  111191. /**
  111192. * Add an array of elements to this block
  111193. * @param entries defines the array of elements to add
  111194. */
  111195. addEntries(entries: T[]): void;
  111196. /**
  111197. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111198. * @param frustumPlanes defines the frustum planes to test
  111199. * @param selection defines the array to store current content if selection is positive
  111200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111201. */
  111202. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111203. /**
  111204. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111205. * @param sphereCenter defines the bounding sphere center
  111206. * @param sphereRadius defines the bounding sphere radius
  111207. * @param selection defines the array to store current content if selection is positive
  111208. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111209. */
  111210. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111211. /**
  111212. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111213. * @param ray defines the ray to test with
  111214. * @param selection defines the array to store current content if selection is positive
  111215. */
  111216. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111217. /**
  111218. * Subdivide the content into child blocks (this block will then be empty)
  111219. */
  111220. createInnerBlocks(): void;
  111221. /**
  111222. * @hidden
  111223. */
  111224. 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;
  111225. }
  111226. }
  111227. declare module BABYLON {
  111228. /**
  111229. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111230. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111231. */
  111232. export class Octree<T> {
  111233. /** 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.) */
  111234. maxDepth: number;
  111235. /**
  111236. * Blocks within the octree containing objects
  111237. */
  111238. blocks: Array<OctreeBlock<T>>;
  111239. /**
  111240. * Content stored in the octree
  111241. */
  111242. dynamicContent: T[];
  111243. private _maxBlockCapacity;
  111244. private _selectionContent;
  111245. private _creationFunc;
  111246. /**
  111247. * Creates a octree
  111248. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111249. * @param creationFunc function to be used to instatiate the octree
  111250. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111251. * @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.)
  111252. */
  111253. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111254. /** 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.) */
  111255. maxDepth?: number);
  111256. /**
  111257. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111258. * @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);
  111259. * @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);
  111260. * @param entries meshes to be added to the octree blocks
  111261. */
  111262. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111263. /**
  111264. * Adds a mesh to the octree
  111265. * @param entry Mesh to add to the octree
  111266. */
  111267. addMesh(entry: T): void;
  111268. /**
  111269. * Remove an element from the octree
  111270. * @param entry defines the element to remove
  111271. */
  111272. removeMesh(entry: T): void;
  111273. /**
  111274. * Selects an array of meshes within the frustum
  111275. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111276. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111277. * @returns array of meshes within the frustum
  111278. */
  111279. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111280. /**
  111281. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111282. * @param sphereCenter defines the bounding sphere center
  111283. * @param sphereRadius defines the bounding sphere radius
  111284. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111285. * @returns an array of objects that intersect the sphere
  111286. */
  111287. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111288. /**
  111289. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111290. * @param ray defines the ray to test with
  111291. * @returns array of intersected objects
  111292. */
  111293. intersectsRay(ray: Ray): SmartArray<T>;
  111294. /**
  111295. * Adds a mesh into the octree block if it intersects the block
  111296. */
  111297. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111298. /**
  111299. * Adds a submesh into the octree block if it intersects the block
  111300. */
  111301. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111302. }
  111303. }
  111304. declare module BABYLON {
  111305. interface Scene {
  111306. /**
  111307. * @hidden
  111308. * Backing Filed
  111309. */
  111310. _selectionOctree: Octree<AbstractMesh>;
  111311. /**
  111312. * Gets the octree used to boost mesh selection (picking)
  111313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111314. */
  111315. selectionOctree: Octree<AbstractMesh>;
  111316. /**
  111317. * Creates or updates the octree used to boost selection (picking)
  111318. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111319. * @param maxCapacity defines the maximum capacity per leaf
  111320. * @param maxDepth defines the maximum depth of the octree
  111321. * @returns an octree of AbstractMesh
  111322. */
  111323. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111324. }
  111325. interface AbstractMesh {
  111326. /**
  111327. * @hidden
  111328. * Backing Field
  111329. */
  111330. _submeshesOctree: Octree<SubMesh>;
  111331. /**
  111332. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111333. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111334. * @param maxCapacity defines the maximum size of each block (64 by default)
  111335. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111336. * @returns the new octree
  111337. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111339. */
  111340. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111341. }
  111342. /**
  111343. * Defines the octree scene component responsible to manage any octrees
  111344. * in a given scene.
  111345. */
  111346. export class OctreeSceneComponent {
  111347. /**
  111348. * The component name help to identify the component in the list of scene components.
  111349. */
  111350. readonly name: string;
  111351. /**
  111352. * The scene the component belongs to.
  111353. */
  111354. scene: Scene;
  111355. /**
  111356. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111357. */
  111358. readonly checksIsEnabled: boolean;
  111359. /**
  111360. * Creates a new instance of the component for the given scene
  111361. * @param scene Defines the scene to register the component in
  111362. */
  111363. constructor(scene: Scene);
  111364. /**
  111365. * Registers the component in a given scene
  111366. */
  111367. register(): void;
  111368. /**
  111369. * Return the list of active meshes
  111370. * @returns the list of active meshes
  111371. */
  111372. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111373. /**
  111374. * Return the list of active sub meshes
  111375. * @param mesh The mesh to get the candidates sub meshes from
  111376. * @returns the list of active sub meshes
  111377. */
  111378. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111379. private _tempRay;
  111380. /**
  111381. * Return the list of sub meshes intersecting with a given local ray
  111382. * @param mesh defines the mesh to find the submesh for
  111383. * @param localRay defines the ray in local space
  111384. * @returns the list of intersecting sub meshes
  111385. */
  111386. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111387. /**
  111388. * Return the list of sub meshes colliding with a collider
  111389. * @param mesh defines the mesh to find the submesh for
  111390. * @param collider defines the collider to evaluate the collision against
  111391. * @returns the list of colliding sub meshes
  111392. */
  111393. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111394. /**
  111395. * Rebuilds the elements related to this component in case of
  111396. * context lost for instance.
  111397. */
  111398. rebuild(): void;
  111399. /**
  111400. * Disposes the component and the associated ressources.
  111401. */
  111402. dispose(): void;
  111403. }
  111404. }
  111405. declare module BABYLON {
  111406. /**
  111407. * Renders a layer on top of an existing scene
  111408. */
  111409. export class UtilityLayerRenderer implements IDisposable {
  111410. /** the original scene that will be rendered on top of */
  111411. originalScene: Scene;
  111412. private _pointerCaptures;
  111413. private _lastPointerEvents;
  111414. private static _DefaultUtilityLayer;
  111415. private static _DefaultKeepDepthUtilityLayer;
  111416. private _sharedGizmoLight;
  111417. private _renderCamera;
  111418. /**
  111419. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111420. * @returns the camera that is used when rendering the utility layer
  111421. */
  111422. getRenderCamera(): Nullable<Camera>;
  111423. /**
  111424. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111425. * @param cam the camera that should be used when rendering the utility layer
  111426. */
  111427. setRenderCamera(cam: Nullable<Camera>): void;
  111428. /**
  111429. * @hidden
  111430. * Light which used by gizmos to get light shading
  111431. */
  111432. _getSharedGizmoLight(): HemisphericLight;
  111433. /**
  111434. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111435. */
  111436. pickUtilitySceneFirst: boolean;
  111437. /**
  111438. * 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)
  111439. */
  111440. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111441. /**
  111442. * 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)
  111443. */
  111444. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111445. /**
  111446. * The scene that is rendered on top of the original scene
  111447. */
  111448. utilityLayerScene: Scene;
  111449. /**
  111450. * If the utility layer should automatically be rendered on top of existing scene
  111451. */
  111452. shouldRender: boolean;
  111453. /**
  111454. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111455. */
  111456. onlyCheckPointerDownEvents: boolean;
  111457. /**
  111458. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111459. */
  111460. processAllEvents: boolean;
  111461. /**
  111462. * Observable raised when the pointer move from the utility layer scene to the main scene
  111463. */
  111464. onPointerOutObservable: Observable<number>;
  111465. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111466. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111467. private _afterRenderObserver;
  111468. private _sceneDisposeObserver;
  111469. private _originalPointerObserver;
  111470. /**
  111471. * Instantiates a UtilityLayerRenderer
  111472. * @param originalScene the original scene that will be rendered on top of
  111473. * @param handleEvents boolean indicating if the utility layer should handle events
  111474. */
  111475. constructor(
  111476. /** the original scene that will be rendered on top of */
  111477. originalScene: Scene, handleEvents?: boolean);
  111478. private _notifyObservers;
  111479. /**
  111480. * Renders the utility layers scene on top of the original scene
  111481. */
  111482. render(): void;
  111483. /**
  111484. * Disposes of the renderer
  111485. */
  111486. dispose(): void;
  111487. private _updateCamera;
  111488. }
  111489. }
  111490. declare module BABYLON {
  111491. /**
  111492. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111493. */
  111494. export class Gizmo implements IDisposable {
  111495. /** The utility layer the gizmo will be added to */
  111496. gizmoLayer: UtilityLayerRenderer;
  111497. /**
  111498. * The root mesh of the gizmo
  111499. */
  111500. _rootMesh: Mesh;
  111501. private _attachedMesh;
  111502. /**
  111503. * Ratio for the scale of the gizmo (Default: 1)
  111504. */
  111505. scaleRatio: number;
  111506. /**
  111507. * If a custom mesh has been set (Default: false)
  111508. */
  111509. protected _customMeshSet: boolean;
  111510. /**
  111511. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111512. * * When set, interactions will be enabled
  111513. */
  111514. attachedMesh: Nullable<AbstractMesh>;
  111515. /**
  111516. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111517. * @param mesh The mesh to replace the default mesh of the gizmo
  111518. */
  111519. setCustomMesh(mesh: Mesh): void;
  111520. /**
  111521. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111522. */
  111523. updateGizmoRotationToMatchAttachedMesh: boolean;
  111524. /**
  111525. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111526. */
  111527. updateGizmoPositionToMatchAttachedMesh: boolean;
  111528. /**
  111529. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111530. */
  111531. updateScale: boolean;
  111532. protected _interactionsEnabled: boolean;
  111533. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111534. private _beforeRenderObserver;
  111535. private _tempVector;
  111536. /**
  111537. * Creates a gizmo
  111538. * @param gizmoLayer The utility layer the gizmo will be added to
  111539. */
  111540. constructor(
  111541. /** The utility layer the gizmo will be added to */
  111542. gizmoLayer?: UtilityLayerRenderer);
  111543. /**
  111544. * Updates the gizmo to match the attached mesh's position/rotation
  111545. */
  111546. protected _update(): void;
  111547. /**
  111548. * Disposes of the gizmo
  111549. */
  111550. dispose(): void;
  111551. }
  111552. }
  111553. declare module BABYLON {
  111554. /**
  111555. * Single plane drag gizmo
  111556. */
  111557. export class PlaneDragGizmo extends Gizmo {
  111558. /**
  111559. * Drag behavior responsible for the gizmos dragging interactions
  111560. */
  111561. dragBehavior: PointerDragBehavior;
  111562. private _pointerObserver;
  111563. /**
  111564. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111565. */
  111566. snapDistance: number;
  111567. /**
  111568. * Event that fires each time the gizmo snaps to a new location.
  111569. * * snapDistance is the the change in distance
  111570. */
  111571. onSnapObservable: Observable<{
  111572. snapDistance: number;
  111573. }>;
  111574. private _plane;
  111575. private _coloredMaterial;
  111576. private _hoverMaterial;
  111577. private _isEnabled;
  111578. private _parent;
  111579. /** @hidden */
  111580. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111581. /** @hidden */
  111582. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111583. /**
  111584. * Creates a PlaneDragGizmo
  111585. * @param gizmoLayer The utility layer the gizmo will be added to
  111586. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111587. * @param color The color of the gizmo
  111588. */
  111589. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111590. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111591. /**
  111592. * If the gizmo is enabled
  111593. */
  111594. isEnabled: boolean;
  111595. /**
  111596. * Disposes of the gizmo
  111597. */
  111598. dispose(): void;
  111599. }
  111600. }
  111601. declare module BABYLON {
  111602. /**
  111603. * Gizmo that enables dragging a mesh along 3 axis
  111604. */
  111605. export class PositionGizmo extends Gizmo {
  111606. /**
  111607. * Internal gizmo used for interactions on the x axis
  111608. */
  111609. xGizmo: AxisDragGizmo;
  111610. /**
  111611. * Internal gizmo used for interactions on the y axis
  111612. */
  111613. yGizmo: AxisDragGizmo;
  111614. /**
  111615. * Internal gizmo used for interactions on the z axis
  111616. */
  111617. zGizmo: AxisDragGizmo;
  111618. /**
  111619. * Internal gizmo used for interactions on the yz plane
  111620. */
  111621. xPlaneGizmo: PlaneDragGizmo;
  111622. /**
  111623. * Internal gizmo used for interactions on the xz plane
  111624. */
  111625. yPlaneGizmo: PlaneDragGizmo;
  111626. /**
  111627. * Internal gizmo used for interactions on the xy plane
  111628. */
  111629. zPlaneGizmo: PlaneDragGizmo;
  111630. /**
  111631. * private variables
  111632. */
  111633. private _meshAttached;
  111634. private _updateGizmoRotationToMatchAttachedMesh;
  111635. private _snapDistance;
  111636. private _scaleRatio;
  111637. /** Fires an event when any of it's sub gizmos are dragged */
  111638. onDragStartObservable: Observable<unknown>;
  111639. /** Fires an event when any of it's sub gizmos are released from dragging */
  111640. onDragEndObservable: Observable<unknown>;
  111641. /**
  111642. * If set to true, planar drag is enabled
  111643. */
  111644. private _planarGizmoEnabled;
  111645. attachedMesh: Nullable<AbstractMesh>;
  111646. /**
  111647. * Creates a PositionGizmo
  111648. * @param gizmoLayer The utility layer the gizmo will be added to
  111649. */
  111650. constructor(gizmoLayer?: UtilityLayerRenderer);
  111651. /**
  111652. * If the planar drag gizmo is enabled
  111653. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111654. */
  111655. planarGizmoEnabled: boolean;
  111656. updateGizmoRotationToMatchAttachedMesh: boolean;
  111657. /**
  111658. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111659. */
  111660. snapDistance: number;
  111661. /**
  111662. * Ratio for the scale of the gizmo (Default: 1)
  111663. */
  111664. scaleRatio: number;
  111665. /**
  111666. * Disposes of the gizmo
  111667. */
  111668. dispose(): void;
  111669. /**
  111670. * CustomMeshes are not supported by this gizmo
  111671. * @param mesh The mesh to replace the default mesh of the gizmo
  111672. */
  111673. setCustomMesh(mesh: Mesh): void;
  111674. }
  111675. }
  111676. declare module BABYLON {
  111677. /**
  111678. * Single axis drag gizmo
  111679. */
  111680. export class AxisDragGizmo extends Gizmo {
  111681. /**
  111682. * Drag behavior responsible for the gizmos dragging interactions
  111683. */
  111684. dragBehavior: PointerDragBehavior;
  111685. private _pointerObserver;
  111686. /**
  111687. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111688. */
  111689. snapDistance: number;
  111690. /**
  111691. * Event that fires each time the gizmo snaps to a new location.
  111692. * * snapDistance is the the change in distance
  111693. */
  111694. onSnapObservable: Observable<{
  111695. snapDistance: number;
  111696. }>;
  111697. private _isEnabled;
  111698. private _parent;
  111699. private _arrow;
  111700. private _coloredMaterial;
  111701. private _hoverMaterial;
  111702. /** @hidden */
  111703. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111704. /** @hidden */
  111705. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111706. /**
  111707. * Creates an AxisDragGizmo
  111708. * @param gizmoLayer The utility layer the gizmo will be added to
  111709. * @param dragAxis The axis which the gizmo will be able to drag on
  111710. * @param color The color of the gizmo
  111711. */
  111712. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111713. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111714. /**
  111715. * If the gizmo is enabled
  111716. */
  111717. isEnabled: boolean;
  111718. /**
  111719. * Disposes of the gizmo
  111720. */
  111721. dispose(): void;
  111722. }
  111723. }
  111724. declare module BABYLON.Debug {
  111725. /**
  111726. * The Axes viewer will show 3 axes in a specific point in space
  111727. */
  111728. export class AxesViewer {
  111729. private _xAxis;
  111730. private _yAxis;
  111731. private _zAxis;
  111732. private _scaleLinesFactor;
  111733. private _instanced;
  111734. /**
  111735. * Gets the hosting scene
  111736. */
  111737. scene: Scene;
  111738. /**
  111739. * Gets or sets a number used to scale line length
  111740. */
  111741. scaleLines: number;
  111742. /** Gets the node hierarchy used to render x-axis */
  111743. readonly xAxis: TransformNode;
  111744. /** Gets the node hierarchy used to render y-axis */
  111745. readonly yAxis: TransformNode;
  111746. /** Gets the node hierarchy used to render z-axis */
  111747. readonly zAxis: TransformNode;
  111748. /**
  111749. * Creates a new AxesViewer
  111750. * @param scene defines the hosting scene
  111751. * @param scaleLines defines a number used to scale line length (1 by default)
  111752. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111753. * @param xAxis defines the node hierarchy used to render the x-axis
  111754. * @param yAxis defines the node hierarchy used to render the y-axis
  111755. * @param zAxis defines the node hierarchy used to render the z-axis
  111756. */
  111757. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111758. /**
  111759. * Force the viewer to update
  111760. * @param position defines the position of the viewer
  111761. * @param xaxis defines the x axis of the viewer
  111762. * @param yaxis defines the y axis of the viewer
  111763. * @param zaxis defines the z axis of the viewer
  111764. */
  111765. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111766. /**
  111767. * Creates an instance of this axes viewer.
  111768. * @returns a new axes viewer with instanced meshes
  111769. */
  111770. createInstance(): AxesViewer;
  111771. /** Releases resources */
  111772. dispose(): void;
  111773. private static _SetRenderingGroupId;
  111774. }
  111775. }
  111776. declare module BABYLON.Debug {
  111777. /**
  111778. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111779. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111780. */
  111781. export class BoneAxesViewer extends AxesViewer {
  111782. /**
  111783. * Gets or sets the target mesh where to display the axes viewer
  111784. */
  111785. mesh: Nullable<Mesh>;
  111786. /**
  111787. * Gets or sets the target bone where to display the axes viewer
  111788. */
  111789. bone: Nullable<Bone>;
  111790. /** Gets current position */
  111791. pos: Vector3;
  111792. /** Gets direction of X axis */
  111793. xaxis: Vector3;
  111794. /** Gets direction of Y axis */
  111795. yaxis: Vector3;
  111796. /** Gets direction of Z axis */
  111797. zaxis: Vector3;
  111798. /**
  111799. * Creates a new BoneAxesViewer
  111800. * @param scene defines the hosting scene
  111801. * @param bone defines the target bone
  111802. * @param mesh defines the target mesh
  111803. * @param scaleLines defines a scaling factor for line length (1 by default)
  111804. */
  111805. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111806. /**
  111807. * Force the viewer to update
  111808. */
  111809. update(): void;
  111810. /** Releases resources */
  111811. dispose(): void;
  111812. }
  111813. }
  111814. declare module BABYLON {
  111815. /**
  111816. * Interface used to define scene explorer extensibility option
  111817. */
  111818. export interface IExplorerExtensibilityOption {
  111819. /**
  111820. * Define the option label
  111821. */
  111822. label: string;
  111823. /**
  111824. * Defines the action to execute on click
  111825. */
  111826. action: (entity: any) => void;
  111827. }
  111828. /**
  111829. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111830. */
  111831. export interface IExplorerExtensibilityGroup {
  111832. /**
  111833. * Defines a predicate to test if a given type mut be extended
  111834. */
  111835. predicate: (entity: any) => boolean;
  111836. /**
  111837. * Gets the list of options added to a type
  111838. */
  111839. entries: IExplorerExtensibilityOption[];
  111840. }
  111841. /**
  111842. * Interface used to define the options to use to create the Inspector
  111843. */
  111844. export interface IInspectorOptions {
  111845. /**
  111846. * Display in overlay mode (default: false)
  111847. */
  111848. overlay?: boolean;
  111849. /**
  111850. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111851. */
  111852. globalRoot?: HTMLElement;
  111853. /**
  111854. * Display the Scene explorer
  111855. */
  111856. showExplorer?: boolean;
  111857. /**
  111858. * Display the property inspector
  111859. */
  111860. showInspector?: boolean;
  111861. /**
  111862. * Display in embed mode (both panes on the right)
  111863. */
  111864. embedMode?: boolean;
  111865. /**
  111866. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111867. */
  111868. handleResize?: boolean;
  111869. /**
  111870. * Allow the panes to popup (default: true)
  111871. */
  111872. enablePopup?: boolean;
  111873. /**
  111874. * Allow the panes to be closed by users (default: true)
  111875. */
  111876. enableClose?: boolean;
  111877. /**
  111878. * Optional list of extensibility entries
  111879. */
  111880. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111881. /**
  111882. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111883. */
  111884. inspectorURL?: string;
  111885. }
  111886. interface Scene {
  111887. /**
  111888. * @hidden
  111889. * Backing field
  111890. */
  111891. _debugLayer: DebugLayer;
  111892. /**
  111893. * Gets the debug layer (aka Inspector) associated with the scene
  111894. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111895. */
  111896. debugLayer: DebugLayer;
  111897. }
  111898. /**
  111899. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111900. * what is happening in your scene
  111901. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111902. */
  111903. export class DebugLayer {
  111904. /**
  111905. * Define the url to get the inspector script from.
  111906. * By default it uses the babylonjs CDN.
  111907. * @ignoreNaming
  111908. */
  111909. static InspectorURL: string;
  111910. private _scene;
  111911. private BJSINSPECTOR;
  111912. private _onPropertyChangedObservable?;
  111913. /**
  111914. * Observable triggered when a property is changed through the inspector.
  111915. */
  111916. readonly onPropertyChangedObservable: any;
  111917. /**
  111918. * Instantiates a new debug layer.
  111919. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111920. * what is happening in your scene
  111921. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111922. * @param scene Defines the scene to inspect
  111923. */
  111924. constructor(scene: Scene);
  111925. /** Creates the inspector window. */
  111926. private _createInspector;
  111927. /**
  111928. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111929. * @param entity defines the entity to select
  111930. * @param lineContainerTitle defines the specific block to highlight
  111931. */
  111932. select(entity: any, lineContainerTitle?: string): void;
  111933. /** Get the inspector from bundle or global */
  111934. private _getGlobalInspector;
  111935. /**
  111936. * Get if the inspector is visible or not.
  111937. * @returns true if visible otherwise, false
  111938. */
  111939. isVisible(): boolean;
  111940. /**
  111941. * Hide the inspector and close its window.
  111942. */
  111943. hide(): void;
  111944. /**
  111945. * Launch the debugLayer.
  111946. * @param config Define the configuration of the inspector
  111947. * @return a promise fulfilled when the debug layer is visible
  111948. */
  111949. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111950. }
  111951. }
  111952. declare module BABYLON {
  111953. /**
  111954. * Class containing static functions to help procedurally build meshes
  111955. */
  111956. export class BoxBuilder {
  111957. /**
  111958. * Creates a box mesh
  111959. * * The parameter `size` sets the size (float) of each box side (default 1)
  111960. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111961. * * 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)
  111962. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111966. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111967. * @param name defines the name of the mesh
  111968. * @param options defines the options used to create the mesh
  111969. * @param scene defines the hosting scene
  111970. * @returns the box mesh
  111971. */
  111972. static CreateBox(name: string, options: {
  111973. size?: number;
  111974. width?: number;
  111975. height?: number;
  111976. depth?: number;
  111977. faceUV?: Vector4[];
  111978. faceColors?: Color4[];
  111979. sideOrientation?: number;
  111980. frontUVs?: Vector4;
  111981. backUVs?: Vector4;
  111982. wrap?: boolean;
  111983. topBaseAt?: number;
  111984. bottomBaseAt?: number;
  111985. updatable?: boolean;
  111986. }, scene?: Nullable<Scene>): Mesh;
  111987. }
  111988. }
  111989. declare module BABYLON {
  111990. /**
  111991. * Class containing static functions to help procedurally build meshes
  111992. */
  111993. export class SphereBuilder {
  111994. /**
  111995. * Creates a sphere mesh
  111996. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111997. * * 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`)
  111998. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111999. * * 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
  112000. * * 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)
  112001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112004. * @param name defines the name of the mesh
  112005. * @param options defines the options used to create the mesh
  112006. * @param scene defines the hosting scene
  112007. * @returns the sphere mesh
  112008. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  112009. */
  112010. static CreateSphere(name: string, options: {
  112011. segments?: number;
  112012. diameter?: number;
  112013. diameterX?: number;
  112014. diameterY?: number;
  112015. diameterZ?: number;
  112016. arc?: number;
  112017. slice?: number;
  112018. sideOrientation?: number;
  112019. frontUVs?: Vector4;
  112020. backUVs?: Vector4;
  112021. updatable?: boolean;
  112022. }, scene?: Nullable<Scene>): Mesh;
  112023. }
  112024. }
  112025. declare module BABYLON.Debug {
  112026. /**
  112027. * Used to show the physics impostor around the specific mesh
  112028. */
  112029. export class PhysicsViewer {
  112030. /** @hidden */
  112031. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112032. /** @hidden */
  112033. protected _meshes: Array<Nullable<AbstractMesh>>;
  112034. /** @hidden */
  112035. protected _scene: Nullable<Scene>;
  112036. /** @hidden */
  112037. protected _numMeshes: number;
  112038. /** @hidden */
  112039. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112040. private _renderFunction;
  112041. private _utilityLayer;
  112042. private _debugBoxMesh;
  112043. private _debugSphereMesh;
  112044. private _debugCylinderMesh;
  112045. private _debugMaterial;
  112046. private _debugMeshMeshes;
  112047. /**
  112048. * Creates a new PhysicsViewer
  112049. * @param scene defines the hosting scene
  112050. */
  112051. constructor(scene: Scene);
  112052. /** @hidden */
  112053. protected _updateDebugMeshes(): void;
  112054. /**
  112055. * Renders a specified physic impostor
  112056. * @param impostor defines the impostor to render
  112057. * @param targetMesh defines the mesh represented by the impostor
  112058. * @returns the new debug mesh used to render the impostor
  112059. */
  112060. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112061. /**
  112062. * Hides a specified physic impostor
  112063. * @param impostor defines the impostor to hide
  112064. */
  112065. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112066. private _getDebugMaterial;
  112067. private _getDebugBoxMesh;
  112068. private _getDebugSphereMesh;
  112069. private _getDebugCylinderMesh;
  112070. private _getDebugMeshMesh;
  112071. private _getDebugMesh;
  112072. /** Releases all resources */
  112073. dispose(): void;
  112074. }
  112075. }
  112076. declare module BABYLON {
  112077. /**
  112078. * Class containing static functions to help procedurally build meshes
  112079. */
  112080. export class LinesBuilder {
  112081. /**
  112082. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112083. * * 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
  112084. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112085. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112086. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112087. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112088. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112089. * * 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
  112090. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112093. * @param name defines the name of the new line system
  112094. * @param options defines the options used to create the line system
  112095. * @param scene defines the hosting scene
  112096. * @returns a new line system mesh
  112097. */
  112098. static CreateLineSystem(name: string, options: {
  112099. lines: Vector3[][];
  112100. updatable?: boolean;
  112101. instance?: Nullable<LinesMesh>;
  112102. colors?: Nullable<Color4[][]>;
  112103. useVertexAlpha?: boolean;
  112104. }, scene: Nullable<Scene>): LinesMesh;
  112105. /**
  112106. * Creates a line mesh
  112107. * 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
  112108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112109. * * The parameter `points` is an array successive Vector3
  112110. * * 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
  112111. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112112. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112113. * * When updating an instance, remember that only point positions can change, not the number of points
  112114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112116. * @param name defines the name of the new line system
  112117. * @param options defines the options used to create the line system
  112118. * @param scene defines the hosting scene
  112119. * @returns a new line mesh
  112120. */
  112121. static CreateLines(name: string, options: {
  112122. points: Vector3[];
  112123. updatable?: boolean;
  112124. instance?: Nullable<LinesMesh>;
  112125. colors?: Color4[];
  112126. useVertexAlpha?: boolean;
  112127. }, scene?: Nullable<Scene>): LinesMesh;
  112128. /**
  112129. * Creates a dashed line mesh
  112130. * * 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
  112131. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112132. * * The parameter `points` is an array successive Vector3
  112133. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112134. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112135. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112136. * * 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
  112137. * * When updating an instance, remember that only point positions can change, not the number of points
  112138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112139. * @param name defines the name of the mesh
  112140. * @param options defines the options used to create the mesh
  112141. * @param scene defines the hosting scene
  112142. * @returns the dashed line mesh
  112143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112144. */
  112145. static CreateDashedLines(name: string, options: {
  112146. points: Vector3[];
  112147. dashSize?: number;
  112148. gapSize?: number;
  112149. dashNb?: number;
  112150. updatable?: boolean;
  112151. instance?: LinesMesh;
  112152. }, scene?: Nullable<Scene>): LinesMesh;
  112153. }
  112154. }
  112155. declare module BABYLON {
  112156. /**
  112157. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112158. * in order to better appreciate the issue one might have.
  112159. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112160. */
  112161. export class RayHelper {
  112162. /**
  112163. * Defines the ray we are currently tryin to visualize.
  112164. */
  112165. ray: Nullable<Ray>;
  112166. private _renderPoints;
  112167. private _renderLine;
  112168. private _renderFunction;
  112169. private _scene;
  112170. private _updateToMeshFunction;
  112171. private _attachedToMesh;
  112172. private _meshSpaceDirection;
  112173. private _meshSpaceOrigin;
  112174. /**
  112175. * Helper function to create a colored helper in a scene in one line.
  112176. * @param ray Defines the ray we are currently tryin to visualize
  112177. * @param scene Defines the scene the ray is used in
  112178. * @param color Defines the color we want to see the ray in
  112179. * @returns The newly created ray helper.
  112180. */
  112181. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112182. /**
  112183. * Instantiate a new ray helper.
  112184. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112185. * in order to better appreciate the issue one might have.
  112186. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112187. * @param ray Defines the ray we are currently tryin to visualize
  112188. */
  112189. constructor(ray: Ray);
  112190. /**
  112191. * Shows the ray we are willing to debug.
  112192. * @param scene Defines the scene the ray needs to be rendered in
  112193. * @param color Defines the color the ray needs to be rendered in
  112194. */
  112195. show(scene: Scene, color?: Color3): void;
  112196. /**
  112197. * Hides the ray we are debugging.
  112198. */
  112199. hide(): void;
  112200. private _render;
  112201. /**
  112202. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112203. * @param mesh Defines the mesh we want the helper attached to
  112204. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112205. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112206. * @param length Defines the length of the ray
  112207. */
  112208. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112209. /**
  112210. * Detach the ray helper from the mesh it has previously been attached to.
  112211. */
  112212. detachFromMesh(): void;
  112213. private _updateToMesh;
  112214. /**
  112215. * Dispose the helper and release its associated resources.
  112216. */
  112217. dispose(): void;
  112218. }
  112219. }
  112220. declare module BABYLON.Debug {
  112221. /**
  112222. * Class used to render a debug view of a given skeleton
  112223. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112224. */
  112225. export class SkeletonViewer {
  112226. /** defines the skeleton to render */
  112227. skeleton: Skeleton;
  112228. /** defines the mesh attached to the skeleton */
  112229. mesh: AbstractMesh;
  112230. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112231. autoUpdateBonesMatrices: boolean;
  112232. /** defines the rendering group id to use with the viewer */
  112233. renderingGroupId: number;
  112234. /** Gets or sets the color used to render the skeleton */
  112235. color: Color3;
  112236. private _scene;
  112237. private _debugLines;
  112238. private _debugMesh;
  112239. private _isEnabled;
  112240. private _renderFunction;
  112241. private _utilityLayer;
  112242. /**
  112243. * Returns the mesh used to render the bones
  112244. */
  112245. readonly debugMesh: Nullable<LinesMesh>;
  112246. /**
  112247. * Creates a new SkeletonViewer
  112248. * @param skeleton defines the skeleton to render
  112249. * @param mesh defines the mesh attached to the skeleton
  112250. * @param scene defines the hosting scene
  112251. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112252. * @param renderingGroupId defines the rendering group id to use with the viewer
  112253. */
  112254. constructor(
  112255. /** defines the skeleton to render */
  112256. skeleton: Skeleton,
  112257. /** defines the mesh attached to the skeleton */
  112258. mesh: AbstractMesh, scene: Scene,
  112259. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112260. autoUpdateBonesMatrices?: boolean,
  112261. /** defines the rendering group id to use with the viewer */
  112262. renderingGroupId?: number);
  112263. /** Gets or sets a boolean indicating if the viewer is enabled */
  112264. isEnabled: boolean;
  112265. private _getBonePosition;
  112266. private _getLinesForBonesWithLength;
  112267. private _getLinesForBonesNoLength;
  112268. /** Update the viewer to sync with current skeleton state */
  112269. update(): void;
  112270. /** Release associated resources */
  112271. dispose(): void;
  112272. }
  112273. }
  112274. declare module BABYLON {
  112275. /**
  112276. * Options to create the null engine
  112277. */
  112278. export class NullEngineOptions {
  112279. /**
  112280. * Render width (Default: 512)
  112281. */
  112282. renderWidth: number;
  112283. /**
  112284. * Render height (Default: 256)
  112285. */
  112286. renderHeight: number;
  112287. /**
  112288. * Texture size (Default: 512)
  112289. */
  112290. textureSize: number;
  112291. /**
  112292. * If delta time between frames should be constant
  112293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112294. */
  112295. deterministicLockstep: boolean;
  112296. /**
  112297. * Maximum about of steps between frames (Default: 4)
  112298. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112299. */
  112300. lockstepMaxSteps: number;
  112301. }
  112302. /**
  112303. * The null engine class provides support for headless version of babylon.js.
  112304. * This can be used in server side scenario or for testing purposes
  112305. */
  112306. export class NullEngine extends Engine {
  112307. private _options;
  112308. /**
  112309. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112310. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112311. * @returns true if engine is in deterministic lock step mode
  112312. */
  112313. isDeterministicLockStep(): boolean;
  112314. /**
  112315. * Gets the max steps when engine is running in deterministic lock step
  112316. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112317. * @returns the max steps
  112318. */
  112319. getLockstepMaxSteps(): number;
  112320. /**
  112321. * Gets the current hardware scaling level.
  112322. * By default the hardware scaling level is computed from the window device ratio.
  112323. * 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.
  112324. * @returns a number indicating the current hardware scaling level
  112325. */
  112326. getHardwareScalingLevel(): number;
  112327. constructor(options?: NullEngineOptions);
  112328. /**
  112329. * Creates a vertex buffer
  112330. * @param vertices the data for the vertex buffer
  112331. * @returns the new WebGL static buffer
  112332. */
  112333. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112334. /**
  112335. * Creates a new index buffer
  112336. * @param indices defines the content of the index buffer
  112337. * @param updatable defines if the index buffer must be updatable
  112338. * @returns a new webGL buffer
  112339. */
  112340. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112341. /**
  112342. * Clear the current render buffer or the current render target (if any is set up)
  112343. * @param color defines the color to use
  112344. * @param backBuffer defines if the back buffer must be cleared
  112345. * @param depth defines if the depth buffer must be cleared
  112346. * @param stencil defines if the stencil buffer must be cleared
  112347. */
  112348. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112349. /**
  112350. * Gets the current render width
  112351. * @param useScreen defines if screen size must be used (or the current render target if any)
  112352. * @returns a number defining the current render width
  112353. */
  112354. getRenderWidth(useScreen?: boolean): number;
  112355. /**
  112356. * Gets the current render height
  112357. * @param useScreen defines if screen size must be used (or the current render target if any)
  112358. * @returns a number defining the current render height
  112359. */
  112360. getRenderHeight(useScreen?: boolean): number;
  112361. /**
  112362. * Set the WebGL's viewport
  112363. * @param viewport defines the viewport element to be used
  112364. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112365. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112366. */
  112367. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112368. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112369. /**
  112370. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112371. * @param pipelineContext defines the pipeline context to use
  112372. * @param uniformsNames defines the list of uniform names
  112373. * @returns an array of webGL uniform locations
  112374. */
  112375. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112376. /**
  112377. * Gets the lsit of active attributes for a given webGL program
  112378. * @param pipelineContext defines the pipeline context to use
  112379. * @param attributesNames defines the list of attribute names to get
  112380. * @returns an array of indices indicating the offset of each attribute
  112381. */
  112382. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112383. /**
  112384. * Binds an effect to the webGL context
  112385. * @param effect defines the effect to bind
  112386. */
  112387. bindSamplers(effect: Effect): void;
  112388. /**
  112389. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112390. * @param effect defines the effect to activate
  112391. */
  112392. enableEffect(effect: Effect): void;
  112393. /**
  112394. * Set various states to the webGL context
  112395. * @param culling defines backface culling state
  112396. * @param zOffset defines the value to apply to zOffset (0 by default)
  112397. * @param force defines if states must be applied even if cache is up to date
  112398. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112399. */
  112400. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112401. /**
  112402. * Set the value of an uniform to an array of int32
  112403. * @param uniform defines the webGL uniform location where to store the value
  112404. * @param array defines the array of int32 to store
  112405. */
  112406. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112407. /**
  112408. * Set the value of an uniform to an array of int32 (stored as vec2)
  112409. * @param uniform defines the webGL uniform location where to store the value
  112410. * @param array defines the array of int32 to store
  112411. */
  112412. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112413. /**
  112414. * Set the value of an uniform to an array of int32 (stored as vec3)
  112415. * @param uniform defines the webGL uniform location where to store the value
  112416. * @param array defines the array of int32 to store
  112417. */
  112418. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112419. /**
  112420. * Set the value of an uniform to an array of int32 (stored as vec4)
  112421. * @param uniform defines the webGL uniform location where to store the value
  112422. * @param array defines the array of int32 to store
  112423. */
  112424. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112425. /**
  112426. * Set the value of an uniform to an array of float32
  112427. * @param uniform defines the webGL uniform location where to store the value
  112428. * @param array defines the array of float32 to store
  112429. */
  112430. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112431. /**
  112432. * Set the value of an uniform to an array of float32 (stored as vec2)
  112433. * @param uniform defines the webGL uniform location where to store the value
  112434. * @param array defines the array of float32 to store
  112435. */
  112436. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112437. /**
  112438. * Set the value of an uniform to an array of float32 (stored as vec3)
  112439. * @param uniform defines the webGL uniform location where to store the value
  112440. * @param array defines the array of float32 to store
  112441. */
  112442. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112443. /**
  112444. * Set the value of an uniform to an array of float32 (stored as vec4)
  112445. * @param uniform defines the webGL uniform location where to store the value
  112446. * @param array defines the array of float32 to store
  112447. */
  112448. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112449. /**
  112450. * Set the value of an uniform to an array of number
  112451. * @param uniform defines the webGL uniform location where to store the value
  112452. * @param array defines the array of number to store
  112453. */
  112454. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112455. /**
  112456. * Set the value of an uniform to an array of number (stored as vec2)
  112457. * @param uniform defines the webGL uniform location where to store the value
  112458. * @param array defines the array of number to store
  112459. */
  112460. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112461. /**
  112462. * Set the value of an uniform to an array of number (stored as vec3)
  112463. * @param uniform defines the webGL uniform location where to store the value
  112464. * @param array defines the array of number to store
  112465. */
  112466. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112467. /**
  112468. * Set the value of an uniform to an array of number (stored as vec4)
  112469. * @param uniform defines the webGL uniform location where to store the value
  112470. * @param array defines the array of number to store
  112471. */
  112472. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112473. /**
  112474. * Set the value of an uniform to an array of float32 (stored as matrices)
  112475. * @param uniform defines the webGL uniform location where to store the value
  112476. * @param matrices defines the array of float32 to store
  112477. */
  112478. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112479. /**
  112480. * Set the value of an uniform to a matrix (3x3)
  112481. * @param uniform defines the webGL uniform location where to store the value
  112482. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112483. */
  112484. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112485. /**
  112486. * Set the value of an uniform to a matrix (2x2)
  112487. * @param uniform defines the webGL uniform location where to store the value
  112488. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112489. */
  112490. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112491. /**
  112492. * Set the value of an uniform to a number (float)
  112493. * @param uniform defines the webGL uniform location where to store the value
  112494. * @param value defines the float number to store
  112495. */
  112496. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112497. /**
  112498. * Set the value of an uniform to a vec2
  112499. * @param uniform defines the webGL uniform location where to store the value
  112500. * @param x defines the 1st component of the value
  112501. * @param y defines the 2nd component of the value
  112502. */
  112503. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112504. /**
  112505. * Set the value of an uniform to a vec3
  112506. * @param uniform defines the webGL uniform location where to store the value
  112507. * @param x defines the 1st component of the value
  112508. * @param y defines the 2nd component of the value
  112509. * @param z defines the 3rd component of the value
  112510. */
  112511. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112512. /**
  112513. * Set the value of an uniform to a boolean
  112514. * @param uniform defines the webGL uniform location where to store the value
  112515. * @param bool defines the boolean to store
  112516. */
  112517. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112518. /**
  112519. * Set the value of an uniform to a vec4
  112520. * @param uniform defines the webGL uniform location where to store the value
  112521. * @param x defines the 1st component of the value
  112522. * @param y defines the 2nd component of the value
  112523. * @param z defines the 3rd component of the value
  112524. * @param w defines the 4th component of the value
  112525. */
  112526. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112527. /**
  112528. * Sets the current alpha mode
  112529. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112530. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112531. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112532. */
  112533. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112534. /**
  112535. * Bind webGl buffers directly to the webGL context
  112536. * @param vertexBuffers defines the vertex buffer to bind
  112537. * @param indexBuffer defines the index buffer to bind
  112538. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112539. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112540. * @param effect defines the effect associated with the vertex buffer
  112541. */
  112542. bindBuffers(vertexBuffers: {
  112543. [key: string]: VertexBuffer;
  112544. }, indexBuffer: DataBuffer, effect: Effect): void;
  112545. /**
  112546. * Force the entire cache to be cleared
  112547. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112548. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112549. */
  112550. wipeCaches(bruteForce?: boolean): void;
  112551. /**
  112552. * Send a draw order
  112553. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112554. * @param indexStart defines the starting index
  112555. * @param indexCount defines the number of index to draw
  112556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112557. */
  112558. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112559. /**
  112560. * Draw a list of indexed primitives
  112561. * @param fillMode defines the primitive to use
  112562. * @param indexStart defines the starting index
  112563. * @param indexCount defines the number of index to draw
  112564. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112565. */
  112566. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112567. /**
  112568. * Draw a list of unindexed primitives
  112569. * @param fillMode defines the primitive to use
  112570. * @param verticesStart defines the index of first vertex to draw
  112571. * @param verticesCount defines the count of vertices to draw
  112572. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112573. */
  112574. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112575. /** @hidden */
  112576. _createTexture(): WebGLTexture;
  112577. /** @hidden */
  112578. _releaseTexture(texture: InternalTexture): void;
  112579. /**
  112580. * Usually called from Texture.ts.
  112581. * Passed information to create a WebGLTexture
  112582. * @param urlArg defines a value which contains one of the following:
  112583. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112584. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112585. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112586. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112587. * @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)
  112588. * @param scene needed for loading to the correct scene
  112589. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112590. * @param onLoad optional callback to be called upon successful completion
  112591. * @param onError optional callback to be called upon failure
  112592. * @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
  112593. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112594. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112595. * @param forcedExtension defines the extension to use to pick the right loader
  112596. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112597. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112598. */
  112599. 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;
  112600. /**
  112601. * Creates a new render target texture
  112602. * @param size defines the size of the texture
  112603. * @param options defines the options used to create the texture
  112604. * @returns a new render target texture stored in an InternalTexture
  112605. */
  112606. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112607. /**
  112608. * Update the sampling mode of a given texture
  112609. * @param samplingMode defines the required sampling mode
  112610. * @param texture defines the texture to update
  112611. */
  112612. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112613. /**
  112614. * Binds the frame buffer to the specified texture.
  112615. * @param texture The texture to render to or null for the default canvas
  112616. * @param faceIndex The face of the texture to render to in case of cube texture
  112617. * @param requiredWidth The width of the target to render to
  112618. * @param requiredHeight The height of the target to render to
  112619. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112620. * @param depthStencilTexture The depth stencil texture to use to render
  112621. * @param lodLevel defines le lod level to bind to the frame buffer
  112622. */
  112623. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112624. /**
  112625. * Unbind the current render target texture from the webGL context
  112626. * @param texture defines the render target texture to unbind
  112627. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112628. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112629. */
  112630. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112631. /**
  112632. * Creates a dynamic vertex buffer
  112633. * @param vertices the data for the dynamic vertex buffer
  112634. * @returns the new WebGL dynamic buffer
  112635. */
  112636. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112637. /**
  112638. * Update the content of a dynamic texture
  112639. * @param texture defines the texture to update
  112640. * @param canvas defines the canvas containing the source
  112641. * @param invertY defines if data must be stored with Y axis inverted
  112642. * @param premulAlpha defines if alpha is stored as premultiplied
  112643. * @param format defines the format of the data
  112644. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112645. */
  112646. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112647. /**
  112648. * Gets a boolean indicating if all created effects are ready
  112649. * @returns true if all effects are ready
  112650. */
  112651. areAllEffectsReady(): boolean;
  112652. /**
  112653. * @hidden
  112654. * Get the current error code of the webGL context
  112655. * @returns the error code
  112656. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112657. */
  112658. getError(): number;
  112659. /** @hidden */
  112660. _getUnpackAlignement(): number;
  112661. /** @hidden */
  112662. _unpackFlipY(value: boolean): void;
  112663. /**
  112664. * Update a dynamic index buffer
  112665. * @param indexBuffer defines the target index buffer
  112666. * @param indices defines the data to update
  112667. * @param offset defines the offset in the target index buffer where update should start
  112668. */
  112669. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112670. /**
  112671. * Updates a dynamic vertex buffer.
  112672. * @param vertexBuffer the vertex buffer to update
  112673. * @param vertices the data used to update the vertex buffer
  112674. * @param byteOffset the byte offset of the data (optional)
  112675. * @param byteLength the byte length of the data (optional)
  112676. */
  112677. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112678. /** @hidden */
  112679. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112680. /** @hidden */
  112681. _bindTexture(channel: number, texture: InternalTexture): void;
  112682. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112683. /**
  112684. * 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
  112685. */
  112686. releaseEffects(): void;
  112687. displayLoadingUI(): void;
  112688. hideLoadingUI(): void;
  112689. /** @hidden */
  112690. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112691. /** @hidden */
  112692. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112693. /** @hidden */
  112694. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112695. /** @hidden */
  112696. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112697. }
  112698. }
  112699. declare module BABYLON {
  112700. /** @hidden */
  112701. export class _OcclusionDataStorage {
  112702. /** @hidden */
  112703. occlusionInternalRetryCounter: number;
  112704. /** @hidden */
  112705. isOcclusionQueryInProgress: boolean;
  112706. /** @hidden */
  112707. isOccluded: boolean;
  112708. /** @hidden */
  112709. occlusionRetryCount: number;
  112710. /** @hidden */
  112711. occlusionType: number;
  112712. /** @hidden */
  112713. occlusionQueryAlgorithmType: number;
  112714. }
  112715. interface Engine {
  112716. /**
  112717. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112718. * @return the new query
  112719. */
  112720. createQuery(): WebGLQuery;
  112721. /**
  112722. * Delete and release a webGL query
  112723. * @param query defines the query to delete
  112724. * @return the current engine
  112725. */
  112726. deleteQuery(query: WebGLQuery): Engine;
  112727. /**
  112728. * Check if a given query has resolved and got its value
  112729. * @param query defines the query to check
  112730. * @returns true if the query got its value
  112731. */
  112732. isQueryResultAvailable(query: WebGLQuery): boolean;
  112733. /**
  112734. * Gets the value of a given query
  112735. * @param query defines the query to check
  112736. * @returns the value of the query
  112737. */
  112738. getQueryResult(query: WebGLQuery): number;
  112739. /**
  112740. * Initiates an occlusion query
  112741. * @param algorithmType defines the algorithm to use
  112742. * @param query defines the query to use
  112743. * @returns the current engine
  112744. * @see http://doc.babylonjs.com/features/occlusionquery
  112745. */
  112746. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112747. /**
  112748. * Ends an occlusion query
  112749. * @see http://doc.babylonjs.com/features/occlusionquery
  112750. * @param algorithmType defines the algorithm to use
  112751. * @returns the current engine
  112752. */
  112753. endOcclusionQuery(algorithmType: number): Engine;
  112754. /**
  112755. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112756. * Please note that only one query can be issued at a time
  112757. * @returns a time token used to track the time span
  112758. */
  112759. startTimeQuery(): Nullable<_TimeToken>;
  112760. /**
  112761. * Ends a time query
  112762. * @param token defines the token used to measure the time span
  112763. * @returns the time spent (in ns)
  112764. */
  112765. endTimeQuery(token: _TimeToken): int;
  112766. /** @hidden */
  112767. _currentNonTimestampToken: Nullable<_TimeToken>;
  112768. /** @hidden */
  112769. _createTimeQuery(): WebGLQuery;
  112770. /** @hidden */
  112771. _deleteTimeQuery(query: WebGLQuery): void;
  112772. /** @hidden */
  112773. _getGlAlgorithmType(algorithmType: number): number;
  112774. /** @hidden */
  112775. _getTimeQueryResult(query: WebGLQuery): any;
  112776. /** @hidden */
  112777. _getTimeQueryAvailability(query: WebGLQuery): any;
  112778. }
  112779. interface AbstractMesh {
  112780. /**
  112781. * Backing filed
  112782. * @hidden
  112783. */
  112784. __occlusionDataStorage: _OcclusionDataStorage;
  112785. /**
  112786. * Access property
  112787. * @hidden
  112788. */
  112789. _occlusionDataStorage: _OcclusionDataStorage;
  112790. /**
  112791. * 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.
  112792. * The default value is -1 which means don't break the query and wait till the result
  112793. * @see http://doc.babylonjs.com/features/occlusionquery
  112794. */
  112795. occlusionRetryCount: number;
  112796. /**
  112797. * 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:
  112798. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112799. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112800. * * 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.
  112801. * @see http://doc.babylonjs.com/features/occlusionquery
  112802. */
  112803. occlusionType: number;
  112804. /**
  112805. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112806. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112807. * * 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.
  112808. * @see http://doc.babylonjs.com/features/occlusionquery
  112809. */
  112810. occlusionQueryAlgorithmType: number;
  112811. /**
  112812. * 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
  112813. * @see http://doc.babylonjs.com/features/occlusionquery
  112814. */
  112815. isOccluded: boolean;
  112816. /**
  112817. * Flag to check the progress status of the query
  112818. * @see http://doc.babylonjs.com/features/occlusionquery
  112819. */
  112820. isOcclusionQueryInProgress: boolean;
  112821. }
  112822. }
  112823. declare module BABYLON {
  112824. /** @hidden */
  112825. export var _forceTransformFeedbackToBundle: boolean;
  112826. interface Engine {
  112827. /**
  112828. * Creates a webGL transform feedback object
  112829. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112830. * @returns the webGL transform feedback object
  112831. */
  112832. createTransformFeedback(): WebGLTransformFeedback;
  112833. /**
  112834. * Delete a webGL transform feedback object
  112835. * @param value defines the webGL transform feedback object to delete
  112836. */
  112837. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112838. /**
  112839. * Bind a webGL transform feedback object to the webgl context
  112840. * @param value defines the webGL transform feedback object to bind
  112841. */
  112842. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112843. /**
  112844. * Begins a transform feedback operation
  112845. * @param usePoints defines if points or triangles must be used
  112846. */
  112847. beginTransformFeedback(usePoints: boolean): void;
  112848. /**
  112849. * Ends a transform feedback operation
  112850. */
  112851. endTransformFeedback(): void;
  112852. /**
  112853. * Specify the varyings to use with transform feedback
  112854. * @param program defines the associated webGL program
  112855. * @param value defines the list of strings representing the varying names
  112856. */
  112857. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112858. /**
  112859. * Bind a webGL buffer for a transform feedback operation
  112860. * @param value defines the webGL buffer to bind
  112861. */
  112862. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112863. }
  112864. }
  112865. declare module BABYLON {
  112866. /**
  112867. * Creation options of the multi render target texture.
  112868. */
  112869. export interface IMultiRenderTargetOptions {
  112870. /**
  112871. * Define if the texture needs to create mip maps after render.
  112872. */
  112873. generateMipMaps?: boolean;
  112874. /**
  112875. * Define the types of all the draw buffers we want to create
  112876. */
  112877. types?: number[];
  112878. /**
  112879. * Define the sampling modes of all the draw buffers we want to create
  112880. */
  112881. samplingModes?: number[];
  112882. /**
  112883. * Define if a depth buffer is required
  112884. */
  112885. generateDepthBuffer?: boolean;
  112886. /**
  112887. * Define if a stencil buffer is required
  112888. */
  112889. generateStencilBuffer?: boolean;
  112890. /**
  112891. * Define if a depth texture is required instead of a depth buffer
  112892. */
  112893. generateDepthTexture?: boolean;
  112894. /**
  112895. * Define the number of desired draw buffers
  112896. */
  112897. textureCount?: number;
  112898. /**
  112899. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112900. */
  112901. doNotChangeAspectRatio?: boolean;
  112902. /**
  112903. * Define the default type of the buffers we are creating
  112904. */
  112905. defaultType?: number;
  112906. }
  112907. /**
  112908. * A multi render target, like a render target provides the ability to render to a texture.
  112909. * Unlike the render target, it can render to several draw buffers in one draw.
  112910. * This is specially interesting in deferred rendering or for any effects requiring more than
  112911. * just one color from a single pass.
  112912. */
  112913. export class MultiRenderTarget extends RenderTargetTexture {
  112914. private _internalTextures;
  112915. private _textures;
  112916. private _multiRenderTargetOptions;
  112917. /**
  112918. * Get if draw buffers are currently supported by the used hardware and browser.
  112919. */
  112920. readonly isSupported: boolean;
  112921. /**
  112922. * Get the list of textures generated by the multi render target.
  112923. */
  112924. readonly textures: Texture[];
  112925. /**
  112926. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112927. */
  112928. readonly depthTexture: Texture;
  112929. /**
  112930. * Set the wrapping mode on U of all the textures we are rendering to.
  112931. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112932. */
  112933. wrapU: number;
  112934. /**
  112935. * Set the wrapping mode on V of all the textures we are rendering to.
  112936. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112937. */
  112938. wrapV: number;
  112939. /**
  112940. * Instantiate a new multi render target texture.
  112941. * A multi render target, like a render target provides the ability to render to a texture.
  112942. * Unlike the render target, it can render to several draw buffers in one draw.
  112943. * This is specially interesting in deferred rendering or for any effects requiring more than
  112944. * just one color from a single pass.
  112945. * @param name Define the name of the texture
  112946. * @param size Define the size of the buffers to render to
  112947. * @param count Define the number of target we are rendering into
  112948. * @param scene Define the scene the texture belongs to
  112949. * @param options Define the options used to create the multi render target
  112950. */
  112951. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112952. /** @hidden */
  112953. _rebuild(): void;
  112954. private _createInternalTextures;
  112955. private _createTextures;
  112956. /**
  112957. * Define the number of samples used if MSAA is enabled.
  112958. */
  112959. samples: number;
  112960. /**
  112961. * Resize all the textures in the multi render target.
  112962. * Be carrefull as it will recreate all the data in the new texture.
  112963. * @param size Define the new size
  112964. */
  112965. resize(size: any): void;
  112966. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112967. /**
  112968. * Dispose the render targets and their associated resources
  112969. */
  112970. dispose(): void;
  112971. /**
  112972. * Release all the underlying texture used as draw buffers.
  112973. */
  112974. releaseInternalTextures(): void;
  112975. }
  112976. }
  112977. declare module BABYLON {
  112978. interface ThinEngine {
  112979. /**
  112980. * Unbind a list of render target textures from the webGL context
  112981. * This is used only when drawBuffer extension or webGL2 are active
  112982. * @param textures defines the render target textures to unbind
  112983. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112984. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112985. */
  112986. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112987. /**
  112988. * Create a multi render target texture
  112989. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112990. * @param size defines the size of the texture
  112991. * @param options defines the creation options
  112992. * @returns the cube texture as an InternalTexture
  112993. */
  112994. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112995. /**
  112996. * Update the sample count for a given multiple render target texture
  112997. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112998. * @param textures defines the textures to update
  112999. * @param samples defines the sample count to set
  113000. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113001. */
  113002. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  113003. }
  113004. }
  113005. declare module BABYLON {
  113006. /**
  113007. * Class used to define an additional view for the engine
  113008. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113009. */
  113010. export class EngineView {
  113011. /** Defines the canvas where to render the view */
  113012. target: HTMLCanvasElement;
  113013. /** Defines an optional camera used to render the view (will use active camera else) */
  113014. camera?: Camera;
  113015. }
  113016. interface Engine {
  113017. /**
  113018. * Gets or sets the HTML element to use for attaching events
  113019. */
  113020. inputElement: Nullable<HTMLElement>;
  113021. /**
  113022. * Gets the current engine view
  113023. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113024. */
  113025. activeView: Nullable<EngineView>;
  113026. /** Gets or sets the list of views */
  113027. views: EngineView[];
  113028. /**
  113029. * Register a new child canvas
  113030. * @param canvas defines the canvas to register
  113031. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113032. * @returns the associated view
  113033. */
  113034. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113035. /**
  113036. * Remove a registered child canvas
  113037. * @param canvas defines the canvas to remove
  113038. * @returns the current engine
  113039. */
  113040. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113041. }
  113042. }
  113043. declare module BABYLON {
  113044. /**
  113045. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113046. */
  113047. export interface CubeMapInfo {
  113048. /**
  113049. * The pixel array for the front face.
  113050. * This is stored in format, left to right, up to down format.
  113051. */
  113052. front: Nullable<ArrayBufferView>;
  113053. /**
  113054. * The pixel array for the back face.
  113055. * This is stored in format, left to right, up to down format.
  113056. */
  113057. back: Nullable<ArrayBufferView>;
  113058. /**
  113059. * The pixel array for the left face.
  113060. * This is stored in format, left to right, up to down format.
  113061. */
  113062. left: Nullable<ArrayBufferView>;
  113063. /**
  113064. * The pixel array for the right face.
  113065. * This is stored in format, left to right, up to down format.
  113066. */
  113067. right: Nullable<ArrayBufferView>;
  113068. /**
  113069. * The pixel array for the up face.
  113070. * This is stored in format, left to right, up to down format.
  113071. */
  113072. up: Nullable<ArrayBufferView>;
  113073. /**
  113074. * The pixel array for the down face.
  113075. * This is stored in format, left to right, up to down format.
  113076. */
  113077. down: Nullable<ArrayBufferView>;
  113078. /**
  113079. * The size of the cubemap stored.
  113080. *
  113081. * Each faces will be size * size pixels.
  113082. */
  113083. size: number;
  113084. /**
  113085. * The format of the texture.
  113086. *
  113087. * RGBA, RGB.
  113088. */
  113089. format: number;
  113090. /**
  113091. * The type of the texture data.
  113092. *
  113093. * UNSIGNED_INT, FLOAT.
  113094. */
  113095. type: number;
  113096. /**
  113097. * Specifies whether the texture is in gamma space.
  113098. */
  113099. gammaSpace: boolean;
  113100. }
  113101. /**
  113102. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113103. */
  113104. export class PanoramaToCubeMapTools {
  113105. private static FACE_FRONT;
  113106. private static FACE_BACK;
  113107. private static FACE_RIGHT;
  113108. private static FACE_LEFT;
  113109. private static FACE_DOWN;
  113110. private static FACE_UP;
  113111. /**
  113112. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113113. *
  113114. * @param float32Array The source data.
  113115. * @param inputWidth The width of the input panorama.
  113116. * @param inputHeight The height of the input panorama.
  113117. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113118. * @return The cubemap data
  113119. */
  113120. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113121. private static CreateCubemapTexture;
  113122. private static CalcProjectionSpherical;
  113123. }
  113124. }
  113125. declare module BABYLON {
  113126. /**
  113127. * Helper class dealing with the extraction of spherical polynomial dataArray
  113128. * from a cube map.
  113129. */
  113130. export class CubeMapToSphericalPolynomialTools {
  113131. private static FileFaces;
  113132. /**
  113133. * Converts a texture to the according Spherical Polynomial data.
  113134. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113135. *
  113136. * @param texture The texture to extract the information from.
  113137. * @return The Spherical Polynomial data.
  113138. */
  113139. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113140. /**
  113141. * Converts a cubemap to the according Spherical Polynomial data.
  113142. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113143. *
  113144. * @param cubeInfo The Cube map to extract the information from.
  113145. * @return The Spherical Polynomial data.
  113146. */
  113147. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113148. }
  113149. }
  113150. declare module BABYLON {
  113151. interface BaseTexture {
  113152. /**
  113153. * Get the polynomial representation of the texture data.
  113154. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113155. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113156. */
  113157. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113158. }
  113159. }
  113160. declare module BABYLON {
  113161. /** @hidden */
  113162. export var rgbdEncodePixelShader: {
  113163. name: string;
  113164. shader: string;
  113165. };
  113166. }
  113167. declare module BABYLON {
  113168. /** @hidden */
  113169. export var rgbdDecodePixelShader: {
  113170. name: string;
  113171. shader: string;
  113172. };
  113173. }
  113174. declare module BABYLON {
  113175. /**
  113176. * Raw texture data and descriptor sufficient for WebGL texture upload
  113177. */
  113178. export interface EnvironmentTextureInfo {
  113179. /**
  113180. * Version of the environment map
  113181. */
  113182. version: number;
  113183. /**
  113184. * Width of image
  113185. */
  113186. width: number;
  113187. /**
  113188. * Irradiance information stored in the file.
  113189. */
  113190. irradiance: any;
  113191. /**
  113192. * Specular information stored in the file.
  113193. */
  113194. specular: any;
  113195. }
  113196. /**
  113197. * Defines One Image in the file. It requires only the position in the file
  113198. * as well as the length.
  113199. */
  113200. interface BufferImageData {
  113201. /**
  113202. * Length of the image data.
  113203. */
  113204. length: number;
  113205. /**
  113206. * Position of the data from the null terminator delimiting the end of the JSON.
  113207. */
  113208. position: number;
  113209. }
  113210. /**
  113211. * Defines the specular data enclosed in the file.
  113212. * This corresponds to the version 1 of the data.
  113213. */
  113214. export interface EnvironmentTextureSpecularInfoV1 {
  113215. /**
  113216. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113217. */
  113218. specularDataPosition?: number;
  113219. /**
  113220. * This contains all the images data needed to reconstruct the cubemap.
  113221. */
  113222. mipmaps: Array<BufferImageData>;
  113223. /**
  113224. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113225. */
  113226. lodGenerationScale: number;
  113227. }
  113228. /**
  113229. * Sets of helpers addressing the serialization and deserialization of environment texture
  113230. * stored in a BabylonJS env file.
  113231. * Those files are usually stored as .env files.
  113232. */
  113233. export class EnvironmentTextureTools {
  113234. /**
  113235. * Magic number identifying the env file.
  113236. */
  113237. private static _MagicBytes;
  113238. /**
  113239. * Gets the environment info from an env file.
  113240. * @param data The array buffer containing the .env bytes.
  113241. * @returns the environment file info (the json header) if successfully parsed.
  113242. */
  113243. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113244. /**
  113245. * Creates an environment texture from a loaded cube texture.
  113246. * @param texture defines the cube texture to convert in env file
  113247. * @return a promise containing the environment data if succesfull.
  113248. */
  113249. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113250. /**
  113251. * Creates a JSON representation of the spherical data.
  113252. * @param texture defines the texture containing the polynomials
  113253. * @return the JSON representation of the spherical info
  113254. */
  113255. private static _CreateEnvTextureIrradiance;
  113256. /**
  113257. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113258. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113259. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113260. * @return the views described by info providing access to the underlying buffer
  113261. */
  113262. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113263. /**
  113264. * Uploads the texture info contained in the env file to the GPU.
  113265. * @param texture defines the internal texture to upload to
  113266. * @param arrayBuffer defines the buffer cotaining the data to load
  113267. * @param info defines the texture info retrieved through the GetEnvInfo method
  113268. * @returns a promise
  113269. */
  113270. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113271. private static _OnImageReadyAsync;
  113272. /**
  113273. * Uploads the levels of image data to the GPU.
  113274. * @param texture defines the internal texture to upload to
  113275. * @param imageData defines the array buffer views of image data [mipmap][face]
  113276. * @returns a promise
  113277. */
  113278. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113279. /**
  113280. * Uploads spherical polynomials information to the texture.
  113281. * @param texture defines the texture we are trying to upload the information to
  113282. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113283. */
  113284. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113285. /** @hidden */
  113286. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113287. }
  113288. }
  113289. declare module BABYLON {
  113290. /**
  113291. * Contains position and normal vectors for a vertex
  113292. */
  113293. export class PositionNormalVertex {
  113294. /** the position of the vertex (defaut: 0,0,0) */
  113295. position: Vector3;
  113296. /** the normal of the vertex (defaut: 0,1,0) */
  113297. normal: Vector3;
  113298. /**
  113299. * Creates a PositionNormalVertex
  113300. * @param position the position of the vertex (defaut: 0,0,0)
  113301. * @param normal the normal of the vertex (defaut: 0,1,0)
  113302. */
  113303. constructor(
  113304. /** the position of the vertex (defaut: 0,0,0) */
  113305. position?: Vector3,
  113306. /** the normal of the vertex (defaut: 0,1,0) */
  113307. normal?: Vector3);
  113308. /**
  113309. * Clones the PositionNormalVertex
  113310. * @returns the cloned PositionNormalVertex
  113311. */
  113312. clone(): PositionNormalVertex;
  113313. }
  113314. /**
  113315. * Contains position, normal and uv vectors for a vertex
  113316. */
  113317. export class PositionNormalTextureVertex {
  113318. /** the position of the vertex (defaut: 0,0,0) */
  113319. position: Vector3;
  113320. /** the normal of the vertex (defaut: 0,1,0) */
  113321. normal: Vector3;
  113322. /** the uv of the vertex (default: 0,0) */
  113323. uv: Vector2;
  113324. /**
  113325. * Creates a PositionNormalTextureVertex
  113326. * @param position the position of the vertex (defaut: 0,0,0)
  113327. * @param normal the normal of the vertex (defaut: 0,1,0)
  113328. * @param uv the uv of the vertex (default: 0,0)
  113329. */
  113330. constructor(
  113331. /** the position of the vertex (defaut: 0,0,0) */
  113332. position?: Vector3,
  113333. /** the normal of the vertex (defaut: 0,1,0) */
  113334. normal?: Vector3,
  113335. /** the uv of the vertex (default: 0,0) */
  113336. uv?: Vector2);
  113337. /**
  113338. * Clones the PositionNormalTextureVertex
  113339. * @returns the cloned PositionNormalTextureVertex
  113340. */
  113341. clone(): PositionNormalTextureVertex;
  113342. }
  113343. }
  113344. declare module BABYLON {
  113345. /** @hidden */
  113346. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113347. private _genericAttributeLocation;
  113348. private _varyingLocationCount;
  113349. private _varyingLocationMap;
  113350. private _replacements;
  113351. private _textureCount;
  113352. private _uniforms;
  113353. lineProcessor(line: string): string;
  113354. attributeProcessor(attribute: string): string;
  113355. varyingProcessor(varying: string, isFragment: boolean): string;
  113356. uniformProcessor(uniform: string): string;
  113357. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113358. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113359. }
  113360. }
  113361. declare module BABYLON {
  113362. /**
  113363. * Container for accessors for natively-stored mesh data buffers.
  113364. */
  113365. class NativeDataBuffer extends DataBuffer {
  113366. /**
  113367. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113368. */
  113369. nativeIndexBuffer?: any;
  113370. /**
  113371. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113372. */
  113373. nativeVertexBuffer?: any;
  113374. }
  113375. /** @hidden */
  113376. class NativeTexture extends InternalTexture {
  113377. getInternalTexture(): InternalTexture;
  113378. getViewCount(): number;
  113379. }
  113380. /** @hidden */
  113381. export class NativeEngine extends Engine {
  113382. private readonly _native;
  113383. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  113384. private readonly INVALID_HANDLE;
  113385. getHardwareScalingLevel(): number;
  113386. constructor();
  113387. /**
  113388. * Can be used to override the current requestAnimationFrame requester.
  113389. * @hidden
  113390. */
  113391. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113392. /**
  113393. * Override default engine behavior.
  113394. * @param color
  113395. * @param backBuffer
  113396. * @param depth
  113397. * @param stencil
  113398. */
  113399. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113400. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113401. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113402. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113403. recordVertexArrayObject(vertexBuffers: {
  113404. [key: string]: VertexBuffer;
  113405. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113406. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113407. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113408. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113409. /**
  113410. * Draw a list of indexed primitives
  113411. * @param fillMode defines the primitive to use
  113412. * @param indexStart defines the starting index
  113413. * @param indexCount defines the number of index to draw
  113414. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113415. */
  113416. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113417. /**
  113418. * Draw a list of unindexed primitives
  113419. * @param fillMode defines the primitive to use
  113420. * @param verticesStart defines the index of first vertex to draw
  113421. * @param verticesCount defines the count of vertices to draw
  113422. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113423. */
  113424. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113425. createPipelineContext(): IPipelineContext;
  113426. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113427. /** @hidden */
  113428. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113429. /** @hidden */
  113430. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113431. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113432. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113433. protected _setProgram(program: WebGLProgram): void;
  113434. _releaseEffect(effect: Effect): void;
  113435. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113436. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113437. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113438. bindSamplers(effect: Effect): void;
  113439. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113440. getRenderWidth(useScreen?: boolean): number;
  113441. getRenderHeight(useScreen?: boolean): number;
  113442. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113443. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113444. /**
  113445. * Set the z offset to apply to current rendering
  113446. * @param value defines the offset to apply
  113447. */
  113448. setZOffset(value: number): void;
  113449. /**
  113450. * Gets the current value of the zOffset
  113451. * @returns the current zOffset state
  113452. */
  113453. getZOffset(): number;
  113454. /**
  113455. * Enable or disable depth buffering
  113456. * @param enable defines the state to set
  113457. */
  113458. setDepthBuffer(enable: boolean): void;
  113459. /**
  113460. * Gets a boolean indicating if depth writing is enabled
  113461. * @returns the current depth writing state
  113462. */
  113463. getDepthWrite(): boolean;
  113464. /**
  113465. * Enable or disable depth writing
  113466. * @param enable defines the state to set
  113467. */
  113468. setDepthWrite(enable: boolean): void;
  113469. /**
  113470. * Enable or disable color writing
  113471. * @param enable defines the state to set
  113472. */
  113473. setColorWrite(enable: boolean): void;
  113474. /**
  113475. * Gets a boolean indicating if color writing is enabled
  113476. * @returns the current color writing state
  113477. */
  113478. getColorWrite(): boolean;
  113479. /**
  113480. * Sets alpha constants used by some alpha blending modes
  113481. * @param r defines the red component
  113482. * @param g defines the green component
  113483. * @param b defines the blue component
  113484. * @param a defines the alpha component
  113485. */
  113486. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113487. /**
  113488. * Sets the current alpha mode
  113489. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113490. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113491. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113492. */
  113493. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113494. /**
  113495. * Gets the current alpha mode
  113496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113497. * @returns the current alpha mode
  113498. */
  113499. getAlphaMode(): number;
  113500. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113501. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113502. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113503. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113504. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113505. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113506. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113507. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113508. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113509. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113510. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113511. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113512. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113513. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113514. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113515. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113516. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113517. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113518. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113519. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113520. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113521. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113522. wipeCaches(bruteForce?: boolean): void;
  113523. _createTexture(): WebGLTexture;
  113524. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113525. /**
  113526. * Usually called from BABYLON.Texture.ts.
  113527. * Passed information to create a WebGLTexture
  113528. * @param urlArg defines a value which contains one of the following:
  113529. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113530. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113531. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113533. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113534. * @param scene needed for loading to the correct scene
  113535. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113536. * @param onLoad optional callback to be called upon successful completion
  113537. * @param onError optional callback to be called upon failure
  113538. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113539. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113540. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113541. * @param forcedExtension defines the extension to use to pick the right loader
  113542. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113543. */
  113544. 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;
  113545. /**
  113546. * Creates a cube texture
  113547. * @param rootUrl defines the url where the files to load is located
  113548. * @param scene defines the current scene
  113549. * @param files defines the list of files to load (1 per face)
  113550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113551. * @param onLoad defines an optional callback raised when the texture is loaded
  113552. * @param onError defines an optional callback raised if there is an issue to load the texture
  113553. * @param format defines the format of the data
  113554. * @param forcedExtension defines the extension to use to pick the right loader
  113555. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113556. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113557. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113558. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113559. * @returns the cube texture as an InternalTexture
  113560. */
  113561. 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;
  113562. private _getSamplingFilter;
  113563. private static _GetNativeTextureFormat;
  113564. createRenderTargetTexture(size: number | {
  113565. width: number;
  113566. height: number;
  113567. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113568. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113569. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113570. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113571. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113572. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113573. /**
  113574. * Updates a dynamic vertex buffer.
  113575. * @param vertexBuffer the vertex buffer to update
  113576. * @param data the data used to update the vertex buffer
  113577. * @param byteOffset the byte offset of the data (optional)
  113578. * @param byteLength the byte length of the data (optional)
  113579. */
  113580. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113581. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113582. private _updateAnisotropicLevel;
  113583. private _getAddressMode;
  113584. /** @hidden */
  113585. _bindTexture(channel: number, texture: InternalTexture): void;
  113586. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113587. releaseEffects(): void;
  113588. /** @hidden */
  113589. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113590. /** @hidden */
  113591. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113592. /** @hidden */
  113593. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113594. /** @hidden */
  113595. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113596. }
  113597. }
  113598. declare module BABYLON {
  113599. /**
  113600. * Gather the list of clipboard event types as constants.
  113601. */
  113602. export class ClipboardEventTypes {
  113603. /**
  113604. * The clipboard event is fired when a copy command is active (pressed).
  113605. */
  113606. static readonly COPY: number;
  113607. /**
  113608. * The clipboard event is fired when a cut command is active (pressed).
  113609. */
  113610. static readonly CUT: number;
  113611. /**
  113612. * The clipboard event is fired when a paste command is active (pressed).
  113613. */
  113614. static readonly PASTE: number;
  113615. }
  113616. /**
  113617. * This class is used to store clipboard related info for the onClipboardObservable event.
  113618. */
  113619. export class ClipboardInfo {
  113620. /**
  113621. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113622. */
  113623. type: number;
  113624. /**
  113625. * Defines the related dom event
  113626. */
  113627. event: ClipboardEvent;
  113628. /**
  113629. *Creates an instance of ClipboardInfo.
  113630. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113631. * @param event Defines the related dom event
  113632. */
  113633. constructor(
  113634. /**
  113635. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113636. */
  113637. type: number,
  113638. /**
  113639. * Defines the related dom event
  113640. */
  113641. event: ClipboardEvent);
  113642. /**
  113643. * Get the clipboard event's type from the keycode.
  113644. * @param keyCode Defines the keyCode for the current keyboard event.
  113645. * @return {number}
  113646. */
  113647. static GetTypeFromCharacter(keyCode: number): number;
  113648. }
  113649. }
  113650. declare module BABYLON {
  113651. /**
  113652. * Google Daydream controller
  113653. */
  113654. export class DaydreamController extends WebVRController {
  113655. /**
  113656. * Base Url for the controller model.
  113657. */
  113658. static MODEL_BASE_URL: string;
  113659. /**
  113660. * File name for the controller model.
  113661. */
  113662. static MODEL_FILENAME: string;
  113663. /**
  113664. * Gamepad Id prefix used to identify Daydream Controller.
  113665. */
  113666. static readonly GAMEPAD_ID_PREFIX: string;
  113667. /**
  113668. * Creates a new DaydreamController from a gamepad
  113669. * @param vrGamepad the gamepad that the controller should be created from
  113670. */
  113671. constructor(vrGamepad: any);
  113672. /**
  113673. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113674. * @param scene scene in which to add meshes
  113675. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113676. */
  113677. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113678. /**
  113679. * Called once for each button that changed state since the last frame
  113680. * @param buttonIdx Which button index changed
  113681. * @param state New state of the button
  113682. * @param changes Which properties on the state changed since last frame
  113683. */
  113684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113685. }
  113686. }
  113687. declare module BABYLON {
  113688. /**
  113689. * Gear VR Controller
  113690. */
  113691. export class GearVRController extends WebVRController {
  113692. /**
  113693. * Base Url for the controller model.
  113694. */
  113695. static MODEL_BASE_URL: string;
  113696. /**
  113697. * File name for the controller model.
  113698. */
  113699. static MODEL_FILENAME: string;
  113700. /**
  113701. * Gamepad Id prefix used to identify this controller.
  113702. */
  113703. static readonly GAMEPAD_ID_PREFIX: string;
  113704. private readonly _buttonIndexToObservableNameMap;
  113705. /**
  113706. * Creates a new GearVRController from a gamepad
  113707. * @param vrGamepad the gamepad that the controller should be created from
  113708. */
  113709. constructor(vrGamepad: any);
  113710. /**
  113711. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113712. * @param scene scene in which to add meshes
  113713. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113714. */
  113715. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113716. /**
  113717. * Called once for each button that changed state since the last frame
  113718. * @param buttonIdx Which button index changed
  113719. * @param state New state of the button
  113720. * @param changes Which properties on the state changed since last frame
  113721. */
  113722. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113723. }
  113724. }
  113725. declare module BABYLON {
  113726. /**
  113727. * Class containing static functions to help procedurally build meshes
  113728. */
  113729. export class PolyhedronBuilder {
  113730. /**
  113731. * Creates a polyhedron mesh
  113732. * * 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
  113733. * * The parameter `size` (positive float, default 1) sets the polygon size
  113734. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113735. * * 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`
  113736. * * 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
  113737. * * 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)`)
  113738. * * 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
  113739. * * 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
  113740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113743. * @param name defines the name of the mesh
  113744. * @param options defines the options used to create the mesh
  113745. * @param scene defines the hosting scene
  113746. * @returns the polyhedron mesh
  113747. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113748. */
  113749. static CreatePolyhedron(name: string, options: {
  113750. type?: number;
  113751. size?: number;
  113752. sizeX?: number;
  113753. sizeY?: number;
  113754. sizeZ?: number;
  113755. custom?: any;
  113756. faceUV?: Vector4[];
  113757. faceColors?: Color4[];
  113758. flat?: boolean;
  113759. updatable?: boolean;
  113760. sideOrientation?: number;
  113761. frontUVs?: Vector4;
  113762. backUVs?: Vector4;
  113763. }, scene?: Nullable<Scene>): Mesh;
  113764. }
  113765. }
  113766. declare module BABYLON {
  113767. /**
  113768. * Gizmo that enables scaling a mesh along 3 axis
  113769. */
  113770. export class ScaleGizmo extends Gizmo {
  113771. /**
  113772. * Internal gizmo used for interactions on the x axis
  113773. */
  113774. xGizmo: AxisScaleGizmo;
  113775. /**
  113776. * Internal gizmo used for interactions on the y axis
  113777. */
  113778. yGizmo: AxisScaleGizmo;
  113779. /**
  113780. * Internal gizmo used for interactions on the z axis
  113781. */
  113782. zGizmo: AxisScaleGizmo;
  113783. /**
  113784. * Internal gizmo used to scale all axis equally
  113785. */
  113786. uniformScaleGizmo: AxisScaleGizmo;
  113787. private _meshAttached;
  113788. private _updateGizmoRotationToMatchAttachedMesh;
  113789. private _snapDistance;
  113790. private _scaleRatio;
  113791. private _uniformScalingMesh;
  113792. private _octahedron;
  113793. /** Fires an event when any of it's sub gizmos are dragged */
  113794. onDragStartObservable: Observable<unknown>;
  113795. /** Fires an event when any of it's sub gizmos are released from dragging */
  113796. onDragEndObservable: Observable<unknown>;
  113797. attachedMesh: Nullable<AbstractMesh>;
  113798. /**
  113799. * Creates a ScaleGizmo
  113800. * @param gizmoLayer The utility layer the gizmo will be added to
  113801. */
  113802. constructor(gizmoLayer?: UtilityLayerRenderer);
  113803. updateGizmoRotationToMatchAttachedMesh: boolean;
  113804. /**
  113805. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113806. */
  113807. snapDistance: number;
  113808. /**
  113809. * Ratio for the scale of the gizmo (Default: 1)
  113810. */
  113811. scaleRatio: number;
  113812. /**
  113813. * Disposes of the gizmo
  113814. */
  113815. dispose(): void;
  113816. }
  113817. }
  113818. declare module BABYLON {
  113819. /**
  113820. * Single axis scale gizmo
  113821. */
  113822. export class AxisScaleGizmo extends Gizmo {
  113823. /**
  113824. * Drag behavior responsible for the gizmos dragging interactions
  113825. */
  113826. dragBehavior: PointerDragBehavior;
  113827. private _pointerObserver;
  113828. /**
  113829. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113830. */
  113831. snapDistance: number;
  113832. /**
  113833. * Event that fires each time the gizmo snaps to a new location.
  113834. * * snapDistance is the the change in distance
  113835. */
  113836. onSnapObservable: Observable<{
  113837. snapDistance: number;
  113838. }>;
  113839. /**
  113840. * If the scaling operation should be done on all axis (default: false)
  113841. */
  113842. uniformScaling: boolean;
  113843. private _isEnabled;
  113844. private _parent;
  113845. private _arrow;
  113846. private _coloredMaterial;
  113847. private _hoverMaterial;
  113848. /**
  113849. * Creates an AxisScaleGizmo
  113850. * @param gizmoLayer The utility layer the gizmo will be added to
  113851. * @param dragAxis The axis which the gizmo will be able to scale on
  113852. * @param color The color of the gizmo
  113853. */
  113854. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113855. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113856. /**
  113857. * If the gizmo is enabled
  113858. */
  113859. isEnabled: boolean;
  113860. /**
  113861. * Disposes of the gizmo
  113862. */
  113863. dispose(): void;
  113864. /**
  113865. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113866. * @param mesh The mesh to replace the default mesh of the gizmo
  113867. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113868. */
  113869. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113870. }
  113871. }
  113872. declare module BABYLON {
  113873. /**
  113874. * Bounding box gizmo
  113875. */
  113876. export class BoundingBoxGizmo extends Gizmo {
  113877. private _lineBoundingBox;
  113878. private _rotateSpheresParent;
  113879. private _scaleBoxesParent;
  113880. private _boundingDimensions;
  113881. private _renderObserver;
  113882. private _pointerObserver;
  113883. private _scaleDragSpeed;
  113884. private _tmpQuaternion;
  113885. private _tmpVector;
  113886. private _tmpRotationMatrix;
  113887. /**
  113888. * 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)
  113889. */
  113890. ignoreChildren: boolean;
  113891. /**
  113892. * 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)
  113893. */
  113894. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113895. /**
  113896. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113897. */
  113898. rotationSphereSize: number;
  113899. /**
  113900. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113901. */
  113902. scaleBoxSize: number;
  113903. /**
  113904. * 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)
  113905. */
  113906. fixedDragMeshScreenSize: boolean;
  113907. /**
  113908. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113909. */
  113910. fixedDragMeshScreenSizeDistanceFactor: number;
  113911. /**
  113912. * Fired when a rotation sphere or scale box is dragged
  113913. */
  113914. onDragStartObservable: Observable<{}>;
  113915. /**
  113916. * Fired when a scale box is dragged
  113917. */
  113918. onScaleBoxDragObservable: Observable<{}>;
  113919. /**
  113920. * Fired when a scale box drag is ended
  113921. */
  113922. onScaleBoxDragEndObservable: Observable<{}>;
  113923. /**
  113924. * Fired when a rotation sphere is dragged
  113925. */
  113926. onRotationSphereDragObservable: Observable<{}>;
  113927. /**
  113928. * Fired when a rotation sphere drag is ended
  113929. */
  113930. onRotationSphereDragEndObservable: Observable<{}>;
  113931. /**
  113932. * 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)
  113933. */
  113934. scalePivot: Nullable<Vector3>;
  113935. /**
  113936. * Mesh used as a pivot to rotate the attached mesh
  113937. */
  113938. private _anchorMesh;
  113939. private _existingMeshScale;
  113940. private _dragMesh;
  113941. private pointerDragBehavior;
  113942. private coloredMaterial;
  113943. private hoverColoredMaterial;
  113944. /**
  113945. * Sets the color of the bounding box gizmo
  113946. * @param color the color to set
  113947. */
  113948. setColor(color: Color3): void;
  113949. /**
  113950. * Creates an BoundingBoxGizmo
  113951. * @param gizmoLayer The utility layer the gizmo will be added to
  113952. * @param color The color of the gizmo
  113953. */
  113954. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113955. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113956. private _selectNode;
  113957. /**
  113958. * Updates the bounding box information for the Gizmo
  113959. */
  113960. updateBoundingBox(): void;
  113961. private _updateRotationSpheres;
  113962. private _updateScaleBoxes;
  113963. /**
  113964. * Enables rotation on the specified axis and disables rotation on the others
  113965. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113966. */
  113967. setEnabledRotationAxis(axis: string): void;
  113968. /**
  113969. * Enables/disables scaling
  113970. * @param enable if scaling should be enabled
  113971. */
  113972. setEnabledScaling(enable: boolean): void;
  113973. private _updateDummy;
  113974. /**
  113975. * Enables a pointer drag behavior on the bounding box of the gizmo
  113976. */
  113977. enableDragBehavior(): void;
  113978. /**
  113979. * Disposes of the gizmo
  113980. */
  113981. dispose(): void;
  113982. /**
  113983. * 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)
  113984. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113985. * @returns the bounding box mesh with the passed in mesh as a child
  113986. */
  113987. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113988. /**
  113989. * CustomMeshes are not supported by this gizmo
  113990. * @param mesh The mesh to replace the default mesh of the gizmo
  113991. */
  113992. setCustomMesh(mesh: Mesh): void;
  113993. }
  113994. }
  113995. declare module BABYLON {
  113996. /**
  113997. * Single plane rotation gizmo
  113998. */
  113999. export class PlaneRotationGizmo extends Gizmo {
  114000. /**
  114001. * Drag behavior responsible for the gizmos dragging interactions
  114002. */
  114003. dragBehavior: PointerDragBehavior;
  114004. private _pointerObserver;
  114005. /**
  114006. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  114007. */
  114008. snapDistance: number;
  114009. /**
  114010. * Event that fires each time the gizmo snaps to a new location.
  114011. * * snapDistance is the the change in distance
  114012. */
  114013. onSnapObservable: Observable<{
  114014. snapDistance: number;
  114015. }>;
  114016. private _isEnabled;
  114017. private _parent;
  114018. /**
  114019. * Creates a PlaneRotationGizmo
  114020. * @param gizmoLayer The utility layer the gizmo will be added to
  114021. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114022. * @param color The color of the gizmo
  114023. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114024. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114025. */
  114026. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114027. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114028. /**
  114029. * If the gizmo is enabled
  114030. */
  114031. isEnabled: boolean;
  114032. /**
  114033. * Disposes of the gizmo
  114034. */
  114035. dispose(): void;
  114036. }
  114037. }
  114038. declare module BABYLON {
  114039. /**
  114040. * Gizmo that enables rotating a mesh along 3 axis
  114041. */
  114042. export class RotationGizmo extends Gizmo {
  114043. /**
  114044. * Internal gizmo used for interactions on the x axis
  114045. */
  114046. xGizmo: PlaneRotationGizmo;
  114047. /**
  114048. * Internal gizmo used for interactions on the y axis
  114049. */
  114050. yGizmo: PlaneRotationGizmo;
  114051. /**
  114052. * Internal gizmo used for interactions on the z axis
  114053. */
  114054. zGizmo: PlaneRotationGizmo;
  114055. /** Fires an event when any of it's sub gizmos are dragged */
  114056. onDragStartObservable: Observable<unknown>;
  114057. /** Fires an event when any of it's sub gizmos are released from dragging */
  114058. onDragEndObservable: Observable<unknown>;
  114059. private _meshAttached;
  114060. attachedMesh: Nullable<AbstractMesh>;
  114061. /**
  114062. * Creates a RotationGizmo
  114063. * @param gizmoLayer The utility layer the gizmo will be added to
  114064. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114065. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114066. */
  114067. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114068. updateGizmoRotationToMatchAttachedMesh: boolean;
  114069. /**
  114070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114071. */
  114072. snapDistance: number;
  114073. /**
  114074. * Ratio for the scale of the gizmo (Default: 1)
  114075. */
  114076. scaleRatio: number;
  114077. /**
  114078. * Disposes of the gizmo
  114079. */
  114080. dispose(): void;
  114081. /**
  114082. * CustomMeshes are not supported by this gizmo
  114083. * @param mesh The mesh to replace the default mesh of the gizmo
  114084. */
  114085. setCustomMesh(mesh: Mesh): void;
  114086. }
  114087. }
  114088. declare module BABYLON {
  114089. /**
  114090. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114091. */
  114092. export class GizmoManager implements IDisposable {
  114093. private scene;
  114094. /**
  114095. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114096. */
  114097. gizmos: {
  114098. positionGizmo: Nullable<PositionGizmo>;
  114099. rotationGizmo: Nullable<RotationGizmo>;
  114100. scaleGizmo: Nullable<ScaleGizmo>;
  114101. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114102. };
  114103. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114104. clearGizmoOnEmptyPointerEvent: boolean;
  114105. /** Fires an event when the manager is attached to a mesh */
  114106. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114107. private _gizmosEnabled;
  114108. private _pointerObserver;
  114109. private _attachedMesh;
  114110. private _boundingBoxColor;
  114111. private _defaultUtilityLayer;
  114112. private _defaultKeepDepthUtilityLayer;
  114113. /**
  114114. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114115. */
  114116. boundingBoxDragBehavior: SixDofDragBehavior;
  114117. /**
  114118. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114119. */
  114120. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114121. /**
  114122. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114123. */
  114124. usePointerToAttachGizmos: boolean;
  114125. /**
  114126. * Utility layer that the bounding box gizmo belongs to
  114127. */
  114128. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114129. /**
  114130. * Utility layer that all gizmos besides bounding box belong to
  114131. */
  114132. readonly utilityLayer: UtilityLayerRenderer;
  114133. /**
  114134. * Instatiates a gizmo manager
  114135. * @param scene the scene to overlay the gizmos on top of
  114136. */
  114137. constructor(scene: Scene);
  114138. /**
  114139. * Attaches a set of gizmos to the specified mesh
  114140. * @param mesh The mesh the gizmo's should be attached to
  114141. */
  114142. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114143. /**
  114144. * If the position gizmo is enabled
  114145. */
  114146. positionGizmoEnabled: boolean;
  114147. /**
  114148. * If the rotation gizmo is enabled
  114149. */
  114150. rotationGizmoEnabled: boolean;
  114151. /**
  114152. * If the scale gizmo is enabled
  114153. */
  114154. scaleGizmoEnabled: boolean;
  114155. /**
  114156. * If the boundingBox gizmo is enabled
  114157. */
  114158. boundingBoxGizmoEnabled: boolean;
  114159. /**
  114160. * Disposes of the gizmo manager
  114161. */
  114162. dispose(): void;
  114163. }
  114164. }
  114165. declare module BABYLON {
  114166. /**
  114167. * A directional light is defined by a direction (what a surprise!).
  114168. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114169. * 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.
  114170. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114171. */
  114172. export class DirectionalLight extends ShadowLight {
  114173. private _shadowFrustumSize;
  114174. /**
  114175. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114176. */
  114177. /**
  114178. * Specifies a fix frustum size for the shadow generation.
  114179. */
  114180. shadowFrustumSize: number;
  114181. private _shadowOrthoScale;
  114182. /**
  114183. * Gets the shadow projection scale against the optimal computed one.
  114184. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114185. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114186. */
  114187. /**
  114188. * Sets the shadow projection scale against the optimal computed one.
  114189. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114190. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114191. */
  114192. shadowOrthoScale: number;
  114193. /**
  114194. * Automatically compute the projection matrix to best fit (including all the casters)
  114195. * on each frame.
  114196. */
  114197. autoUpdateExtends: boolean;
  114198. private _orthoLeft;
  114199. private _orthoRight;
  114200. private _orthoTop;
  114201. private _orthoBottom;
  114202. /**
  114203. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114204. * The directional light is emitted from everywhere in the given direction.
  114205. * It can cast shadows.
  114206. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114207. * @param name The friendly name of the light
  114208. * @param direction The direction of the light
  114209. * @param scene The scene the light belongs to
  114210. */
  114211. constructor(name: string, direction: Vector3, scene: Scene);
  114212. /**
  114213. * Returns the string "DirectionalLight".
  114214. * @return The class name
  114215. */
  114216. getClassName(): string;
  114217. /**
  114218. * Returns the integer 1.
  114219. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114220. */
  114221. getTypeID(): number;
  114222. /**
  114223. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114224. * Returns the DirectionalLight Shadow projection matrix.
  114225. */
  114226. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114227. /**
  114228. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114229. * Returns the DirectionalLight Shadow projection matrix.
  114230. */
  114231. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114232. /**
  114233. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114234. * Returns the DirectionalLight Shadow projection matrix.
  114235. */
  114236. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114237. protected _buildUniformLayout(): void;
  114238. /**
  114239. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114240. * @param effect The effect to update
  114241. * @param lightIndex The index of the light in the effect to update
  114242. * @returns The directional light
  114243. */
  114244. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114245. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114246. /**
  114247. * Gets the minZ used for shadow according to both the scene and the light.
  114248. *
  114249. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114250. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114251. * @param activeCamera The camera we are returning the min for
  114252. * @returns the depth min z
  114253. */
  114254. getDepthMinZ(activeCamera: Camera): number;
  114255. /**
  114256. * Gets the maxZ used for shadow according to both the scene and the light.
  114257. *
  114258. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114259. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114260. * @param activeCamera The camera we are returning the max for
  114261. * @returns the depth max z
  114262. */
  114263. getDepthMaxZ(activeCamera: Camera): number;
  114264. /**
  114265. * Prepares the list of defines specific to the light type.
  114266. * @param defines the list of defines
  114267. * @param lightIndex defines the index of the light for the effect
  114268. */
  114269. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114270. }
  114271. }
  114272. declare module BABYLON {
  114273. /**
  114274. * Class containing static functions to help procedurally build meshes
  114275. */
  114276. export class HemisphereBuilder {
  114277. /**
  114278. * Creates a hemisphere mesh
  114279. * @param name defines the name of the mesh
  114280. * @param options defines the options used to create the mesh
  114281. * @param scene defines the hosting scene
  114282. * @returns the hemisphere mesh
  114283. */
  114284. static CreateHemisphere(name: string, options: {
  114285. segments?: number;
  114286. diameter?: number;
  114287. sideOrientation?: number;
  114288. }, scene: any): Mesh;
  114289. }
  114290. }
  114291. declare module BABYLON {
  114292. /**
  114293. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114294. * These values define a cone of light starting from the position, emitting toward the direction.
  114295. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114296. * and the exponent defines the speed of the decay of the light with distance (reach).
  114297. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114298. */
  114299. export class SpotLight extends ShadowLight {
  114300. private _angle;
  114301. private _innerAngle;
  114302. private _cosHalfAngle;
  114303. private _lightAngleScale;
  114304. private _lightAngleOffset;
  114305. /**
  114306. * Gets the cone angle of the spot light in Radians.
  114307. */
  114308. /**
  114309. * Sets the cone angle of the spot light in Radians.
  114310. */
  114311. angle: number;
  114312. /**
  114313. * Only used in gltf falloff mode, this defines the angle where
  114314. * the directional falloff will start before cutting at angle which could be seen
  114315. * as outer angle.
  114316. */
  114317. /**
  114318. * Only used in gltf falloff mode, this defines the angle where
  114319. * the directional falloff will start before cutting at angle which could be seen
  114320. * as outer angle.
  114321. */
  114322. innerAngle: number;
  114323. private _shadowAngleScale;
  114324. /**
  114325. * Allows scaling the angle of the light for shadow generation only.
  114326. */
  114327. /**
  114328. * Allows scaling the angle of the light for shadow generation only.
  114329. */
  114330. shadowAngleScale: number;
  114331. /**
  114332. * The light decay speed with the distance from the emission spot.
  114333. */
  114334. exponent: number;
  114335. private _projectionTextureMatrix;
  114336. /**
  114337. * Allows reading the projecton texture
  114338. */
  114339. readonly projectionTextureMatrix: Matrix;
  114340. protected _projectionTextureLightNear: number;
  114341. /**
  114342. * Gets the near clip of the Spotlight for texture projection.
  114343. */
  114344. /**
  114345. * Sets the near clip of the Spotlight for texture projection.
  114346. */
  114347. projectionTextureLightNear: number;
  114348. protected _projectionTextureLightFar: number;
  114349. /**
  114350. * Gets the far clip of the Spotlight for texture projection.
  114351. */
  114352. /**
  114353. * Sets the far clip of the Spotlight for texture projection.
  114354. */
  114355. projectionTextureLightFar: number;
  114356. protected _projectionTextureUpDirection: Vector3;
  114357. /**
  114358. * Gets the Up vector of the Spotlight for texture projection.
  114359. */
  114360. /**
  114361. * Sets the Up vector of the Spotlight for texture projection.
  114362. */
  114363. projectionTextureUpDirection: Vector3;
  114364. private _projectionTexture;
  114365. /**
  114366. * Gets the projection texture of the light.
  114367. */
  114368. /**
  114369. * Sets the projection texture of the light.
  114370. */
  114371. projectionTexture: Nullable<BaseTexture>;
  114372. private _projectionTextureViewLightDirty;
  114373. private _projectionTextureProjectionLightDirty;
  114374. private _projectionTextureDirty;
  114375. private _projectionTextureViewTargetVector;
  114376. private _projectionTextureViewLightMatrix;
  114377. private _projectionTextureProjectionLightMatrix;
  114378. private _projectionTextureScalingMatrix;
  114379. /**
  114380. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114381. * It can cast shadows.
  114382. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114383. * @param name The light friendly name
  114384. * @param position The position of the spot light in the scene
  114385. * @param direction The direction of the light in the scene
  114386. * @param angle The cone angle of the light in Radians
  114387. * @param exponent The light decay speed with the distance from the emission spot
  114388. * @param scene The scene the lights belongs to
  114389. */
  114390. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114391. /**
  114392. * Returns the string "SpotLight".
  114393. * @returns the class name
  114394. */
  114395. getClassName(): string;
  114396. /**
  114397. * Returns the integer 2.
  114398. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114399. */
  114400. getTypeID(): number;
  114401. /**
  114402. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114403. */
  114404. protected _setDirection(value: Vector3): void;
  114405. /**
  114406. * Overrides the position setter to recompute the projection texture view light Matrix.
  114407. */
  114408. protected _setPosition(value: Vector3): void;
  114409. /**
  114410. * 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.
  114411. * Returns the SpotLight.
  114412. */
  114413. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114414. protected _computeProjectionTextureViewLightMatrix(): void;
  114415. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114416. /**
  114417. * Main function for light texture projection matrix computing.
  114418. */
  114419. protected _computeProjectionTextureMatrix(): void;
  114420. protected _buildUniformLayout(): void;
  114421. private _computeAngleValues;
  114422. /**
  114423. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114424. * @param effect The effect to update
  114425. * @param lightIndex The index of the light in the effect to update
  114426. * @returns The spot light
  114427. */
  114428. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114429. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114430. /**
  114431. * Disposes the light and the associated resources.
  114432. */
  114433. dispose(): void;
  114434. /**
  114435. * Prepares the list of defines specific to the light type.
  114436. * @param defines the list of defines
  114437. * @param lightIndex defines the index of the light for the effect
  114438. */
  114439. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114440. }
  114441. }
  114442. declare module BABYLON {
  114443. /**
  114444. * Gizmo that enables viewing a light
  114445. */
  114446. export class LightGizmo extends Gizmo {
  114447. private _lightMesh;
  114448. private _material;
  114449. private cachedPosition;
  114450. private cachedForward;
  114451. /**
  114452. * Creates a LightGizmo
  114453. * @param gizmoLayer The utility layer the gizmo will be added to
  114454. */
  114455. constructor(gizmoLayer?: UtilityLayerRenderer);
  114456. private _light;
  114457. /**
  114458. * The light that the gizmo is attached to
  114459. */
  114460. light: Nullable<Light>;
  114461. /**
  114462. * Gets the material used to render the light gizmo
  114463. */
  114464. readonly material: StandardMaterial;
  114465. /**
  114466. * @hidden
  114467. * Updates the gizmo to match the attached mesh's position/rotation
  114468. */
  114469. protected _update(): void;
  114470. private static _Scale;
  114471. /**
  114472. * Creates the lines for a light mesh
  114473. */
  114474. private static _createLightLines;
  114475. /**
  114476. * Disposes of the light gizmo
  114477. */
  114478. dispose(): void;
  114479. private static _CreateHemisphericLightMesh;
  114480. private static _CreatePointLightMesh;
  114481. private static _CreateSpotLightMesh;
  114482. private static _CreateDirectionalLightMesh;
  114483. }
  114484. }
  114485. declare module BABYLON {
  114486. /** @hidden */
  114487. export var backgroundFragmentDeclaration: {
  114488. name: string;
  114489. shader: string;
  114490. };
  114491. }
  114492. declare module BABYLON {
  114493. /** @hidden */
  114494. export var backgroundUboDeclaration: {
  114495. name: string;
  114496. shader: string;
  114497. };
  114498. }
  114499. declare module BABYLON {
  114500. /** @hidden */
  114501. export var backgroundPixelShader: {
  114502. name: string;
  114503. shader: string;
  114504. };
  114505. }
  114506. declare module BABYLON {
  114507. /** @hidden */
  114508. export var backgroundVertexDeclaration: {
  114509. name: string;
  114510. shader: string;
  114511. };
  114512. }
  114513. declare module BABYLON {
  114514. /** @hidden */
  114515. export var backgroundVertexShader: {
  114516. name: string;
  114517. shader: string;
  114518. };
  114519. }
  114520. declare module BABYLON {
  114521. /**
  114522. * Background material used to create an efficient environement around your scene.
  114523. */
  114524. export class BackgroundMaterial extends PushMaterial {
  114525. /**
  114526. * Standard reflectance value at parallel view angle.
  114527. */
  114528. static StandardReflectance0: number;
  114529. /**
  114530. * Standard reflectance value at grazing angle.
  114531. */
  114532. static StandardReflectance90: number;
  114533. protected _primaryColor: Color3;
  114534. /**
  114535. * Key light Color (multiply against the environement texture)
  114536. */
  114537. primaryColor: Color3;
  114538. protected __perceptualColor: Nullable<Color3>;
  114539. /**
  114540. * Experimental Internal Use Only.
  114541. *
  114542. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114543. * This acts as a helper to set the primary color to a more "human friendly" value.
  114544. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114545. * output color as close as possible from the chosen value.
  114546. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114547. * part of lighting setup.)
  114548. */
  114549. _perceptualColor: Nullable<Color3>;
  114550. protected _primaryColorShadowLevel: float;
  114551. /**
  114552. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114553. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114554. */
  114555. primaryColorShadowLevel: float;
  114556. protected _primaryColorHighlightLevel: float;
  114557. /**
  114558. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114559. * The primary color is used at the level chosen to define what the white area would look.
  114560. */
  114561. primaryColorHighlightLevel: float;
  114562. protected _reflectionTexture: Nullable<BaseTexture>;
  114563. /**
  114564. * Reflection Texture used in the material.
  114565. * Should be author in a specific way for the best result (refer to the documentation).
  114566. */
  114567. reflectionTexture: Nullable<BaseTexture>;
  114568. protected _reflectionBlur: float;
  114569. /**
  114570. * Reflection Texture level of blur.
  114571. *
  114572. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114573. * texture twice.
  114574. */
  114575. reflectionBlur: float;
  114576. protected _diffuseTexture: Nullable<BaseTexture>;
  114577. /**
  114578. * Diffuse Texture used in the material.
  114579. * Should be author in a specific way for the best result (refer to the documentation).
  114580. */
  114581. diffuseTexture: Nullable<BaseTexture>;
  114582. protected _shadowLights: Nullable<IShadowLight[]>;
  114583. /**
  114584. * Specify the list of lights casting shadow on the material.
  114585. * All scene shadow lights will be included if null.
  114586. */
  114587. shadowLights: Nullable<IShadowLight[]>;
  114588. protected _shadowLevel: float;
  114589. /**
  114590. * Helps adjusting the shadow to a softer level if required.
  114591. * 0 means black shadows and 1 means no shadows.
  114592. */
  114593. shadowLevel: float;
  114594. protected _sceneCenter: Vector3;
  114595. /**
  114596. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114597. * It is usually zero but might be interesting to modify according to your setup.
  114598. */
  114599. sceneCenter: Vector3;
  114600. protected _opacityFresnel: boolean;
  114601. /**
  114602. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114603. * This helps ensuring a nice transition when the camera goes under the ground.
  114604. */
  114605. opacityFresnel: boolean;
  114606. protected _reflectionFresnel: boolean;
  114607. /**
  114608. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114609. * This helps adding a mirror texture on the ground.
  114610. */
  114611. reflectionFresnel: boolean;
  114612. protected _reflectionFalloffDistance: number;
  114613. /**
  114614. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114615. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114616. */
  114617. reflectionFalloffDistance: number;
  114618. protected _reflectionAmount: number;
  114619. /**
  114620. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114621. */
  114622. reflectionAmount: number;
  114623. protected _reflectionReflectance0: number;
  114624. /**
  114625. * This specifies the weight of the reflection at grazing angle.
  114626. */
  114627. reflectionReflectance0: number;
  114628. protected _reflectionReflectance90: number;
  114629. /**
  114630. * This specifies the weight of the reflection at a perpendicular point of view.
  114631. */
  114632. reflectionReflectance90: number;
  114633. /**
  114634. * Sets the reflection reflectance fresnel values according to the default standard
  114635. * empirically know to work well :-)
  114636. */
  114637. reflectionStandardFresnelWeight: number;
  114638. protected _useRGBColor: boolean;
  114639. /**
  114640. * Helps to directly use the maps channels instead of their level.
  114641. */
  114642. useRGBColor: boolean;
  114643. protected _enableNoise: boolean;
  114644. /**
  114645. * This helps reducing the banding effect that could occur on the background.
  114646. */
  114647. enableNoise: boolean;
  114648. /**
  114649. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114650. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114651. * Recommended to be keep at 1.0 except for special cases.
  114652. */
  114653. fovMultiplier: number;
  114654. private _fovMultiplier;
  114655. /**
  114656. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114657. */
  114658. useEquirectangularFOV: boolean;
  114659. private _maxSimultaneousLights;
  114660. /**
  114661. * Number of Simultaneous lights allowed on the material.
  114662. */
  114663. maxSimultaneousLights: int;
  114664. /**
  114665. * Default configuration related to image processing available in the Background Material.
  114666. */
  114667. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114668. /**
  114669. * Keep track of the image processing observer to allow dispose and replace.
  114670. */
  114671. private _imageProcessingObserver;
  114672. /**
  114673. * Attaches a new image processing configuration to the PBR Material.
  114674. * @param configuration (if null the scene configuration will be use)
  114675. */
  114676. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114677. /**
  114678. * Gets the image processing configuration used either in this material.
  114679. */
  114680. /**
  114681. * Sets the Default image processing configuration used either in the this material.
  114682. *
  114683. * If sets to null, the scene one is in use.
  114684. */
  114685. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114686. /**
  114687. * Gets wether the color curves effect is enabled.
  114688. */
  114689. /**
  114690. * Sets wether the color curves effect is enabled.
  114691. */
  114692. cameraColorCurvesEnabled: boolean;
  114693. /**
  114694. * Gets wether the color grading effect is enabled.
  114695. */
  114696. /**
  114697. * Gets wether the color grading effect is enabled.
  114698. */
  114699. cameraColorGradingEnabled: boolean;
  114700. /**
  114701. * Gets wether tonemapping is enabled or not.
  114702. */
  114703. /**
  114704. * Sets wether tonemapping is enabled or not
  114705. */
  114706. cameraToneMappingEnabled: boolean;
  114707. /**
  114708. * The camera exposure used on this material.
  114709. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114710. * This corresponds to a photographic exposure.
  114711. */
  114712. /**
  114713. * The camera exposure used on this material.
  114714. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114715. * This corresponds to a photographic exposure.
  114716. */
  114717. cameraExposure: float;
  114718. /**
  114719. * Gets The camera contrast used on this material.
  114720. */
  114721. /**
  114722. * Sets The camera contrast used on this material.
  114723. */
  114724. cameraContrast: float;
  114725. /**
  114726. * Gets the Color Grading 2D Lookup Texture.
  114727. */
  114728. /**
  114729. * Sets the Color Grading 2D Lookup Texture.
  114730. */
  114731. cameraColorGradingTexture: Nullable<BaseTexture>;
  114732. /**
  114733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114735. * 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;
  114736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114737. */
  114738. /**
  114739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114741. * 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;
  114742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114743. */
  114744. cameraColorCurves: Nullable<ColorCurves>;
  114745. /**
  114746. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114747. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114748. */
  114749. switchToBGR: boolean;
  114750. private _renderTargets;
  114751. private _reflectionControls;
  114752. private _white;
  114753. private _primaryShadowColor;
  114754. private _primaryHighlightColor;
  114755. /**
  114756. * Instantiates a Background Material in the given scene
  114757. * @param name The friendly name of the material
  114758. * @param scene The scene to add the material to
  114759. */
  114760. constructor(name: string, scene: Scene);
  114761. /**
  114762. * Gets a boolean indicating that current material needs to register RTT
  114763. */
  114764. readonly hasRenderTargetTextures: boolean;
  114765. /**
  114766. * The entire material has been created in order to prevent overdraw.
  114767. * @returns false
  114768. */
  114769. needAlphaTesting(): boolean;
  114770. /**
  114771. * The entire material has been created in order to prevent overdraw.
  114772. * @returns true if blending is enable
  114773. */
  114774. needAlphaBlending(): boolean;
  114775. /**
  114776. * Checks wether the material is ready to be rendered for a given mesh.
  114777. * @param mesh The mesh to render
  114778. * @param subMesh The submesh to check against
  114779. * @param useInstances Specify wether or not the material is used with instances
  114780. * @returns true if all the dependencies are ready (Textures, Effects...)
  114781. */
  114782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114783. /**
  114784. * Compute the primary color according to the chosen perceptual color.
  114785. */
  114786. private _computePrimaryColorFromPerceptualColor;
  114787. /**
  114788. * Compute the highlights and shadow colors according to their chosen levels.
  114789. */
  114790. private _computePrimaryColors;
  114791. /**
  114792. * Build the uniform buffer used in the material.
  114793. */
  114794. buildUniformLayout(): void;
  114795. /**
  114796. * Unbind the material.
  114797. */
  114798. unbind(): void;
  114799. /**
  114800. * Bind only the world matrix to the material.
  114801. * @param world The world matrix to bind.
  114802. */
  114803. bindOnlyWorldMatrix(world: Matrix): void;
  114804. /**
  114805. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114806. * @param world The world matrix to bind.
  114807. * @param subMesh The submesh to bind for.
  114808. */
  114809. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114810. /**
  114811. * Checks to see if a texture is used in the material.
  114812. * @param texture - Base texture to use.
  114813. * @returns - Boolean specifying if a texture is used in the material.
  114814. */
  114815. hasTexture(texture: BaseTexture): boolean;
  114816. /**
  114817. * Dispose the material.
  114818. * @param forceDisposeEffect Force disposal of the associated effect.
  114819. * @param forceDisposeTextures Force disposal of the associated textures.
  114820. */
  114821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114822. /**
  114823. * Clones the material.
  114824. * @param name The cloned name.
  114825. * @returns The cloned material.
  114826. */
  114827. clone(name: string): BackgroundMaterial;
  114828. /**
  114829. * Serializes the current material to its JSON representation.
  114830. * @returns The JSON representation.
  114831. */
  114832. serialize(): any;
  114833. /**
  114834. * Gets the class name of the material
  114835. * @returns "BackgroundMaterial"
  114836. */
  114837. getClassName(): string;
  114838. /**
  114839. * Parse a JSON input to create back a background material.
  114840. * @param source The JSON data to parse
  114841. * @param scene The scene to create the parsed material in
  114842. * @param rootUrl The root url of the assets the material depends upon
  114843. * @returns the instantiated BackgroundMaterial.
  114844. */
  114845. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114846. }
  114847. }
  114848. declare module BABYLON {
  114849. /**
  114850. * Represents the different options available during the creation of
  114851. * a Environment helper.
  114852. *
  114853. * This can control the default ground, skybox and image processing setup of your scene.
  114854. */
  114855. export interface IEnvironmentHelperOptions {
  114856. /**
  114857. * Specifies wether or not to create a ground.
  114858. * True by default.
  114859. */
  114860. createGround: boolean;
  114861. /**
  114862. * Specifies the ground size.
  114863. * 15 by default.
  114864. */
  114865. groundSize: number;
  114866. /**
  114867. * The texture used on the ground for the main color.
  114868. * Comes from the BabylonJS CDN by default.
  114869. *
  114870. * Remarks: Can be either a texture or a url.
  114871. */
  114872. groundTexture: string | BaseTexture;
  114873. /**
  114874. * The color mixed in the ground texture by default.
  114875. * BabylonJS clearColor by default.
  114876. */
  114877. groundColor: Color3;
  114878. /**
  114879. * Specifies the ground opacity.
  114880. * 1 by default.
  114881. */
  114882. groundOpacity: number;
  114883. /**
  114884. * Enables the ground to receive shadows.
  114885. * True by default.
  114886. */
  114887. enableGroundShadow: boolean;
  114888. /**
  114889. * Helps preventing the shadow to be fully black on the ground.
  114890. * 0.5 by default.
  114891. */
  114892. groundShadowLevel: number;
  114893. /**
  114894. * Creates a mirror texture attach to the ground.
  114895. * false by default.
  114896. */
  114897. enableGroundMirror: boolean;
  114898. /**
  114899. * Specifies the ground mirror size ratio.
  114900. * 0.3 by default as the default kernel is 64.
  114901. */
  114902. groundMirrorSizeRatio: number;
  114903. /**
  114904. * Specifies the ground mirror blur kernel size.
  114905. * 64 by default.
  114906. */
  114907. groundMirrorBlurKernel: number;
  114908. /**
  114909. * Specifies the ground mirror visibility amount.
  114910. * 1 by default
  114911. */
  114912. groundMirrorAmount: number;
  114913. /**
  114914. * Specifies the ground mirror reflectance weight.
  114915. * This uses the standard weight of the background material to setup the fresnel effect
  114916. * of the mirror.
  114917. * 1 by default.
  114918. */
  114919. groundMirrorFresnelWeight: number;
  114920. /**
  114921. * Specifies the ground mirror Falloff distance.
  114922. * This can helps reducing the size of the reflection.
  114923. * 0 by Default.
  114924. */
  114925. groundMirrorFallOffDistance: number;
  114926. /**
  114927. * Specifies the ground mirror texture type.
  114928. * Unsigned Int by Default.
  114929. */
  114930. groundMirrorTextureType: number;
  114931. /**
  114932. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114933. * the shown objects.
  114934. */
  114935. groundYBias: number;
  114936. /**
  114937. * Specifies wether or not to create a skybox.
  114938. * True by default.
  114939. */
  114940. createSkybox: boolean;
  114941. /**
  114942. * Specifies the skybox size.
  114943. * 20 by default.
  114944. */
  114945. skyboxSize: number;
  114946. /**
  114947. * The texture used on the skybox for the main color.
  114948. * Comes from the BabylonJS CDN by default.
  114949. *
  114950. * Remarks: Can be either a texture or a url.
  114951. */
  114952. skyboxTexture: string | BaseTexture;
  114953. /**
  114954. * The color mixed in the skybox texture by default.
  114955. * BabylonJS clearColor by default.
  114956. */
  114957. skyboxColor: Color3;
  114958. /**
  114959. * The background rotation around the Y axis of the scene.
  114960. * This helps aligning the key lights of your scene with the background.
  114961. * 0 by default.
  114962. */
  114963. backgroundYRotation: number;
  114964. /**
  114965. * Compute automatically the size of the elements to best fit with the scene.
  114966. */
  114967. sizeAuto: boolean;
  114968. /**
  114969. * Default position of the rootMesh if autoSize is not true.
  114970. */
  114971. rootPosition: Vector3;
  114972. /**
  114973. * Sets up the image processing in the scene.
  114974. * true by default.
  114975. */
  114976. setupImageProcessing: boolean;
  114977. /**
  114978. * The texture used as your environment texture in the scene.
  114979. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114980. *
  114981. * Remarks: Can be either a texture or a url.
  114982. */
  114983. environmentTexture: string | BaseTexture;
  114984. /**
  114985. * The value of the exposure to apply to the scene.
  114986. * 0.6 by default if setupImageProcessing is true.
  114987. */
  114988. cameraExposure: number;
  114989. /**
  114990. * The value of the contrast to apply to the scene.
  114991. * 1.6 by default if setupImageProcessing is true.
  114992. */
  114993. cameraContrast: number;
  114994. /**
  114995. * Specifies wether or not tonemapping should be enabled in the scene.
  114996. * true by default if setupImageProcessing is true.
  114997. */
  114998. toneMappingEnabled: boolean;
  114999. }
  115000. /**
  115001. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  115002. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  115003. * It also helps with the default setup of your imageProcessing configuration.
  115004. */
  115005. export class EnvironmentHelper {
  115006. /**
  115007. * Default ground texture URL.
  115008. */
  115009. private static _groundTextureCDNUrl;
  115010. /**
  115011. * Default skybox texture URL.
  115012. */
  115013. private static _skyboxTextureCDNUrl;
  115014. /**
  115015. * Default environment texture URL.
  115016. */
  115017. private static _environmentTextureCDNUrl;
  115018. /**
  115019. * Creates the default options for the helper.
  115020. */
  115021. private static _getDefaultOptions;
  115022. private _rootMesh;
  115023. /**
  115024. * Gets the root mesh created by the helper.
  115025. */
  115026. readonly rootMesh: Mesh;
  115027. private _skybox;
  115028. /**
  115029. * Gets the skybox created by the helper.
  115030. */
  115031. readonly skybox: Nullable<Mesh>;
  115032. private _skyboxTexture;
  115033. /**
  115034. * Gets the skybox texture created by the helper.
  115035. */
  115036. readonly skyboxTexture: Nullable<BaseTexture>;
  115037. private _skyboxMaterial;
  115038. /**
  115039. * Gets the skybox material created by the helper.
  115040. */
  115041. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115042. private _ground;
  115043. /**
  115044. * Gets the ground mesh created by the helper.
  115045. */
  115046. readonly ground: Nullable<Mesh>;
  115047. private _groundTexture;
  115048. /**
  115049. * Gets the ground texture created by the helper.
  115050. */
  115051. readonly groundTexture: Nullable<BaseTexture>;
  115052. private _groundMirror;
  115053. /**
  115054. * Gets the ground mirror created by the helper.
  115055. */
  115056. readonly groundMirror: Nullable<MirrorTexture>;
  115057. /**
  115058. * Gets the ground mirror render list to helps pushing the meshes
  115059. * you wish in the ground reflection.
  115060. */
  115061. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115062. private _groundMaterial;
  115063. /**
  115064. * Gets the ground material created by the helper.
  115065. */
  115066. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115067. /**
  115068. * Stores the creation options.
  115069. */
  115070. private readonly _scene;
  115071. private _options;
  115072. /**
  115073. * This observable will be notified with any error during the creation of the environment,
  115074. * mainly texture creation errors.
  115075. */
  115076. onErrorObservable: Observable<{
  115077. message?: string;
  115078. exception?: any;
  115079. }>;
  115080. /**
  115081. * constructor
  115082. * @param options Defines the options we want to customize the helper
  115083. * @param scene The scene to add the material to
  115084. */
  115085. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115086. /**
  115087. * Updates the background according to the new options
  115088. * @param options
  115089. */
  115090. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115091. /**
  115092. * Sets the primary color of all the available elements.
  115093. * @param color the main color to affect to the ground and the background
  115094. */
  115095. setMainColor(color: Color3): void;
  115096. /**
  115097. * Setup the image processing according to the specified options.
  115098. */
  115099. private _setupImageProcessing;
  115100. /**
  115101. * Setup the environment texture according to the specified options.
  115102. */
  115103. private _setupEnvironmentTexture;
  115104. /**
  115105. * Setup the background according to the specified options.
  115106. */
  115107. private _setupBackground;
  115108. /**
  115109. * Get the scene sizes according to the setup.
  115110. */
  115111. private _getSceneSize;
  115112. /**
  115113. * Setup the ground according to the specified options.
  115114. */
  115115. private _setupGround;
  115116. /**
  115117. * Setup the ground material according to the specified options.
  115118. */
  115119. private _setupGroundMaterial;
  115120. /**
  115121. * Setup the ground diffuse texture according to the specified options.
  115122. */
  115123. private _setupGroundDiffuseTexture;
  115124. /**
  115125. * Setup the ground mirror texture according to the specified options.
  115126. */
  115127. private _setupGroundMirrorTexture;
  115128. /**
  115129. * Setup the ground to receive the mirror texture.
  115130. */
  115131. private _setupMirrorInGroundMaterial;
  115132. /**
  115133. * Setup the skybox according to the specified options.
  115134. */
  115135. private _setupSkybox;
  115136. /**
  115137. * Setup the skybox material according to the specified options.
  115138. */
  115139. private _setupSkyboxMaterial;
  115140. /**
  115141. * Setup the skybox reflection texture according to the specified options.
  115142. */
  115143. private _setupSkyboxReflectionTexture;
  115144. private _errorHandler;
  115145. /**
  115146. * Dispose all the elements created by the Helper.
  115147. */
  115148. dispose(): void;
  115149. }
  115150. }
  115151. declare module BABYLON {
  115152. /**
  115153. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115154. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115155. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115156. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115157. */
  115158. export class PhotoDome extends TransformNode {
  115159. /**
  115160. * Define the image as a Monoscopic panoramic 360 image.
  115161. */
  115162. static readonly MODE_MONOSCOPIC: number;
  115163. /**
  115164. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115165. */
  115166. static readonly MODE_TOPBOTTOM: number;
  115167. /**
  115168. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115169. */
  115170. static readonly MODE_SIDEBYSIDE: number;
  115171. private _useDirectMapping;
  115172. /**
  115173. * The texture being displayed on the sphere
  115174. */
  115175. protected _photoTexture: Texture;
  115176. /**
  115177. * Gets or sets the texture being displayed on the sphere
  115178. */
  115179. photoTexture: Texture;
  115180. /**
  115181. * Observable raised when an error occured while loading the 360 image
  115182. */
  115183. onLoadErrorObservable: Observable<string>;
  115184. /**
  115185. * The skybox material
  115186. */
  115187. protected _material: BackgroundMaterial;
  115188. /**
  115189. * The surface used for the skybox
  115190. */
  115191. protected _mesh: Mesh;
  115192. /**
  115193. * Gets the mesh used for the skybox.
  115194. */
  115195. readonly mesh: Mesh;
  115196. /**
  115197. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115198. * Also see the options.resolution property.
  115199. */
  115200. fovMultiplier: number;
  115201. private _imageMode;
  115202. /**
  115203. * Gets or set the current video mode for the video. It can be:
  115204. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115205. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115206. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115207. */
  115208. imageMode: number;
  115209. /**
  115210. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115211. * @param name Element's name, child elements will append suffixes for their own names.
  115212. * @param urlsOfPhoto defines the url of the photo to display
  115213. * @param options defines an object containing optional or exposed sub element properties
  115214. * @param onError defines a callback called when an error occured while loading the texture
  115215. */
  115216. constructor(name: string, urlOfPhoto: string, options: {
  115217. resolution?: number;
  115218. size?: number;
  115219. useDirectMapping?: boolean;
  115220. faceForward?: boolean;
  115221. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115222. private _onBeforeCameraRenderObserver;
  115223. private _changeImageMode;
  115224. /**
  115225. * Releases resources associated with this node.
  115226. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115227. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115228. */
  115229. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115230. }
  115231. }
  115232. declare module BABYLON {
  115233. /**
  115234. * Class used to host RGBD texture specific utilities
  115235. */
  115236. export class RGBDTextureTools {
  115237. /**
  115238. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115239. * @param texture the texture to expand.
  115240. */
  115241. static ExpandRGBDTexture(texture: Texture): void;
  115242. }
  115243. }
  115244. declare module BABYLON {
  115245. /**
  115246. * Class used to host texture specific utilities
  115247. */
  115248. export class BRDFTextureTools {
  115249. /**
  115250. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115251. * @param scene defines the hosting scene
  115252. * @returns the environment BRDF texture
  115253. */
  115254. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115255. private static _environmentBRDFBase64Texture;
  115256. }
  115257. }
  115258. declare module BABYLON {
  115259. /**
  115260. * @hidden
  115261. */
  115262. export interface IMaterialClearCoatDefines {
  115263. CLEARCOAT: boolean;
  115264. CLEARCOAT_DEFAULTIOR: boolean;
  115265. CLEARCOAT_TEXTURE: boolean;
  115266. CLEARCOAT_TEXTUREDIRECTUV: number;
  115267. CLEARCOAT_BUMP: boolean;
  115268. CLEARCOAT_BUMPDIRECTUV: number;
  115269. CLEARCOAT_TINT: boolean;
  115270. CLEARCOAT_TINT_TEXTURE: boolean;
  115271. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115272. /** @hidden */
  115273. _areTexturesDirty: boolean;
  115274. }
  115275. /**
  115276. * Define the code related to the clear coat parameters of the pbr material.
  115277. */
  115278. export class PBRClearCoatConfiguration {
  115279. /**
  115280. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115281. * The default fits with a polyurethane material.
  115282. */
  115283. private static readonly _DefaultIndexOfRefraction;
  115284. private _isEnabled;
  115285. /**
  115286. * Defines if the clear coat is enabled in the material.
  115287. */
  115288. isEnabled: boolean;
  115289. /**
  115290. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115291. */
  115292. intensity: number;
  115293. /**
  115294. * Defines the clear coat layer roughness.
  115295. */
  115296. roughness: number;
  115297. private _indexOfRefraction;
  115298. /**
  115299. * Defines the index of refraction of the clear coat.
  115300. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115301. * The default fits with a polyurethane material.
  115302. * Changing the default value is more performance intensive.
  115303. */
  115304. indexOfRefraction: number;
  115305. private _texture;
  115306. /**
  115307. * Stores the clear coat values in a texture.
  115308. */
  115309. texture: Nullable<BaseTexture>;
  115310. private _bumpTexture;
  115311. /**
  115312. * Define the clear coat specific bump texture.
  115313. */
  115314. bumpTexture: Nullable<BaseTexture>;
  115315. private _isTintEnabled;
  115316. /**
  115317. * Defines if the clear coat tint is enabled in the material.
  115318. */
  115319. isTintEnabled: boolean;
  115320. /**
  115321. * Defines the clear coat tint of the material.
  115322. * This is only use if tint is enabled
  115323. */
  115324. tintColor: Color3;
  115325. /**
  115326. * Defines the distance at which the tint color should be found in the
  115327. * clear coat media.
  115328. * This is only use if tint is enabled
  115329. */
  115330. tintColorAtDistance: number;
  115331. /**
  115332. * Defines the clear coat layer thickness.
  115333. * This is only use if tint is enabled
  115334. */
  115335. tintThickness: number;
  115336. private _tintTexture;
  115337. /**
  115338. * Stores the clear tint values in a texture.
  115339. * rgb is tint
  115340. * a is a thickness factor
  115341. */
  115342. tintTexture: Nullable<BaseTexture>;
  115343. /** @hidden */
  115344. private _internalMarkAllSubMeshesAsTexturesDirty;
  115345. /** @hidden */
  115346. _markAllSubMeshesAsTexturesDirty(): void;
  115347. /**
  115348. * Instantiate a new istance of clear coat configuration.
  115349. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115350. */
  115351. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115352. /**
  115353. * Gets wehter the submesh is ready to be used or not.
  115354. * @param defines the list of "defines" to update.
  115355. * @param scene defines the scene the material belongs to.
  115356. * @param engine defines the engine the material belongs to.
  115357. * @param disableBumpMap defines wether the material disables bump or not.
  115358. * @returns - boolean indicating that the submesh is ready or not.
  115359. */
  115360. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115361. /**
  115362. * Checks to see if a texture is used in the material.
  115363. * @param defines the list of "defines" to update.
  115364. * @param scene defines the scene to the material belongs to.
  115365. */
  115366. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115367. /**
  115368. * Binds the material data.
  115369. * @param uniformBuffer defines the Uniform buffer to fill in.
  115370. * @param scene defines the scene the material belongs to.
  115371. * @param engine defines the engine the material belongs to.
  115372. * @param disableBumpMap defines wether the material disables bump or not.
  115373. * @param isFrozen defines wether the material is frozen or not.
  115374. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115375. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115376. */
  115377. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115378. /**
  115379. * Checks to see if a texture is used in the material.
  115380. * @param texture - Base texture to use.
  115381. * @returns - Boolean specifying if a texture is used in the material.
  115382. */
  115383. hasTexture(texture: BaseTexture): boolean;
  115384. /**
  115385. * Returns an array of the actively used textures.
  115386. * @param activeTextures Array of BaseTextures
  115387. */
  115388. getActiveTextures(activeTextures: BaseTexture[]): void;
  115389. /**
  115390. * Returns the animatable textures.
  115391. * @param animatables Array of animatable textures.
  115392. */
  115393. getAnimatables(animatables: IAnimatable[]): void;
  115394. /**
  115395. * Disposes the resources of the material.
  115396. * @param forceDisposeTextures - Forces the disposal of all textures.
  115397. */
  115398. dispose(forceDisposeTextures?: boolean): void;
  115399. /**
  115400. * Get the current class name of the texture useful for serialization or dynamic coding.
  115401. * @returns "PBRClearCoatConfiguration"
  115402. */
  115403. getClassName(): string;
  115404. /**
  115405. * Add fallbacks to the effect fallbacks list.
  115406. * @param defines defines the Base texture to use.
  115407. * @param fallbacks defines the current fallback list.
  115408. * @param currentRank defines the current fallback rank.
  115409. * @returns the new fallback rank.
  115410. */
  115411. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115412. /**
  115413. * Add the required uniforms to the current list.
  115414. * @param uniforms defines the current uniform list.
  115415. */
  115416. static AddUniforms(uniforms: string[]): void;
  115417. /**
  115418. * Add the required samplers to the current list.
  115419. * @param samplers defines the current sampler list.
  115420. */
  115421. static AddSamplers(samplers: string[]): void;
  115422. /**
  115423. * Add the required uniforms to the current buffer.
  115424. * @param uniformBuffer defines the current uniform buffer.
  115425. */
  115426. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115427. /**
  115428. * Makes a duplicate of the current configuration into another one.
  115429. * @param clearCoatConfiguration define the config where to copy the info
  115430. */
  115431. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115432. /**
  115433. * Serializes this clear coat configuration.
  115434. * @returns - An object with the serialized config.
  115435. */
  115436. serialize(): any;
  115437. /**
  115438. * Parses a anisotropy Configuration from a serialized object.
  115439. * @param source - Serialized object.
  115440. * @param scene Defines the scene we are parsing for
  115441. * @param rootUrl Defines the rootUrl to load from
  115442. */
  115443. parse(source: any, scene: Scene, rootUrl: string): void;
  115444. }
  115445. }
  115446. declare module BABYLON {
  115447. /**
  115448. * @hidden
  115449. */
  115450. export interface IMaterialAnisotropicDefines {
  115451. ANISOTROPIC: boolean;
  115452. ANISOTROPIC_TEXTURE: boolean;
  115453. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115454. MAINUV1: boolean;
  115455. _areTexturesDirty: boolean;
  115456. _needUVs: boolean;
  115457. }
  115458. /**
  115459. * Define the code related to the anisotropic parameters of the pbr material.
  115460. */
  115461. export class PBRAnisotropicConfiguration {
  115462. private _isEnabled;
  115463. /**
  115464. * Defines if the anisotropy is enabled in the material.
  115465. */
  115466. isEnabled: boolean;
  115467. /**
  115468. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115469. */
  115470. intensity: number;
  115471. /**
  115472. * Defines if the effect is along the tangents, bitangents or in between.
  115473. * By default, the effect is "strectching" the highlights along the tangents.
  115474. */
  115475. direction: Vector2;
  115476. private _texture;
  115477. /**
  115478. * Stores the anisotropy values in a texture.
  115479. * rg is direction (like normal from -1 to 1)
  115480. * b is a intensity
  115481. */
  115482. texture: Nullable<BaseTexture>;
  115483. /** @hidden */
  115484. private _internalMarkAllSubMeshesAsTexturesDirty;
  115485. /** @hidden */
  115486. _markAllSubMeshesAsTexturesDirty(): void;
  115487. /**
  115488. * Instantiate a new istance of anisotropy configuration.
  115489. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115490. */
  115491. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115492. /**
  115493. * Specifies that the submesh is ready to be used.
  115494. * @param defines the list of "defines" to update.
  115495. * @param scene defines the scene the material belongs to.
  115496. * @returns - boolean indicating that the submesh is ready or not.
  115497. */
  115498. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115499. /**
  115500. * Checks to see if a texture is used in the material.
  115501. * @param defines the list of "defines" to update.
  115502. * @param mesh the mesh we are preparing the defines for.
  115503. * @param scene defines the scene the material belongs to.
  115504. */
  115505. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115506. /**
  115507. * Binds the material data.
  115508. * @param uniformBuffer defines the Uniform buffer to fill in.
  115509. * @param scene defines the scene the material belongs to.
  115510. * @param isFrozen defines wether the material is frozen or not.
  115511. */
  115512. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115513. /**
  115514. * Checks to see if a texture is used in the material.
  115515. * @param texture - Base texture to use.
  115516. * @returns - Boolean specifying if a texture is used in the material.
  115517. */
  115518. hasTexture(texture: BaseTexture): boolean;
  115519. /**
  115520. * Returns an array of the actively used textures.
  115521. * @param activeTextures Array of BaseTextures
  115522. */
  115523. getActiveTextures(activeTextures: BaseTexture[]): void;
  115524. /**
  115525. * Returns the animatable textures.
  115526. * @param animatables Array of animatable textures.
  115527. */
  115528. getAnimatables(animatables: IAnimatable[]): void;
  115529. /**
  115530. * Disposes the resources of the material.
  115531. * @param forceDisposeTextures - Forces the disposal of all textures.
  115532. */
  115533. dispose(forceDisposeTextures?: boolean): void;
  115534. /**
  115535. * Get the current class name of the texture useful for serialization or dynamic coding.
  115536. * @returns "PBRAnisotropicConfiguration"
  115537. */
  115538. getClassName(): string;
  115539. /**
  115540. * Add fallbacks to the effect fallbacks list.
  115541. * @param defines defines the Base texture to use.
  115542. * @param fallbacks defines the current fallback list.
  115543. * @param currentRank defines the current fallback rank.
  115544. * @returns the new fallback rank.
  115545. */
  115546. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115547. /**
  115548. * Add the required uniforms to the current list.
  115549. * @param uniforms defines the current uniform list.
  115550. */
  115551. static AddUniforms(uniforms: string[]): void;
  115552. /**
  115553. * Add the required uniforms to the current buffer.
  115554. * @param uniformBuffer defines the current uniform buffer.
  115555. */
  115556. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115557. /**
  115558. * Add the required samplers to the current list.
  115559. * @param samplers defines the current sampler list.
  115560. */
  115561. static AddSamplers(samplers: string[]): void;
  115562. /**
  115563. * Makes a duplicate of the current configuration into another one.
  115564. * @param anisotropicConfiguration define the config where to copy the info
  115565. */
  115566. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115567. /**
  115568. * Serializes this anisotropy configuration.
  115569. * @returns - An object with the serialized config.
  115570. */
  115571. serialize(): any;
  115572. /**
  115573. * Parses a anisotropy Configuration from a serialized object.
  115574. * @param source - Serialized object.
  115575. * @param scene Defines the scene we are parsing for
  115576. * @param rootUrl Defines the rootUrl to load from
  115577. */
  115578. parse(source: any, scene: Scene, rootUrl: string): void;
  115579. }
  115580. }
  115581. declare module BABYLON {
  115582. /**
  115583. * @hidden
  115584. */
  115585. export interface IMaterialBRDFDefines {
  115586. BRDF_V_HEIGHT_CORRELATED: boolean;
  115587. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115588. SPHERICAL_HARMONICS: boolean;
  115589. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115590. /** @hidden */
  115591. _areMiscDirty: boolean;
  115592. }
  115593. /**
  115594. * Define the code related to the BRDF parameters of the pbr material.
  115595. */
  115596. export class PBRBRDFConfiguration {
  115597. /**
  115598. * Default value used for the energy conservation.
  115599. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115600. */
  115601. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115602. /**
  115603. * Default value used for the Smith Visibility Height Correlated mode.
  115604. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115605. */
  115606. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115607. /**
  115608. * Default value used for the IBL diffuse part.
  115609. * This can help switching back to the polynomials mode globally which is a tiny bit
  115610. * less GPU intensive at the drawback of a lower quality.
  115611. */
  115612. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115613. /**
  115614. * Default value used for activating energy conservation for the specular workflow.
  115615. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115616. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115617. */
  115618. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115619. private _useEnergyConservation;
  115620. /**
  115621. * Defines if the material uses energy conservation.
  115622. */
  115623. useEnergyConservation: boolean;
  115624. private _useSmithVisibilityHeightCorrelated;
  115625. /**
  115626. * LEGACY Mode set to false
  115627. * Defines if the material uses height smith correlated visibility term.
  115628. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115629. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115630. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115631. * Not relying on height correlated will also disable energy conservation.
  115632. */
  115633. useSmithVisibilityHeightCorrelated: boolean;
  115634. private _useSphericalHarmonics;
  115635. /**
  115636. * LEGACY Mode set to false
  115637. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115638. * diffuse part of the IBL.
  115639. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115640. * to the ground truth.
  115641. */
  115642. useSphericalHarmonics: boolean;
  115643. private _useSpecularGlossinessInputEnergyConservation;
  115644. /**
  115645. * Defines if the material uses energy conservation, when the specular workflow is active.
  115646. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115647. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115648. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115649. */
  115650. useSpecularGlossinessInputEnergyConservation: boolean;
  115651. /** @hidden */
  115652. private _internalMarkAllSubMeshesAsMiscDirty;
  115653. /** @hidden */
  115654. _markAllSubMeshesAsMiscDirty(): void;
  115655. /**
  115656. * Instantiate a new istance of clear coat configuration.
  115657. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115658. */
  115659. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115660. /**
  115661. * Checks to see if a texture is used in the material.
  115662. * @param defines the list of "defines" to update.
  115663. */
  115664. prepareDefines(defines: IMaterialBRDFDefines): void;
  115665. /**
  115666. * Get the current class name of the texture useful for serialization or dynamic coding.
  115667. * @returns "PBRClearCoatConfiguration"
  115668. */
  115669. getClassName(): string;
  115670. /**
  115671. * Makes a duplicate of the current configuration into another one.
  115672. * @param brdfConfiguration define the config where to copy the info
  115673. */
  115674. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115675. /**
  115676. * Serializes this BRDF configuration.
  115677. * @returns - An object with the serialized config.
  115678. */
  115679. serialize(): any;
  115680. /**
  115681. * Parses a anisotropy Configuration from a serialized object.
  115682. * @param source - Serialized object.
  115683. * @param scene Defines the scene we are parsing for
  115684. * @param rootUrl Defines the rootUrl to load from
  115685. */
  115686. parse(source: any, scene: Scene, rootUrl: string): void;
  115687. }
  115688. }
  115689. declare module BABYLON {
  115690. /**
  115691. * @hidden
  115692. */
  115693. export interface IMaterialSheenDefines {
  115694. SHEEN: boolean;
  115695. SHEEN_TEXTURE: boolean;
  115696. SHEEN_TEXTUREDIRECTUV: number;
  115697. SHEEN_LINKWITHALBEDO: boolean;
  115698. /** @hidden */
  115699. _areTexturesDirty: boolean;
  115700. }
  115701. /**
  115702. * Define the code related to the Sheen parameters of the pbr material.
  115703. */
  115704. export class PBRSheenConfiguration {
  115705. private _isEnabled;
  115706. /**
  115707. * Defines if the material uses sheen.
  115708. */
  115709. isEnabled: boolean;
  115710. private _linkSheenWithAlbedo;
  115711. /**
  115712. * Defines if the sheen is linked to the sheen color.
  115713. */
  115714. linkSheenWithAlbedo: boolean;
  115715. /**
  115716. * Defines the sheen intensity.
  115717. */
  115718. intensity: number;
  115719. /**
  115720. * Defines the sheen color.
  115721. */
  115722. color: Color3;
  115723. private _texture;
  115724. /**
  115725. * Stores the sheen tint values in a texture.
  115726. * rgb is tint
  115727. * a is a intensity
  115728. */
  115729. texture: Nullable<BaseTexture>;
  115730. /** @hidden */
  115731. private _internalMarkAllSubMeshesAsTexturesDirty;
  115732. /** @hidden */
  115733. _markAllSubMeshesAsTexturesDirty(): void;
  115734. /**
  115735. * Instantiate a new istance of clear coat configuration.
  115736. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115737. */
  115738. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115739. /**
  115740. * Specifies that the submesh is ready to be used.
  115741. * @param defines the list of "defines" to update.
  115742. * @param scene defines the scene the material belongs to.
  115743. * @returns - boolean indicating that the submesh is ready or not.
  115744. */
  115745. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115746. /**
  115747. * Checks to see if a texture is used in the material.
  115748. * @param defines the list of "defines" to update.
  115749. * @param scene defines the scene the material belongs to.
  115750. */
  115751. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115752. /**
  115753. * Binds the material data.
  115754. * @param uniformBuffer defines the Uniform buffer to fill in.
  115755. * @param scene defines the scene the material belongs to.
  115756. * @param isFrozen defines wether the material is frozen or not.
  115757. */
  115758. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115759. /**
  115760. * Checks to see if a texture is used in the material.
  115761. * @param texture - Base texture to use.
  115762. * @returns - Boolean specifying if a texture is used in the material.
  115763. */
  115764. hasTexture(texture: BaseTexture): boolean;
  115765. /**
  115766. * Returns an array of the actively used textures.
  115767. * @param activeTextures Array of BaseTextures
  115768. */
  115769. getActiveTextures(activeTextures: BaseTexture[]): void;
  115770. /**
  115771. * Returns the animatable textures.
  115772. * @param animatables Array of animatable textures.
  115773. */
  115774. getAnimatables(animatables: IAnimatable[]): void;
  115775. /**
  115776. * Disposes the resources of the material.
  115777. * @param forceDisposeTextures - Forces the disposal of all textures.
  115778. */
  115779. dispose(forceDisposeTextures?: boolean): void;
  115780. /**
  115781. * Get the current class name of the texture useful for serialization or dynamic coding.
  115782. * @returns "PBRSheenConfiguration"
  115783. */
  115784. getClassName(): string;
  115785. /**
  115786. * Add fallbacks to the effect fallbacks list.
  115787. * @param defines defines the Base texture to use.
  115788. * @param fallbacks defines the current fallback list.
  115789. * @param currentRank defines the current fallback rank.
  115790. * @returns the new fallback rank.
  115791. */
  115792. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115793. /**
  115794. * Add the required uniforms to the current list.
  115795. * @param uniforms defines the current uniform list.
  115796. */
  115797. static AddUniforms(uniforms: string[]): void;
  115798. /**
  115799. * Add the required uniforms to the current buffer.
  115800. * @param uniformBuffer defines the current uniform buffer.
  115801. */
  115802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115803. /**
  115804. * Add the required samplers to the current list.
  115805. * @param samplers defines the current sampler list.
  115806. */
  115807. static AddSamplers(samplers: string[]): void;
  115808. /**
  115809. * Makes a duplicate of the current configuration into another one.
  115810. * @param sheenConfiguration define the config where to copy the info
  115811. */
  115812. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115813. /**
  115814. * Serializes this BRDF configuration.
  115815. * @returns - An object with the serialized config.
  115816. */
  115817. serialize(): any;
  115818. /**
  115819. * Parses a anisotropy Configuration from a serialized object.
  115820. * @param source - Serialized object.
  115821. * @param scene Defines the scene we are parsing for
  115822. * @param rootUrl Defines the rootUrl to load from
  115823. */
  115824. parse(source: any, scene: Scene, rootUrl: string): void;
  115825. }
  115826. }
  115827. declare module BABYLON {
  115828. /**
  115829. * @hidden
  115830. */
  115831. export interface IMaterialSubSurfaceDefines {
  115832. SUBSURFACE: boolean;
  115833. SS_REFRACTION: boolean;
  115834. SS_TRANSLUCENCY: boolean;
  115835. SS_SCATERRING: boolean;
  115836. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115837. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115838. SS_REFRACTIONMAP_3D: boolean;
  115839. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115840. SS_LODINREFRACTIONALPHA: boolean;
  115841. SS_GAMMAREFRACTION: boolean;
  115842. SS_RGBDREFRACTION: boolean;
  115843. SS_LINEARSPECULARREFRACTION: boolean;
  115844. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115845. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115846. /** @hidden */
  115847. _areTexturesDirty: boolean;
  115848. }
  115849. /**
  115850. * Define the code related to the sub surface parameters of the pbr material.
  115851. */
  115852. export class PBRSubSurfaceConfiguration {
  115853. private _isRefractionEnabled;
  115854. /**
  115855. * Defines if the refraction is enabled in the material.
  115856. */
  115857. isRefractionEnabled: boolean;
  115858. private _isTranslucencyEnabled;
  115859. /**
  115860. * Defines if the translucency is enabled in the material.
  115861. */
  115862. isTranslucencyEnabled: boolean;
  115863. private _isScatteringEnabled;
  115864. /**
  115865. * Defines the refraction intensity of the material.
  115866. * The refraction when enabled replaces the Diffuse part of the material.
  115867. * The intensity helps transitionning between diffuse and refraction.
  115868. */
  115869. refractionIntensity: number;
  115870. /**
  115871. * Defines the translucency intensity of the material.
  115872. * When translucency has been enabled, this defines how much of the "translucency"
  115873. * is addded to the diffuse part of the material.
  115874. */
  115875. translucencyIntensity: number;
  115876. /**
  115877. * Defines the scattering intensity of the material.
  115878. * When scattering has been enabled, this defines how much of the "scattered light"
  115879. * is addded to the diffuse part of the material.
  115880. */
  115881. scatteringIntensity: number;
  115882. private _thicknessTexture;
  115883. /**
  115884. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115885. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115886. * 0 would mean minimumThickness
  115887. * 1 would mean maximumThickness
  115888. * The other channels might be use as a mask to vary the different effects intensity.
  115889. */
  115890. thicknessTexture: Nullable<BaseTexture>;
  115891. private _refractionTexture;
  115892. /**
  115893. * Defines the texture to use for refraction.
  115894. */
  115895. refractionTexture: Nullable<BaseTexture>;
  115896. private _indexOfRefraction;
  115897. /**
  115898. * Defines the index of refraction used in the material.
  115899. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115900. */
  115901. indexOfRefraction: number;
  115902. private _invertRefractionY;
  115903. /**
  115904. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115905. */
  115906. invertRefractionY: boolean;
  115907. private _linkRefractionWithTransparency;
  115908. /**
  115909. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115910. * Materials half opaque for instance using refraction could benefit from this control.
  115911. */
  115912. linkRefractionWithTransparency: boolean;
  115913. /**
  115914. * Defines the minimum thickness stored in the thickness map.
  115915. * If no thickness map is defined, this value will be used to simulate thickness.
  115916. */
  115917. minimumThickness: number;
  115918. /**
  115919. * Defines the maximum thickness stored in the thickness map.
  115920. */
  115921. maximumThickness: number;
  115922. /**
  115923. * Defines the volume tint of the material.
  115924. * This is used for both translucency and scattering.
  115925. */
  115926. tintColor: Color3;
  115927. /**
  115928. * Defines the distance at which the tint color should be found in the media.
  115929. * This is used for refraction only.
  115930. */
  115931. tintColorAtDistance: number;
  115932. /**
  115933. * Defines how far each channel transmit through the media.
  115934. * It is defined as a color to simplify it selection.
  115935. */
  115936. diffusionDistance: Color3;
  115937. private _useMaskFromThicknessTexture;
  115938. /**
  115939. * Stores the intensity of the different subsurface effects in the thickness texture.
  115940. * * the green channel is the translucency intensity.
  115941. * * the blue channel is the scattering intensity.
  115942. * * the alpha channel is the refraction intensity.
  115943. */
  115944. useMaskFromThicknessTexture: boolean;
  115945. /** @hidden */
  115946. private _internalMarkAllSubMeshesAsTexturesDirty;
  115947. /** @hidden */
  115948. _markAllSubMeshesAsTexturesDirty(): void;
  115949. /**
  115950. * Instantiate a new istance of sub surface configuration.
  115951. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115952. */
  115953. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115954. /**
  115955. * Gets wehter the submesh is ready to be used or not.
  115956. * @param defines the list of "defines" to update.
  115957. * @param scene defines the scene the material belongs to.
  115958. * @returns - boolean indicating that the submesh is ready or not.
  115959. */
  115960. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115961. /**
  115962. * Checks to see if a texture is used in the material.
  115963. * @param defines the list of "defines" to update.
  115964. * @param scene defines the scene to the material belongs to.
  115965. */
  115966. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115967. /**
  115968. * Binds the material data.
  115969. * @param uniformBuffer defines the Uniform buffer to fill in.
  115970. * @param scene defines the scene the material belongs to.
  115971. * @param engine defines the engine the material belongs to.
  115972. * @param isFrozen defines wether the material is frozen or not.
  115973. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115974. */
  115975. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115976. /**
  115977. * Unbinds the material from the mesh.
  115978. * @param activeEffect defines the effect that should be unbound from.
  115979. * @returns true if unbound, otherwise false
  115980. */
  115981. unbind(activeEffect: Effect): boolean;
  115982. /**
  115983. * Returns the texture used for refraction or null if none is used.
  115984. * @param scene defines the scene the material belongs to.
  115985. * @returns - Refraction texture if present. If no refraction texture and refraction
  115986. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115987. */
  115988. private _getRefractionTexture;
  115989. /**
  115990. * Returns true if alpha blending should be disabled.
  115991. */
  115992. readonly disableAlphaBlending: boolean;
  115993. /**
  115994. * Fills the list of render target textures.
  115995. * @param renderTargets the list of render targets to update
  115996. */
  115997. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115998. /**
  115999. * Checks to see if a texture is used in the material.
  116000. * @param texture - Base texture to use.
  116001. * @returns - Boolean specifying if a texture is used in the material.
  116002. */
  116003. hasTexture(texture: BaseTexture): boolean;
  116004. /**
  116005. * Gets a boolean indicating that current material needs to register RTT
  116006. * @returns true if this uses a render target otherwise false.
  116007. */
  116008. hasRenderTargetTextures(): boolean;
  116009. /**
  116010. * Returns an array of the actively used textures.
  116011. * @param activeTextures Array of BaseTextures
  116012. */
  116013. getActiveTextures(activeTextures: BaseTexture[]): void;
  116014. /**
  116015. * Returns the animatable textures.
  116016. * @param animatables Array of animatable textures.
  116017. */
  116018. getAnimatables(animatables: IAnimatable[]): void;
  116019. /**
  116020. * Disposes the resources of the material.
  116021. * @param forceDisposeTextures - Forces the disposal of all textures.
  116022. */
  116023. dispose(forceDisposeTextures?: boolean): void;
  116024. /**
  116025. * Get the current class name of the texture useful for serialization or dynamic coding.
  116026. * @returns "PBRSubSurfaceConfiguration"
  116027. */
  116028. getClassName(): string;
  116029. /**
  116030. * Add fallbacks to the effect fallbacks list.
  116031. * @param defines defines the Base texture to use.
  116032. * @param fallbacks defines the current fallback list.
  116033. * @param currentRank defines the current fallback rank.
  116034. * @returns the new fallback rank.
  116035. */
  116036. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116037. /**
  116038. * Add the required uniforms to the current list.
  116039. * @param uniforms defines the current uniform list.
  116040. */
  116041. static AddUniforms(uniforms: string[]): void;
  116042. /**
  116043. * Add the required samplers to the current list.
  116044. * @param samplers defines the current sampler list.
  116045. */
  116046. static AddSamplers(samplers: string[]): void;
  116047. /**
  116048. * Add the required uniforms to the current buffer.
  116049. * @param uniformBuffer defines the current uniform buffer.
  116050. */
  116051. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116052. /**
  116053. * Makes a duplicate of the current configuration into another one.
  116054. * @param configuration define the config where to copy the info
  116055. */
  116056. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116057. /**
  116058. * Serializes this Sub Surface configuration.
  116059. * @returns - An object with the serialized config.
  116060. */
  116061. serialize(): any;
  116062. /**
  116063. * Parses a anisotropy Configuration from a serialized object.
  116064. * @param source - Serialized object.
  116065. * @param scene Defines the scene we are parsing for
  116066. * @param rootUrl Defines the rootUrl to load from
  116067. */
  116068. parse(source: any, scene: Scene, rootUrl: string): void;
  116069. }
  116070. }
  116071. declare module BABYLON {
  116072. /** @hidden */
  116073. export var pbrFragmentDeclaration: {
  116074. name: string;
  116075. shader: string;
  116076. };
  116077. }
  116078. declare module BABYLON {
  116079. /** @hidden */
  116080. export var pbrUboDeclaration: {
  116081. name: string;
  116082. shader: string;
  116083. };
  116084. }
  116085. declare module BABYLON {
  116086. /** @hidden */
  116087. export var pbrFragmentExtraDeclaration: {
  116088. name: string;
  116089. shader: string;
  116090. };
  116091. }
  116092. declare module BABYLON {
  116093. /** @hidden */
  116094. export var pbrFragmentSamplersDeclaration: {
  116095. name: string;
  116096. shader: string;
  116097. };
  116098. }
  116099. declare module BABYLON {
  116100. /** @hidden */
  116101. export var pbrHelperFunctions: {
  116102. name: string;
  116103. shader: string;
  116104. };
  116105. }
  116106. declare module BABYLON {
  116107. /** @hidden */
  116108. export var harmonicsFunctions: {
  116109. name: string;
  116110. shader: string;
  116111. };
  116112. }
  116113. declare module BABYLON {
  116114. /** @hidden */
  116115. export var pbrDirectLightingSetupFunctions: {
  116116. name: string;
  116117. shader: string;
  116118. };
  116119. }
  116120. declare module BABYLON {
  116121. /** @hidden */
  116122. export var pbrDirectLightingFalloffFunctions: {
  116123. name: string;
  116124. shader: string;
  116125. };
  116126. }
  116127. declare module BABYLON {
  116128. /** @hidden */
  116129. export var pbrBRDFFunctions: {
  116130. name: string;
  116131. shader: string;
  116132. };
  116133. }
  116134. declare module BABYLON {
  116135. /** @hidden */
  116136. export var pbrDirectLightingFunctions: {
  116137. name: string;
  116138. shader: string;
  116139. };
  116140. }
  116141. declare module BABYLON {
  116142. /** @hidden */
  116143. export var pbrIBLFunctions: {
  116144. name: string;
  116145. shader: string;
  116146. };
  116147. }
  116148. declare module BABYLON {
  116149. /** @hidden */
  116150. export var pbrDebug: {
  116151. name: string;
  116152. shader: string;
  116153. };
  116154. }
  116155. declare module BABYLON {
  116156. /** @hidden */
  116157. export var pbrPixelShader: {
  116158. name: string;
  116159. shader: string;
  116160. };
  116161. }
  116162. declare module BABYLON {
  116163. /** @hidden */
  116164. export var pbrVertexDeclaration: {
  116165. name: string;
  116166. shader: string;
  116167. };
  116168. }
  116169. declare module BABYLON {
  116170. /** @hidden */
  116171. export var pbrVertexShader: {
  116172. name: string;
  116173. shader: string;
  116174. };
  116175. }
  116176. declare module BABYLON {
  116177. /**
  116178. * Manages the defines for the PBR Material.
  116179. * @hidden
  116180. */
  116181. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116182. PBR: boolean;
  116183. MAINUV1: boolean;
  116184. MAINUV2: boolean;
  116185. UV1: boolean;
  116186. UV2: boolean;
  116187. ALBEDO: boolean;
  116188. ALBEDODIRECTUV: number;
  116189. VERTEXCOLOR: boolean;
  116190. AMBIENT: boolean;
  116191. AMBIENTDIRECTUV: number;
  116192. AMBIENTINGRAYSCALE: boolean;
  116193. OPACITY: boolean;
  116194. VERTEXALPHA: boolean;
  116195. OPACITYDIRECTUV: number;
  116196. OPACITYRGB: boolean;
  116197. ALPHATEST: boolean;
  116198. DEPTHPREPASS: boolean;
  116199. ALPHABLEND: boolean;
  116200. ALPHAFROMALBEDO: boolean;
  116201. ALPHATESTVALUE: string;
  116202. SPECULAROVERALPHA: boolean;
  116203. RADIANCEOVERALPHA: boolean;
  116204. ALPHAFRESNEL: boolean;
  116205. LINEARALPHAFRESNEL: boolean;
  116206. PREMULTIPLYALPHA: boolean;
  116207. EMISSIVE: boolean;
  116208. EMISSIVEDIRECTUV: number;
  116209. REFLECTIVITY: boolean;
  116210. REFLECTIVITYDIRECTUV: number;
  116211. SPECULARTERM: boolean;
  116212. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116213. MICROSURFACEAUTOMATIC: boolean;
  116214. LODBASEDMICROSFURACE: boolean;
  116215. MICROSURFACEMAP: boolean;
  116216. MICROSURFACEMAPDIRECTUV: number;
  116217. METALLICWORKFLOW: boolean;
  116218. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116219. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116220. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116221. AOSTOREINMETALMAPRED: boolean;
  116222. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116223. ENVIRONMENTBRDF: boolean;
  116224. ENVIRONMENTBRDF_RGBD: boolean;
  116225. NORMAL: boolean;
  116226. TANGENT: boolean;
  116227. BUMP: boolean;
  116228. BUMPDIRECTUV: number;
  116229. OBJECTSPACE_NORMALMAP: boolean;
  116230. PARALLAX: boolean;
  116231. PARALLAXOCCLUSION: boolean;
  116232. NORMALXYSCALE: boolean;
  116233. LIGHTMAP: boolean;
  116234. LIGHTMAPDIRECTUV: number;
  116235. USELIGHTMAPASSHADOWMAP: boolean;
  116236. GAMMALIGHTMAP: boolean;
  116237. RGBDLIGHTMAP: boolean;
  116238. REFLECTION: boolean;
  116239. REFLECTIONMAP_3D: boolean;
  116240. REFLECTIONMAP_SPHERICAL: boolean;
  116241. REFLECTIONMAP_PLANAR: boolean;
  116242. REFLECTIONMAP_CUBIC: boolean;
  116243. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116244. REFLECTIONMAP_PROJECTION: boolean;
  116245. REFLECTIONMAP_SKYBOX: boolean;
  116246. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116247. REFLECTIONMAP_EXPLICIT: boolean;
  116248. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116249. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116250. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116251. INVERTCUBICMAP: boolean;
  116252. USESPHERICALFROMREFLECTIONMAP: boolean;
  116253. USEIRRADIANCEMAP: boolean;
  116254. SPHERICAL_HARMONICS: boolean;
  116255. USESPHERICALINVERTEX: boolean;
  116256. REFLECTIONMAP_OPPOSITEZ: boolean;
  116257. LODINREFLECTIONALPHA: boolean;
  116258. GAMMAREFLECTION: boolean;
  116259. RGBDREFLECTION: boolean;
  116260. LINEARSPECULARREFLECTION: boolean;
  116261. RADIANCEOCCLUSION: boolean;
  116262. HORIZONOCCLUSION: boolean;
  116263. INSTANCES: boolean;
  116264. NUM_BONE_INFLUENCERS: number;
  116265. BonesPerMesh: number;
  116266. BONETEXTURE: boolean;
  116267. NONUNIFORMSCALING: boolean;
  116268. MORPHTARGETS: boolean;
  116269. MORPHTARGETS_NORMAL: boolean;
  116270. MORPHTARGETS_TANGENT: boolean;
  116271. MORPHTARGETS_UV: boolean;
  116272. NUM_MORPH_INFLUENCERS: number;
  116273. IMAGEPROCESSING: boolean;
  116274. VIGNETTE: boolean;
  116275. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116276. VIGNETTEBLENDMODEOPAQUE: boolean;
  116277. TONEMAPPING: boolean;
  116278. TONEMAPPING_ACES: boolean;
  116279. CONTRAST: boolean;
  116280. COLORCURVES: boolean;
  116281. COLORGRADING: boolean;
  116282. COLORGRADING3D: boolean;
  116283. SAMPLER3DGREENDEPTH: boolean;
  116284. SAMPLER3DBGRMAP: boolean;
  116285. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116286. EXPOSURE: boolean;
  116287. MULTIVIEW: boolean;
  116288. USEPHYSICALLIGHTFALLOFF: boolean;
  116289. USEGLTFLIGHTFALLOFF: boolean;
  116290. TWOSIDEDLIGHTING: boolean;
  116291. SHADOWFLOAT: boolean;
  116292. CLIPPLANE: boolean;
  116293. CLIPPLANE2: boolean;
  116294. CLIPPLANE3: boolean;
  116295. CLIPPLANE4: boolean;
  116296. POINTSIZE: boolean;
  116297. FOG: boolean;
  116298. LOGARITHMICDEPTH: boolean;
  116299. FORCENORMALFORWARD: boolean;
  116300. SPECULARAA: boolean;
  116301. CLEARCOAT: boolean;
  116302. CLEARCOAT_DEFAULTIOR: boolean;
  116303. CLEARCOAT_TEXTURE: boolean;
  116304. CLEARCOAT_TEXTUREDIRECTUV: number;
  116305. CLEARCOAT_BUMP: boolean;
  116306. CLEARCOAT_BUMPDIRECTUV: number;
  116307. CLEARCOAT_TINT: boolean;
  116308. CLEARCOAT_TINT_TEXTURE: boolean;
  116309. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116310. ANISOTROPIC: boolean;
  116311. ANISOTROPIC_TEXTURE: boolean;
  116312. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116313. BRDF_V_HEIGHT_CORRELATED: boolean;
  116314. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116315. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116316. SHEEN: boolean;
  116317. SHEEN_TEXTURE: boolean;
  116318. SHEEN_TEXTUREDIRECTUV: number;
  116319. SHEEN_LINKWITHALBEDO: boolean;
  116320. SUBSURFACE: boolean;
  116321. SS_REFRACTION: boolean;
  116322. SS_TRANSLUCENCY: boolean;
  116323. SS_SCATERRING: boolean;
  116324. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116325. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116326. SS_REFRACTIONMAP_3D: boolean;
  116327. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116328. SS_LODINREFRACTIONALPHA: boolean;
  116329. SS_GAMMAREFRACTION: boolean;
  116330. SS_RGBDREFRACTION: boolean;
  116331. SS_LINEARSPECULARREFRACTION: boolean;
  116332. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116333. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116334. UNLIT: boolean;
  116335. DEBUGMODE: number;
  116336. /**
  116337. * Initializes the PBR Material defines.
  116338. */
  116339. constructor();
  116340. /**
  116341. * Resets the PBR Material defines.
  116342. */
  116343. reset(): void;
  116344. }
  116345. /**
  116346. * The Physically based material base class of BJS.
  116347. *
  116348. * This offers the main features of a standard PBR material.
  116349. * For more information, please refer to the documentation :
  116350. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116351. */
  116352. export abstract class PBRBaseMaterial extends PushMaterial {
  116353. /**
  116354. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116355. */
  116356. static readonly PBRMATERIAL_OPAQUE: number;
  116357. /**
  116358. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116359. */
  116360. static readonly PBRMATERIAL_ALPHATEST: number;
  116361. /**
  116362. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116363. */
  116364. static readonly PBRMATERIAL_ALPHABLEND: number;
  116365. /**
  116366. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116367. * They are also discarded below the alpha cutoff threshold to improve performances.
  116368. */
  116369. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116370. /**
  116371. * Defines the default value of how much AO map is occluding the analytical lights
  116372. * (point spot...).
  116373. */
  116374. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116375. /**
  116376. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116377. */
  116378. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116379. /**
  116380. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116381. * to enhance interoperability with other engines.
  116382. */
  116383. static readonly LIGHTFALLOFF_GLTF: number;
  116384. /**
  116385. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116386. * to enhance interoperability with other materials.
  116387. */
  116388. static readonly LIGHTFALLOFF_STANDARD: number;
  116389. /**
  116390. * Intensity of the direct lights e.g. the four lights available in your scene.
  116391. * This impacts both the direct diffuse and specular highlights.
  116392. */
  116393. protected _directIntensity: number;
  116394. /**
  116395. * Intensity of the emissive part of the material.
  116396. * This helps controlling the emissive effect without modifying the emissive color.
  116397. */
  116398. protected _emissiveIntensity: number;
  116399. /**
  116400. * Intensity of the environment e.g. how much the environment will light the object
  116401. * either through harmonics for rough material or through the refelction for shiny ones.
  116402. */
  116403. protected _environmentIntensity: number;
  116404. /**
  116405. * This is a special control allowing the reduction of the specular highlights coming from the
  116406. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116407. */
  116408. protected _specularIntensity: number;
  116409. /**
  116410. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116411. */
  116412. private _lightingInfos;
  116413. /**
  116414. * Debug Control allowing disabling the bump map on this material.
  116415. */
  116416. protected _disableBumpMap: boolean;
  116417. /**
  116418. * AKA Diffuse Texture in standard nomenclature.
  116419. */
  116420. protected _albedoTexture: Nullable<BaseTexture>;
  116421. /**
  116422. * AKA Occlusion Texture in other nomenclature.
  116423. */
  116424. protected _ambientTexture: Nullable<BaseTexture>;
  116425. /**
  116426. * AKA Occlusion Texture Intensity in other nomenclature.
  116427. */
  116428. protected _ambientTextureStrength: number;
  116429. /**
  116430. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116431. * 1 means it completely occludes it
  116432. * 0 mean it has no impact
  116433. */
  116434. protected _ambientTextureImpactOnAnalyticalLights: number;
  116435. /**
  116436. * Stores the alpha values in a texture.
  116437. */
  116438. protected _opacityTexture: Nullable<BaseTexture>;
  116439. /**
  116440. * Stores the reflection values in a texture.
  116441. */
  116442. protected _reflectionTexture: Nullable<BaseTexture>;
  116443. /**
  116444. * Stores the emissive values in a texture.
  116445. */
  116446. protected _emissiveTexture: Nullable<BaseTexture>;
  116447. /**
  116448. * AKA Specular texture in other nomenclature.
  116449. */
  116450. protected _reflectivityTexture: Nullable<BaseTexture>;
  116451. /**
  116452. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116453. */
  116454. protected _metallicTexture: Nullable<BaseTexture>;
  116455. /**
  116456. * Specifies the metallic scalar of the metallic/roughness workflow.
  116457. * Can also be used to scale the metalness values of the metallic texture.
  116458. */
  116459. protected _metallic: Nullable<number>;
  116460. /**
  116461. * Specifies the roughness scalar of the metallic/roughness workflow.
  116462. * Can also be used to scale the roughness values of the metallic texture.
  116463. */
  116464. protected _roughness: Nullable<number>;
  116465. /**
  116466. * Specifies the an F0 factor to help configuring the material F0.
  116467. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116468. * to 0.5 the previously hard coded value stays the same.
  116469. * Can also be used to scale the F0 values of the metallic texture.
  116470. */
  116471. protected _metallicF0Factor: number;
  116472. /**
  116473. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116474. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116475. * your expectation as it multiplies with the texture data.
  116476. */
  116477. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116478. /**
  116479. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116480. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116481. */
  116482. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116483. /**
  116484. * Stores surface normal data used to displace a mesh in a texture.
  116485. */
  116486. protected _bumpTexture: Nullable<BaseTexture>;
  116487. /**
  116488. * Stores the pre-calculated light information of a mesh in a texture.
  116489. */
  116490. protected _lightmapTexture: Nullable<BaseTexture>;
  116491. /**
  116492. * The color of a material in ambient lighting.
  116493. */
  116494. protected _ambientColor: Color3;
  116495. /**
  116496. * AKA Diffuse Color in other nomenclature.
  116497. */
  116498. protected _albedoColor: Color3;
  116499. /**
  116500. * AKA Specular Color in other nomenclature.
  116501. */
  116502. protected _reflectivityColor: Color3;
  116503. /**
  116504. * The color applied when light is reflected from a material.
  116505. */
  116506. protected _reflectionColor: Color3;
  116507. /**
  116508. * The color applied when light is emitted from a material.
  116509. */
  116510. protected _emissiveColor: Color3;
  116511. /**
  116512. * AKA Glossiness in other nomenclature.
  116513. */
  116514. protected _microSurface: number;
  116515. /**
  116516. * Specifies that the material will use the light map as a show map.
  116517. */
  116518. protected _useLightmapAsShadowmap: boolean;
  116519. /**
  116520. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116521. * makes the reflect vector face the model (under horizon).
  116522. */
  116523. protected _useHorizonOcclusion: boolean;
  116524. /**
  116525. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116526. * too much the area relying on ambient texture to define their ambient occlusion.
  116527. */
  116528. protected _useRadianceOcclusion: boolean;
  116529. /**
  116530. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116531. */
  116532. protected _useAlphaFromAlbedoTexture: boolean;
  116533. /**
  116534. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116535. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116536. */
  116537. protected _useSpecularOverAlpha: boolean;
  116538. /**
  116539. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116540. */
  116541. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116542. /**
  116543. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116544. */
  116545. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116546. /**
  116547. * Specifies if the metallic texture contains the roughness information in its green channel.
  116548. */
  116549. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116550. /**
  116551. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116552. */
  116553. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116554. /**
  116555. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116556. */
  116557. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116558. /**
  116559. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116560. */
  116561. protected _useAmbientInGrayScale: boolean;
  116562. /**
  116563. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116564. * The material will try to infer what glossiness each pixel should be.
  116565. */
  116566. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116567. /**
  116568. * Defines the falloff type used in this material.
  116569. * It by default is Physical.
  116570. */
  116571. protected _lightFalloff: number;
  116572. /**
  116573. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116574. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116575. */
  116576. protected _useRadianceOverAlpha: boolean;
  116577. /**
  116578. * Allows using an object space normal map (instead of tangent space).
  116579. */
  116580. protected _useObjectSpaceNormalMap: boolean;
  116581. /**
  116582. * Allows using the bump map in parallax mode.
  116583. */
  116584. protected _useParallax: boolean;
  116585. /**
  116586. * Allows using the bump map in parallax occlusion mode.
  116587. */
  116588. protected _useParallaxOcclusion: boolean;
  116589. /**
  116590. * Controls the scale bias of the parallax mode.
  116591. */
  116592. protected _parallaxScaleBias: number;
  116593. /**
  116594. * If sets to true, disables all the lights affecting the material.
  116595. */
  116596. protected _disableLighting: boolean;
  116597. /**
  116598. * Number of Simultaneous lights allowed on the material.
  116599. */
  116600. protected _maxSimultaneousLights: number;
  116601. /**
  116602. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116603. */
  116604. protected _invertNormalMapX: boolean;
  116605. /**
  116606. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116607. */
  116608. protected _invertNormalMapY: boolean;
  116609. /**
  116610. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116611. */
  116612. protected _twoSidedLighting: boolean;
  116613. /**
  116614. * Defines the alpha limits in alpha test mode.
  116615. */
  116616. protected _alphaCutOff: number;
  116617. /**
  116618. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116619. */
  116620. protected _forceAlphaTest: boolean;
  116621. /**
  116622. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116623. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116624. */
  116625. protected _useAlphaFresnel: boolean;
  116626. /**
  116627. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116628. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116629. */
  116630. protected _useLinearAlphaFresnel: boolean;
  116631. /**
  116632. * The transparency mode of the material.
  116633. */
  116634. protected _transparencyMode: Nullable<number>;
  116635. /**
  116636. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116637. * from cos thetav and roughness:
  116638. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116639. */
  116640. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116641. /**
  116642. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116643. */
  116644. protected _forceIrradianceInFragment: boolean;
  116645. /**
  116646. * Force normal to face away from face.
  116647. */
  116648. protected _forceNormalForward: boolean;
  116649. /**
  116650. * Enables specular anti aliasing in the PBR shader.
  116651. * It will both interacts on the Geometry for analytical and IBL lighting.
  116652. * It also prefilter the roughness map based on the bump values.
  116653. */
  116654. protected _enableSpecularAntiAliasing: boolean;
  116655. /**
  116656. * Default configuration related to image processing available in the PBR Material.
  116657. */
  116658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116659. /**
  116660. * Keep track of the image processing observer to allow dispose and replace.
  116661. */
  116662. private _imageProcessingObserver;
  116663. /**
  116664. * Attaches a new image processing configuration to the PBR Material.
  116665. * @param configuration
  116666. */
  116667. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116668. /**
  116669. * Stores the available render targets.
  116670. */
  116671. private _renderTargets;
  116672. /**
  116673. * Sets the global ambient color for the material used in lighting calculations.
  116674. */
  116675. private _globalAmbientColor;
  116676. /**
  116677. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116678. */
  116679. private _useLogarithmicDepth;
  116680. /**
  116681. * If set to true, no lighting calculations will be applied.
  116682. */
  116683. private _unlit;
  116684. private _debugMode;
  116685. /**
  116686. * @hidden
  116687. * This is reserved for the inspector.
  116688. * Defines the material debug mode.
  116689. * It helps seeing only some components of the material while troubleshooting.
  116690. */
  116691. debugMode: number;
  116692. /**
  116693. * @hidden
  116694. * This is reserved for the inspector.
  116695. * Specify from where on screen the debug mode should start.
  116696. * The value goes from -1 (full screen) to 1 (not visible)
  116697. * It helps with side by side comparison against the final render
  116698. * This defaults to -1
  116699. */
  116700. private debugLimit;
  116701. /**
  116702. * @hidden
  116703. * This is reserved for the inspector.
  116704. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116705. * You can use the factor to better multiply the final value.
  116706. */
  116707. private debugFactor;
  116708. /**
  116709. * Defines the clear coat layer parameters for the material.
  116710. */
  116711. readonly clearCoat: PBRClearCoatConfiguration;
  116712. /**
  116713. * Defines the anisotropic parameters for the material.
  116714. */
  116715. readonly anisotropy: PBRAnisotropicConfiguration;
  116716. /**
  116717. * Defines the BRDF parameters for the material.
  116718. */
  116719. readonly brdf: PBRBRDFConfiguration;
  116720. /**
  116721. * Defines the Sheen parameters for the material.
  116722. */
  116723. readonly sheen: PBRSheenConfiguration;
  116724. /**
  116725. * Defines the SubSurface parameters for the material.
  116726. */
  116727. readonly subSurface: PBRSubSurfaceConfiguration;
  116728. /**
  116729. * Custom callback helping to override the default shader used in the material.
  116730. */
  116731. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116732. protected _rebuildInParallel: boolean;
  116733. /**
  116734. * Instantiates a new PBRMaterial instance.
  116735. *
  116736. * @param name The material name
  116737. * @param scene The scene the material will be use in.
  116738. */
  116739. constructor(name: string, scene: Scene);
  116740. /**
  116741. * Gets a boolean indicating that current material needs to register RTT
  116742. */
  116743. readonly hasRenderTargetTextures: boolean;
  116744. /**
  116745. * Gets the name of the material class.
  116746. */
  116747. getClassName(): string;
  116748. /**
  116749. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116750. */
  116751. /**
  116752. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116753. */
  116754. useLogarithmicDepth: boolean;
  116755. /**
  116756. * Gets the current transparency mode.
  116757. */
  116758. /**
  116759. * Sets the transparency mode of the material.
  116760. *
  116761. * | Value | Type | Description |
  116762. * | ----- | ----------------------------------- | ----------- |
  116763. * | 0 | OPAQUE | |
  116764. * | 1 | ALPHATEST | |
  116765. * | 2 | ALPHABLEND | |
  116766. * | 3 | ALPHATESTANDBLEND | |
  116767. *
  116768. */
  116769. transparencyMode: Nullable<number>;
  116770. /**
  116771. * Returns true if alpha blending should be disabled.
  116772. */
  116773. private readonly _disableAlphaBlending;
  116774. /**
  116775. * Specifies whether or not this material should be rendered in alpha blend mode.
  116776. */
  116777. needAlphaBlending(): boolean;
  116778. /**
  116779. * Specifies if the mesh will require alpha blending.
  116780. * @param mesh - BJS mesh.
  116781. */
  116782. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116783. /**
  116784. * Specifies whether or not this material should be rendered in alpha test mode.
  116785. */
  116786. needAlphaTesting(): boolean;
  116787. /**
  116788. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116789. */
  116790. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116791. /**
  116792. * Gets the texture used for the alpha test.
  116793. */
  116794. getAlphaTestTexture(): Nullable<BaseTexture>;
  116795. /**
  116796. * Specifies that the submesh is ready to be used.
  116797. * @param mesh - BJS mesh.
  116798. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116799. * @param useInstances - Specifies that instances should be used.
  116800. * @returns - boolean indicating that the submesh is ready or not.
  116801. */
  116802. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116803. /**
  116804. * Specifies if the material uses metallic roughness workflow.
  116805. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116806. */
  116807. isMetallicWorkflow(): boolean;
  116808. private _prepareEffect;
  116809. private _prepareDefines;
  116810. /**
  116811. * Force shader compilation
  116812. */
  116813. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116814. /**
  116815. * Initializes the uniform buffer layout for the shader.
  116816. */
  116817. buildUniformLayout(): void;
  116818. /**
  116819. * Unbinds the material from the mesh
  116820. */
  116821. unbind(): void;
  116822. /**
  116823. * Binds the submesh data.
  116824. * @param world - The world matrix.
  116825. * @param mesh - The BJS mesh.
  116826. * @param subMesh - A submesh of the BJS mesh.
  116827. */
  116828. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116829. /**
  116830. * Returns the animatable textures.
  116831. * @returns - Array of animatable textures.
  116832. */
  116833. getAnimatables(): IAnimatable[];
  116834. /**
  116835. * Returns the texture used for reflections.
  116836. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116837. */
  116838. private _getReflectionTexture;
  116839. /**
  116840. * Returns an array of the actively used textures.
  116841. * @returns - Array of BaseTextures
  116842. */
  116843. getActiveTextures(): BaseTexture[];
  116844. /**
  116845. * Checks to see if a texture is used in the material.
  116846. * @param texture - Base texture to use.
  116847. * @returns - Boolean specifying if a texture is used in the material.
  116848. */
  116849. hasTexture(texture: BaseTexture): boolean;
  116850. /**
  116851. * Disposes the resources of the material.
  116852. * @param forceDisposeEffect - Forces the disposal of effects.
  116853. * @param forceDisposeTextures - Forces the disposal of all textures.
  116854. */
  116855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116856. }
  116857. }
  116858. declare module BABYLON {
  116859. /**
  116860. * The Physically based material of BJS.
  116861. *
  116862. * This offers the main features of a standard PBR material.
  116863. * For more information, please refer to the documentation :
  116864. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116865. */
  116866. export class PBRMaterial extends PBRBaseMaterial {
  116867. /**
  116868. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116869. */
  116870. static readonly PBRMATERIAL_OPAQUE: number;
  116871. /**
  116872. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116873. */
  116874. static readonly PBRMATERIAL_ALPHATEST: number;
  116875. /**
  116876. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116877. */
  116878. static readonly PBRMATERIAL_ALPHABLEND: number;
  116879. /**
  116880. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116881. * They are also discarded below the alpha cutoff threshold to improve performances.
  116882. */
  116883. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116884. /**
  116885. * Defines the default value of how much AO map is occluding the analytical lights
  116886. * (point spot...).
  116887. */
  116888. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116889. /**
  116890. * Intensity of the direct lights e.g. the four lights available in your scene.
  116891. * This impacts both the direct diffuse and specular highlights.
  116892. */
  116893. directIntensity: number;
  116894. /**
  116895. * Intensity of the emissive part of the material.
  116896. * This helps controlling the emissive effect without modifying the emissive color.
  116897. */
  116898. emissiveIntensity: number;
  116899. /**
  116900. * Intensity of the environment e.g. how much the environment will light the object
  116901. * either through harmonics for rough material or through the refelction for shiny ones.
  116902. */
  116903. environmentIntensity: number;
  116904. /**
  116905. * This is a special control allowing the reduction of the specular highlights coming from the
  116906. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116907. */
  116908. specularIntensity: number;
  116909. /**
  116910. * Debug Control allowing disabling the bump map on this material.
  116911. */
  116912. disableBumpMap: boolean;
  116913. /**
  116914. * AKA Diffuse Texture in standard nomenclature.
  116915. */
  116916. albedoTexture: BaseTexture;
  116917. /**
  116918. * AKA Occlusion Texture in other nomenclature.
  116919. */
  116920. ambientTexture: BaseTexture;
  116921. /**
  116922. * AKA Occlusion Texture Intensity in other nomenclature.
  116923. */
  116924. ambientTextureStrength: number;
  116925. /**
  116926. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116927. * 1 means it completely occludes it
  116928. * 0 mean it has no impact
  116929. */
  116930. ambientTextureImpactOnAnalyticalLights: number;
  116931. /**
  116932. * Stores the alpha values in a texture.
  116933. */
  116934. opacityTexture: BaseTexture;
  116935. /**
  116936. * Stores the reflection values in a texture.
  116937. */
  116938. reflectionTexture: Nullable<BaseTexture>;
  116939. /**
  116940. * Stores the emissive values in a texture.
  116941. */
  116942. emissiveTexture: BaseTexture;
  116943. /**
  116944. * AKA Specular texture in other nomenclature.
  116945. */
  116946. reflectivityTexture: BaseTexture;
  116947. /**
  116948. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116949. */
  116950. metallicTexture: BaseTexture;
  116951. /**
  116952. * Specifies the metallic scalar of the metallic/roughness workflow.
  116953. * Can also be used to scale the metalness values of the metallic texture.
  116954. */
  116955. metallic: Nullable<number>;
  116956. /**
  116957. * Specifies the roughness scalar of the metallic/roughness workflow.
  116958. * Can also be used to scale the roughness values of the metallic texture.
  116959. */
  116960. roughness: Nullable<number>;
  116961. /**
  116962. * Specifies the an F0 factor to help configuring the material F0.
  116963. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116964. * to 0.5 the previously hard coded value stays the same.
  116965. * Can also be used to scale the F0 values of the metallic texture.
  116966. */
  116967. metallicF0Factor: number;
  116968. /**
  116969. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116970. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116971. * your expectation as it multiplies with the texture data.
  116972. */
  116973. useMetallicF0FactorFromMetallicTexture: boolean;
  116974. /**
  116975. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116976. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116977. */
  116978. microSurfaceTexture: BaseTexture;
  116979. /**
  116980. * Stores surface normal data used to displace a mesh in a texture.
  116981. */
  116982. bumpTexture: BaseTexture;
  116983. /**
  116984. * Stores the pre-calculated light information of a mesh in a texture.
  116985. */
  116986. lightmapTexture: BaseTexture;
  116987. /**
  116988. * Stores the refracted light information in a texture.
  116989. */
  116990. refractionTexture: Nullable<BaseTexture>;
  116991. /**
  116992. * The color of a material in ambient lighting.
  116993. */
  116994. ambientColor: Color3;
  116995. /**
  116996. * AKA Diffuse Color in other nomenclature.
  116997. */
  116998. albedoColor: Color3;
  116999. /**
  117000. * AKA Specular Color in other nomenclature.
  117001. */
  117002. reflectivityColor: Color3;
  117003. /**
  117004. * The color reflected from the material.
  117005. */
  117006. reflectionColor: Color3;
  117007. /**
  117008. * The color emitted from the material.
  117009. */
  117010. emissiveColor: Color3;
  117011. /**
  117012. * AKA Glossiness in other nomenclature.
  117013. */
  117014. microSurface: number;
  117015. /**
  117016. * source material index of refraction (IOR)' / 'destination material IOR.
  117017. */
  117018. indexOfRefraction: number;
  117019. /**
  117020. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117021. */
  117022. invertRefractionY: boolean;
  117023. /**
  117024. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117025. * Materials half opaque for instance using refraction could benefit from this control.
  117026. */
  117027. linkRefractionWithTransparency: boolean;
  117028. /**
  117029. * If true, the light map contains occlusion information instead of lighting info.
  117030. */
  117031. useLightmapAsShadowmap: boolean;
  117032. /**
  117033. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117034. */
  117035. useAlphaFromAlbedoTexture: boolean;
  117036. /**
  117037. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117038. */
  117039. forceAlphaTest: boolean;
  117040. /**
  117041. * Defines the alpha limits in alpha test mode.
  117042. */
  117043. alphaCutOff: number;
  117044. /**
  117045. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117046. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117047. */
  117048. useSpecularOverAlpha: boolean;
  117049. /**
  117050. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117051. */
  117052. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117053. /**
  117054. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117055. */
  117056. useRoughnessFromMetallicTextureAlpha: boolean;
  117057. /**
  117058. * Specifies if the metallic texture contains the roughness information in its green channel.
  117059. */
  117060. useRoughnessFromMetallicTextureGreen: boolean;
  117061. /**
  117062. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117063. */
  117064. useMetallnessFromMetallicTextureBlue: boolean;
  117065. /**
  117066. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117067. */
  117068. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117069. /**
  117070. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117071. */
  117072. useAmbientInGrayScale: boolean;
  117073. /**
  117074. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117075. * The material will try to infer what glossiness each pixel should be.
  117076. */
  117077. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117078. /**
  117079. * BJS is using an harcoded light falloff based on a manually sets up range.
  117080. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117081. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117082. */
  117083. /**
  117084. * BJS is using an harcoded light falloff based on a manually sets up range.
  117085. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117086. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117087. */
  117088. usePhysicalLightFalloff: boolean;
  117089. /**
  117090. * In order to support the falloff compatibility with gltf, a special mode has been added
  117091. * to reproduce the gltf light falloff.
  117092. */
  117093. /**
  117094. * In order to support the falloff compatibility with gltf, a special mode has been added
  117095. * to reproduce the gltf light falloff.
  117096. */
  117097. useGLTFLightFalloff: boolean;
  117098. /**
  117099. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117100. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117101. */
  117102. useRadianceOverAlpha: boolean;
  117103. /**
  117104. * Allows using an object space normal map (instead of tangent space).
  117105. */
  117106. useObjectSpaceNormalMap: boolean;
  117107. /**
  117108. * Allows using the bump map in parallax mode.
  117109. */
  117110. useParallax: boolean;
  117111. /**
  117112. * Allows using the bump map in parallax occlusion mode.
  117113. */
  117114. useParallaxOcclusion: boolean;
  117115. /**
  117116. * Controls the scale bias of the parallax mode.
  117117. */
  117118. parallaxScaleBias: number;
  117119. /**
  117120. * If sets to true, disables all the lights affecting the material.
  117121. */
  117122. disableLighting: boolean;
  117123. /**
  117124. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117125. */
  117126. forceIrradianceInFragment: boolean;
  117127. /**
  117128. * Number of Simultaneous lights allowed on the material.
  117129. */
  117130. maxSimultaneousLights: number;
  117131. /**
  117132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117133. */
  117134. invertNormalMapX: boolean;
  117135. /**
  117136. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117137. */
  117138. invertNormalMapY: boolean;
  117139. /**
  117140. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117141. */
  117142. twoSidedLighting: boolean;
  117143. /**
  117144. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117145. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117146. */
  117147. useAlphaFresnel: boolean;
  117148. /**
  117149. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117150. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117151. */
  117152. useLinearAlphaFresnel: boolean;
  117153. /**
  117154. * Let user defines the brdf lookup texture used for IBL.
  117155. * A default 8bit version is embedded but you could point at :
  117156. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117157. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117158. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117159. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117160. */
  117161. environmentBRDFTexture: Nullable<BaseTexture>;
  117162. /**
  117163. * Force normal to face away from face.
  117164. */
  117165. forceNormalForward: boolean;
  117166. /**
  117167. * Enables specular anti aliasing in the PBR shader.
  117168. * It will both interacts on the Geometry for analytical and IBL lighting.
  117169. * It also prefilter the roughness map based on the bump values.
  117170. */
  117171. enableSpecularAntiAliasing: boolean;
  117172. /**
  117173. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117174. * makes the reflect vector face the model (under horizon).
  117175. */
  117176. useHorizonOcclusion: boolean;
  117177. /**
  117178. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117179. * too much the area relying on ambient texture to define their ambient occlusion.
  117180. */
  117181. useRadianceOcclusion: boolean;
  117182. /**
  117183. * If set to true, no lighting calculations will be applied.
  117184. */
  117185. unlit: boolean;
  117186. /**
  117187. * Gets the image processing configuration used either in this material.
  117188. */
  117189. /**
  117190. * Sets the Default image processing configuration used either in the this material.
  117191. *
  117192. * If sets to null, the scene one is in use.
  117193. */
  117194. imageProcessingConfiguration: ImageProcessingConfiguration;
  117195. /**
  117196. * Gets wether the color curves effect is enabled.
  117197. */
  117198. /**
  117199. * Sets wether the color curves effect is enabled.
  117200. */
  117201. cameraColorCurvesEnabled: boolean;
  117202. /**
  117203. * Gets wether the color grading effect is enabled.
  117204. */
  117205. /**
  117206. * Gets wether the color grading effect is enabled.
  117207. */
  117208. cameraColorGradingEnabled: boolean;
  117209. /**
  117210. * Gets wether tonemapping is enabled or not.
  117211. */
  117212. /**
  117213. * Sets wether tonemapping is enabled or not
  117214. */
  117215. cameraToneMappingEnabled: boolean;
  117216. /**
  117217. * The camera exposure used on this material.
  117218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117219. * This corresponds to a photographic exposure.
  117220. */
  117221. /**
  117222. * The camera exposure used on this material.
  117223. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117224. * This corresponds to a photographic exposure.
  117225. */
  117226. cameraExposure: number;
  117227. /**
  117228. * Gets The camera contrast used on this material.
  117229. */
  117230. /**
  117231. * Sets The camera contrast used on this material.
  117232. */
  117233. cameraContrast: number;
  117234. /**
  117235. * Gets the Color Grading 2D Lookup Texture.
  117236. */
  117237. /**
  117238. * Sets the Color Grading 2D Lookup Texture.
  117239. */
  117240. cameraColorGradingTexture: Nullable<BaseTexture>;
  117241. /**
  117242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117244. * 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;
  117245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117246. */
  117247. /**
  117248. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117249. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117250. * 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;
  117251. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117252. */
  117253. cameraColorCurves: Nullable<ColorCurves>;
  117254. /**
  117255. * Instantiates a new PBRMaterial instance.
  117256. *
  117257. * @param name The material name
  117258. * @param scene The scene the material will be use in.
  117259. */
  117260. constructor(name: string, scene: Scene);
  117261. /**
  117262. * Returns the name of this material class.
  117263. */
  117264. getClassName(): string;
  117265. /**
  117266. * Makes a duplicate of the current material.
  117267. * @param name - name to use for the new material.
  117268. */
  117269. clone(name: string): PBRMaterial;
  117270. /**
  117271. * Serializes this PBR Material.
  117272. * @returns - An object with the serialized material.
  117273. */
  117274. serialize(): any;
  117275. /**
  117276. * Parses a PBR Material from a serialized object.
  117277. * @param source - Serialized object.
  117278. * @param scene - BJS scene instance.
  117279. * @param rootUrl - url for the scene object
  117280. * @returns - PBRMaterial
  117281. */
  117282. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117283. }
  117284. }
  117285. declare module BABYLON {
  117286. /**
  117287. * Direct draw surface info
  117288. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117289. */
  117290. export interface DDSInfo {
  117291. /**
  117292. * Width of the texture
  117293. */
  117294. width: number;
  117295. /**
  117296. * Width of the texture
  117297. */
  117298. height: number;
  117299. /**
  117300. * Number of Mipmaps for the texture
  117301. * @see https://en.wikipedia.org/wiki/Mipmap
  117302. */
  117303. mipmapCount: number;
  117304. /**
  117305. * If the textures format is a known fourCC format
  117306. * @see https://www.fourcc.org/
  117307. */
  117308. isFourCC: boolean;
  117309. /**
  117310. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117311. */
  117312. isRGB: boolean;
  117313. /**
  117314. * If the texture is a lumincance format
  117315. */
  117316. isLuminance: boolean;
  117317. /**
  117318. * If this is a cube texture
  117319. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117320. */
  117321. isCube: boolean;
  117322. /**
  117323. * If the texture is a compressed format eg. FOURCC_DXT1
  117324. */
  117325. isCompressed: boolean;
  117326. /**
  117327. * The dxgiFormat of the texture
  117328. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117329. */
  117330. dxgiFormat: number;
  117331. /**
  117332. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117333. */
  117334. textureType: number;
  117335. /**
  117336. * Sphericle polynomial created for the dds texture
  117337. */
  117338. sphericalPolynomial?: SphericalPolynomial;
  117339. }
  117340. /**
  117341. * Class used to provide DDS decompression tools
  117342. */
  117343. export class DDSTools {
  117344. /**
  117345. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117346. */
  117347. static StoreLODInAlphaChannel: boolean;
  117348. /**
  117349. * Gets DDS information from an array buffer
  117350. * @param arrayBuffer defines the array buffer to read data from
  117351. * @returns the DDS information
  117352. */
  117353. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117354. private static _FloatView;
  117355. private static _Int32View;
  117356. private static _ToHalfFloat;
  117357. private static _FromHalfFloat;
  117358. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117359. private static _GetHalfFloatRGBAArrayBuffer;
  117360. private static _GetFloatRGBAArrayBuffer;
  117361. private static _GetFloatAsUIntRGBAArrayBuffer;
  117362. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117363. private static _GetRGBAArrayBuffer;
  117364. private static _ExtractLongWordOrder;
  117365. private static _GetRGBArrayBuffer;
  117366. private static _GetLuminanceArrayBuffer;
  117367. /**
  117368. * Uploads DDS Levels to a Babylon Texture
  117369. * @hidden
  117370. */
  117371. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117372. }
  117373. interface ThinEngine {
  117374. /**
  117375. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117376. * @param rootUrl defines the url where the file to load is located
  117377. * @param scene defines the current scene
  117378. * @param lodScale defines scale to apply to the mip map selection
  117379. * @param lodOffset defines offset to apply to the mip map selection
  117380. * @param onLoad defines an optional callback raised when the texture is loaded
  117381. * @param onError defines an optional callback raised if there is an issue to load the texture
  117382. * @param format defines the format of the data
  117383. * @param forcedExtension defines the extension to use to pick the right loader
  117384. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117385. * @returns the cube texture as an InternalTexture
  117386. */
  117387. 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;
  117388. }
  117389. }
  117390. declare module BABYLON {
  117391. /**
  117392. * Implementation of the DDS Texture Loader.
  117393. * @hidden
  117394. */
  117395. export class _DDSTextureLoader implements IInternalTextureLoader {
  117396. /**
  117397. * Defines wether the loader supports cascade loading the different faces.
  117398. */
  117399. readonly supportCascades: boolean;
  117400. /**
  117401. * This returns if the loader support the current file information.
  117402. * @param extension defines the file extension of the file being loaded
  117403. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117404. * @param fallback defines the fallback internal texture if any
  117405. * @param isBase64 defines whether the texture is encoded as a base64
  117406. * @param isBuffer defines whether the texture data are stored as a buffer
  117407. * @returns true if the loader can load the specified file
  117408. */
  117409. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117410. /**
  117411. * Transform the url before loading if required.
  117412. * @param rootUrl the url of the texture
  117413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117414. * @returns the transformed texture
  117415. */
  117416. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117417. /**
  117418. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117419. * @param rootUrl the url of the texture
  117420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117421. * @returns the fallback texture
  117422. */
  117423. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117424. /**
  117425. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117426. * @param data contains the texture data
  117427. * @param texture defines the BabylonJS internal texture
  117428. * @param createPolynomials will be true if polynomials have been requested
  117429. * @param onLoad defines the callback to trigger once the texture is ready
  117430. * @param onError defines the callback to trigger in case of error
  117431. */
  117432. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117433. /**
  117434. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117435. * @param data contains the texture data
  117436. * @param texture defines the BabylonJS internal texture
  117437. * @param callback defines the method to call once ready to upload
  117438. */
  117439. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117440. }
  117441. }
  117442. declare module BABYLON {
  117443. /**
  117444. * Implementation of the ENV Texture Loader.
  117445. * @hidden
  117446. */
  117447. export class _ENVTextureLoader implements IInternalTextureLoader {
  117448. /**
  117449. * Defines wether the loader supports cascade loading the different faces.
  117450. */
  117451. readonly supportCascades: boolean;
  117452. /**
  117453. * This returns if the loader support the current file information.
  117454. * @param extension defines the file extension of the file being loaded
  117455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117456. * @param fallback defines the fallback internal texture if any
  117457. * @param isBase64 defines whether the texture is encoded as a base64
  117458. * @param isBuffer defines whether the texture data are stored as a buffer
  117459. * @returns true if the loader can load the specified file
  117460. */
  117461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117462. /**
  117463. * Transform the url before loading if required.
  117464. * @param rootUrl the url of the texture
  117465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117466. * @returns the transformed texture
  117467. */
  117468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117469. /**
  117470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117471. * @param rootUrl the url of the texture
  117472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117473. * @returns the fallback texture
  117474. */
  117475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117476. /**
  117477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117478. * @param data contains the texture data
  117479. * @param texture defines the BabylonJS internal texture
  117480. * @param createPolynomials will be true if polynomials have been requested
  117481. * @param onLoad defines the callback to trigger once the texture is ready
  117482. * @param onError defines the callback to trigger in case of error
  117483. */
  117484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117485. /**
  117486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117487. * @param data contains the texture data
  117488. * @param texture defines the BabylonJS internal texture
  117489. * @param callback defines the method to call once ready to upload
  117490. */
  117491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117492. }
  117493. }
  117494. declare module BABYLON {
  117495. /**
  117496. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117497. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117498. */
  117499. export class KhronosTextureContainer {
  117500. /** contents of the KTX container file */
  117501. arrayBuffer: any;
  117502. private static HEADER_LEN;
  117503. private static COMPRESSED_2D;
  117504. private static COMPRESSED_3D;
  117505. private static TEX_2D;
  117506. private static TEX_3D;
  117507. /**
  117508. * Gets the openGL type
  117509. */
  117510. glType: number;
  117511. /**
  117512. * Gets the openGL type size
  117513. */
  117514. glTypeSize: number;
  117515. /**
  117516. * Gets the openGL format
  117517. */
  117518. glFormat: number;
  117519. /**
  117520. * Gets the openGL internal format
  117521. */
  117522. glInternalFormat: number;
  117523. /**
  117524. * Gets the base internal format
  117525. */
  117526. glBaseInternalFormat: number;
  117527. /**
  117528. * Gets image width in pixel
  117529. */
  117530. pixelWidth: number;
  117531. /**
  117532. * Gets image height in pixel
  117533. */
  117534. pixelHeight: number;
  117535. /**
  117536. * Gets image depth in pixels
  117537. */
  117538. pixelDepth: number;
  117539. /**
  117540. * Gets the number of array elements
  117541. */
  117542. numberOfArrayElements: number;
  117543. /**
  117544. * Gets the number of faces
  117545. */
  117546. numberOfFaces: number;
  117547. /**
  117548. * Gets the number of mipmap levels
  117549. */
  117550. numberOfMipmapLevels: number;
  117551. /**
  117552. * Gets the bytes of key value data
  117553. */
  117554. bytesOfKeyValueData: number;
  117555. /**
  117556. * Gets the load type
  117557. */
  117558. loadType: number;
  117559. /**
  117560. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117561. */
  117562. isInvalid: boolean;
  117563. /**
  117564. * Creates a new KhronosTextureContainer
  117565. * @param arrayBuffer contents of the KTX container file
  117566. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117567. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117568. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117569. */
  117570. constructor(
  117571. /** contents of the KTX container file */
  117572. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117573. /**
  117574. * Uploads KTX content to a Babylon Texture.
  117575. * It is assumed that the texture has already been created & is currently bound
  117576. * @hidden
  117577. */
  117578. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117579. private _upload2DCompressedLevels;
  117580. }
  117581. }
  117582. declare module BABYLON {
  117583. /**
  117584. * Implementation of the KTX Texture Loader.
  117585. * @hidden
  117586. */
  117587. export class _KTXTextureLoader implements IInternalTextureLoader {
  117588. /**
  117589. * Defines wether the loader supports cascade loading the different faces.
  117590. */
  117591. readonly supportCascades: boolean;
  117592. /**
  117593. * This returns if the loader support the current file information.
  117594. * @param extension defines the file extension of the file being loaded
  117595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117596. * @param fallback defines the fallback internal texture if any
  117597. * @param isBase64 defines whether the texture is encoded as a base64
  117598. * @param isBuffer defines whether the texture data are stored as a buffer
  117599. * @returns true if the loader can load the specified file
  117600. */
  117601. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117602. /**
  117603. * Transform the url before loading if required.
  117604. * @param rootUrl the url of the texture
  117605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117606. * @returns the transformed texture
  117607. */
  117608. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117609. /**
  117610. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117611. * @param rootUrl the url of the texture
  117612. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117613. * @returns the fallback texture
  117614. */
  117615. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117616. /**
  117617. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117618. * @param data contains the texture data
  117619. * @param texture defines the BabylonJS internal texture
  117620. * @param createPolynomials will be true if polynomials have been requested
  117621. * @param onLoad defines the callback to trigger once the texture is ready
  117622. * @param onError defines the callback to trigger in case of error
  117623. */
  117624. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117625. /**
  117626. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117627. * @param data contains the texture data
  117628. * @param texture defines the BabylonJS internal texture
  117629. * @param callback defines the method to call once ready to upload
  117630. */
  117631. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117632. }
  117633. }
  117634. declare module BABYLON {
  117635. /**
  117636. * Options for the default xr helper
  117637. */
  117638. export class WebXRDefaultExperienceOptions {
  117639. /**
  117640. * Floor meshes that should be used for teleporting
  117641. */
  117642. floorMeshes: Array<AbstractMesh>;
  117643. /**
  117644. * Enable or disable default UI to enter XR
  117645. */
  117646. disableDefaultUI: boolean;
  117647. }
  117648. /**
  117649. * Default experience which provides a similar setup to the previous webVRExperience
  117650. */
  117651. export class WebXRDefaultExperience {
  117652. /**
  117653. * Base experience
  117654. */
  117655. baseExperience: WebXRExperienceHelper;
  117656. /**
  117657. * Input experience extension
  117658. */
  117659. input: WebXRInput;
  117660. /**
  117661. * Loads the controller models
  117662. */
  117663. controllerModelLoader: WebXRControllerModelLoader;
  117664. /**
  117665. * Enables laser pointer and selection
  117666. */
  117667. pointerSelection: WebXRControllerPointerSelection;
  117668. /**
  117669. * Enables teleportation
  117670. */
  117671. teleportation: WebXRControllerTeleportation;
  117672. /**
  117673. * Enables ui for enetering/exiting xr
  117674. */
  117675. enterExitUI: WebXREnterExitUI;
  117676. /**
  117677. * Default target xr should render to
  117678. */
  117679. renderTarget: WebXRRenderTarget;
  117680. /**
  117681. * Creates the default xr experience
  117682. * @param scene scene
  117683. * @param options options for basic configuration
  117684. * @returns resulting WebXRDefaultExperience
  117685. */
  117686. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117687. private constructor();
  117688. /**
  117689. * DIsposes of the experience helper
  117690. */
  117691. dispose(): void;
  117692. }
  117693. }
  117694. declare module BABYLON {
  117695. /** @hidden */
  117696. export var _forceSceneHelpersToBundle: boolean;
  117697. interface Scene {
  117698. /**
  117699. * Creates a default light for the scene.
  117700. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117701. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117702. */
  117703. createDefaultLight(replace?: boolean): void;
  117704. /**
  117705. * Creates a default camera for the scene.
  117706. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117707. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117708. * @param replace has default false, when true replaces the active camera in the scene
  117709. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117710. */
  117711. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117712. /**
  117713. * Creates a default camera and a default light.
  117714. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117715. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117716. * @param replace has the default false, when true replaces the active camera/light in the scene
  117717. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117718. */
  117719. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117720. /**
  117721. * Creates a new sky box
  117722. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117723. * @param environmentTexture defines the texture to use as environment texture
  117724. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117725. * @param scale defines the overall scale of the skybox
  117726. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117727. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117728. * @returns a new mesh holding the sky box
  117729. */
  117730. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117731. /**
  117732. * Creates a new environment
  117733. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117734. * @param options defines the options you can use to configure the environment
  117735. * @returns the new EnvironmentHelper
  117736. */
  117737. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117738. /**
  117739. * Creates a new VREXperienceHelper
  117740. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117741. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117742. * @returns a new VREXperienceHelper
  117743. */
  117744. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117745. /**
  117746. * Creates a new WebXRDefaultExperience
  117747. * @see http://doc.babylonjs.com/how_to/webxr
  117748. * @param options experience options
  117749. * @returns a promise for a new WebXRDefaultExperience
  117750. */
  117751. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117752. }
  117753. }
  117754. declare module BABYLON {
  117755. /**
  117756. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117757. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117758. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117759. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117760. */
  117761. export class VideoDome extends TransformNode {
  117762. /**
  117763. * Define the video source as a Monoscopic panoramic 360 video.
  117764. */
  117765. static readonly MODE_MONOSCOPIC: number;
  117766. /**
  117767. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117768. */
  117769. static readonly MODE_TOPBOTTOM: number;
  117770. /**
  117771. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117772. */
  117773. static readonly MODE_SIDEBYSIDE: number;
  117774. private _halfDome;
  117775. private _useDirectMapping;
  117776. /**
  117777. * The video texture being displayed on the sphere
  117778. */
  117779. protected _videoTexture: VideoTexture;
  117780. /**
  117781. * Gets the video texture being displayed on the sphere
  117782. */
  117783. readonly videoTexture: VideoTexture;
  117784. /**
  117785. * The skybox material
  117786. */
  117787. protected _material: BackgroundMaterial;
  117788. /**
  117789. * The surface used for the skybox
  117790. */
  117791. protected _mesh: Mesh;
  117792. /**
  117793. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117794. */
  117795. private _halfDomeMask;
  117796. /**
  117797. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117798. * Also see the options.resolution property.
  117799. */
  117800. fovMultiplier: number;
  117801. private _videoMode;
  117802. /**
  117803. * Gets or set the current video mode for the video. It can be:
  117804. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117805. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117806. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117807. */
  117808. videoMode: number;
  117809. /**
  117810. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117811. *
  117812. */
  117813. /**
  117814. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117815. */
  117816. halfDome: boolean;
  117817. /**
  117818. * Oberserver used in Stereoscopic VR Mode.
  117819. */
  117820. private _onBeforeCameraRenderObserver;
  117821. /**
  117822. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117823. * @param name Element's name, child elements will append suffixes for their own names.
  117824. * @param urlsOrVideo defines the url(s) or the video element to use
  117825. * @param options An object containing optional or exposed sub element properties
  117826. */
  117827. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117828. resolution?: number;
  117829. clickToPlay?: boolean;
  117830. autoPlay?: boolean;
  117831. loop?: boolean;
  117832. size?: number;
  117833. poster?: string;
  117834. faceForward?: boolean;
  117835. useDirectMapping?: boolean;
  117836. halfDomeMode?: boolean;
  117837. }, scene: Scene);
  117838. private _changeVideoMode;
  117839. /**
  117840. * Releases resources associated with this node.
  117841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117843. */
  117844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117845. }
  117846. }
  117847. declare module BABYLON {
  117848. /**
  117849. * This class can be used to get instrumentation data from a Babylon engine
  117850. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117851. */
  117852. export class EngineInstrumentation implements IDisposable {
  117853. /**
  117854. * Define the instrumented engine.
  117855. */
  117856. engine: Engine;
  117857. private _captureGPUFrameTime;
  117858. private _gpuFrameTimeToken;
  117859. private _gpuFrameTime;
  117860. private _captureShaderCompilationTime;
  117861. private _shaderCompilationTime;
  117862. private _onBeginFrameObserver;
  117863. private _onEndFrameObserver;
  117864. private _onBeforeShaderCompilationObserver;
  117865. private _onAfterShaderCompilationObserver;
  117866. /**
  117867. * Gets the perf counter used for GPU frame time
  117868. */
  117869. readonly gpuFrameTimeCounter: PerfCounter;
  117870. /**
  117871. * Gets the GPU frame time capture status
  117872. */
  117873. /**
  117874. * Enable or disable the GPU frame time capture
  117875. */
  117876. captureGPUFrameTime: boolean;
  117877. /**
  117878. * Gets the perf counter used for shader compilation time
  117879. */
  117880. readonly shaderCompilationTimeCounter: PerfCounter;
  117881. /**
  117882. * Gets the shader compilation time capture status
  117883. */
  117884. /**
  117885. * Enable or disable the shader compilation time capture
  117886. */
  117887. captureShaderCompilationTime: boolean;
  117888. /**
  117889. * Instantiates a new engine instrumentation.
  117890. * This class can be used to get instrumentation data from a Babylon engine
  117891. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117892. * @param engine Defines the engine to instrument
  117893. */
  117894. constructor(
  117895. /**
  117896. * Define the instrumented engine.
  117897. */
  117898. engine: Engine);
  117899. /**
  117900. * Dispose and release associated resources.
  117901. */
  117902. dispose(): void;
  117903. }
  117904. }
  117905. declare module BABYLON {
  117906. /**
  117907. * This class can be used to get instrumentation data from a Babylon engine
  117908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117909. */
  117910. export class SceneInstrumentation implements IDisposable {
  117911. /**
  117912. * Defines the scene to instrument
  117913. */
  117914. scene: Scene;
  117915. private _captureActiveMeshesEvaluationTime;
  117916. private _activeMeshesEvaluationTime;
  117917. private _captureRenderTargetsRenderTime;
  117918. private _renderTargetsRenderTime;
  117919. private _captureFrameTime;
  117920. private _frameTime;
  117921. private _captureRenderTime;
  117922. private _renderTime;
  117923. private _captureInterFrameTime;
  117924. private _interFrameTime;
  117925. private _captureParticlesRenderTime;
  117926. private _particlesRenderTime;
  117927. private _captureSpritesRenderTime;
  117928. private _spritesRenderTime;
  117929. private _capturePhysicsTime;
  117930. private _physicsTime;
  117931. private _captureAnimationsTime;
  117932. private _animationsTime;
  117933. private _captureCameraRenderTime;
  117934. private _cameraRenderTime;
  117935. private _onBeforeActiveMeshesEvaluationObserver;
  117936. private _onAfterActiveMeshesEvaluationObserver;
  117937. private _onBeforeRenderTargetsRenderObserver;
  117938. private _onAfterRenderTargetsRenderObserver;
  117939. private _onAfterRenderObserver;
  117940. private _onBeforeDrawPhaseObserver;
  117941. private _onAfterDrawPhaseObserver;
  117942. private _onBeforeAnimationsObserver;
  117943. private _onBeforeParticlesRenderingObserver;
  117944. private _onAfterParticlesRenderingObserver;
  117945. private _onBeforeSpritesRenderingObserver;
  117946. private _onAfterSpritesRenderingObserver;
  117947. private _onBeforePhysicsObserver;
  117948. private _onAfterPhysicsObserver;
  117949. private _onAfterAnimationsObserver;
  117950. private _onBeforeCameraRenderObserver;
  117951. private _onAfterCameraRenderObserver;
  117952. /**
  117953. * Gets the perf counter used for active meshes evaluation time
  117954. */
  117955. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117956. /**
  117957. * Gets the active meshes evaluation time capture status
  117958. */
  117959. /**
  117960. * Enable or disable the active meshes evaluation time capture
  117961. */
  117962. captureActiveMeshesEvaluationTime: boolean;
  117963. /**
  117964. * Gets the perf counter used for render targets render time
  117965. */
  117966. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117967. /**
  117968. * Gets the render targets render time capture status
  117969. */
  117970. /**
  117971. * Enable or disable the render targets render time capture
  117972. */
  117973. captureRenderTargetsRenderTime: boolean;
  117974. /**
  117975. * Gets the perf counter used for particles render time
  117976. */
  117977. readonly particlesRenderTimeCounter: PerfCounter;
  117978. /**
  117979. * Gets the particles render time capture status
  117980. */
  117981. /**
  117982. * Enable or disable the particles render time capture
  117983. */
  117984. captureParticlesRenderTime: boolean;
  117985. /**
  117986. * Gets the perf counter used for sprites render time
  117987. */
  117988. readonly spritesRenderTimeCounter: PerfCounter;
  117989. /**
  117990. * Gets the sprites render time capture status
  117991. */
  117992. /**
  117993. * Enable or disable the sprites render time capture
  117994. */
  117995. captureSpritesRenderTime: boolean;
  117996. /**
  117997. * Gets the perf counter used for physics time
  117998. */
  117999. readonly physicsTimeCounter: PerfCounter;
  118000. /**
  118001. * Gets the physics time capture status
  118002. */
  118003. /**
  118004. * Enable or disable the physics time capture
  118005. */
  118006. capturePhysicsTime: boolean;
  118007. /**
  118008. * Gets the perf counter used for animations time
  118009. */
  118010. readonly animationsTimeCounter: PerfCounter;
  118011. /**
  118012. * Gets the animations time capture status
  118013. */
  118014. /**
  118015. * Enable or disable the animations time capture
  118016. */
  118017. captureAnimationsTime: boolean;
  118018. /**
  118019. * Gets the perf counter used for frame time capture
  118020. */
  118021. readonly frameTimeCounter: PerfCounter;
  118022. /**
  118023. * Gets the frame time capture status
  118024. */
  118025. /**
  118026. * Enable or disable the frame time capture
  118027. */
  118028. captureFrameTime: boolean;
  118029. /**
  118030. * Gets the perf counter used for inter-frames time capture
  118031. */
  118032. readonly interFrameTimeCounter: PerfCounter;
  118033. /**
  118034. * Gets the inter-frames time capture status
  118035. */
  118036. /**
  118037. * Enable or disable the inter-frames time capture
  118038. */
  118039. captureInterFrameTime: boolean;
  118040. /**
  118041. * Gets the perf counter used for render time capture
  118042. */
  118043. readonly renderTimeCounter: PerfCounter;
  118044. /**
  118045. * Gets the render time capture status
  118046. */
  118047. /**
  118048. * Enable or disable the render time capture
  118049. */
  118050. captureRenderTime: boolean;
  118051. /**
  118052. * Gets the perf counter used for camera render time capture
  118053. */
  118054. readonly cameraRenderTimeCounter: PerfCounter;
  118055. /**
  118056. * Gets the camera render time capture status
  118057. */
  118058. /**
  118059. * Enable or disable the camera render time capture
  118060. */
  118061. captureCameraRenderTime: boolean;
  118062. /**
  118063. * Gets the perf counter used for draw calls
  118064. */
  118065. readonly drawCallsCounter: PerfCounter;
  118066. /**
  118067. * Instantiates a new scene instrumentation.
  118068. * This class can be used to get instrumentation data from a Babylon engine
  118069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118070. * @param scene Defines the scene to instrument
  118071. */
  118072. constructor(
  118073. /**
  118074. * Defines the scene to instrument
  118075. */
  118076. scene: Scene);
  118077. /**
  118078. * Dispose and release associated resources.
  118079. */
  118080. dispose(): void;
  118081. }
  118082. }
  118083. declare module BABYLON {
  118084. /** @hidden */
  118085. export var glowMapGenerationPixelShader: {
  118086. name: string;
  118087. shader: string;
  118088. };
  118089. }
  118090. declare module BABYLON {
  118091. /** @hidden */
  118092. export var glowMapGenerationVertexShader: {
  118093. name: string;
  118094. shader: string;
  118095. };
  118096. }
  118097. declare module BABYLON {
  118098. /**
  118099. * Effect layer options. This helps customizing the behaviour
  118100. * of the effect layer.
  118101. */
  118102. export interface IEffectLayerOptions {
  118103. /**
  118104. * Multiplication factor apply to the canvas size to compute the render target size
  118105. * used to generated the objects (the smaller the faster).
  118106. */
  118107. mainTextureRatio: number;
  118108. /**
  118109. * Enforces a fixed size texture to ensure effect stability across devices.
  118110. */
  118111. mainTextureFixedSize?: number;
  118112. /**
  118113. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118114. */
  118115. alphaBlendingMode: number;
  118116. /**
  118117. * The camera attached to the layer.
  118118. */
  118119. camera: Nullable<Camera>;
  118120. /**
  118121. * The rendering group to draw the layer in.
  118122. */
  118123. renderingGroupId: number;
  118124. }
  118125. /**
  118126. * The effect layer Helps adding post process effect blended with the main pass.
  118127. *
  118128. * This can be for instance use to generate glow or higlight effects on the scene.
  118129. *
  118130. * The effect layer class can not be used directly and is intented to inherited from to be
  118131. * customized per effects.
  118132. */
  118133. export abstract class EffectLayer {
  118134. private _vertexBuffers;
  118135. private _indexBuffer;
  118136. private _cachedDefines;
  118137. private _effectLayerMapGenerationEffect;
  118138. private _effectLayerOptions;
  118139. private _mergeEffect;
  118140. protected _scene: Scene;
  118141. protected _engine: Engine;
  118142. protected _maxSize: number;
  118143. protected _mainTextureDesiredSize: ISize;
  118144. protected _mainTexture: RenderTargetTexture;
  118145. protected _shouldRender: boolean;
  118146. protected _postProcesses: PostProcess[];
  118147. protected _textures: BaseTexture[];
  118148. protected _emissiveTextureAndColor: {
  118149. texture: Nullable<BaseTexture>;
  118150. color: Color4;
  118151. };
  118152. /**
  118153. * The name of the layer
  118154. */
  118155. name: string;
  118156. /**
  118157. * The clear color of the texture used to generate the glow map.
  118158. */
  118159. neutralColor: Color4;
  118160. /**
  118161. * Specifies wether the highlight layer is enabled or not.
  118162. */
  118163. isEnabled: boolean;
  118164. /**
  118165. * Gets the camera attached to the layer.
  118166. */
  118167. readonly camera: Nullable<Camera>;
  118168. /**
  118169. * Gets the rendering group id the layer should render in.
  118170. */
  118171. renderingGroupId: number;
  118172. /**
  118173. * An event triggered when the effect layer has been disposed.
  118174. */
  118175. onDisposeObservable: Observable<EffectLayer>;
  118176. /**
  118177. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118178. */
  118179. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118180. /**
  118181. * An event triggered when the generated texture is being merged in the scene.
  118182. */
  118183. onBeforeComposeObservable: Observable<EffectLayer>;
  118184. /**
  118185. * An event triggered when the mesh is rendered into the effect render target.
  118186. */
  118187. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118188. /**
  118189. * An event triggered after the mesh has been rendered into the effect render target.
  118190. */
  118191. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118192. /**
  118193. * An event triggered when the generated texture has been merged in the scene.
  118194. */
  118195. onAfterComposeObservable: Observable<EffectLayer>;
  118196. /**
  118197. * An event triggered when the efffect layer changes its size.
  118198. */
  118199. onSizeChangedObservable: Observable<EffectLayer>;
  118200. /** @hidden */
  118201. static _SceneComponentInitialization: (scene: Scene) => void;
  118202. /**
  118203. * Instantiates a new effect Layer and references it in the scene.
  118204. * @param name The name of the layer
  118205. * @param scene The scene to use the layer in
  118206. */
  118207. constructor(
  118208. /** The Friendly of the effect in the scene */
  118209. name: string, scene: Scene);
  118210. /**
  118211. * Get the effect name of the layer.
  118212. * @return The effect name
  118213. */
  118214. abstract getEffectName(): string;
  118215. /**
  118216. * Checks for the readiness of the element composing the layer.
  118217. * @param subMesh the mesh to check for
  118218. * @param useInstances specify wether or not to use instances to render the mesh
  118219. * @return true if ready otherwise, false
  118220. */
  118221. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118222. /**
  118223. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118224. * @returns true if the effect requires stencil during the main canvas render pass.
  118225. */
  118226. abstract needStencil(): boolean;
  118227. /**
  118228. * Create the merge effect. This is the shader use to blit the information back
  118229. * to the main canvas at the end of the scene rendering.
  118230. * @returns The effect containing the shader used to merge the effect on the main canvas
  118231. */
  118232. protected abstract _createMergeEffect(): Effect;
  118233. /**
  118234. * Creates the render target textures and post processes used in the effect layer.
  118235. */
  118236. protected abstract _createTextureAndPostProcesses(): void;
  118237. /**
  118238. * Implementation specific of rendering the generating effect on the main canvas.
  118239. * @param effect The effect used to render through
  118240. */
  118241. protected abstract _internalRender(effect: Effect): void;
  118242. /**
  118243. * Sets the required values for both the emissive texture and and the main color.
  118244. */
  118245. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118246. /**
  118247. * Free any resources and references associated to a mesh.
  118248. * Internal use
  118249. * @param mesh The mesh to free.
  118250. */
  118251. abstract _disposeMesh(mesh: Mesh): void;
  118252. /**
  118253. * Serializes this layer (Glow or Highlight for example)
  118254. * @returns a serialized layer object
  118255. */
  118256. abstract serialize?(): any;
  118257. /**
  118258. * Initializes the effect layer with the required options.
  118259. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118260. */
  118261. protected _init(options: Partial<IEffectLayerOptions>): void;
  118262. /**
  118263. * Generates the index buffer of the full screen quad blending to the main canvas.
  118264. */
  118265. private _generateIndexBuffer;
  118266. /**
  118267. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118268. */
  118269. private _generateVertexBuffer;
  118270. /**
  118271. * Sets the main texture desired size which is the closest power of two
  118272. * of the engine canvas size.
  118273. */
  118274. private _setMainTextureSize;
  118275. /**
  118276. * Creates the main texture for the effect layer.
  118277. */
  118278. protected _createMainTexture(): void;
  118279. /**
  118280. * Adds specific effects defines.
  118281. * @param defines The defines to add specifics to.
  118282. */
  118283. protected _addCustomEffectDefines(defines: string[]): void;
  118284. /**
  118285. * Checks for the readiness of the element composing the layer.
  118286. * @param subMesh the mesh to check for
  118287. * @param useInstances specify wether or not to use instances to render the mesh
  118288. * @param emissiveTexture the associated emissive texture used to generate the glow
  118289. * @return true if ready otherwise, false
  118290. */
  118291. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118292. /**
  118293. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118294. */
  118295. render(): void;
  118296. /**
  118297. * Determine if a given mesh will be used in the current effect.
  118298. * @param mesh mesh to test
  118299. * @returns true if the mesh will be used
  118300. */
  118301. hasMesh(mesh: AbstractMesh): boolean;
  118302. /**
  118303. * Returns true if the layer contains information to display, otherwise false.
  118304. * @returns true if the glow layer should be rendered
  118305. */
  118306. shouldRender(): boolean;
  118307. /**
  118308. * Returns true if the mesh should render, otherwise false.
  118309. * @param mesh The mesh to render
  118310. * @returns true if it should render otherwise false
  118311. */
  118312. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118313. /**
  118314. * Returns true if the mesh can be rendered, otherwise false.
  118315. * @param mesh The mesh to render
  118316. * @param material The material used on the mesh
  118317. * @returns true if it can be rendered otherwise false
  118318. */
  118319. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118320. /**
  118321. * Returns true if the mesh should render, otherwise false.
  118322. * @param mesh The mesh to render
  118323. * @returns true if it should render otherwise false
  118324. */
  118325. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118326. /**
  118327. * Renders the submesh passed in parameter to the generation map.
  118328. */
  118329. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118330. /**
  118331. * Defines wether the current material of the mesh should be use to render the effect.
  118332. * @param mesh defines the current mesh to render
  118333. */
  118334. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118335. /**
  118336. * Rebuild the required buffers.
  118337. * @hidden Internal use only.
  118338. */
  118339. _rebuild(): void;
  118340. /**
  118341. * Dispose only the render target textures and post process.
  118342. */
  118343. private _disposeTextureAndPostProcesses;
  118344. /**
  118345. * Dispose the highlight layer and free resources.
  118346. */
  118347. dispose(): void;
  118348. /**
  118349. * Gets the class name of the effect layer
  118350. * @returns the string with the class name of the effect layer
  118351. */
  118352. getClassName(): string;
  118353. /**
  118354. * Creates an effect layer from parsed effect layer data
  118355. * @param parsedEffectLayer defines effect layer data
  118356. * @param scene defines the current scene
  118357. * @param rootUrl defines the root URL containing the effect layer information
  118358. * @returns a parsed effect Layer
  118359. */
  118360. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118361. }
  118362. }
  118363. declare module BABYLON {
  118364. interface AbstractScene {
  118365. /**
  118366. * The list of effect layers (highlights/glow) added to the scene
  118367. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118368. * @see http://doc.babylonjs.com/how_to/glow_layer
  118369. */
  118370. effectLayers: Array<EffectLayer>;
  118371. /**
  118372. * Removes the given effect layer from this scene.
  118373. * @param toRemove defines the effect layer to remove
  118374. * @returns the index of the removed effect layer
  118375. */
  118376. removeEffectLayer(toRemove: EffectLayer): number;
  118377. /**
  118378. * Adds the given effect layer to this scene
  118379. * @param newEffectLayer defines the effect layer to add
  118380. */
  118381. addEffectLayer(newEffectLayer: EffectLayer): void;
  118382. }
  118383. /**
  118384. * Defines the layer scene component responsible to manage any effect layers
  118385. * in a given scene.
  118386. */
  118387. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118388. /**
  118389. * The component name helpfull to identify the component in the list of scene components.
  118390. */
  118391. readonly name: string;
  118392. /**
  118393. * The scene the component belongs to.
  118394. */
  118395. scene: Scene;
  118396. private _engine;
  118397. private _renderEffects;
  118398. private _needStencil;
  118399. private _previousStencilState;
  118400. /**
  118401. * Creates a new instance of the component for the given scene
  118402. * @param scene Defines the scene to register the component in
  118403. */
  118404. constructor(scene: Scene);
  118405. /**
  118406. * Registers the component in a given scene
  118407. */
  118408. register(): void;
  118409. /**
  118410. * Rebuilds the elements related to this component in case of
  118411. * context lost for instance.
  118412. */
  118413. rebuild(): void;
  118414. /**
  118415. * Serializes the component data to the specified json object
  118416. * @param serializationObject The object to serialize to
  118417. */
  118418. serialize(serializationObject: any): void;
  118419. /**
  118420. * Adds all the elements from the container to the scene
  118421. * @param container the container holding the elements
  118422. */
  118423. addFromContainer(container: AbstractScene): void;
  118424. /**
  118425. * Removes all the elements in the container from the scene
  118426. * @param container contains the elements to remove
  118427. * @param dispose if the removed element should be disposed (default: false)
  118428. */
  118429. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118430. /**
  118431. * Disposes the component and the associated ressources.
  118432. */
  118433. dispose(): void;
  118434. private _isReadyForMesh;
  118435. private _renderMainTexture;
  118436. private _setStencil;
  118437. private _setStencilBack;
  118438. private _draw;
  118439. private _drawCamera;
  118440. private _drawRenderingGroup;
  118441. }
  118442. }
  118443. declare module BABYLON {
  118444. /** @hidden */
  118445. export var glowMapMergePixelShader: {
  118446. name: string;
  118447. shader: string;
  118448. };
  118449. }
  118450. declare module BABYLON {
  118451. /** @hidden */
  118452. export var glowMapMergeVertexShader: {
  118453. name: string;
  118454. shader: string;
  118455. };
  118456. }
  118457. declare module BABYLON {
  118458. interface AbstractScene {
  118459. /**
  118460. * Return a the first highlight layer of the scene with a given name.
  118461. * @param name The name of the highlight layer to look for.
  118462. * @return The highlight layer if found otherwise null.
  118463. */
  118464. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118465. }
  118466. /**
  118467. * Glow layer options. This helps customizing the behaviour
  118468. * of the glow layer.
  118469. */
  118470. export interface IGlowLayerOptions {
  118471. /**
  118472. * Multiplication factor apply to the canvas size to compute the render target size
  118473. * used to generated the glowing objects (the smaller the faster).
  118474. */
  118475. mainTextureRatio: number;
  118476. /**
  118477. * Enforces a fixed size texture to ensure resize independant blur.
  118478. */
  118479. mainTextureFixedSize?: number;
  118480. /**
  118481. * How big is the kernel of the blur texture.
  118482. */
  118483. blurKernelSize: number;
  118484. /**
  118485. * The camera attached to the layer.
  118486. */
  118487. camera: Nullable<Camera>;
  118488. /**
  118489. * Enable MSAA by chosing the number of samples.
  118490. */
  118491. mainTextureSamples?: number;
  118492. /**
  118493. * The rendering group to draw the layer in.
  118494. */
  118495. renderingGroupId: number;
  118496. }
  118497. /**
  118498. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118499. *
  118500. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118501. *
  118502. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118503. */
  118504. export class GlowLayer extends EffectLayer {
  118505. /**
  118506. * Effect Name of the layer.
  118507. */
  118508. static readonly EffectName: string;
  118509. /**
  118510. * The default blur kernel size used for the glow.
  118511. */
  118512. static DefaultBlurKernelSize: number;
  118513. /**
  118514. * The default texture size ratio used for the glow.
  118515. */
  118516. static DefaultTextureRatio: number;
  118517. /**
  118518. * Sets the kernel size of the blur.
  118519. */
  118520. /**
  118521. * Gets the kernel size of the blur.
  118522. */
  118523. blurKernelSize: number;
  118524. /**
  118525. * Sets the glow intensity.
  118526. */
  118527. /**
  118528. * Gets the glow intensity.
  118529. */
  118530. intensity: number;
  118531. private _options;
  118532. private _intensity;
  118533. private _horizontalBlurPostprocess1;
  118534. private _verticalBlurPostprocess1;
  118535. private _horizontalBlurPostprocess2;
  118536. private _verticalBlurPostprocess2;
  118537. private _blurTexture1;
  118538. private _blurTexture2;
  118539. private _postProcesses1;
  118540. private _postProcesses2;
  118541. private _includedOnlyMeshes;
  118542. private _excludedMeshes;
  118543. private _meshesUsingTheirOwnMaterials;
  118544. /**
  118545. * Callback used to let the user override the color selection on a per mesh basis
  118546. */
  118547. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118548. /**
  118549. * Callback used to let the user override the texture selection on a per mesh basis
  118550. */
  118551. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118552. /**
  118553. * Instantiates a new glow Layer and references it to the scene.
  118554. * @param name The name of the layer
  118555. * @param scene The scene to use the layer in
  118556. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118557. */
  118558. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118559. /**
  118560. * Get the effect name of the layer.
  118561. * @return The effect name
  118562. */
  118563. getEffectName(): string;
  118564. /**
  118565. * Create the merge effect. This is the shader use to blit the information back
  118566. * to the main canvas at the end of the scene rendering.
  118567. */
  118568. protected _createMergeEffect(): Effect;
  118569. /**
  118570. * Creates the render target textures and post processes used in the glow layer.
  118571. */
  118572. protected _createTextureAndPostProcesses(): void;
  118573. /**
  118574. * Checks for the readiness of the element composing the layer.
  118575. * @param subMesh the mesh to check for
  118576. * @param useInstances specify wether or not to use instances to render the mesh
  118577. * @param emissiveTexture the associated emissive texture used to generate the glow
  118578. * @return true if ready otherwise, false
  118579. */
  118580. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118581. /**
  118582. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118583. */
  118584. needStencil(): boolean;
  118585. /**
  118586. * Returns true if the mesh can be rendered, otherwise false.
  118587. * @param mesh The mesh to render
  118588. * @param material The material used on the mesh
  118589. * @returns true if it can be rendered otherwise false
  118590. */
  118591. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118592. /**
  118593. * Implementation specific of rendering the generating effect on the main canvas.
  118594. * @param effect The effect used to render through
  118595. */
  118596. protected _internalRender(effect: Effect): void;
  118597. /**
  118598. * Sets the required values for both the emissive texture and and the main color.
  118599. */
  118600. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118601. /**
  118602. * Returns true if the mesh should render, otherwise false.
  118603. * @param mesh The mesh to render
  118604. * @returns true if it should render otherwise false
  118605. */
  118606. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118607. /**
  118608. * Adds specific effects defines.
  118609. * @param defines The defines to add specifics to.
  118610. */
  118611. protected _addCustomEffectDefines(defines: string[]): void;
  118612. /**
  118613. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118614. * @param mesh The mesh to exclude from the glow layer
  118615. */
  118616. addExcludedMesh(mesh: Mesh): void;
  118617. /**
  118618. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118619. * @param mesh The mesh to remove
  118620. */
  118621. removeExcludedMesh(mesh: Mesh): void;
  118622. /**
  118623. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118624. * @param mesh The mesh to include in the glow layer
  118625. */
  118626. addIncludedOnlyMesh(mesh: Mesh): void;
  118627. /**
  118628. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118629. * @param mesh The mesh to remove
  118630. */
  118631. removeIncludedOnlyMesh(mesh: Mesh): void;
  118632. /**
  118633. * Determine if a given mesh will be used in the glow layer
  118634. * @param mesh The mesh to test
  118635. * @returns true if the mesh will be highlighted by the current glow layer
  118636. */
  118637. hasMesh(mesh: AbstractMesh): boolean;
  118638. /**
  118639. * Defines wether the current material of the mesh should be use to render the effect.
  118640. * @param mesh defines the current mesh to render
  118641. */
  118642. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118643. /**
  118644. * Add a mesh to be rendered through its own material and not with emissive only.
  118645. * @param mesh The mesh for which we need to use its material
  118646. */
  118647. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118648. /**
  118649. * Remove a mesh from being rendered through its own material and not with emissive only.
  118650. * @param mesh The mesh for which we need to not use its material
  118651. */
  118652. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118653. /**
  118654. * Free any resources and references associated to a mesh.
  118655. * Internal use
  118656. * @param mesh The mesh to free.
  118657. * @hidden
  118658. */
  118659. _disposeMesh(mesh: Mesh): void;
  118660. /**
  118661. * Gets the class name of the effect layer
  118662. * @returns the string with the class name of the effect layer
  118663. */
  118664. getClassName(): string;
  118665. /**
  118666. * Serializes this glow layer
  118667. * @returns a serialized glow layer object
  118668. */
  118669. serialize(): any;
  118670. /**
  118671. * Creates a Glow Layer from parsed glow layer data
  118672. * @param parsedGlowLayer defines glow layer data
  118673. * @param scene defines the current scene
  118674. * @param rootUrl defines the root URL containing the glow layer information
  118675. * @returns a parsed Glow Layer
  118676. */
  118677. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118678. }
  118679. }
  118680. declare module BABYLON {
  118681. /** @hidden */
  118682. export var glowBlurPostProcessPixelShader: {
  118683. name: string;
  118684. shader: string;
  118685. };
  118686. }
  118687. declare module BABYLON {
  118688. interface AbstractScene {
  118689. /**
  118690. * Return a the first highlight layer of the scene with a given name.
  118691. * @param name The name of the highlight layer to look for.
  118692. * @return The highlight layer if found otherwise null.
  118693. */
  118694. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118695. }
  118696. /**
  118697. * Highlight layer options. This helps customizing the behaviour
  118698. * of the highlight layer.
  118699. */
  118700. export interface IHighlightLayerOptions {
  118701. /**
  118702. * Multiplication factor apply to the canvas size to compute the render target size
  118703. * used to generated the glowing objects (the smaller the faster).
  118704. */
  118705. mainTextureRatio: number;
  118706. /**
  118707. * Enforces a fixed size texture to ensure resize independant blur.
  118708. */
  118709. mainTextureFixedSize?: number;
  118710. /**
  118711. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118712. * of the picture to blur (the smaller the faster).
  118713. */
  118714. blurTextureSizeRatio: number;
  118715. /**
  118716. * How big in texel of the blur texture is the vertical blur.
  118717. */
  118718. blurVerticalSize: number;
  118719. /**
  118720. * How big in texel of the blur texture is the horizontal blur.
  118721. */
  118722. blurHorizontalSize: number;
  118723. /**
  118724. * Alpha blending mode used to apply the blur. Default is combine.
  118725. */
  118726. alphaBlendingMode: number;
  118727. /**
  118728. * The camera attached to the layer.
  118729. */
  118730. camera: Nullable<Camera>;
  118731. /**
  118732. * Should we display highlight as a solid stroke?
  118733. */
  118734. isStroke?: boolean;
  118735. /**
  118736. * The rendering group to draw the layer in.
  118737. */
  118738. renderingGroupId: number;
  118739. }
  118740. /**
  118741. * The highlight layer Helps adding a glow effect around a mesh.
  118742. *
  118743. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118744. * glowy meshes to your scene.
  118745. *
  118746. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118747. */
  118748. export class HighlightLayer extends EffectLayer {
  118749. name: string;
  118750. /**
  118751. * Effect Name of the highlight layer.
  118752. */
  118753. static readonly EffectName: string;
  118754. /**
  118755. * The neutral color used during the preparation of the glow effect.
  118756. * This is black by default as the blend operation is a blend operation.
  118757. */
  118758. static NeutralColor: Color4;
  118759. /**
  118760. * Stencil value used for glowing meshes.
  118761. */
  118762. static GlowingMeshStencilReference: number;
  118763. /**
  118764. * Stencil value used for the other meshes in the scene.
  118765. */
  118766. static NormalMeshStencilReference: number;
  118767. /**
  118768. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118769. */
  118770. innerGlow: boolean;
  118771. /**
  118772. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118773. */
  118774. outerGlow: boolean;
  118775. /**
  118776. * Specifies the horizontal size of the blur.
  118777. */
  118778. /**
  118779. * Gets the horizontal size of the blur.
  118780. */
  118781. blurHorizontalSize: number;
  118782. /**
  118783. * Specifies the vertical size of the blur.
  118784. */
  118785. /**
  118786. * Gets the vertical size of the blur.
  118787. */
  118788. blurVerticalSize: number;
  118789. /**
  118790. * An event triggered when the highlight layer is being blurred.
  118791. */
  118792. onBeforeBlurObservable: Observable<HighlightLayer>;
  118793. /**
  118794. * An event triggered when the highlight layer has been blurred.
  118795. */
  118796. onAfterBlurObservable: Observable<HighlightLayer>;
  118797. private _instanceGlowingMeshStencilReference;
  118798. private _options;
  118799. private _downSamplePostprocess;
  118800. private _horizontalBlurPostprocess;
  118801. private _verticalBlurPostprocess;
  118802. private _blurTexture;
  118803. private _meshes;
  118804. private _excludedMeshes;
  118805. /**
  118806. * Instantiates a new highlight Layer and references it to the scene..
  118807. * @param name The name of the layer
  118808. * @param scene The scene to use the layer in
  118809. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118810. */
  118811. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118812. /**
  118813. * Get the effect name of the layer.
  118814. * @return The effect name
  118815. */
  118816. getEffectName(): string;
  118817. /**
  118818. * Create the merge effect. This is the shader use to blit the information back
  118819. * to the main canvas at the end of the scene rendering.
  118820. */
  118821. protected _createMergeEffect(): Effect;
  118822. /**
  118823. * Creates the render target textures and post processes used in the highlight layer.
  118824. */
  118825. protected _createTextureAndPostProcesses(): void;
  118826. /**
  118827. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118828. */
  118829. needStencil(): boolean;
  118830. /**
  118831. * Checks for the readiness of the element composing the layer.
  118832. * @param subMesh the mesh to check for
  118833. * @param useInstances specify wether or not to use instances to render the mesh
  118834. * @param emissiveTexture the associated emissive texture used to generate the glow
  118835. * @return true if ready otherwise, false
  118836. */
  118837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118838. /**
  118839. * Implementation specific of rendering the generating effect on the main canvas.
  118840. * @param effect The effect used to render through
  118841. */
  118842. protected _internalRender(effect: Effect): void;
  118843. /**
  118844. * Returns true if the layer contains information to display, otherwise false.
  118845. */
  118846. shouldRender(): boolean;
  118847. /**
  118848. * Returns true if the mesh should render, otherwise false.
  118849. * @param mesh The mesh to render
  118850. * @returns true if it should render otherwise false
  118851. */
  118852. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118853. /**
  118854. * Sets the required values for both the emissive texture and and the main color.
  118855. */
  118856. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118857. /**
  118858. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118859. * @param mesh The mesh to exclude from the highlight layer
  118860. */
  118861. addExcludedMesh(mesh: Mesh): void;
  118862. /**
  118863. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118864. * @param mesh The mesh to highlight
  118865. */
  118866. removeExcludedMesh(mesh: Mesh): void;
  118867. /**
  118868. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118869. * @param mesh mesh to test
  118870. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118871. */
  118872. hasMesh(mesh: AbstractMesh): boolean;
  118873. /**
  118874. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118875. * @param mesh The mesh to highlight
  118876. * @param color The color of the highlight
  118877. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118878. */
  118879. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118880. /**
  118881. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118882. * @param mesh The mesh to highlight
  118883. */
  118884. removeMesh(mesh: Mesh): void;
  118885. /**
  118886. * Force the stencil to the normal expected value for none glowing parts
  118887. */
  118888. private _defaultStencilReference;
  118889. /**
  118890. * Free any resources and references associated to a mesh.
  118891. * Internal use
  118892. * @param mesh The mesh to free.
  118893. * @hidden
  118894. */
  118895. _disposeMesh(mesh: Mesh): void;
  118896. /**
  118897. * Dispose the highlight layer and free resources.
  118898. */
  118899. dispose(): void;
  118900. /**
  118901. * Gets the class name of the effect layer
  118902. * @returns the string with the class name of the effect layer
  118903. */
  118904. getClassName(): string;
  118905. /**
  118906. * Serializes this Highlight layer
  118907. * @returns a serialized Highlight layer object
  118908. */
  118909. serialize(): any;
  118910. /**
  118911. * Creates a Highlight layer from parsed Highlight layer data
  118912. * @param parsedHightlightLayer defines the Highlight layer data
  118913. * @param scene defines the current scene
  118914. * @param rootUrl defines the root URL containing the Highlight layer information
  118915. * @returns a parsed Highlight layer
  118916. */
  118917. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118918. }
  118919. }
  118920. declare module BABYLON {
  118921. interface AbstractScene {
  118922. /**
  118923. * The list of layers (background and foreground) of the scene
  118924. */
  118925. layers: Array<Layer>;
  118926. }
  118927. /**
  118928. * Defines the layer scene component responsible to manage any layers
  118929. * in a given scene.
  118930. */
  118931. export class LayerSceneComponent implements ISceneComponent {
  118932. /**
  118933. * The component name helpfull to identify the component in the list of scene components.
  118934. */
  118935. readonly name: string;
  118936. /**
  118937. * The scene the component belongs to.
  118938. */
  118939. scene: Scene;
  118940. private _engine;
  118941. /**
  118942. * Creates a new instance of the component for the given scene
  118943. * @param scene Defines the scene to register the component in
  118944. */
  118945. constructor(scene: Scene);
  118946. /**
  118947. * Registers the component in a given scene
  118948. */
  118949. register(): void;
  118950. /**
  118951. * Rebuilds the elements related to this component in case of
  118952. * context lost for instance.
  118953. */
  118954. rebuild(): void;
  118955. /**
  118956. * Disposes the component and the associated ressources.
  118957. */
  118958. dispose(): void;
  118959. private _draw;
  118960. private _drawCameraPredicate;
  118961. private _drawCameraBackground;
  118962. private _drawCameraForeground;
  118963. private _drawRenderTargetPredicate;
  118964. private _drawRenderTargetBackground;
  118965. private _drawRenderTargetForeground;
  118966. /**
  118967. * Adds all the elements from the container to the scene
  118968. * @param container the container holding the elements
  118969. */
  118970. addFromContainer(container: AbstractScene): void;
  118971. /**
  118972. * Removes all the elements in the container from the scene
  118973. * @param container contains the elements to remove
  118974. * @param dispose if the removed element should be disposed (default: false)
  118975. */
  118976. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118977. }
  118978. }
  118979. declare module BABYLON {
  118980. /** @hidden */
  118981. export var layerPixelShader: {
  118982. name: string;
  118983. shader: string;
  118984. };
  118985. }
  118986. declare module BABYLON {
  118987. /** @hidden */
  118988. export var layerVertexShader: {
  118989. name: string;
  118990. shader: string;
  118991. };
  118992. }
  118993. declare module BABYLON {
  118994. /**
  118995. * This represents a full screen 2d layer.
  118996. * This can be useful to display a picture in the background of your scene for instance.
  118997. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118998. */
  118999. export class Layer {
  119000. /**
  119001. * Define the name of the layer.
  119002. */
  119003. name: string;
  119004. /**
  119005. * Define the texture the layer should display.
  119006. */
  119007. texture: Nullable<Texture>;
  119008. /**
  119009. * Is the layer in background or foreground.
  119010. */
  119011. isBackground: boolean;
  119012. /**
  119013. * Define the color of the layer (instead of texture).
  119014. */
  119015. color: Color4;
  119016. /**
  119017. * Define the scale of the layer in order to zoom in out of the texture.
  119018. */
  119019. scale: Vector2;
  119020. /**
  119021. * Define an offset for the layer in order to shift the texture.
  119022. */
  119023. offset: Vector2;
  119024. /**
  119025. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119026. */
  119027. alphaBlendingMode: number;
  119028. /**
  119029. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119030. * Alpha test will not mix with the background color in case of transparency.
  119031. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119032. */
  119033. alphaTest: boolean;
  119034. /**
  119035. * Define a mask to restrict the layer to only some of the scene cameras.
  119036. */
  119037. layerMask: number;
  119038. /**
  119039. * Define the list of render target the layer is visible into.
  119040. */
  119041. renderTargetTextures: RenderTargetTexture[];
  119042. /**
  119043. * Define if the layer is only used in renderTarget or if it also
  119044. * renders in the main frame buffer of the canvas.
  119045. */
  119046. renderOnlyInRenderTargetTextures: boolean;
  119047. private _scene;
  119048. private _vertexBuffers;
  119049. private _indexBuffer;
  119050. private _effect;
  119051. private _alphaTestEffect;
  119052. /**
  119053. * An event triggered when the layer is disposed.
  119054. */
  119055. onDisposeObservable: Observable<Layer>;
  119056. private _onDisposeObserver;
  119057. /**
  119058. * Back compatibility with callback before the onDisposeObservable existed.
  119059. * The set callback will be triggered when the layer has been disposed.
  119060. */
  119061. onDispose: () => void;
  119062. /**
  119063. * An event triggered before rendering the scene
  119064. */
  119065. onBeforeRenderObservable: Observable<Layer>;
  119066. private _onBeforeRenderObserver;
  119067. /**
  119068. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119069. * The set callback will be triggered just before rendering the layer.
  119070. */
  119071. onBeforeRender: () => void;
  119072. /**
  119073. * An event triggered after rendering the scene
  119074. */
  119075. onAfterRenderObservable: Observable<Layer>;
  119076. private _onAfterRenderObserver;
  119077. /**
  119078. * Back compatibility with callback before the onAfterRenderObservable existed.
  119079. * The set callback will be triggered just after rendering the layer.
  119080. */
  119081. onAfterRender: () => void;
  119082. /**
  119083. * Instantiates a new layer.
  119084. * This represents a full screen 2d layer.
  119085. * This can be useful to display a picture in the background of your scene for instance.
  119086. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119087. * @param name Define the name of the layer in the scene
  119088. * @param imgUrl Define the url of the texture to display in the layer
  119089. * @param scene Define the scene the layer belongs to
  119090. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119091. * @param color Defines a color for the layer
  119092. */
  119093. constructor(
  119094. /**
  119095. * Define the name of the layer.
  119096. */
  119097. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119098. private _createIndexBuffer;
  119099. /** @hidden */
  119100. _rebuild(): void;
  119101. /**
  119102. * Renders the layer in the scene.
  119103. */
  119104. render(): void;
  119105. /**
  119106. * Disposes and releases the associated ressources.
  119107. */
  119108. dispose(): void;
  119109. }
  119110. }
  119111. declare module BABYLON {
  119112. /** @hidden */
  119113. export var lensFlarePixelShader: {
  119114. name: string;
  119115. shader: string;
  119116. };
  119117. }
  119118. declare module BABYLON {
  119119. /** @hidden */
  119120. export var lensFlareVertexShader: {
  119121. name: string;
  119122. shader: string;
  119123. };
  119124. }
  119125. declare module BABYLON {
  119126. /**
  119127. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119128. * It is usually composed of several `lensFlare`.
  119129. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119130. */
  119131. export class LensFlareSystem {
  119132. /**
  119133. * Define the name of the lens flare system
  119134. */
  119135. name: string;
  119136. /**
  119137. * List of lens flares used in this system.
  119138. */
  119139. lensFlares: LensFlare[];
  119140. /**
  119141. * Define a limit from the border the lens flare can be visible.
  119142. */
  119143. borderLimit: number;
  119144. /**
  119145. * Define a viewport border we do not want to see the lens flare in.
  119146. */
  119147. viewportBorder: number;
  119148. /**
  119149. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119150. */
  119151. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119152. /**
  119153. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119154. */
  119155. layerMask: number;
  119156. /**
  119157. * Define the id of the lens flare system in the scene.
  119158. * (equal to name by default)
  119159. */
  119160. id: string;
  119161. private _scene;
  119162. private _emitter;
  119163. private _vertexBuffers;
  119164. private _indexBuffer;
  119165. private _effect;
  119166. private _positionX;
  119167. private _positionY;
  119168. private _isEnabled;
  119169. /** @hidden */
  119170. static _SceneComponentInitialization: (scene: Scene) => void;
  119171. /**
  119172. * Instantiates a lens flare system.
  119173. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119174. * It is usually composed of several `lensFlare`.
  119175. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119176. * @param name Define the name of the lens flare system in the scene
  119177. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119178. * @param scene Define the scene the lens flare system belongs to
  119179. */
  119180. constructor(
  119181. /**
  119182. * Define the name of the lens flare system
  119183. */
  119184. name: string, emitter: any, scene: Scene);
  119185. /**
  119186. * Define if the lens flare system is enabled.
  119187. */
  119188. isEnabled: boolean;
  119189. /**
  119190. * Get the scene the effects belongs to.
  119191. * @returns the scene holding the lens flare system
  119192. */
  119193. getScene(): Scene;
  119194. /**
  119195. * Get the emitter of the lens flare system.
  119196. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119197. * @returns the emitter of the lens flare system
  119198. */
  119199. getEmitter(): any;
  119200. /**
  119201. * Set the emitter of the lens flare system.
  119202. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119203. * @param newEmitter Define the new emitter of the system
  119204. */
  119205. setEmitter(newEmitter: any): void;
  119206. /**
  119207. * Get the lens flare system emitter position.
  119208. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119209. * @returns the position
  119210. */
  119211. getEmitterPosition(): Vector3;
  119212. /**
  119213. * @hidden
  119214. */
  119215. computeEffectivePosition(globalViewport: Viewport): boolean;
  119216. /** @hidden */
  119217. _isVisible(): boolean;
  119218. /**
  119219. * @hidden
  119220. */
  119221. render(): boolean;
  119222. /**
  119223. * Dispose and release the lens flare with its associated resources.
  119224. */
  119225. dispose(): void;
  119226. /**
  119227. * Parse a lens flare system from a JSON repressentation
  119228. * @param parsedLensFlareSystem Define the JSON to parse
  119229. * @param scene Define the scene the parsed system should be instantiated in
  119230. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119231. * @returns the parsed system
  119232. */
  119233. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119234. /**
  119235. * Serialize the current Lens Flare System into a JSON representation.
  119236. * @returns the serialized JSON
  119237. */
  119238. serialize(): any;
  119239. }
  119240. }
  119241. declare module BABYLON {
  119242. /**
  119243. * This represents one of the lens effect in a `lensFlareSystem`.
  119244. * It controls one of the indiviual texture used in the effect.
  119245. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119246. */
  119247. export class LensFlare {
  119248. /**
  119249. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119250. */
  119251. size: number;
  119252. /**
  119253. * 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.
  119254. */
  119255. position: number;
  119256. /**
  119257. * Define the lens color.
  119258. */
  119259. color: Color3;
  119260. /**
  119261. * Define the lens texture.
  119262. */
  119263. texture: Nullable<Texture>;
  119264. /**
  119265. * Define the alpha mode to render this particular lens.
  119266. */
  119267. alphaMode: number;
  119268. private _system;
  119269. /**
  119270. * Creates a new Lens Flare.
  119271. * This represents one of the lens effect in a `lensFlareSystem`.
  119272. * It controls one of the indiviual texture used in the effect.
  119273. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119274. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119275. * @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.
  119276. * @param color Define the lens color
  119277. * @param imgUrl Define the lens texture url
  119278. * @param system Define the `lensFlareSystem` this flare is part of
  119279. * @returns The newly created Lens Flare
  119280. */
  119281. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119282. /**
  119283. * Instantiates a new Lens Flare.
  119284. * This represents one of the lens effect in a `lensFlareSystem`.
  119285. * It controls one of the indiviual texture used in the effect.
  119286. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119287. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119288. * @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.
  119289. * @param color Define the lens color
  119290. * @param imgUrl Define the lens texture url
  119291. * @param system Define the `lensFlareSystem` this flare is part of
  119292. */
  119293. constructor(
  119294. /**
  119295. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119296. */
  119297. size: number,
  119298. /**
  119299. * 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.
  119300. */
  119301. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119302. /**
  119303. * Dispose and release the lens flare with its associated resources.
  119304. */
  119305. dispose(): void;
  119306. }
  119307. }
  119308. declare module BABYLON {
  119309. interface AbstractScene {
  119310. /**
  119311. * The list of lens flare system added to the scene
  119312. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119313. */
  119314. lensFlareSystems: Array<LensFlareSystem>;
  119315. /**
  119316. * Removes the given lens flare system from this scene.
  119317. * @param toRemove The lens flare system to remove
  119318. * @returns The index of the removed lens flare system
  119319. */
  119320. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119321. /**
  119322. * Adds the given lens flare system to this scene
  119323. * @param newLensFlareSystem The lens flare system to add
  119324. */
  119325. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119326. /**
  119327. * Gets a lens flare system using its name
  119328. * @param name defines the name to look for
  119329. * @returns the lens flare system or null if not found
  119330. */
  119331. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119332. /**
  119333. * Gets a lens flare system using its id
  119334. * @param id defines the id to look for
  119335. * @returns the lens flare system or null if not found
  119336. */
  119337. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119338. }
  119339. /**
  119340. * Defines the lens flare scene component responsible to manage any lens flares
  119341. * in a given scene.
  119342. */
  119343. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119344. /**
  119345. * The component name helpfull to identify the component in the list of scene components.
  119346. */
  119347. readonly name: string;
  119348. /**
  119349. * The scene the component belongs to.
  119350. */
  119351. scene: Scene;
  119352. /**
  119353. * Creates a new instance of the component for the given scene
  119354. * @param scene Defines the scene to register the component in
  119355. */
  119356. constructor(scene: Scene);
  119357. /**
  119358. * Registers the component in a given scene
  119359. */
  119360. register(): void;
  119361. /**
  119362. * Rebuilds the elements related to this component in case of
  119363. * context lost for instance.
  119364. */
  119365. rebuild(): void;
  119366. /**
  119367. * Adds all the elements from the container to the scene
  119368. * @param container the container holding the elements
  119369. */
  119370. addFromContainer(container: AbstractScene): void;
  119371. /**
  119372. * Removes all the elements in the container from the scene
  119373. * @param container contains the elements to remove
  119374. * @param dispose if the removed element should be disposed (default: false)
  119375. */
  119376. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119377. /**
  119378. * Serializes the component data to the specified json object
  119379. * @param serializationObject The object to serialize to
  119380. */
  119381. serialize(serializationObject: any): void;
  119382. /**
  119383. * Disposes the component and the associated ressources.
  119384. */
  119385. dispose(): void;
  119386. private _draw;
  119387. }
  119388. }
  119389. declare module BABYLON {
  119390. /**
  119391. * Defines the shadow generator component responsible to manage any shadow generators
  119392. * in a given scene.
  119393. */
  119394. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119395. /**
  119396. * The component name helpfull to identify the component in the list of scene components.
  119397. */
  119398. readonly name: string;
  119399. /**
  119400. * The scene the component belongs to.
  119401. */
  119402. scene: Scene;
  119403. /**
  119404. * Creates a new instance of the component for the given scene
  119405. * @param scene Defines the scene to register the component in
  119406. */
  119407. constructor(scene: Scene);
  119408. /**
  119409. * Registers the component in a given scene
  119410. */
  119411. register(): void;
  119412. /**
  119413. * Rebuilds the elements related to this component in case of
  119414. * context lost for instance.
  119415. */
  119416. rebuild(): void;
  119417. /**
  119418. * Serializes the component data to the specified json object
  119419. * @param serializationObject The object to serialize to
  119420. */
  119421. serialize(serializationObject: any): void;
  119422. /**
  119423. * Adds all the elements from the container to the scene
  119424. * @param container the container holding the elements
  119425. */
  119426. addFromContainer(container: AbstractScene): void;
  119427. /**
  119428. * Removes all the elements in the container from the scene
  119429. * @param container contains the elements to remove
  119430. * @param dispose if the removed element should be disposed (default: false)
  119431. */
  119432. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119433. /**
  119434. * Rebuilds the elements related to this component in case of
  119435. * context lost for instance.
  119436. */
  119437. dispose(): void;
  119438. private _gatherRenderTargets;
  119439. }
  119440. }
  119441. declare module BABYLON {
  119442. /**
  119443. * A point light is a light defined by an unique point in world space.
  119444. * The light is emitted in every direction from this point.
  119445. * A good example of a point light is a standard light bulb.
  119446. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119447. */
  119448. export class PointLight extends ShadowLight {
  119449. private _shadowAngle;
  119450. /**
  119451. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119452. * This specifies what angle the shadow will use to be created.
  119453. *
  119454. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119455. */
  119456. /**
  119457. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119458. * This specifies what angle the shadow will use to be created.
  119459. *
  119460. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119461. */
  119462. shadowAngle: number;
  119463. /**
  119464. * Gets the direction if it has been set.
  119465. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119466. */
  119467. /**
  119468. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119469. */
  119470. direction: Vector3;
  119471. /**
  119472. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119473. * A PointLight emits the light in every direction.
  119474. * It can cast shadows.
  119475. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119476. * ```javascript
  119477. * var pointLight = new PointLight("pl", camera.position, scene);
  119478. * ```
  119479. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119480. * @param name The light friendly name
  119481. * @param position The position of the point light in the scene
  119482. * @param scene The scene the lights belongs to
  119483. */
  119484. constructor(name: string, position: Vector3, scene: Scene);
  119485. /**
  119486. * Returns the string "PointLight"
  119487. * @returns the class name
  119488. */
  119489. getClassName(): string;
  119490. /**
  119491. * Returns the integer 0.
  119492. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119493. */
  119494. getTypeID(): number;
  119495. /**
  119496. * Specifies wether or not the shadowmap should be a cube texture.
  119497. * @returns true if the shadowmap needs to be a cube texture.
  119498. */
  119499. needCube(): boolean;
  119500. /**
  119501. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119502. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119503. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119504. */
  119505. getShadowDirection(faceIndex?: number): Vector3;
  119506. /**
  119507. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119508. * - fov = PI / 2
  119509. * - aspect ratio : 1.0
  119510. * - z-near and far equal to the active camera minZ and maxZ.
  119511. * Returns the PointLight.
  119512. */
  119513. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119514. protected _buildUniformLayout(): void;
  119515. /**
  119516. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119517. * @param effect The effect to update
  119518. * @param lightIndex The index of the light in the effect to update
  119519. * @returns The point light
  119520. */
  119521. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119523. /**
  119524. * Prepares the list of defines specific to the light type.
  119525. * @param defines the list of defines
  119526. * @param lightIndex defines the index of the light for the effect
  119527. */
  119528. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119529. }
  119530. }
  119531. declare module BABYLON {
  119532. /**
  119533. * Header information of HDR texture files.
  119534. */
  119535. export interface HDRInfo {
  119536. /**
  119537. * The height of the texture in pixels.
  119538. */
  119539. height: number;
  119540. /**
  119541. * The width of the texture in pixels.
  119542. */
  119543. width: number;
  119544. /**
  119545. * The index of the beginning of the data in the binary file.
  119546. */
  119547. dataPosition: number;
  119548. }
  119549. /**
  119550. * This groups tools to convert HDR texture to native colors array.
  119551. */
  119552. export class HDRTools {
  119553. private static Ldexp;
  119554. private static Rgbe2float;
  119555. private static readStringLine;
  119556. /**
  119557. * Reads header information from an RGBE texture stored in a native array.
  119558. * More information on this format are available here:
  119559. * https://en.wikipedia.org/wiki/RGBE_image_format
  119560. *
  119561. * @param uint8array The binary file stored in native array.
  119562. * @return The header information.
  119563. */
  119564. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119565. /**
  119566. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119567. * This RGBE texture needs to store the information as a panorama.
  119568. *
  119569. * More information on this format are available here:
  119570. * https://en.wikipedia.org/wiki/RGBE_image_format
  119571. *
  119572. * @param buffer The binary file stored in an array buffer.
  119573. * @param size The expected size of the extracted cubemap.
  119574. * @return The Cube Map information.
  119575. */
  119576. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119577. /**
  119578. * Returns the pixels data extracted from an RGBE texture.
  119579. * This pixels will be stored left to right up to down in the R G B order in one array.
  119580. *
  119581. * More information on this format are available here:
  119582. * https://en.wikipedia.org/wiki/RGBE_image_format
  119583. *
  119584. * @param uint8array The binary file stored in an array buffer.
  119585. * @param hdrInfo The header information of the file.
  119586. * @return The pixels data in RGB right to left up to down order.
  119587. */
  119588. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119589. private static RGBE_ReadPixels_RLE;
  119590. }
  119591. }
  119592. declare module BABYLON {
  119593. /**
  119594. * This represents a texture coming from an HDR input.
  119595. *
  119596. * The only supported format is currently panorama picture stored in RGBE format.
  119597. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119598. */
  119599. export class HDRCubeTexture extends BaseTexture {
  119600. private static _facesMapping;
  119601. private _generateHarmonics;
  119602. private _noMipmap;
  119603. private _textureMatrix;
  119604. private _size;
  119605. private _onLoad;
  119606. private _onError;
  119607. /**
  119608. * The texture URL.
  119609. */
  119610. url: string;
  119611. /**
  119612. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119613. */
  119614. coordinatesMode: number;
  119615. protected _isBlocking: boolean;
  119616. /**
  119617. * Sets wether or not the texture is blocking during loading.
  119618. */
  119619. /**
  119620. * Gets wether or not the texture is blocking during loading.
  119621. */
  119622. isBlocking: boolean;
  119623. protected _rotationY: number;
  119624. /**
  119625. * Sets texture matrix rotation angle around Y axis in radians.
  119626. */
  119627. /**
  119628. * Gets texture matrix rotation angle around Y axis radians.
  119629. */
  119630. rotationY: number;
  119631. /**
  119632. * Gets or sets the center of the bounding box associated with the cube texture
  119633. * It must define where the camera used to render the texture was set
  119634. */
  119635. boundingBoxPosition: Vector3;
  119636. private _boundingBoxSize;
  119637. /**
  119638. * Gets or sets the size of the bounding box associated with the cube texture
  119639. * When defined, the cubemap will switch to local mode
  119640. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119641. * @example https://www.babylonjs-playground.com/#RNASML
  119642. */
  119643. boundingBoxSize: Vector3;
  119644. /**
  119645. * Instantiates an HDRTexture from the following parameters.
  119646. *
  119647. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119648. * @param scene The scene the texture will be used in
  119649. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119650. * @param noMipmap Forces to not generate the mipmap if true
  119651. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119652. * @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)
  119653. * @param reserved Reserved flag for internal use.
  119654. */
  119655. 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>);
  119656. /**
  119657. * Get the current class name of the texture useful for serialization or dynamic coding.
  119658. * @returns "HDRCubeTexture"
  119659. */
  119660. getClassName(): string;
  119661. /**
  119662. * Occurs when the file is raw .hdr file.
  119663. */
  119664. private loadTexture;
  119665. clone(): HDRCubeTexture;
  119666. delayLoad(): void;
  119667. /**
  119668. * Get the texture reflection matrix used to rotate/transform the reflection.
  119669. * @returns the reflection matrix
  119670. */
  119671. getReflectionTextureMatrix(): Matrix;
  119672. /**
  119673. * Set the texture reflection matrix used to rotate/transform the reflection.
  119674. * @param value Define the reflection matrix to set
  119675. */
  119676. setReflectionTextureMatrix(value: Matrix): void;
  119677. /**
  119678. * Parses a JSON representation of an HDR Texture in order to create the texture
  119679. * @param parsedTexture Define the JSON representation
  119680. * @param scene Define the scene the texture should be created in
  119681. * @param rootUrl Define the root url in case we need to load relative dependencies
  119682. * @returns the newly created texture after parsing
  119683. */
  119684. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119685. serialize(): any;
  119686. }
  119687. }
  119688. declare module BABYLON {
  119689. /**
  119690. * Class used to control physics engine
  119691. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119692. */
  119693. export class PhysicsEngine implements IPhysicsEngine {
  119694. private _physicsPlugin;
  119695. /**
  119696. * Global value used to control the smallest number supported by the simulation
  119697. */
  119698. static Epsilon: number;
  119699. private _impostors;
  119700. private _joints;
  119701. /**
  119702. * Gets the gravity vector used by the simulation
  119703. */
  119704. gravity: Vector3;
  119705. /**
  119706. * Factory used to create the default physics plugin.
  119707. * @returns The default physics plugin
  119708. */
  119709. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119710. /**
  119711. * Creates a new Physics Engine
  119712. * @param gravity defines the gravity vector used by the simulation
  119713. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119714. */
  119715. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119716. /**
  119717. * Sets the gravity vector used by the simulation
  119718. * @param gravity defines the gravity vector to use
  119719. */
  119720. setGravity(gravity: Vector3): void;
  119721. /**
  119722. * Set the time step of the physics engine.
  119723. * Default is 1/60.
  119724. * To slow it down, enter 1/600 for example.
  119725. * To speed it up, 1/30
  119726. * @param newTimeStep defines the new timestep to apply to this world.
  119727. */
  119728. setTimeStep(newTimeStep?: number): void;
  119729. /**
  119730. * Get the time step of the physics engine.
  119731. * @returns the current time step
  119732. */
  119733. getTimeStep(): number;
  119734. /**
  119735. * Release all resources
  119736. */
  119737. dispose(): void;
  119738. /**
  119739. * Gets the name of the current physics plugin
  119740. * @returns the name of the plugin
  119741. */
  119742. getPhysicsPluginName(): string;
  119743. /**
  119744. * Adding a new impostor for the impostor tracking.
  119745. * This will be done by the impostor itself.
  119746. * @param impostor the impostor to add
  119747. */
  119748. addImpostor(impostor: PhysicsImpostor): void;
  119749. /**
  119750. * Remove an impostor from the engine.
  119751. * This impostor and its mesh will not longer be updated by the physics engine.
  119752. * @param impostor the impostor to remove
  119753. */
  119754. removeImpostor(impostor: PhysicsImpostor): void;
  119755. /**
  119756. * Add a joint to the physics engine
  119757. * @param mainImpostor defines the main impostor to which the joint is added.
  119758. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119759. * @param joint defines the joint that will connect both impostors.
  119760. */
  119761. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119762. /**
  119763. * Removes a joint from the simulation
  119764. * @param mainImpostor defines the impostor used with the joint
  119765. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119766. * @param joint defines the joint to remove
  119767. */
  119768. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119769. /**
  119770. * Called by the scene. No need to call it.
  119771. * @param delta defines the timespam between frames
  119772. */
  119773. _step(delta: number): void;
  119774. /**
  119775. * Gets the current plugin used to run the simulation
  119776. * @returns current plugin
  119777. */
  119778. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119779. /**
  119780. * Gets the list of physic impostors
  119781. * @returns an array of PhysicsImpostor
  119782. */
  119783. getImpostors(): Array<PhysicsImpostor>;
  119784. /**
  119785. * Gets the impostor for a physics enabled object
  119786. * @param object defines the object impersonated by the impostor
  119787. * @returns the PhysicsImpostor or null if not found
  119788. */
  119789. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119790. /**
  119791. * Gets the impostor for a physics body object
  119792. * @param body defines physics body used by the impostor
  119793. * @returns the PhysicsImpostor or null if not found
  119794. */
  119795. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119796. /**
  119797. * Does a raycast in the physics world
  119798. * @param from when should the ray start?
  119799. * @param to when should the ray end?
  119800. * @returns PhysicsRaycastResult
  119801. */
  119802. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119803. }
  119804. }
  119805. declare module BABYLON {
  119806. /** @hidden */
  119807. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119808. private _useDeltaForWorldStep;
  119809. world: any;
  119810. name: string;
  119811. private _physicsMaterials;
  119812. private _fixedTimeStep;
  119813. private _cannonRaycastResult;
  119814. private _raycastResult;
  119815. private _physicsBodysToRemoveAfterStep;
  119816. BJSCANNON: any;
  119817. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119818. setGravity(gravity: Vector3): void;
  119819. setTimeStep(timeStep: number): void;
  119820. getTimeStep(): number;
  119821. executeStep(delta: number): void;
  119822. private _removeMarkedPhysicsBodiesFromWorld;
  119823. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119824. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119825. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119826. private _processChildMeshes;
  119827. removePhysicsBody(impostor: PhysicsImpostor): void;
  119828. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119829. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119830. private _addMaterial;
  119831. private _checkWithEpsilon;
  119832. private _createShape;
  119833. private _createHeightmap;
  119834. private _minus90X;
  119835. private _plus90X;
  119836. private _tmpPosition;
  119837. private _tmpDeltaPosition;
  119838. private _tmpUnityRotation;
  119839. private _updatePhysicsBodyTransformation;
  119840. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119841. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119842. isSupported(): boolean;
  119843. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119844. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119845. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119846. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119847. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119848. getBodyMass(impostor: PhysicsImpostor): number;
  119849. getBodyFriction(impostor: PhysicsImpostor): number;
  119850. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119851. getBodyRestitution(impostor: PhysicsImpostor): number;
  119852. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119853. sleepBody(impostor: PhysicsImpostor): void;
  119854. wakeUpBody(impostor: PhysicsImpostor): void;
  119855. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119856. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119857. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119858. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119859. getRadius(impostor: PhysicsImpostor): number;
  119860. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119861. dispose(): void;
  119862. private _extendNamespace;
  119863. /**
  119864. * Does a raycast in the physics world
  119865. * @param from when should the ray start?
  119866. * @param to when should the ray end?
  119867. * @returns PhysicsRaycastResult
  119868. */
  119869. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119870. }
  119871. }
  119872. declare module BABYLON {
  119873. /** @hidden */
  119874. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119875. world: any;
  119876. name: string;
  119877. BJSOIMO: any;
  119878. private _raycastResult;
  119879. constructor(iterations?: number, oimoInjection?: any);
  119880. setGravity(gravity: Vector3): void;
  119881. setTimeStep(timeStep: number): void;
  119882. getTimeStep(): number;
  119883. private _tmpImpostorsArray;
  119884. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119885. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119887. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119888. private _tmpPositionVector;
  119889. removePhysicsBody(impostor: PhysicsImpostor): void;
  119890. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119891. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119892. isSupported(): boolean;
  119893. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119894. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119895. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119896. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119897. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119899. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119900. getBodyMass(impostor: PhysicsImpostor): number;
  119901. getBodyFriction(impostor: PhysicsImpostor): number;
  119902. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119903. getBodyRestitution(impostor: PhysicsImpostor): number;
  119904. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119905. sleepBody(impostor: PhysicsImpostor): void;
  119906. wakeUpBody(impostor: PhysicsImpostor): void;
  119907. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119908. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119909. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119910. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119911. getRadius(impostor: PhysicsImpostor): number;
  119912. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119913. dispose(): void;
  119914. /**
  119915. * Does a raycast in the physics world
  119916. * @param from when should the ray start?
  119917. * @param to when should the ray end?
  119918. * @returns PhysicsRaycastResult
  119919. */
  119920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119921. }
  119922. }
  119923. declare module BABYLON {
  119924. /**
  119925. * Class containing static functions to help procedurally build meshes
  119926. */
  119927. export class RibbonBuilder {
  119928. /**
  119929. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119930. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119931. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119932. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119933. * * 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
  119934. * * 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
  119935. * * 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
  119936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119939. * * 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
  119940. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119941. * * 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
  119942. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119944. * @param name defines the name of the mesh
  119945. * @param options defines the options used to create the mesh
  119946. * @param scene defines the hosting scene
  119947. * @returns the ribbon mesh
  119948. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119950. */
  119951. static CreateRibbon(name: string, options: {
  119952. pathArray: Vector3[][];
  119953. closeArray?: boolean;
  119954. closePath?: boolean;
  119955. offset?: number;
  119956. updatable?: boolean;
  119957. sideOrientation?: number;
  119958. frontUVs?: Vector4;
  119959. backUVs?: Vector4;
  119960. instance?: Mesh;
  119961. invertUV?: boolean;
  119962. uvs?: Vector2[];
  119963. colors?: Color4[];
  119964. }, scene?: Nullable<Scene>): Mesh;
  119965. }
  119966. }
  119967. declare module BABYLON {
  119968. /**
  119969. * Class containing static functions to help procedurally build meshes
  119970. */
  119971. export class ShapeBuilder {
  119972. /**
  119973. * 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.
  119974. * * 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.
  119975. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119976. * * 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.
  119977. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119978. * * 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
  119979. * * 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
  119980. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119985. * @param name defines the name of the mesh
  119986. * @param options defines the options used to create the mesh
  119987. * @param scene defines the hosting scene
  119988. * @returns the extruded shape mesh
  119989. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119991. */
  119992. static ExtrudeShape(name: string, options: {
  119993. shape: Vector3[];
  119994. path: Vector3[];
  119995. scale?: number;
  119996. rotation?: number;
  119997. cap?: number;
  119998. updatable?: boolean;
  119999. sideOrientation?: number;
  120000. frontUVs?: Vector4;
  120001. backUVs?: Vector4;
  120002. instance?: Mesh;
  120003. invertUV?: boolean;
  120004. }, scene?: Nullable<Scene>): Mesh;
  120005. /**
  120006. * Creates an custom extruded shape mesh.
  120007. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120008. * * 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.
  120009. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120010. * * 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
  120011. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120012. * * 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
  120013. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120014. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120015. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120016. * * 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
  120017. * * 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
  120018. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120021. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120023. * @param name defines the name of the mesh
  120024. * @param options defines the options used to create the mesh
  120025. * @param scene defines the hosting scene
  120026. * @returns the custom extruded shape mesh
  120027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120030. */
  120031. static ExtrudeShapeCustom(name: string, options: {
  120032. shape: Vector3[];
  120033. path: Vector3[];
  120034. scaleFunction?: any;
  120035. rotationFunction?: any;
  120036. ribbonCloseArray?: boolean;
  120037. ribbonClosePath?: boolean;
  120038. cap?: number;
  120039. updatable?: boolean;
  120040. sideOrientation?: number;
  120041. frontUVs?: Vector4;
  120042. backUVs?: Vector4;
  120043. instance?: Mesh;
  120044. invertUV?: boolean;
  120045. }, scene?: Nullable<Scene>): Mesh;
  120046. private static _ExtrudeShapeGeneric;
  120047. }
  120048. }
  120049. declare module BABYLON {
  120050. /**
  120051. * AmmoJS Physics plugin
  120052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120053. * @see https://github.com/kripken/ammo.js/
  120054. */
  120055. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120056. private _useDeltaForWorldStep;
  120057. /**
  120058. * Reference to the Ammo library
  120059. */
  120060. bjsAMMO: any;
  120061. /**
  120062. * Created ammoJS world which physics bodies are added to
  120063. */
  120064. world: any;
  120065. /**
  120066. * Name of the plugin
  120067. */
  120068. name: string;
  120069. private _timeStep;
  120070. private _fixedTimeStep;
  120071. private _maxSteps;
  120072. private _tmpQuaternion;
  120073. private _tmpAmmoTransform;
  120074. private _tmpAmmoQuaternion;
  120075. private _tmpAmmoConcreteContactResultCallback;
  120076. private _collisionConfiguration;
  120077. private _dispatcher;
  120078. private _overlappingPairCache;
  120079. private _solver;
  120080. private _softBodySolver;
  120081. private _tmpAmmoVectorA;
  120082. private _tmpAmmoVectorB;
  120083. private _tmpAmmoVectorC;
  120084. private _tmpAmmoVectorD;
  120085. private _tmpContactCallbackResult;
  120086. private _tmpAmmoVectorRCA;
  120087. private _tmpAmmoVectorRCB;
  120088. private _raycastResult;
  120089. private static readonly DISABLE_COLLISION_FLAG;
  120090. private static readonly KINEMATIC_FLAG;
  120091. private static readonly DISABLE_DEACTIVATION_FLAG;
  120092. /**
  120093. * Initializes the ammoJS plugin
  120094. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120095. * @param ammoInjection can be used to inject your own ammo reference
  120096. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120097. */
  120098. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120099. /**
  120100. * Sets the gravity of the physics world (m/(s^2))
  120101. * @param gravity Gravity to set
  120102. */
  120103. setGravity(gravity: Vector3): void;
  120104. /**
  120105. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120106. * @param timeStep timestep to use in seconds
  120107. */
  120108. setTimeStep(timeStep: number): void;
  120109. /**
  120110. * 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)
  120111. * @param fixedTimeStep fixedTimeStep to use in seconds
  120112. */
  120113. setFixedTimeStep(fixedTimeStep: number): void;
  120114. /**
  120115. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120116. * @param maxSteps the maximum number of steps by the physics engine per frame
  120117. */
  120118. setMaxSteps(maxSteps: number): void;
  120119. /**
  120120. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120121. * @returns the current timestep in seconds
  120122. */
  120123. getTimeStep(): number;
  120124. private _isImpostorInContact;
  120125. private _isImpostorPairInContact;
  120126. private _stepSimulation;
  120127. /**
  120128. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120129. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120130. * After the step the babylon meshes are set to the position of the physics imposters
  120131. * @param delta amount of time to step forward
  120132. * @param impostors array of imposters to update before/after the step
  120133. */
  120134. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120135. /**
  120136. * Update babylon mesh to match physics world object
  120137. * @param impostor imposter to match
  120138. */
  120139. private _afterSoftStep;
  120140. /**
  120141. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120142. * @param impostor imposter to match
  120143. */
  120144. private _ropeStep;
  120145. /**
  120146. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120147. * @param impostor imposter to match
  120148. */
  120149. private _softbodyOrClothStep;
  120150. private _tmpVector;
  120151. private _tmpMatrix;
  120152. /**
  120153. * Applies an impulse on the imposter
  120154. * @param impostor imposter to apply impulse to
  120155. * @param force amount of force to be applied to the imposter
  120156. * @param contactPoint the location to apply the impulse on the imposter
  120157. */
  120158. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120159. /**
  120160. * Applies a force on the imposter
  120161. * @param impostor imposter to apply force
  120162. * @param force amount of force to be applied to the imposter
  120163. * @param contactPoint the location to apply the force on the imposter
  120164. */
  120165. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120166. /**
  120167. * Creates a physics body using the plugin
  120168. * @param impostor the imposter to create the physics body on
  120169. */
  120170. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120171. /**
  120172. * Removes the physics body from the imposter and disposes of the body's memory
  120173. * @param impostor imposter to remove the physics body from
  120174. */
  120175. removePhysicsBody(impostor: PhysicsImpostor): void;
  120176. /**
  120177. * Generates a joint
  120178. * @param impostorJoint the imposter joint to create the joint with
  120179. */
  120180. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120181. /**
  120182. * Removes a joint
  120183. * @param impostorJoint the imposter joint to remove the joint from
  120184. */
  120185. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120186. private _addMeshVerts;
  120187. /**
  120188. * Initialise the soft body vertices to match its object's (mesh) vertices
  120189. * Softbody vertices (nodes) are in world space and to match this
  120190. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120191. * @param impostor to create the softbody for
  120192. */
  120193. private _softVertexData;
  120194. /**
  120195. * Create an impostor's soft body
  120196. * @param impostor to create the softbody for
  120197. */
  120198. private _createSoftbody;
  120199. /**
  120200. * Create cloth for an impostor
  120201. * @param impostor to create the softbody for
  120202. */
  120203. private _createCloth;
  120204. /**
  120205. * Create rope for an impostor
  120206. * @param impostor to create the softbody for
  120207. */
  120208. private _createRope;
  120209. private _addHullVerts;
  120210. private _createShape;
  120211. /**
  120212. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120213. * @param impostor imposter containing the physics body and babylon object
  120214. */
  120215. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120216. /**
  120217. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120218. * @param impostor imposter containing the physics body and babylon object
  120219. * @param newPosition new position
  120220. * @param newRotation new rotation
  120221. */
  120222. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120223. /**
  120224. * If this plugin is supported
  120225. * @returns true if its supported
  120226. */
  120227. isSupported(): boolean;
  120228. /**
  120229. * Sets the linear velocity of the physics body
  120230. * @param impostor imposter to set the velocity on
  120231. * @param velocity velocity to set
  120232. */
  120233. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120234. /**
  120235. * Sets the angular velocity of the physics body
  120236. * @param impostor imposter to set the velocity on
  120237. * @param velocity velocity to set
  120238. */
  120239. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120240. /**
  120241. * gets the linear velocity
  120242. * @param impostor imposter to get linear velocity from
  120243. * @returns linear velocity
  120244. */
  120245. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120246. /**
  120247. * gets the angular velocity
  120248. * @param impostor imposter to get angular velocity from
  120249. * @returns angular velocity
  120250. */
  120251. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120252. /**
  120253. * Sets the mass of physics body
  120254. * @param impostor imposter to set the mass on
  120255. * @param mass mass to set
  120256. */
  120257. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120258. /**
  120259. * Gets the mass of the physics body
  120260. * @param impostor imposter to get the mass from
  120261. * @returns mass
  120262. */
  120263. getBodyMass(impostor: PhysicsImpostor): number;
  120264. /**
  120265. * Gets friction of the impostor
  120266. * @param impostor impostor to get friction from
  120267. * @returns friction value
  120268. */
  120269. getBodyFriction(impostor: PhysicsImpostor): number;
  120270. /**
  120271. * Sets friction of the impostor
  120272. * @param impostor impostor to set friction on
  120273. * @param friction friction value
  120274. */
  120275. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120276. /**
  120277. * Gets restitution of the impostor
  120278. * @param impostor impostor to get restitution from
  120279. * @returns restitution value
  120280. */
  120281. getBodyRestitution(impostor: PhysicsImpostor): number;
  120282. /**
  120283. * Sets resitution of the impostor
  120284. * @param impostor impostor to set resitution on
  120285. * @param restitution resitution value
  120286. */
  120287. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120288. /**
  120289. * Gets pressure inside the impostor
  120290. * @param impostor impostor to get pressure from
  120291. * @returns pressure value
  120292. */
  120293. getBodyPressure(impostor: PhysicsImpostor): number;
  120294. /**
  120295. * Sets pressure inside a soft body impostor
  120296. * Cloth and rope must remain 0 pressure
  120297. * @param impostor impostor to set pressure on
  120298. * @param pressure pressure value
  120299. */
  120300. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120301. /**
  120302. * Gets stiffness of the impostor
  120303. * @param impostor impostor to get stiffness from
  120304. * @returns pressure value
  120305. */
  120306. getBodyStiffness(impostor: PhysicsImpostor): number;
  120307. /**
  120308. * Sets stiffness of the impostor
  120309. * @param impostor impostor to set stiffness on
  120310. * @param stiffness stiffness value from 0 to 1
  120311. */
  120312. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120313. /**
  120314. * Gets velocityIterations of the impostor
  120315. * @param impostor impostor to get velocity iterations from
  120316. * @returns velocityIterations value
  120317. */
  120318. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120319. /**
  120320. * Sets velocityIterations of the impostor
  120321. * @param impostor impostor to set velocity iterations on
  120322. * @param velocityIterations velocityIterations value
  120323. */
  120324. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120325. /**
  120326. * Gets positionIterations of the impostor
  120327. * @param impostor impostor to get position iterations from
  120328. * @returns positionIterations value
  120329. */
  120330. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120331. /**
  120332. * Sets positionIterations of the impostor
  120333. * @param impostor impostor to set position on
  120334. * @param positionIterations positionIterations value
  120335. */
  120336. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120337. /**
  120338. * Append an anchor to a cloth object
  120339. * @param impostor is the cloth impostor to add anchor to
  120340. * @param otherImpostor is the rigid impostor to anchor to
  120341. * @param width ratio across width from 0 to 1
  120342. * @param height ratio up height from 0 to 1
  120343. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120344. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120345. */
  120346. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120347. /**
  120348. * Append an hook to a rope object
  120349. * @param impostor is the rope impostor to add hook to
  120350. * @param otherImpostor is the rigid impostor to hook to
  120351. * @param length ratio along the rope from 0 to 1
  120352. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120353. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120354. */
  120355. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120356. /**
  120357. * Sleeps the physics body and stops it from being active
  120358. * @param impostor impostor to sleep
  120359. */
  120360. sleepBody(impostor: PhysicsImpostor): void;
  120361. /**
  120362. * Activates the physics body
  120363. * @param impostor impostor to activate
  120364. */
  120365. wakeUpBody(impostor: PhysicsImpostor): void;
  120366. /**
  120367. * Updates the distance parameters of the joint
  120368. * @param joint joint to update
  120369. * @param maxDistance maximum distance of the joint
  120370. * @param minDistance minimum distance of the joint
  120371. */
  120372. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120373. /**
  120374. * Sets a motor on the joint
  120375. * @param joint joint to set motor on
  120376. * @param speed speed of the motor
  120377. * @param maxForce maximum force of the motor
  120378. * @param motorIndex index of the motor
  120379. */
  120380. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120381. /**
  120382. * Sets the motors limit
  120383. * @param joint joint to set limit on
  120384. * @param upperLimit upper limit
  120385. * @param lowerLimit lower limit
  120386. */
  120387. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120388. /**
  120389. * Syncs the position and rotation of a mesh with the impostor
  120390. * @param mesh mesh to sync
  120391. * @param impostor impostor to update the mesh with
  120392. */
  120393. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120394. /**
  120395. * Gets the radius of the impostor
  120396. * @param impostor impostor to get radius from
  120397. * @returns the radius
  120398. */
  120399. getRadius(impostor: PhysicsImpostor): number;
  120400. /**
  120401. * Gets the box size of the impostor
  120402. * @param impostor impostor to get box size from
  120403. * @param result the resulting box size
  120404. */
  120405. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120406. /**
  120407. * Disposes of the impostor
  120408. */
  120409. dispose(): void;
  120410. /**
  120411. * Does a raycast in the physics world
  120412. * @param from when should the ray start?
  120413. * @param to when should the ray end?
  120414. * @returns PhysicsRaycastResult
  120415. */
  120416. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120417. }
  120418. }
  120419. declare module BABYLON {
  120420. interface AbstractScene {
  120421. /**
  120422. * The list of reflection probes added to the scene
  120423. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120424. */
  120425. reflectionProbes: Array<ReflectionProbe>;
  120426. /**
  120427. * Removes the given reflection probe from this scene.
  120428. * @param toRemove The reflection probe to remove
  120429. * @returns The index of the removed reflection probe
  120430. */
  120431. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120432. /**
  120433. * Adds the given reflection probe to this scene.
  120434. * @param newReflectionProbe The reflection probe to add
  120435. */
  120436. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120437. }
  120438. /**
  120439. * Class used to generate realtime reflection / refraction cube textures
  120440. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120441. */
  120442. export class ReflectionProbe {
  120443. /** defines the name of the probe */
  120444. name: string;
  120445. private _scene;
  120446. private _renderTargetTexture;
  120447. private _projectionMatrix;
  120448. private _viewMatrix;
  120449. private _target;
  120450. private _add;
  120451. private _attachedMesh;
  120452. private _invertYAxis;
  120453. /** Gets or sets probe position (center of the cube map) */
  120454. position: Vector3;
  120455. /**
  120456. * Creates a new reflection probe
  120457. * @param name defines the name of the probe
  120458. * @param size defines the texture resolution (for each face)
  120459. * @param scene defines the hosting scene
  120460. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120461. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120462. */
  120463. constructor(
  120464. /** defines the name of the probe */
  120465. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120466. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120467. samples: number;
  120468. /** Gets or sets the refresh rate to use (on every frame by default) */
  120469. refreshRate: number;
  120470. /**
  120471. * Gets the hosting scene
  120472. * @returns a Scene
  120473. */
  120474. getScene(): Scene;
  120475. /** Gets the internal CubeTexture used to render to */
  120476. readonly cubeTexture: RenderTargetTexture;
  120477. /** Gets the list of meshes to render */
  120478. readonly renderList: Nullable<AbstractMesh[]>;
  120479. /**
  120480. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120481. * @param mesh defines the mesh to attach to
  120482. */
  120483. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120484. /**
  120485. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120486. * @param renderingGroupId The rendering group id corresponding to its index
  120487. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120488. */
  120489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120490. /**
  120491. * Clean all associated resources
  120492. */
  120493. dispose(): void;
  120494. /**
  120495. * Converts the reflection probe information to a readable string for debug purpose.
  120496. * @param fullDetails Supports for multiple levels of logging within scene loading
  120497. * @returns the human readable reflection probe info
  120498. */
  120499. toString(fullDetails?: boolean): string;
  120500. /**
  120501. * Get the class name of the relfection probe.
  120502. * @returns "ReflectionProbe"
  120503. */
  120504. getClassName(): string;
  120505. /**
  120506. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120507. * @returns The JSON representation of the texture
  120508. */
  120509. serialize(): any;
  120510. /**
  120511. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120512. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120513. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120514. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120515. * @returns The parsed reflection probe if successful
  120516. */
  120517. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120518. }
  120519. }
  120520. declare module BABYLON {
  120521. /** @hidden */
  120522. export var _BabylonLoaderRegistered: boolean;
  120523. /**
  120524. * Helps setting up some configuration for the babylon file loader.
  120525. */
  120526. export class BabylonFileLoaderConfiguration {
  120527. /**
  120528. * The loader does not allow injecting custom physix engine into the plugins.
  120529. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120530. * So you could set this variable to your engine import to make it work.
  120531. */
  120532. static LoaderInjectedPhysicsEngine: any;
  120533. }
  120534. }
  120535. declare module BABYLON {
  120536. /**
  120537. * The Physically based simple base material of BJS.
  120538. *
  120539. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120540. * It is used as the base class for both the specGloss and metalRough conventions.
  120541. */
  120542. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120543. /**
  120544. * Number of Simultaneous lights allowed on the material.
  120545. */
  120546. maxSimultaneousLights: number;
  120547. /**
  120548. * If sets to true, disables all the lights affecting the material.
  120549. */
  120550. disableLighting: boolean;
  120551. /**
  120552. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120553. */
  120554. environmentTexture: BaseTexture;
  120555. /**
  120556. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120557. */
  120558. invertNormalMapX: boolean;
  120559. /**
  120560. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120561. */
  120562. invertNormalMapY: boolean;
  120563. /**
  120564. * Normal map used in the model.
  120565. */
  120566. normalTexture: BaseTexture;
  120567. /**
  120568. * Emissivie color used to self-illuminate the model.
  120569. */
  120570. emissiveColor: Color3;
  120571. /**
  120572. * Emissivie texture used to self-illuminate the model.
  120573. */
  120574. emissiveTexture: BaseTexture;
  120575. /**
  120576. * Occlusion Channel Strenght.
  120577. */
  120578. occlusionStrength: number;
  120579. /**
  120580. * Occlusion Texture of the material (adding extra occlusion effects).
  120581. */
  120582. occlusionTexture: BaseTexture;
  120583. /**
  120584. * Defines the alpha limits in alpha test mode.
  120585. */
  120586. alphaCutOff: number;
  120587. /**
  120588. * Gets the current double sided mode.
  120589. */
  120590. /**
  120591. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120592. */
  120593. doubleSided: boolean;
  120594. /**
  120595. * Stores the pre-calculated light information of a mesh in a texture.
  120596. */
  120597. lightmapTexture: BaseTexture;
  120598. /**
  120599. * If true, the light map contains occlusion information instead of lighting info.
  120600. */
  120601. useLightmapAsShadowmap: boolean;
  120602. /**
  120603. * Instantiates a new PBRMaterial instance.
  120604. *
  120605. * @param name The material name
  120606. * @param scene The scene the material will be use in.
  120607. */
  120608. constructor(name: string, scene: Scene);
  120609. getClassName(): string;
  120610. }
  120611. }
  120612. declare module BABYLON {
  120613. /**
  120614. * The PBR material of BJS following the metal roughness convention.
  120615. *
  120616. * This fits to the PBR convention in the GLTF definition:
  120617. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120618. */
  120619. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120620. /**
  120621. * The base color has two different interpretations depending on the value of metalness.
  120622. * When the material is a metal, the base color is the specific measured reflectance value
  120623. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120624. * of the material.
  120625. */
  120626. baseColor: Color3;
  120627. /**
  120628. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120629. * well as opacity information in the alpha channel.
  120630. */
  120631. baseTexture: BaseTexture;
  120632. /**
  120633. * Specifies the metallic scalar value of the material.
  120634. * Can also be used to scale the metalness values of the metallic texture.
  120635. */
  120636. metallic: number;
  120637. /**
  120638. * Specifies the roughness scalar value of the material.
  120639. * Can also be used to scale the roughness values of the metallic texture.
  120640. */
  120641. roughness: number;
  120642. /**
  120643. * Texture containing both the metallic value in the B channel and the
  120644. * roughness value in the G channel to keep better precision.
  120645. */
  120646. metallicRoughnessTexture: BaseTexture;
  120647. /**
  120648. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120649. *
  120650. * @param name The material name
  120651. * @param scene The scene the material will be use in.
  120652. */
  120653. constructor(name: string, scene: Scene);
  120654. /**
  120655. * Return the currrent class name of the material.
  120656. */
  120657. getClassName(): string;
  120658. /**
  120659. * Makes a duplicate of the current material.
  120660. * @param name - name to use for the new material.
  120661. */
  120662. clone(name: string): PBRMetallicRoughnessMaterial;
  120663. /**
  120664. * Serialize the material to a parsable JSON object.
  120665. */
  120666. serialize(): any;
  120667. /**
  120668. * Parses a JSON object correponding to the serialize function.
  120669. */
  120670. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120671. }
  120672. }
  120673. declare module BABYLON {
  120674. /**
  120675. * The PBR material of BJS following the specular glossiness convention.
  120676. *
  120677. * This fits to the PBR convention in the GLTF definition:
  120678. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120679. */
  120680. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120681. /**
  120682. * Specifies the diffuse color of the material.
  120683. */
  120684. diffuseColor: Color3;
  120685. /**
  120686. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120687. * channel.
  120688. */
  120689. diffuseTexture: BaseTexture;
  120690. /**
  120691. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120692. */
  120693. specularColor: Color3;
  120694. /**
  120695. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120696. */
  120697. glossiness: number;
  120698. /**
  120699. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120700. */
  120701. specularGlossinessTexture: BaseTexture;
  120702. /**
  120703. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120704. *
  120705. * @param name The material name
  120706. * @param scene The scene the material will be use in.
  120707. */
  120708. constructor(name: string, scene: Scene);
  120709. /**
  120710. * Return the currrent class name of the material.
  120711. */
  120712. getClassName(): string;
  120713. /**
  120714. * Makes a duplicate of the current material.
  120715. * @param name - name to use for the new material.
  120716. */
  120717. clone(name: string): PBRSpecularGlossinessMaterial;
  120718. /**
  120719. * Serialize the material to a parsable JSON object.
  120720. */
  120721. serialize(): any;
  120722. /**
  120723. * Parses a JSON object correponding to the serialize function.
  120724. */
  120725. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120726. }
  120727. }
  120728. declare module BABYLON {
  120729. /**
  120730. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120731. * It can help converting any input color in a desired output one. This can then be used to create effects
  120732. * from sepia, black and white to sixties or futuristic rendering...
  120733. *
  120734. * The only supported format is currently 3dl.
  120735. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120736. */
  120737. export class ColorGradingTexture extends BaseTexture {
  120738. /**
  120739. * The current texture matrix. (will always be identity in color grading texture)
  120740. */
  120741. private _textureMatrix;
  120742. /**
  120743. * The texture URL.
  120744. */
  120745. url: string;
  120746. /**
  120747. * Empty line regex stored for GC.
  120748. */
  120749. private static _noneEmptyLineRegex;
  120750. private _engine;
  120751. /**
  120752. * Instantiates a ColorGradingTexture from the following parameters.
  120753. *
  120754. * @param url The location of the color gradind data (currently only supporting 3dl)
  120755. * @param scene The scene the texture will be used in
  120756. */
  120757. constructor(url: string, scene: Scene);
  120758. /**
  120759. * Returns the texture matrix used in most of the material.
  120760. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120761. */
  120762. getTextureMatrix(): Matrix;
  120763. /**
  120764. * Occurs when the file being loaded is a .3dl LUT file.
  120765. */
  120766. private load3dlTexture;
  120767. /**
  120768. * Starts the loading process of the texture.
  120769. */
  120770. private loadTexture;
  120771. /**
  120772. * Clones the color gradind texture.
  120773. */
  120774. clone(): ColorGradingTexture;
  120775. /**
  120776. * Called during delayed load for textures.
  120777. */
  120778. delayLoad(): void;
  120779. /**
  120780. * Parses a color grading texture serialized by Babylon.
  120781. * @param parsedTexture The texture information being parsedTexture
  120782. * @param scene The scene to load the texture in
  120783. * @param rootUrl The root url of the data assets to load
  120784. * @return A color gradind texture
  120785. */
  120786. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120787. /**
  120788. * Serializes the LUT texture to json format.
  120789. */
  120790. serialize(): any;
  120791. }
  120792. }
  120793. declare module BABYLON {
  120794. /**
  120795. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120796. */
  120797. export class EquiRectangularCubeTexture extends BaseTexture {
  120798. /** The six faces of the cube. */
  120799. private static _FacesMapping;
  120800. private _noMipmap;
  120801. private _onLoad;
  120802. private _onError;
  120803. /** The size of the cubemap. */
  120804. private _size;
  120805. /** The buffer of the image. */
  120806. private _buffer;
  120807. /** The width of the input image. */
  120808. private _width;
  120809. /** The height of the input image. */
  120810. private _height;
  120811. /** The URL to the image. */
  120812. url: string;
  120813. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120814. coordinatesMode: number;
  120815. /**
  120816. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120817. * @param url The location of the image
  120818. * @param scene The scene the texture will be used in
  120819. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120820. * @param noMipmap Forces to not generate the mipmap if true
  120821. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120822. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120823. * @param onLoad — defines a callback called when texture is loaded
  120824. * @param onError — defines a callback called if there is an error
  120825. */
  120826. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120827. /**
  120828. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120829. */
  120830. private loadImage;
  120831. /**
  120832. * Convert the image buffer into a cubemap and create a CubeTexture.
  120833. */
  120834. private loadTexture;
  120835. /**
  120836. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120837. * @param buffer The ArrayBuffer that should be converted.
  120838. * @returns The buffer as Float32Array.
  120839. */
  120840. private getFloat32ArrayFromArrayBuffer;
  120841. /**
  120842. * Get the current class name of the texture useful for serialization or dynamic coding.
  120843. * @returns "EquiRectangularCubeTexture"
  120844. */
  120845. getClassName(): string;
  120846. /**
  120847. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120848. * @returns A clone of the current EquiRectangularCubeTexture.
  120849. */
  120850. clone(): EquiRectangularCubeTexture;
  120851. }
  120852. }
  120853. declare module BABYLON {
  120854. /**
  120855. * Based on jsTGALoader - Javascript loader for TGA file
  120856. * By Vincent Thibault
  120857. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120858. */
  120859. export class TGATools {
  120860. private static _TYPE_INDEXED;
  120861. private static _TYPE_RGB;
  120862. private static _TYPE_GREY;
  120863. private static _TYPE_RLE_INDEXED;
  120864. private static _TYPE_RLE_RGB;
  120865. private static _TYPE_RLE_GREY;
  120866. private static _ORIGIN_MASK;
  120867. private static _ORIGIN_SHIFT;
  120868. private static _ORIGIN_BL;
  120869. private static _ORIGIN_BR;
  120870. private static _ORIGIN_UL;
  120871. private static _ORIGIN_UR;
  120872. /**
  120873. * Gets the header of a TGA file
  120874. * @param data defines the TGA data
  120875. * @returns the header
  120876. */
  120877. static GetTGAHeader(data: Uint8Array): any;
  120878. /**
  120879. * Uploads TGA content to a Babylon Texture
  120880. * @hidden
  120881. */
  120882. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120883. /** @hidden */
  120884. 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;
  120885. /** @hidden */
  120886. 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;
  120887. /** @hidden */
  120888. 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;
  120889. /** @hidden */
  120890. 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;
  120891. /** @hidden */
  120892. 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;
  120893. /** @hidden */
  120894. 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;
  120895. }
  120896. }
  120897. declare module BABYLON {
  120898. /**
  120899. * Implementation of the TGA Texture Loader.
  120900. * @hidden
  120901. */
  120902. export class _TGATextureLoader implements IInternalTextureLoader {
  120903. /**
  120904. * Defines wether the loader supports cascade loading the different faces.
  120905. */
  120906. readonly supportCascades: boolean;
  120907. /**
  120908. * This returns if the loader support the current file information.
  120909. * @param extension defines the file extension of the file being loaded
  120910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120911. * @param fallback defines the fallback internal texture if any
  120912. * @param isBase64 defines whether the texture is encoded as a base64
  120913. * @param isBuffer defines whether the texture data are stored as a buffer
  120914. * @returns true if the loader can load the specified file
  120915. */
  120916. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120917. /**
  120918. * Transform the url before loading if required.
  120919. * @param rootUrl the url of the texture
  120920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120921. * @returns the transformed texture
  120922. */
  120923. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120924. /**
  120925. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120926. * @param rootUrl the url of the texture
  120927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120928. * @returns the fallback texture
  120929. */
  120930. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120931. /**
  120932. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120933. * @param data contains the texture data
  120934. * @param texture defines the BabylonJS internal texture
  120935. * @param createPolynomials will be true if polynomials have been requested
  120936. * @param onLoad defines the callback to trigger once the texture is ready
  120937. * @param onError defines the callback to trigger in case of error
  120938. */
  120939. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120940. /**
  120941. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120942. * @param data contains the texture data
  120943. * @param texture defines the BabylonJS internal texture
  120944. * @param callback defines the method to call once ready to upload
  120945. */
  120946. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120947. }
  120948. }
  120949. declare module BABYLON {
  120950. /**
  120951. * Info about the .basis files
  120952. */
  120953. class BasisFileInfo {
  120954. /**
  120955. * If the file has alpha
  120956. */
  120957. hasAlpha: boolean;
  120958. /**
  120959. * Info about each image of the basis file
  120960. */
  120961. images: Array<{
  120962. levels: Array<{
  120963. width: number;
  120964. height: number;
  120965. transcodedPixels: ArrayBufferView;
  120966. }>;
  120967. }>;
  120968. }
  120969. /**
  120970. * Result of transcoding a basis file
  120971. */
  120972. class TranscodeResult {
  120973. /**
  120974. * Info about the .basis file
  120975. */
  120976. fileInfo: BasisFileInfo;
  120977. /**
  120978. * Format to use when loading the file
  120979. */
  120980. format: number;
  120981. }
  120982. /**
  120983. * Configuration options for the Basis transcoder
  120984. */
  120985. export class BasisTranscodeConfiguration {
  120986. /**
  120987. * Supported compression formats used to determine the supported output format of the transcoder
  120988. */
  120989. supportedCompressionFormats?: {
  120990. /**
  120991. * etc1 compression format
  120992. */
  120993. etc1?: boolean;
  120994. /**
  120995. * s3tc compression format
  120996. */
  120997. s3tc?: boolean;
  120998. /**
  120999. * pvrtc compression format
  121000. */
  121001. pvrtc?: boolean;
  121002. /**
  121003. * etc2 compression format
  121004. */
  121005. etc2?: boolean;
  121006. };
  121007. /**
  121008. * If mipmap levels should be loaded for transcoded images (Default: true)
  121009. */
  121010. loadMipmapLevels?: boolean;
  121011. /**
  121012. * Index of a single image to load (Default: all images)
  121013. */
  121014. loadSingleImage?: number;
  121015. }
  121016. /**
  121017. * Used to load .Basis files
  121018. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121019. */
  121020. export class BasisTools {
  121021. private static _IgnoreSupportedFormats;
  121022. /**
  121023. * URL to use when loading the basis transcoder
  121024. */
  121025. static JSModuleURL: string;
  121026. /**
  121027. * URL to use when loading the wasm module for the transcoder
  121028. */
  121029. static WasmModuleURL: string;
  121030. /**
  121031. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121032. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121033. * @returns internal format corresponding to the Basis format
  121034. */
  121035. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121036. private static _WorkerPromise;
  121037. private static _Worker;
  121038. private static _actionId;
  121039. private static _CreateWorkerAsync;
  121040. /**
  121041. * Transcodes a loaded image file to compressed pixel data
  121042. * @param imageData image data to transcode
  121043. * @param config configuration options for the transcoding
  121044. * @returns a promise resulting in the transcoded image
  121045. */
  121046. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121047. /**
  121048. * Loads a texture from the transcode result
  121049. * @param texture texture load to
  121050. * @param transcodeResult the result of transcoding the basis file to load from
  121051. */
  121052. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121053. }
  121054. }
  121055. declare module BABYLON {
  121056. /**
  121057. * Loader for .basis file format
  121058. */
  121059. export class _BasisTextureLoader implements IInternalTextureLoader {
  121060. /**
  121061. * Defines whether the loader supports cascade loading the different faces.
  121062. */
  121063. readonly supportCascades: boolean;
  121064. /**
  121065. * This returns if the loader support the current file information.
  121066. * @param extension defines the file extension of the file being loaded
  121067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121068. * @param fallback defines the fallback internal texture if any
  121069. * @param isBase64 defines whether the texture is encoded as a base64
  121070. * @param isBuffer defines whether the texture data are stored as a buffer
  121071. * @returns true if the loader can load the specified file
  121072. */
  121073. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121074. /**
  121075. * Transform the url before loading if required.
  121076. * @param rootUrl the url of the texture
  121077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121078. * @returns the transformed texture
  121079. */
  121080. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121081. /**
  121082. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121083. * @param rootUrl the url of the texture
  121084. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121085. * @returns the fallback texture
  121086. */
  121087. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121088. /**
  121089. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121090. * @param data contains the texture data
  121091. * @param texture defines the BabylonJS internal texture
  121092. * @param createPolynomials will be true if polynomials have been requested
  121093. * @param onLoad defines the callback to trigger once the texture is ready
  121094. * @param onError defines the callback to trigger in case of error
  121095. */
  121096. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121097. /**
  121098. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121099. * @param data contains the texture data
  121100. * @param texture defines the BabylonJS internal texture
  121101. * @param callback defines the method to call once ready to upload
  121102. */
  121103. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121104. }
  121105. }
  121106. declare module BABYLON {
  121107. /**
  121108. * 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.
  121109. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121110. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121111. */
  121112. export class CustomProceduralTexture extends ProceduralTexture {
  121113. private _animate;
  121114. private _time;
  121115. private _config;
  121116. private _texturePath;
  121117. /**
  121118. * Instantiates a new Custom Procedural Texture.
  121119. * 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.
  121120. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121121. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121122. * @param name Define the name of the texture
  121123. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121124. * @param size Define the size of the texture to create
  121125. * @param scene Define the scene the texture belongs to
  121126. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121127. * @param generateMipMaps Define if the texture should creates mip maps or not
  121128. */
  121129. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121130. private _loadJson;
  121131. /**
  121132. * Is the texture ready to be used ? (rendered at least once)
  121133. * @returns true if ready, otherwise, false.
  121134. */
  121135. isReady(): boolean;
  121136. /**
  121137. * Render the texture to its associated render target.
  121138. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121139. */
  121140. render(useCameraPostProcess?: boolean): void;
  121141. /**
  121142. * Update the list of dependant textures samplers in the shader.
  121143. */
  121144. updateTextures(): void;
  121145. /**
  121146. * Update the uniform values of the procedural texture in the shader.
  121147. */
  121148. updateShaderUniforms(): void;
  121149. /**
  121150. * Define if the texture animates or not.
  121151. */
  121152. animate: boolean;
  121153. }
  121154. }
  121155. declare module BABYLON {
  121156. /** @hidden */
  121157. export var noisePixelShader: {
  121158. name: string;
  121159. shader: string;
  121160. };
  121161. }
  121162. declare module BABYLON {
  121163. /**
  121164. * Class used to generate noise procedural textures
  121165. */
  121166. export class NoiseProceduralTexture extends ProceduralTexture {
  121167. private _time;
  121168. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121169. brightness: number;
  121170. /** Defines the number of octaves to process */
  121171. octaves: number;
  121172. /** Defines the level of persistence (0.8 by default) */
  121173. persistence: number;
  121174. /** Gets or sets animation speed factor (default is 1) */
  121175. animationSpeedFactor: number;
  121176. /**
  121177. * Creates a new NoiseProceduralTexture
  121178. * @param name defines the name fo the texture
  121179. * @param size defines the size of the texture (default is 256)
  121180. * @param scene defines the hosting scene
  121181. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121182. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121183. */
  121184. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121185. private _updateShaderUniforms;
  121186. protected _getDefines(): string;
  121187. /** Generate the current state of the procedural texture */
  121188. render(useCameraPostProcess?: boolean): void;
  121189. /**
  121190. * Serializes this noise procedural texture
  121191. * @returns a serialized noise procedural texture object
  121192. */
  121193. serialize(): any;
  121194. /**
  121195. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121196. * @param parsedTexture defines parsed texture data
  121197. * @param scene defines the current scene
  121198. * @param rootUrl defines the root URL containing noise procedural texture information
  121199. * @returns a parsed NoiseProceduralTexture
  121200. */
  121201. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121202. }
  121203. }
  121204. declare module BABYLON {
  121205. /**
  121206. * Raw cube texture where the raw buffers are passed in
  121207. */
  121208. export class RawCubeTexture extends CubeTexture {
  121209. /**
  121210. * Creates a cube texture where the raw buffers are passed in.
  121211. * @param scene defines the scene the texture is attached to
  121212. * @param data defines the array of data to use to create each face
  121213. * @param size defines the size of the textures
  121214. * @param format defines the format of the data
  121215. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121216. * @param generateMipMaps defines if the engine should generate the mip levels
  121217. * @param invertY defines if data must be stored with Y axis inverted
  121218. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121219. * @param compression defines the compression used (null by default)
  121220. */
  121221. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121222. /**
  121223. * Updates the raw cube texture.
  121224. * @param data defines the data to store
  121225. * @param format defines the data format
  121226. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121227. * @param invertY defines if data must be stored with Y axis inverted
  121228. * @param compression defines the compression used (null by default)
  121229. * @param level defines which level of the texture to update
  121230. */
  121231. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121232. /**
  121233. * Updates a raw cube texture with RGBD encoded data.
  121234. * @param data defines the array of data [mipmap][face] to use to create each face
  121235. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121236. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121237. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121238. * @returns a promsie that resolves when the operation is complete
  121239. */
  121240. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121241. /**
  121242. * Clones the raw cube texture.
  121243. * @return a new cube texture
  121244. */
  121245. clone(): CubeTexture;
  121246. /** @hidden */
  121247. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121248. }
  121249. }
  121250. declare module BABYLON {
  121251. /**
  121252. * Class used to store 3D textures containing user data
  121253. */
  121254. export class RawTexture3D extends Texture {
  121255. /** Gets or sets the texture format to use */
  121256. format: number;
  121257. private _engine;
  121258. /**
  121259. * Create a new RawTexture3D
  121260. * @param data defines the data of the texture
  121261. * @param width defines the width of the texture
  121262. * @param height defines the height of the texture
  121263. * @param depth defines the depth of the texture
  121264. * @param format defines the texture format to use
  121265. * @param scene defines the hosting scene
  121266. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121267. * @param invertY defines if texture must be stored with Y axis inverted
  121268. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121269. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121270. */
  121271. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121272. /** Gets or sets the texture format to use */
  121273. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121274. /**
  121275. * Update the texture with new data
  121276. * @param data defines the data to store in the texture
  121277. */
  121278. update(data: ArrayBufferView): void;
  121279. }
  121280. }
  121281. declare module BABYLON {
  121282. /**
  121283. * Class used to store 2D array textures containing user data
  121284. */
  121285. export class RawTexture2DArray extends Texture {
  121286. /** Gets or sets the texture format to use */
  121287. format: number;
  121288. private _engine;
  121289. /**
  121290. * Create a new RawTexture2DArray
  121291. * @param data defines the data of the texture
  121292. * @param width defines the width of the texture
  121293. * @param height defines the height of the texture
  121294. * @param depth defines the number of layers of the texture
  121295. * @param format defines the texture format to use
  121296. * @param scene defines the hosting scene
  121297. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121298. * @param invertY defines if texture must be stored with Y axis inverted
  121299. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121300. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121301. */
  121302. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121303. /** Gets or sets the texture format to use */
  121304. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121305. /**
  121306. * Update the texture with new data
  121307. * @param data defines the data to store in the texture
  121308. */
  121309. update(data: ArrayBufferView): void;
  121310. }
  121311. }
  121312. declare module BABYLON {
  121313. /**
  121314. * Creates a refraction texture used by refraction channel of the standard material.
  121315. * It is like a mirror but to see through a material.
  121316. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121317. */
  121318. export class RefractionTexture extends RenderTargetTexture {
  121319. /**
  121320. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121321. * 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.
  121322. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121323. */
  121324. refractionPlane: Plane;
  121325. /**
  121326. * Define how deep under the surface we should see.
  121327. */
  121328. depth: number;
  121329. /**
  121330. * Creates a refraction texture used by refraction channel of the standard material.
  121331. * It is like a mirror but to see through a material.
  121332. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121333. * @param name Define the texture name
  121334. * @param size Define the size of the underlying texture
  121335. * @param scene Define the scene the refraction belongs to
  121336. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121337. */
  121338. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121339. /**
  121340. * Clone the refraction texture.
  121341. * @returns the cloned texture
  121342. */
  121343. clone(): RefractionTexture;
  121344. /**
  121345. * Serialize the texture to a JSON representation you could use in Parse later on
  121346. * @returns the serialized JSON representation
  121347. */
  121348. serialize(): any;
  121349. }
  121350. }
  121351. declare module BABYLON {
  121352. /**
  121353. * Defines the options related to the creation of an HtmlElementTexture
  121354. */
  121355. export interface IHtmlElementTextureOptions {
  121356. /**
  121357. * Defines wether mip maps should be created or not.
  121358. */
  121359. generateMipMaps?: boolean;
  121360. /**
  121361. * Defines the sampling mode of the texture.
  121362. */
  121363. samplingMode?: number;
  121364. /**
  121365. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121366. */
  121367. engine: Nullable<ThinEngine>;
  121368. /**
  121369. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121370. */
  121371. scene: Nullable<Scene>;
  121372. }
  121373. /**
  121374. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121375. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121376. * is automatically managed.
  121377. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121378. * in your application.
  121379. *
  121380. * As the update is not automatic, you need to call them manually.
  121381. */
  121382. export class HtmlElementTexture extends BaseTexture {
  121383. /**
  121384. * The texture URL.
  121385. */
  121386. element: HTMLVideoElement | HTMLCanvasElement;
  121387. private static readonly DefaultOptions;
  121388. private _textureMatrix;
  121389. private _engine;
  121390. private _isVideo;
  121391. private _generateMipMaps;
  121392. private _samplingMode;
  121393. /**
  121394. * Instantiates a HtmlElementTexture from the following parameters.
  121395. *
  121396. * @param name Defines the name of the texture
  121397. * @param element Defines the video or canvas the texture is filled with
  121398. * @param options Defines the other none mandatory texture creation options
  121399. */
  121400. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121401. private _createInternalTexture;
  121402. /**
  121403. * Returns the texture matrix used in most of the material.
  121404. */
  121405. getTextureMatrix(): Matrix;
  121406. /**
  121407. * Updates the content of the texture.
  121408. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121409. */
  121410. update(invertY?: Nullable<boolean>): void;
  121411. }
  121412. }
  121413. declare module BABYLON {
  121414. /**
  121415. * Enum used to define the target of a block
  121416. */
  121417. export enum NodeMaterialBlockTargets {
  121418. /** Vertex shader */
  121419. Vertex = 1,
  121420. /** Fragment shader */
  121421. Fragment = 2,
  121422. /** Neutral */
  121423. Neutral = 4,
  121424. /** Vertex and Fragment */
  121425. VertexAndFragment = 3
  121426. }
  121427. }
  121428. declare module BABYLON {
  121429. /**
  121430. * Defines the kind of connection point for node based material
  121431. */
  121432. export enum NodeMaterialBlockConnectionPointTypes {
  121433. /** Float */
  121434. Float = 1,
  121435. /** Int */
  121436. Int = 2,
  121437. /** Vector2 */
  121438. Vector2 = 4,
  121439. /** Vector3 */
  121440. Vector3 = 8,
  121441. /** Vector4 */
  121442. Vector4 = 16,
  121443. /** Color3 */
  121444. Color3 = 32,
  121445. /** Color4 */
  121446. Color4 = 64,
  121447. /** Matrix */
  121448. Matrix = 128,
  121449. /** Detect type based on connection */
  121450. AutoDetect = 1024,
  121451. /** Output type that will be defined by input type */
  121452. BasedOnInput = 2048
  121453. }
  121454. }
  121455. declare module BABYLON {
  121456. /**
  121457. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121458. */
  121459. export enum NodeMaterialBlockConnectionPointMode {
  121460. /** Value is an uniform */
  121461. Uniform = 0,
  121462. /** Value is a mesh attribute */
  121463. Attribute = 1,
  121464. /** Value is a varying between vertex and fragment shaders */
  121465. Varying = 2,
  121466. /** Mode is undefined */
  121467. Undefined = 3
  121468. }
  121469. }
  121470. declare module BABYLON {
  121471. /**
  121472. * Enum used to define system values e.g. values automatically provided by the system
  121473. */
  121474. export enum NodeMaterialSystemValues {
  121475. /** World */
  121476. World = 1,
  121477. /** View */
  121478. View = 2,
  121479. /** Projection */
  121480. Projection = 3,
  121481. /** ViewProjection */
  121482. ViewProjection = 4,
  121483. /** WorldView */
  121484. WorldView = 5,
  121485. /** WorldViewProjection */
  121486. WorldViewProjection = 6,
  121487. /** CameraPosition */
  121488. CameraPosition = 7,
  121489. /** Fog Color */
  121490. FogColor = 8,
  121491. /** Delta time */
  121492. DeltaTime = 9
  121493. }
  121494. }
  121495. declare module BABYLON {
  121496. /**
  121497. * Root class for all node material optimizers
  121498. */
  121499. export class NodeMaterialOptimizer {
  121500. /**
  121501. * Function used to optimize a NodeMaterial graph
  121502. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121503. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121504. */
  121505. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121511. */
  121512. export class TransformBlock extends NodeMaterialBlock {
  121513. /**
  121514. * Defines the value to use to complement W value to transform it to a Vector4
  121515. */
  121516. complementW: number;
  121517. /**
  121518. * Defines the value to use to complement z value to transform it to a Vector4
  121519. */
  121520. complementZ: number;
  121521. /**
  121522. * Creates a new TransformBlock
  121523. * @param name defines the block name
  121524. */
  121525. constructor(name: string);
  121526. /**
  121527. * Gets the current class name
  121528. * @returns the class name
  121529. */
  121530. getClassName(): string;
  121531. /**
  121532. * Gets the vector input
  121533. */
  121534. readonly vector: NodeMaterialConnectionPoint;
  121535. /**
  121536. * Gets the output component
  121537. */
  121538. readonly output: NodeMaterialConnectionPoint;
  121539. /**
  121540. * Gets the matrix transform input
  121541. */
  121542. readonly transform: NodeMaterialConnectionPoint;
  121543. protected _buildBlock(state: NodeMaterialBuildState): this;
  121544. serialize(): any;
  121545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121546. protected _dumpPropertiesCode(): string;
  121547. }
  121548. }
  121549. declare module BABYLON {
  121550. /**
  121551. * Block used to output the vertex position
  121552. */
  121553. export class VertexOutputBlock extends NodeMaterialBlock {
  121554. /**
  121555. * Creates a new VertexOutputBlock
  121556. * @param name defines the block name
  121557. */
  121558. constructor(name: string);
  121559. /**
  121560. * Gets the current class name
  121561. * @returns the class name
  121562. */
  121563. getClassName(): string;
  121564. /**
  121565. * Gets the vector input component
  121566. */
  121567. readonly vector: NodeMaterialConnectionPoint;
  121568. protected _buildBlock(state: NodeMaterialBuildState): this;
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * Block used to output the final color
  121574. */
  121575. export class FragmentOutputBlock extends NodeMaterialBlock {
  121576. /**
  121577. * Create a new FragmentOutputBlock
  121578. * @param name defines the block name
  121579. */
  121580. constructor(name: string);
  121581. /**
  121582. * Gets the current class name
  121583. * @returns the class name
  121584. */
  121585. getClassName(): string;
  121586. /**
  121587. * Gets the rgba input component
  121588. */
  121589. readonly rgba: NodeMaterialConnectionPoint;
  121590. /**
  121591. * Gets the rgb input component
  121592. */
  121593. readonly rgb: NodeMaterialConnectionPoint;
  121594. /**
  121595. * Gets the a input component
  121596. */
  121597. readonly a: NodeMaterialConnectionPoint;
  121598. protected _buildBlock(state: NodeMaterialBuildState): this;
  121599. }
  121600. }
  121601. declare module BABYLON {
  121602. /**
  121603. * Block used to read a reflection texture from a sampler
  121604. */
  121605. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121606. private _define3DName;
  121607. private _defineCubicName;
  121608. private _defineExplicitName;
  121609. private _defineProjectionName;
  121610. private _defineLocalCubicName;
  121611. private _defineSphericalName;
  121612. private _definePlanarName;
  121613. private _defineEquirectangularName;
  121614. private _defineMirroredEquirectangularFixedName;
  121615. private _defineEquirectangularFixedName;
  121616. private _defineSkyboxName;
  121617. private _cubeSamplerName;
  121618. private _2DSamplerName;
  121619. private _positionUVWName;
  121620. private _directionWName;
  121621. private _reflectionCoordsName;
  121622. private _reflection2DCoordsName;
  121623. private _reflectionColorName;
  121624. private _reflectionMatrixName;
  121625. /**
  121626. * Gets or sets the texture associated with the node
  121627. */
  121628. texture: Nullable<BaseTexture>;
  121629. /**
  121630. * Create a new TextureBlock
  121631. * @param name defines the block name
  121632. */
  121633. constructor(name: string);
  121634. /**
  121635. * Gets the current class name
  121636. * @returns the class name
  121637. */
  121638. getClassName(): string;
  121639. /**
  121640. * Gets the world position input component
  121641. */
  121642. readonly position: NodeMaterialConnectionPoint;
  121643. /**
  121644. * Gets the world position input component
  121645. */
  121646. readonly worldPosition: NodeMaterialConnectionPoint;
  121647. /**
  121648. * Gets the world normal input component
  121649. */
  121650. readonly worldNormal: NodeMaterialConnectionPoint;
  121651. /**
  121652. * Gets the world input component
  121653. */
  121654. readonly world: NodeMaterialConnectionPoint;
  121655. /**
  121656. * Gets the camera (or eye) position component
  121657. */
  121658. readonly cameraPosition: NodeMaterialConnectionPoint;
  121659. /**
  121660. * Gets the view input component
  121661. */
  121662. readonly view: NodeMaterialConnectionPoint;
  121663. /**
  121664. * Gets the rgb output component
  121665. */
  121666. readonly rgb: NodeMaterialConnectionPoint;
  121667. /**
  121668. * Gets the r output component
  121669. */
  121670. readonly r: NodeMaterialConnectionPoint;
  121671. /**
  121672. * Gets the g output component
  121673. */
  121674. readonly g: NodeMaterialConnectionPoint;
  121675. /**
  121676. * Gets the b output component
  121677. */
  121678. readonly b: NodeMaterialConnectionPoint;
  121679. autoConfigure(material: NodeMaterial): void;
  121680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121681. isReady(): boolean;
  121682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121683. private _injectVertexCode;
  121684. private _writeOutput;
  121685. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121686. protected _dumpPropertiesCode(): string;
  121687. serialize(): any;
  121688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121689. }
  121690. }
  121691. declare module BABYLON {
  121692. /**
  121693. * Interface used to configure the node material editor
  121694. */
  121695. export interface INodeMaterialEditorOptions {
  121696. /** Define the URl to load node editor script */
  121697. editorURL?: string;
  121698. }
  121699. /** @hidden */
  121700. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121701. /** BONES */
  121702. NUM_BONE_INFLUENCERS: number;
  121703. BonesPerMesh: number;
  121704. BONETEXTURE: boolean;
  121705. /** MORPH TARGETS */
  121706. MORPHTARGETS: boolean;
  121707. MORPHTARGETS_NORMAL: boolean;
  121708. MORPHTARGETS_TANGENT: boolean;
  121709. MORPHTARGETS_UV: boolean;
  121710. NUM_MORPH_INFLUENCERS: number;
  121711. /** IMAGE PROCESSING */
  121712. IMAGEPROCESSING: boolean;
  121713. VIGNETTE: boolean;
  121714. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121715. VIGNETTEBLENDMODEOPAQUE: boolean;
  121716. TONEMAPPING: boolean;
  121717. TONEMAPPING_ACES: boolean;
  121718. CONTRAST: boolean;
  121719. EXPOSURE: boolean;
  121720. COLORCURVES: boolean;
  121721. COLORGRADING: boolean;
  121722. COLORGRADING3D: boolean;
  121723. SAMPLER3DGREENDEPTH: boolean;
  121724. SAMPLER3DBGRMAP: boolean;
  121725. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121726. /** MISC. */
  121727. BUMPDIRECTUV: number;
  121728. constructor();
  121729. setValue(name: string, value: boolean): void;
  121730. }
  121731. /**
  121732. * Class used to configure NodeMaterial
  121733. */
  121734. export interface INodeMaterialOptions {
  121735. /**
  121736. * Defines if blocks should emit comments
  121737. */
  121738. emitComments: boolean;
  121739. }
  121740. /**
  121741. * Class used to create a node based material built by assembling shader blocks
  121742. */
  121743. export class NodeMaterial extends PushMaterial {
  121744. private static _BuildIdGenerator;
  121745. private _options;
  121746. private _vertexCompilationState;
  121747. private _fragmentCompilationState;
  121748. private _sharedData;
  121749. private _buildId;
  121750. private _buildWasSuccessful;
  121751. private _cachedWorldViewMatrix;
  121752. private _cachedWorldViewProjectionMatrix;
  121753. private _optimizers;
  121754. private _animationFrame;
  121755. /** Define the URl to load node editor script */
  121756. static EditorURL: string;
  121757. private BJSNODEMATERIALEDITOR;
  121758. /** Get the inspector from bundle or global */
  121759. private _getGlobalNodeMaterialEditor;
  121760. /**
  121761. * 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)
  121762. */
  121763. ignoreAlpha: boolean;
  121764. /**
  121765. * Defines the maximum number of lights that can be used in the material
  121766. */
  121767. maxSimultaneousLights: number;
  121768. /**
  121769. * Observable raised when the material is built
  121770. */
  121771. onBuildObservable: Observable<NodeMaterial>;
  121772. /**
  121773. * Gets or sets the root nodes of the material vertex shader
  121774. */
  121775. _vertexOutputNodes: NodeMaterialBlock[];
  121776. /**
  121777. * Gets or sets the root nodes of the material fragment (pixel) shader
  121778. */
  121779. _fragmentOutputNodes: NodeMaterialBlock[];
  121780. /** Gets or sets options to control the node material overall behavior */
  121781. options: INodeMaterialOptions;
  121782. /**
  121783. * Default configuration related to image processing available in the standard Material.
  121784. */
  121785. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121786. /**
  121787. * Gets the image processing configuration used either in this material.
  121788. */
  121789. /**
  121790. * Sets the Default image processing configuration used either in the this material.
  121791. *
  121792. * If sets to null, the scene one is in use.
  121793. */
  121794. imageProcessingConfiguration: ImageProcessingConfiguration;
  121795. /**
  121796. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121797. */
  121798. attachedBlocks: NodeMaterialBlock[];
  121799. /**
  121800. * Create a new node based material
  121801. * @param name defines the material name
  121802. * @param scene defines the hosting scene
  121803. * @param options defines creation option
  121804. */
  121805. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121806. /**
  121807. * Gets the current class name of the material e.g. "NodeMaterial"
  121808. * @returns the class name
  121809. */
  121810. getClassName(): string;
  121811. /**
  121812. * Keep track of the image processing observer to allow dispose and replace.
  121813. */
  121814. private _imageProcessingObserver;
  121815. /**
  121816. * Attaches a new image processing configuration to the Standard Material.
  121817. * @param configuration
  121818. */
  121819. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121820. /**
  121821. * Get a block by its name
  121822. * @param name defines the name of the block to retrieve
  121823. * @returns the required block or null if not found
  121824. */
  121825. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121826. /**
  121827. * Get a block by its name
  121828. * @param predicate defines the predicate used to find the good candidate
  121829. * @returns the required block or null if not found
  121830. */
  121831. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121832. /**
  121833. * Get an input block by its name
  121834. * @param predicate defines the predicate used to find the good candidate
  121835. * @returns the required input block or null if not found
  121836. */
  121837. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121838. /**
  121839. * Gets the list of input blocks attached to this material
  121840. * @returns an array of InputBlocks
  121841. */
  121842. getInputBlocks(): InputBlock[];
  121843. /**
  121844. * Adds a new optimizer to the list of optimizers
  121845. * @param optimizer defines the optimizers to add
  121846. * @returns the current material
  121847. */
  121848. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121849. /**
  121850. * Remove an optimizer from the list of optimizers
  121851. * @param optimizer defines the optimizers to remove
  121852. * @returns the current material
  121853. */
  121854. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121855. /**
  121856. * Add a new block to the list of output nodes
  121857. * @param node defines the node to add
  121858. * @returns the current material
  121859. */
  121860. addOutputNode(node: NodeMaterialBlock): this;
  121861. /**
  121862. * Remove a block from the list of root nodes
  121863. * @param node defines the node to remove
  121864. * @returns the current material
  121865. */
  121866. removeOutputNode(node: NodeMaterialBlock): this;
  121867. private _addVertexOutputNode;
  121868. private _removeVertexOutputNode;
  121869. private _addFragmentOutputNode;
  121870. private _removeFragmentOutputNode;
  121871. /**
  121872. * Specifies if the material will require alpha blending
  121873. * @returns a boolean specifying if alpha blending is needed
  121874. */
  121875. needAlphaBlending(): boolean;
  121876. /**
  121877. * Specifies if this material should be rendered in alpha test mode
  121878. * @returns a boolean specifying if an alpha test is needed.
  121879. */
  121880. needAlphaTesting(): boolean;
  121881. private _initializeBlock;
  121882. private _resetDualBlocks;
  121883. /**
  121884. * Build the material and generates the inner effect
  121885. * @param verbose defines if the build should log activity
  121886. */
  121887. build(verbose?: boolean): void;
  121888. /**
  121889. * Runs an otpimization phase to try to improve the shader code
  121890. */
  121891. optimize(): void;
  121892. private _prepareDefinesForAttributes;
  121893. /**
  121894. * Get if the submesh is ready to be used and all its information available.
  121895. * Child classes can use it to update shaders
  121896. * @param mesh defines the mesh to check
  121897. * @param subMesh defines which submesh to check
  121898. * @param useInstances specifies that instances should be used
  121899. * @returns a boolean indicating that the submesh is ready or not
  121900. */
  121901. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121902. /**
  121903. * Get a string representing the shaders built by the current node graph
  121904. */
  121905. readonly compiledShaders: string;
  121906. /**
  121907. * Binds the world matrix to the material
  121908. * @param world defines the world transformation matrix
  121909. */
  121910. bindOnlyWorldMatrix(world: Matrix): void;
  121911. /**
  121912. * Binds the submesh to this material by preparing the effect and shader to draw
  121913. * @param world defines the world transformation matrix
  121914. * @param mesh defines the mesh containing the submesh
  121915. * @param subMesh defines the submesh to bind the material to
  121916. */
  121917. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121918. /**
  121919. * Gets the active textures from the material
  121920. * @returns an array of textures
  121921. */
  121922. getActiveTextures(): BaseTexture[];
  121923. /**
  121924. * Gets the list of texture blocks
  121925. * @returns an array of texture blocks
  121926. */
  121927. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121928. /**
  121929. * Specifies if the material uses a texture
  121930. * @param texture defines the texture to check against the material
  121931. * @returns a boolean specifying if the material uses the texture
  121932. */
  121933. hasTexture(texture: BaseTexture): boolean;
  121934. /**
  121935. * Disposes the material
  121936. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121937. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121938. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121939. */
  121940. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121941. /** Creates the node editor window. */
  121942. private _createNodeEditor;
  121943. /**
  121944. * Launch the node material editor
  121945. * @param config Define the configuration of the editor
  121946. * @return a promise fulfilled when the node editor is visible
  121947. */
  121948. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121949. /**
  121950. * Clear the current material
  121951. */
  121952. clear(): void;
  121953. /**
  121954. * Clear the current material and set it to a default state
  121955. */
  121956. setToDefault(): void;
  121957. /**
  121958. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121959. * @param url defines the url to load from
  121960. * @returns a promise that will fullfil when the material is fully loaded
  121961. */
  121962. loadAsync(url: string): Promise<void>;
  121963. private _gatherBlocks;
  121964. /**
  121965. * Generate a string containing the code declaration required to create an equivalent of this material
  121966. * @returns a string
  121967. */
  121968. generateCode(): string;
  121969. /**
  121970. * Serializes this material in a JSON representation
  121971. * @returns the serialized material object
  121972. */
  121973. serialize(): any;
  121974. private _restoreConnections;
  121975. /**
  121976. * Clear the current graph and load a new one from a serialization object
  121977. * @param source defines the JSON representation of the material
  121978. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121979. */
  121980. loadFromSerialization(source: any, rootUrl?: string): void;
  121981. /**
  121982. * Creates a node material from parsed material data
  121983. * @param source defines the JSON representation of the material
  121984. * @param scene defines the hosting scene
  121985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121986. * @returns a new node material
  121987. */
  121988. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121989. /**
  121990. * Creates a new node material set to default basic configuration
  121991. * @param name defines the name of the material
  121992. * @param scene defines the hosting scene
  121993. * @returns a new NodeMaterial
  121994. */
  121995. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121996. }
  121997. }
  121998. declare module BABYLON {
  121999. /**
  122000. * Block used to read a texture from a sampler
  122001. */
  122002. export class TextureBlock extends NodeMaterialBlock {
  122003. private _defineName;
  122004. private _linearDefineName;
  122005. private _samplerName;
  122006. private _transformedUVName;
  122007. private _textureTransformName;
  122008. private _textureInfoName;
  122009. private _mainUVName;
  122010. private _mainUVDefineName;
  122011. /**
  122012. * Gets or sets the texture associated with the node
  122013. */
  122014. texture: Nullable<Texture>;
  122015. /**
  122016. * Create a new TextureBlock
  122017. * @param name defines the block name
  122018. */
  122019. constructor(name: string);
  122020. /**
  122021. * Gets the current class name
  122022. * @returns the class name
  122023. */
  122024. getClassName(): string;
  122025. /**
  122026. * Gets the uv input component
  122027. */
  122028. readonly uv: NodeMaterialConnectionPoint;
  122029. /**
  122030. * Gets the rgba output component
  122031. */
  122032. readonly rgba: NodeMaterialConnectionPoint;
  122033. /**
  122034. * Gets the rgb output component
  122035. */
  122036. readonly rgb: NodeMaterialConnectionPoint;
  122037. /**
  122038. * Gets the r output component
  122039. */
  122040. readonly r: NodeMaterialConnectionPoint;
  122041. /**
  122042. * Gets the g output component
  122043. */
  122044. readonly g: NodeMaterialConnectionPoint;
  122045. /**
  122046. * Gets the b output component
  122047. */
  122048. readonly b: NodeMaterialConnectionPoint;
  122049. /**
  122050. * Gets the a output component
  122051. */
  122052. readonly a: NodeMaterialConnectionPoint;
  122053. readonly target: NodeMaterialBlockTargets;
  122054. autoConfigure(material: NodeMaterial): void;
  122055. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122057. isReady(): boolean;
  122058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122059. private readonly _isMixed;
  122060. private _injectVertexCode;
  122061. private _writeOutput;
  122062. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122063. protected _dumpPropertiesCode(): string;
  122064. serialize(): any;
  122065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122066. }
  122067. }
  122068. declare module BABYLON {
  122069. /**
  122070. * Class used to store shared data between 2 NodeMaterialBuildState
  122071. */
  122072. export class NodeMaterialBuildStateSharedData {
  122073. /**
  122074. * Gets the list of emitted varyings
  122075. */
  122076. temps: string[];
  122077. /**
  122078. * Gets the list of emitted varyings
  122079. */
  122080. varyings: string[];
  122081. /**
  122082. * Gets the varying declaration string
  122083. */
  122084. varyingDeclaration: string;
  122085. /**
  122086. * Input blocks
  122087. */
  122088. inputBlocks: InputBlock[];
  122089. /**
  122090. * Input blocks
  122091. */
  122092. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122093. /**
  122094. * Bindable blocks (Blocks that need to set data to the effect)
  122095. */
  122096. bindableBlocks: NodeMaterialBlock[];
  122097. /**
  122098. * List of blocks that can provide a compilation fallback
  122099. */
  122100. blocksWithFallbacks: NodeMaterialBlock[];
  122101. /**
  122102. * List of blocks that can provide a define update
  122103. */
  122104. blocksWithDefines: NodeMaterialBlock[];
  122105. /**
  122106. * List of blocks that can provide a repeatable content
  122107. */
  122108. repeatableContentBlocks: NodeMaterialBlock[];
  122109. /**
  122110. * List of blocks that can provide a dynamic list of uniforms
  122111. */
  122112. dynamicUniformBlocks: NodeMaterialBlock[];
  122113. /**
  122114. * List of blocks that can block the isReady function for the material
  122115. */
  122116. blockingBlocks: NodeMaterialBlock[];
  122117. /**
  122118. * Gets the list of animated inputs
  122119. */
  122120. animatedInputs: InputBlock[];
  122121. /**
  122122. * Build Id used to avoid multiple recompilations
  122123. */
  122124. buildId: number;
  122125. /** List of emitted variables */
  122126. variableNames: {
  122127. [key: string]: number;
  122128. };
  122129. /** List of emitted defines */
  122130. defineNames: {
  122131. [key: string]: number;
  122132. };
  122133. /** Should emit comments? */
  122134. emitComments: boolean;
  122135. /** Emit build activity */
  122136. verbose: boolean;
  122137. /** Gets or sets the hosting scene */
  122138. scene: Scene;
  122139. /**
  122140. * Gets the compilation hints emitted at compilation time
  122141. */
  122142. hints: {
  122143. needWorldViewMatrix: boolean;
  122144. needWorldViewProjectionMatrix: boolean;
  122145. needAlphaBlending: boolean;
  122146. needAlphaTesting: boolean;
  122147. };
  122148. /**
  122149. * List of compilation checks
  122150. */
  122151. checks: {
  122152. emitVertex: boolean;
  122153. emitFragment: boolean;
  122154. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122155. };
  122156. /** Creates a new shared data */
  122157. constructor();
  122158. /**
  122159. * Emits console errors and exceptions if there is a failing check
  122160. */
  122161. emitErrors(): void;
  122162. }
  122163. }
  122164. declare module BABYLON {
  122165. /**
  122166. * Class used to store node based material build state
  122167. */
  122168. export class NodeMaterialBuildState {
  122169. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122170. supportUniformBuffers: boolean;
  122171. /**
  122172. * Gets the list of emitted attributes
  122173. */
  122174. attributes: string[];
  122175. /**
  122176. * Gets the list of emitted uniforms
  122177. */
  122178. uniforms: string[];
  122179. /**
  122180. * Gets the list of emitted constants
  122181. */
  122182. constants: string[];
  122183. /**
  122184. * Gets the list of emitted samplers
  122185. */
  122186. samplers: string[];
  122187. /**
  122188. * Gets the list of emitted functions
  122189. */
  122190. functions: {
  122191. [key: string]: string;
  122192. };
  122193. /**
  122194. * Gets the list of emitted extensions
  122195. */
  122196. extensions: {
  122197. [key: string]: string;
  122198. };
  122199. /**
  122200. * Gets the target of the compilation state
  122201. */
  122202. target: NodeMaterialBlockTargets;
  122203. /**
  122204. * Gets the list of emitted counters
  122205. */
  122206. counters: {
  122207. [key: string]: number;
  122208. };
  122209. /**
  122210. * Shared data between multiple NodeMaterialBuildState instances
  122211. */
  122212. sharedData: NodeMaterialBuildStateSharedData;
  122213. /** @hidden */
  122214. _vertexState: NodeMaterialBuildState;
  122215. /** @hidden */
  122216. _attributeDeclaration: string;
  122217. /** @hidden */
  122218. _uniformDeclaration: string;
  122219. /** @hidden */
  122220. _constantDeclaration: string;
  122221. /** @hidden */
  122222. _samplerDeclaration: string;
  122223. /** @hidden */
  122224. _varyingTransfer: string;
  122225. private _repeatableContentAnchorIndex;
  122226. /** @hidden */
  122227. _builtCompilationString: string;
  122228. /**
  122229. * Gets the emitted compilation strings
  122230. */
  122231. compilationString: string;
  122232. /**
  122233. * Finalize the compilation strings
  122234. * @param state defines the current compilation state
  122235. */
  122236. finalize(state: NodeMaterialBuildState): void;
  122237. /** @hidden */
  122238. readonly _repeatableContentAnchor: string;
  122239. /** @hidden */
  122240. _getFreeVariableName(prefix: string): string;
  122241. /** @hidden */
  122242. _getFreeDefineName(prefix: string): string;
  122243. /** @hidden */
  122244. _excludeVariableName(name: string): void;
  122245. /** @hidden */
  122246. _emit2DSampler(name: string): void;
  122247. /** @hidden */
  122248. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122249. /** @hidden */
  122250. _emitExtension(name: string, extension: string): void;
  122251. /** @hidden */
  122252. _emitFunction(name: string, code: string, comments: string): void;
  122253. /** @hidden */
  122254. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122255. replaceStrings?: {
  122256. search: RegExp;
  122257. replace: string;
  122258. }[];
  122259. repeatKey?: string;
  122260. }): string;
  122261. /** @hidden */
  122262. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122263. repeatKey?: string;
  122264. removeAttributes?: boolean;
  122265. removeUniforms?: boolean;
  122266. removeVaryings?: boolean;
  122267. removeIfDef?: boolean;
  122268. replaceStrings?: {
  122269. search: RegExp;
  122270. replace: string;
  122271. }[];
  122272. }, storeKey?: string): void;
  122273. /** @hidden */
  122274. _registerTempVariable(name: string): boolean;
  122275. /** @hidden */
  122276. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122277. /** @hidden */
  122278. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122279. /** @hidden */
  122280. _emitFloat(value: number): string;
  122281. }
  122282. }
  122283. declare module BABYLON {
  122284. /**
  122285. * Defines a block that can be used inside a node based material
  122286. */
  122287. export class NodeMaterialBlock {
  122288. private _buildId;
  122289. private _buildTarget;
  122290. private _target;
  122291. private _isFinalMerger;
  122292. private _isInput;
  122293. protected _isUnique: boolean;
  122294. /** @hidden */
  122295. _codeVariableName: string;
  122296. /** @hidden */
  122297. _inputs: NodeMaterialConnectionPoint[];
  122298. /** @hidden */
  122299. _outputs: NodeMaterialConnectionPoint[];
  122300. /** @hidden */
  122301. _preparationId: number;
  122302. /**
  122303. * Gets or sets the name of the block
  122304. */
  122305. name: string;
  122306. /**
  122307. * Gets or sets the unique id of the node
  122308. */
  122309. uniqueId: number;
  122310. /**
  122311. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122312. */
  122313. readonly isUnique: boolean;
  122314. /**
  122315. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122316. */
  122317. readonly isFinalMerger: boolean;
  122318. /**
  122319. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122320. */
  122321. readonly isInput: boolean;
  122322. /**
  122323. * Gets or sets the build Id
  122324. */
  122325. buildId: number;
  122326. /**
  122327. * Gets or sets the target of the block
  122328. */
  122329. target: NodeMaterialBlockTargets;
  122330. /**
  122331. * Gets the list of input points
  122332. */
  122333. readonly inputs: NodeMaterialConnectionPoint[];
  122334. /** Gets the list of output points */
  122335. readonly outputs: NodeMaterialConnectionPoint[];
  122336. /**
  122337. * Find an input by its name
  122338. * @param name defines the name of the input to look for
  122339. * @returns the input or null if not found
  122340. */
  122341. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122342. /**
  122343. * Find an output by its name
  122344. * @param name defines the name of the outputto look for
  122345. * @returns the output or null if not found
  122346. */
  122347. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122348. /**
  122349. * Creates a new NodeMaterialBlock
  122350. * @param name defines the block name
  122351. * @param target defines the target of that block (Vertex by default)
  122352. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122353. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122354. */
  122355. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122356. /**
  122357. * Initialize the block and prepare the context for build
  122358. * @param state defines the state that will be used for the build
  122359. */
  122360. initialize(state: NodeMaterialBuildState): void;
  122361. /**
  122362. * Bind data to effect. Will only be called for blocks with isBindable === true
  122363. * @param effect defines the effect to bind data to
  122364. * @param nodeMaterial defines the hosting NodeMaterial
  122365. * @param mesh defines the mesh that will be rendered
  122366. */
  122367. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122368. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122369. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122370. protected _writeFloat(value: number): string;
  122371. /**
  122372. * Gets the current class name e.g. "NodeMaterialBlock"
  122373. * @returns the class name
  122374. */
  122375. getClassName(): string;
  122376. /**
  122377. * Register a new input. Must be called inside a block constructor
  122378. * @param name defines the connection point name
  122379. * @param type defines the connection point type
  122380. * @param isOptional defines a boolean indicating that this input can be omitted
  122381. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122382. * @returns the current block
  122383. */
  122384. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122385. /**
  122386. * Register a new output. Must be called inside a block constructor
  122387. * @param name defines the connection point name
  122388. * @param type defines the connection point type
  122389. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122390. * @returns the current block
  122391. */
  122392. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122393. /**
  122394. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122395. * @param forOutput defines an optional connection point to check compatibility with
  122396. * @returns the first available input or null
  122397. */
  122398. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122399. /**
  122400. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122401. * @param forBlock defines an optional block to check compatibility with
  122402. * @returns the first available input or null
  122403. */
  122404. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122405. /**
  122406. * Gets the sibling of the given output
  122407. * @param current defines the current output
  122408. * @returns the next output in the list or null
  122409. */
  122410. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122411. /**
  122412. * Connect current block with another block
  122413. * @param other defines the block to connect with
  122414. * @param options define the various options to help pick the right connections
  122415. * @returns the current block
  122416. */
  122417. connectTo(other: NodeMaterialBlock, options?: {
  122418. input?: string;
  122419. output?: string;
  122420. outputSwizzle?: string;
  122421. }): this | undefined;
  122422. protected _buildBlock(state: NodeMaterialBuildState): void;
  122423. /**
  122424. * Add uniforms, samplers and uniform buffers at compilation time
  122425. * @param state defines the state to update
  122426. * @param nodeMaterial defines the node material requesting the update
  122427. * @param defines defines the material defines to update
  122428. * @param uniformBuffers defines the list of uniform buffer names
  122429. */
  122430. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122431. /**
  122432. * Add potential fallbacks if shader compilation fails
  122433. * @param mesh defines the mesh to be rendered
  122434. * @param fallbacks defines the current prioritized list of fallbacks
  122435. */
  122436. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122437. /**
  122438. * Initialize defines for shader compilation
  122439. * @param mesh defines the mesh to be rendered
  122440. * @param nodeMaterial defines the node material requesting the update
  122441. * @param defines defines the material defines to update
  122442. * @param useInstances specifies that instances should be used
  122443. */
  122444. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122445. /**
  122446. * Update defines for shader compilation
  122447. * @param mesh defines the mesh to be rendered
  122448. * @param nodeMaterial defines the node material requesting the update
  122449. * @param defines defines the material defines to update
  122450. * @param useInstances specifies that instances should be used
  122451. */
  122452. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122453. /**
  122454. * Lets the block try to connect some inputs automatically
  122455. * @param material defines the hosting NodeMaterial
  122456. */
  122457. autoConfigure(material: NodeMaterial): void;
  122458. /**
  122459. * Function called when a block is declared as repeatable content generator
  122460. * @param vertexShaderState defines the current compilation state for the vertex shader
  122461. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122462. * @param mesh defines the mesh to be rendered
  122463. * @param defines defines the material defines to update
  122464. */
  122465. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122466. /**
  122467. * Checks if the block is ready
  122468. * @param mesh defines the mesh to be rendered
  122469. * @param nodeMaterial defines the node material requesting the update
  122470. * @param defines defines the material defines to update
  122471. * @param useInstances specifies that instances should be used
  122472. * @returns true if the block is ready
  122473. */
  122474. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122475. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122476. private _processBuild;
  122477. /**
  122478. * Compile the current node and generate the shader code
  122479. * @param state defines the current compilation state (uniforms, samplers, current string)
  122480. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122481. * @returns true if already built
  122482. */
  122483. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122484. protected _inputRename(name: string): string;
  122485. protected _outputRename(name: string): string;
  122486. protected _dumpPropertiesCode(): string;
  122487. /** @hidden */
  122488. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122489. /** @hidden */
  122490. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122491. /**
  122492. * Clone the current block to a new identical block
  122493. * @param scene defines the hosting scene
  122494. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122495. * @returns a copy of the current block
  122496. */
  122497. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122498. /**
  122499. * Serializes this block in a JSON representation
  122500. * @returns the serialized block object
  122501. */
  122502. serialize(): any;
  122503. /** @hidden */
  122504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122505. /**
  122506. * Release resources
  122507. */
  122508. dispose(): void;
  122509. }
  122510. }
  122511. declare module BABYLON {
  122512. /**
  122513. * Enum defining the type of animations supported by InputBlock
  122514. */
  122515. export enum AnimatedInputBlockTypes {
  122516. /** No animation */
  122517. None = 0,
  122518. /** Time based animation. Will only work for floats */
  122519. Time = 1
  122520. }
  122521. }
  122522. declare module BABYLON {
  122523. /**
  122524. * Block used to expose an input value
  122525. */
  122526. export class InputBlock extends NodeMaterialBlock {
  122527. private _mode;
  122528. private _associatedVariableName;
  122529. private _storedValue;
  122530. private _valueCallback;
  122531. private _type;
  122532. private _animationType;
  122533. /** Gets or set a value used to limit the range of float values */
  122534. min: number;
  122535. /** Gets or set a value used to limit the range of float values */
  122536. max: number;
  122537. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122538. matrixMode: number;
  122539. /** @hidden */
  122540. _systemValue: Nullable<NodeMaterialSystemValues>;
  122541. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122542. visibleInInspector: boolean;
  122543. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122544. isConstant: boolean;
  122545. /**
  122546. * Gets or sets the connection point type (default is float)
  122547. */
  122548. readonly type: NodeMaterialBlockConnectionPointTypes;
  122549. /**
  122550. * Creates a new InputBlock
  122551. * @param name defines the block name
  122552. * @param target defines the target of that block (Vertex by default)
  122553. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122554. */
  122555. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122556. /**
  122557. * Gets the output component
  122558. */
  122559. readonly output: NodeMaterialConnectionPoint;
  122560. /**
  122561. * Set the source of this connection point to a vertex attribute
  122562. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122563. * @returns the current connection point
  122564. */
  122565. setAsAttribute(attributeName?: string): InputBlock;
  122566. /**
  122567. * Set the source of this connection point to a system value
  122568. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122569. * @returns the current connection point
  122570. */
  122571. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122572. /**
  122573. * Gets or sets the value of that point.
  122574. * Please note that this value will be ignored if valueCallback is defined
  122575. */
  122576. value: any;
  122577. /**
  122578. * Gets or sets a callback used to get the value of that point.
  122579. * Please note that setting this value will force the connection point to ignore the value property
  122580. */
  122581. valueCallback: () => any;
  122582. /**
  122583. * Gets or sets the associated variable name in the shader
  122584. */
  122585. associatedVariableName: string;
  122586. /** Gets or sets the type of animation applied to the input */
  122587. animationType: AnimatedInputBlockTypes;
  122588. /**
  122589. * Gets a boolean indicating that this connection point not defined yet
  122590. */
  122591. readonly isUndefined: boolean;
  122592. /**
  122593. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122594. * In this case the connection point name must be the name of the uniform to use.
  122595. * Can only be set on inputs
  122596. */
  122597. isUniform: boolean;
  122598. /**
  122599. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122600. * In this case the connection point name must be the name of the attribute to use
  122601. * Can only be set on inputs
  122602. */
  122603. isAttribute: boolean;
  122604. /**
  122605. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122606. * Can only be set on exit points
  122607. */
  122608. isVarying: boolean;
  122609. /**
  122610. * Gets a boolean indicating that the current connection point is a system value
  122611. */
  122612. readonly isSystemValue: boolean;
  122613. /**
  122614. * Gets or sets the current well known value or null if not defined as a system value
  122615. */
  122616. systemValue: Nullable<NodeMaterialSystemValues>;
  122617. /**
  122618. * Gets the current class name
  122619. * @returns the class name
  122620. */
  122621. getClassName(): string;
  122622. /**
  122623. * Animate the input if animationType !== None
  122624. * @param scene defines the rendering scene
  122625. */
  122626. animate(scene: Scene): void;
  122627. private _emitDefine;
  122628. initialize(state: NodeMaterialBuildState): void;
  122629. /**
  122630. * Set the input block to its default value (based on its type)
  122631. */
  122632. setDefaultValue(): void;
  122633. private _emitConstant;
  122634. private _emit;
  122635. /** @hidden */
  122636. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122637. /** @hidden */
  122638. _transmit(effect: Effect, scene: Scene): void;
  122639. protected _buildBlock(state: NodeMaterialBuildState): void;
  122640. protected _dumpPropertiesCode(): string;
  122641. serialize(): any;
  122642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122643. }
  122644. }
  122645. declare module BABYLON {
  122646. /**
  122647. * Enum used to define the compatibility state between two connection points
  122648. */
  122649. export enum NodeMaterialConnectionPointCompatibilityStates {
  122650. /** Points are compatibles */
  122651. Compatible = 0,
  122652. /** Points are incompatible because of their types */
  122653. TypeIncompatible = 1,
  122654. /** Points are incompatible because of their targets (vertex vs fragment) */
  122655. TargetIncompatible = 2
  122656. }
  122657. /**
  122658. * Defines a connection point for a block
  122659. */
  122660. export class NodeMaterialConnectionPoint {
  122661. /** @hidden */
  122662. _ownerBlock: NodeMaterialBlock;
  122663. /** @hidden */
  122664. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122665. private _endpoints;
  122666. private _associatedVariableName;
  122667. /** @hidden */
  122668. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122669. /** @hidden */
  122670. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122671. private _type;
  122672. /** @hidden */
  122673. _enforceAssociatedVariableName: boolean;
  122674. /**
  122675. * Gets or sets the additional types supported by this connection point
  122676. */
  122677. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122678. /**
  122679. * Gets or sets the additional types excluded by this connection point
  122680. */
  122681. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122682. /**
  122683. * Observable triggered when this point is connected
  122684. */
  122685. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122686. /**
  122687. * Gets or sets the associated variable name in the shader
  122688. */
  122689. associatedVariableName: string;
  122690. /**
  122691. * Gets or sets the connection point type (default is float)
  122692. */
  122693. type: NodeMaterialBlockConnectionPointTypes;
  122694. /**
  122695. * Gets or sets the connection point name
  122696. */
  122697. name: string;
  122698. /**
  122699. * Gets or sets a boolean indicating that this connection point can be omitted
  122700. */
  122701. isOptional: boolean;
  122702. /**
  122703. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122704. */
  122705. define: string;
  122706. /** @hidden */
  122707. _prioritizeVertex: boolean;
  122708. private _target;
  122709. /** Gets or sets the target of that connection point */
  122710. target: NodeMaterialBlockTargets;
  122711. /**
  122712. * Gets a boolean indicating that the current point is connected
  122713. */
  122714. readonly isConnected: boolean;
  122715. /**
  122716. * Gets a boolean indicating that the current point is connected to an input block
  122717. */
  122718. readonly isConnectedToInputBlock: boolean;
  122719. /**
  122720. * Gets a the connected input block (if any)
  122721. */
  122722. readonly connectInputBlock: Nullable<InputBlock>;
  122723. /** Get the other side of the connection (if any) */
  122724. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122725. /** Get the block that owns this connection point */
  122726. readonly ownerBlock: NodeMaterialBlock;
  122727. /** Get the block connected on the other side of this connection (if any) */
  122728. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122729. /** Get the block connected on the endpoints of this connection (if any) */
  122730. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122731. /** Gets the list of connected endpoints */
  122732. readonly endpoints: NodeMaterialConnectionPoint[];
  122733. /** Gets a boolean indicating if that output point is connected to at least one input */
  122734. readonly hasEndpoints: boolean;
  122735. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122736. readonly isConnectedInVertexShader: boolean;
  122737. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122738. readonly isConnectedInFragmentShader: boolean;
  122739. /**
  122740. * Creates a new connection point
  122741. * @param name defines the connection point name
  122742. * @param ownerBlock defines the block hosting this connection point
  122743. */
  122744. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122745. /**
  122746. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122747. * @returns the class name
  122748. */
  122749. getClassName(): string;
  122750. /**
  122751. * Gets a boolean indicating if the current point can be connected to another point
  122752. * @param connectionPoint defines the other connection point
  122753. * @returns a boolean
  122754. */
  122755. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122756. /**
  122757. * Gets a number indicating if the current point can be connected to another point
  122758. * @param connectionPoint defines the other connection point
  122759. * @returns a number defining the compatibility state
  122760. */
  122761. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  122762. /**
  122763. * Connect this point to another connection point
  122764. * @param connectionPoint defines the other connection point
  122765. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122766. * @returns the current connection point
  122767. */
  122768. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122769. /**
  122770. * Disconnect this point from one of his endpoint
  122771. * @param endpoint defines the other connection point
  122772. * @returns the current connection point
  122773. */
  122774. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122775. /**
  122776. * Serializes this point in a JSON representation
  122777. * @returns the serialized point object
  122778. */
  122779. serialize(): any;
  122780. /**
  122781. * Release resources
  122782. */
  122783. dispose(): void;
  122784. }
  122785. }
  122786. declare module BABYLON {
  122787. /**
  122788. * Block used to add support for vertex skinning (bones)
  122789. */
  122790. export class BonesBlock extends NodeMaterialBlock {
  122791. /**
  122792. * Creates a new BonesBlock
  122793. * @param name defines the block name
  122794. */
  122795. constructor(name: string);
  122796. /**
  122797. * Initialize the block and prepare the context for build
  122798. * @param state defines the state that will be used for the build
  122799. */
  122800. initialize(state: NodeMaterialBuildState): void;
  122801. /**
  122802. * Gets the current class name
  122803. * @returns the class name
  122804. */
  122805. getClassName(): string;
  122806. /**
  122807. * Gets the matrix indices input component
  122808. */
  122809. readonly matricesIndices: NodeMaterialConnectionPoint;
  122810. /**
  122811. * Gets the matrix weights input component
  122812. */
  122813. readonly matricesWeights: NodeMaterialConnectionPoint;
  122814. /**
  122815. * Gets the extra matrix indices input component
  122816. */
  122817. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122818. /**
  122819. * Gets the extra matrix weights input component
  122820. */
  122821. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122822. /**
  122823. * Gets the world input component
  122824. */
  122825. readonly world: NodeMaterialConnectionPoint;
  122826. /**
  122827. * Gets the output component
  122828. */
  122829. readonly output: NodeMaterialConnectionPoint;
  122830. autoConfigure(material: NodeMaterial): void;
  122831. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122834. protected _buildBlock(state: NodeMaterialBuildState): this;
  122835. }
  122836. }
  122837. declare module BABYLON {
  122838. /**
  122839. * Block used to add support for instances
  122840. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122841. */
  122842. export class InstancesBlock extends NodeMaterialBlock {
  122843. /**
  122844. * Creates a new InstancesBlock
  122845. * @param name defines the block name
  122846. */
  122847. constructor(name: string);
  122848. /**
  122849. * Gets the current class name
  122850. * @returns the class name
  122851. */
  122852. getClassName(): string;
  122853. /**
  122854. * Gets the first world row input component
  122855. */
  122856. readonly world0: NodeMaterialConnectionPoint;
  122857. /**
  122858. * Gets the second world row input component
  122859. */
  122860. readonly world1: NodeMaterialConnectionPoint;
  122861. /**
  122862. * Gets the third world row input component
  122863. */
  122864. readonly world2: NodeMaterialConnectionPoint;
  122865. /**
  122866. * Gets the forth world row input component
  122867. */
  122868. readonly world3: NodeMaterialConnectionPoint;
  122869. /**
  122870. * Gets the world input component
  122871. */
  122872. readonly world: NodeMaterialConnectionPoint;
  122873. /**
  122874. * Gets the output component
  122875. */
  122876. readonly output: NodeMaterialConnectionPoint;
  122877. autoConfigure(material: NodeMaterial): void;
  122878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122879. protected _buildBlock(state: NodeMaterialBuildState): this;
  122880. }
  122881. }
  122882. declare module BABYLON {
  122883. /**
  122884. * Block used to add morph targets support to vertex shader
  122885. */
  122886. export class MorphTargetsBlock extends NodeMaterialBlock {
  122887. private _repeatableContentAnchor;
  122888. private _repeatebleContentGenerated;
  122889. /**
  122890. * Create a new MorphTargetsBlock
  122891. * @param name defines the block name
  122892. */
  122893. constructor(name: string);
  122894. /**
  122895. * Gets the current class name
  122896. * @returns the class name
  122897. */
  122898. getClassName(): string;
  122899. /**
  122900. * Gets the position input component
  122901. */
  122902. readonly position: NodeMaterialConnectionPoint;
  122903. /**
  122904. * Gets the normal input component
  122905. */
  122906. readonly normal: NodeMaterialConnectionPoint;
  122907. /**
  122908. * Gets the tangent input component
  122909. */
  122910. readonly tangent: NodeMaterialConnectionPoint;
  122911. /**
  122912. * Gets the tangent input component
  122913. */
  122914. readonly uv: NodeMaterialConnectionPoint;
  122915. /**
  122916. * Gets the position output component
  122917. */
  122918. readonly positionOutput: NodeMaterialConnectionPoint;
  122919. /**
  122920. * Gets the normal output component
  122921. */
  122922. readonly normalOutput: NodeMaterialConnectionPoint;
  122923. /**
  122924. * Gets the tangent output component
  122925. */
  122926. readonly tangentOutput: NodeMaterialConnectionPoint;
  122927. /**
  122928. * Gets the tangent output component
  122929. */
  122930. readonly uvOutput: NodeMaterialConnectionPoint;
  122931. initialize(state: NodeMaterialBuildState): void;
  122932. autoConfigure(material: NodeMaterial): void;
  122933. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122935. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122936. protected _buildBlock(state: NodeMaterialBuildState): this;
  122937. }
  122938. }
  122939. declare module BABYLON {
  122940. /**
  122941. * Block used to get data information from a light
  122942. */
  122943. export class LightInformationBlock extends NodeMaterialBlock {
  122944. private _lightDataUniformName;
  122945. private _lightColorUniformName;
  122946. private _lightTypeDefineName;
  122947. /**
  122948. * Gets or sets the light associated with this block
  122949. */
  122950. light: Nullable<Light>;
  122951. /**
  122952. * Creates a new LightInformationBlock
  122953. * @param name defines the block name
  122954. */
  122955. constructor(name: string);
  122956. /**
  122957. * Gets the current class name
  122958. * @returns the class name
  122959. */
  122960. getClassName(): string;
  122961. /**
  122962. * Gets the world position input component
  122963. */
  122964. readonly worldPosition: NodeMaterialConnectionPoint;
  122965. /**
  122966. * Gets the direction output component
  122967. */
  122968. readonly direction: NodeMaterialConnectionPoint;
  122969. /**
  122970. * Gets the direction output component
  122971. */
  122972. readonly color: NodeMaterialConnectionPoint;
  122973. /**
  122974. * Gets the direction output component
  122975. */
  122976. readonly intensity: NodeMaterialConnectionPoint;
  122977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122979. protected _buildBlock(state: NodeMaterialBuildState): this;
  122980. serialize(): any;
  122981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122982. }
  122983. }
  122984. declare module BABYLON {
  122985. /**
  122986. * Block used to add image processing support to fragment shader
  122987. */
  122988. export class ImageProcessingBlock extends NodeMaterialBlock {
  122989. /**
  122990. * Create a new ImageProcessingBlock
  122991. * @param name defines the block name
  122992. */
  122993. constructor(name: string);
  122994. /**
  122995. * Gets the current class name
  122996. * @returns the class name
  122997. */
  122998. getClassName(): string;
  122999. /**
  123000. * Gets the color input component
  123001. */
  123002. readonly color: NodeMaterialConnectionPoint;
  123003. /**
  123004. * Gets the output component
  123005. */
  123006. readonly output: NodeMaterialConnectionPoint;
  123007. /**
  123008. * Initialize the block and prepare the context for build
  123009. * @param state defines the state that will be used for the build
  123010. */
  123011. initialize(state: NodeMaterialBuildState): void;
  123012. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  123013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123015. protected _buildBlock(state: NodeMaterialBuildState): this;
  123016. }
  123017. }
  123018. declare module BABYLON {
  123019. /**
  123020. * Block used to pertub normals based on a normal map
  123021. */
  123022. export class PerturbNormalBlock extends NodeMaterialBlock {
  123023. private _tangentSpaceParameterName;
  123024. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123025. invertX: boolean;
  123026. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123027. invertY: boolean;
  123028. /**
  123029. * Create a new PerturbNormalBlock
  123030. * @param name defines the block name
  123031. */
  123032. constructor(name: string);
  123033. /**
  123034. * Gets the current class name
  123035. * @returns the class name
  123036. */
  123037. getClassName(): string;
  123038. /**
  123039. * Gets the world position input component
  123040. */
  123041. readonly worldPosition: NodeMaterialConnectionPoint;
  123042. /**
  123043. * Gets the world normal input component
  123044. */
  123045. readonly worldNormal: NodeMaterialConnectionPoint;
  123046. /**
  123047. * Gets the uv input component
  123048. */
  123049. readonly uv: NodeMaterialConnectionPoint;
  123050. /**
  123051. * Gets the normal map color input component
  123052. */
  123053. readonly normalMapColor: NodeMaterialConnectionPoint;
  123054. /**
  123055. * Gets the strength input component
  123056. */
  123057. readonly strength: NodeMaterialConnectionPoint;
  123058. /**
  123059. * Gets the output component
  123060. */
  123061. readonly output: NodeMaterialConnectionPoint;
  123062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123064. autoConfigure(material: NodeMaterial): void;
  123065. protected _buildBlock(state: NodeMaterialBuildState): this;
  123066. protected _dumpPropertiesCode(): string;
  123067. serialize(): any;
  123068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123069. }
  123070. }
  123071. declare module BABYLON {
  123072. /**
  123073. * Block used to discard a pixel if a value is smaller than a cutoff
  123074. */
  123075. export class DiscardBlock extends NodeMaterialBlock {
  123076. /**
  123077. * Create a new DiscardBlock
  123078. * @param name defines the block name
  123079. */
  123080. constructor(name: string);
  123081. /**
  123082. * Gets the current class name
  123083. * @returns the class name
  123084. */
  123085. getClassName(): string;
  123086. /**
  123087. * Gets the color input component
  123088. */
  123089. readonly value: NodeMaterialConnectionPoint;
  123090. /**
  123091. * Gets the cutoff input component
  123092. */
  123093. readonly cutoff: NodeMaterialConnectionPoint;
  123094. protected _buildBlock(state: NodeMaterialBuildState): this;
  123095. }
  123096. }
  123097. declare module BABYLON {
  123098. /**
  123099. * Block used to test if the fragment shader is front facing
  123100. */
  123101. export class FrontFacingBlock extends NodeMaterialBlock {
  123102. /**
  123103. * Creates a new FrontFacingBlock
  123104. * @param name defines the block name
  123105. */
  123106. constructor(name: string);
  123107. /**
  123108. * Gets the current class name
  123109. * @returns the class name
  123110. */
  123111. getClassName(): string;
  123112. /**
  123113. * Gets the output component
  123114. */
  123115. readonly output: NodeMaterialConnectionPoint;
  123116. protected _buildBlock(state: NodeMaterialBuildState): this;
  123117. }
  123118. }
  123119. declare module BABYLON {
  123120. /**
  123121. * Block used to add support for scene fog
  123122. */
  123123. export class FogBlock extends NodeMaterialBlock {
  123124. private _fogDistanceName;
  123125. private _fogParameters;
  123126. /**
  123127. * Create a new FogBlock
  123128. * @param name defines the block name
  123129. */
  123130. constructor(name: string);
  123131. /**
  123132. * Gets the current class name
  123133. * @returns the class name
  123134. */
  123135. getClassName(): string;
  123136. /**
  123137. * Gets the world position input component
  123138. */
  123139. readonly worldPosition: NodeMaterialConnectionPoint;
  123140. /**
  123141. * Gets the view input component
  123142. */
  123143. readonly view: NodeMaterialConnectionPoint;
  123144. /**
  123145. * Gets the color input component
  123146. */
  123147. readonly input: NodeMaterialConnectionPoint;
  123148. /**
  123149. * Gets the fog color input component
  123150. */
  123151. readonly fogColor: NodeMaterialConnectionPoint;
  123152. /**
  123153. * Gets the output component
  123154. */
  123155. readonly output: NodeMaterialConnectionPoint;
  123156. autoConfigure(material: NodeMaterial): void;
  123157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123159. protected _buildBlock(state: NodeMaterialBuildState): this;
  123160. }
  123161. }
  123162. declare module BABYLON {
  123163. /**
  123164. * Block used to add light in the fragment shader
  123165. */
  123166. export class LightBlock extends NodeMaterialBlock {
  123167. private _lightId;
  123168. /**
  123169. * Gets or sets the light associated with this block
  123170. */
  123171. light: Nullable<Light>;
  123172. /**
  123173. * Create a new LightBlock
  123174. * @param name defines the block name
  123175. */
  123176. constructor(name: string);
  123177. /**
  123178. * Gets the current class name
  123179. * @returns the class name
  123180. */
  123181. getClassName(): string;
  123182. /**
  123183. * Gets the world position input component
  123184. */
  123185. readonly worldPosition: NodeMaterialConnectionPoint;
  123186. /**
  123187. * Gets the world normal input component
  123188. */
  123189. readonly worldNormal: NodeMaterialConnectionPoint;
  123190. /**
  123191. * Gets the camera (or eye) position component
  123192. */
  123193. readonly cameraPosition: NodeMaterialConnectionPoint;
  123194. /**
  123195. * Gets the glossiness component
  123196. */
  123197. readonly glossiness: NodeMaterialConnectionPoint;
  123198. /**
  123199. * Gets the glossinness power component
  123200. */
  123201. readonly glossPower: NodeMaterialConnectionPoint;
  123202. /**
  123203. * Gets the diffuse color component
  123204. */
  123205. readonly diffuseColor: NodeMaterialConnectionPoint;
  123206. /**
  123207. * Gets the specular color component
  123208. */
  123209. readonly specularColor: NodeMaterialConnectionPoint;
  123210. /**
  123211. * Gets the diffuse output component
  123212. */
  123213. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123214. /**
  123215. * Gets the specular output component
  123216. */
  123217. readonly specularOutput: NodeMaterialConnectionPoint;
  123218. autoConfigure(material: NodeMaterial): void;
  123219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123220. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123222. private _injectVertexCode;
  123223. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123224. serialize(): any;
  123225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123226. }
  123227. }
  123228. declare module BABYLON {
  123229. /**
  123230. * Block used to multiply 2 values
  123231. */
  123232. export class MultiplyBlock extends NodeMaterialBlock {
  123233. /**
  123234. * Creates a new MultiplyBlock
  123235. * @param name defines the block name
  123236. */
  123237. constructor(name: string);
  123238. /**
  123239. * Gets the current class name
  123240. * @returns the class name
  123241. */
  123242. getClassName(): string;
  123243. /**
  123244. * Gets the left operand input component
  123245. */
  123246. readonly left: NodeMaterialConnectionPoint;
  123247. /**
  123248. * Gets the right operand input component
  123249. */
  123250. readonly right: NodeMaterialConnectionPoint;
  123251. /**
  123252. * Gets the output component
  123253. */
  123254. readonly output: NodeMaterialConnectionPoint;
  123255. protected _buildBlock(state: NodeMaterialBuildState): this;
  123256. }
  123257. }
  123258. declare module BABYLON {
  123259. /**
  123260. * Block used to add 2 vectors
  123261. */
  123262. export class AddBlock extends NodeMaterialBlock {
  123263. /**
  123264. * Creates a new AddBlock
  123265. * @param name defines the block name
  123266. */
  123267. constructor(name: string);
  123268. /**
  123269. * Gets the current class name
  123270. * @returns the class name
  123271. */
  123272. getClassName(): string;
  123273. /**
  123274. * Gets the left operand input component
  123275. */
  123276. readonly left: NodeMaterialConnectionPoint;
  123277. /**
  123278. * Gets the right operand input component
  123279. */
  123280. readonly right: NodeMaterialConnectionPoint;
  123281. /**
  123282. * Gets the output component
  123283. */
  123284. readonly output: NodeMaterialConnectionPoint;
  123285. protected _buildBlock(state: NodeMaterialBuildState): this;
  123286. }
  123287. }
  123288. declare module BABYLON {
  123289. /**
  123290. * Block used to scale a vector by a float
  123291. */
  123292. export class ScaleBlock extends NodeMaterialBlock {
  123293. /**
  123294. * Creates a new ScaleBlock
  123295. * @param name defines the block name
  123296. */
  123297. constructor(name: string);
  123298. /**
  123299. * Gets the current class name
  123300. * @returns the class name
  123301. */
  123302. getClassName(): string;
  123303. /**
  123304. * Gets the input component
  123305. */
  123306. readonly input: NodeMaterialConnectionPoint;
  123307. /**
  123308. * Gets the factor input component
  123309. */
  123310. readonly factor: NodeMaterialConnectionPoint;
  123311. /**
  123312. * Gets the output component
  123313. */
  123314. readonly output: NodeMaterialConnectionPoint;
  123315. protected _buildBlock(state: NodeMaterialBuildState): this;
  123316. }
  123317. }
  123318. declare module BABYLON {
  123319. /**
  123320. * Block used to clamp a float
  123321. */
  123322. export class ClampBlock extends NodeMaterialBlock {
  123323. /** Gets or sets the minimum range */
  123324. minimum: number;
  123325. /** Gets or sets the maximum range */
  123326. maximum: number;
  123327. /**
  123328. * Creates a new ClampBlock
  123329. * @param name defines the block name
  123330. */
  123331. constructor(name: string);
  123332. /**
  123333. * Gets the current class name
  123334. * @returns the class name
  123335. */
  123336. getClassName(): string;
  123337. /**
  123338. * Gets the value input component
  123339. */
  123340. readonly value: NodeMaterialConnectionPoint;
  123341. /**
  123342. * Gets the output component
  123343. */
  123344. readonly output: NodeMaterialConnectionPoint;
  123345. protected _buildBlock(state: NodeMaterialBuildState): this;
  123346. protected _dumpPropertiesCode(): string;
  123347. serialize(): any;
  123348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123349. }
  123350. }
  123351. declare module BABYLON {
  123352. /**
  123353. * Block used to apply a cross product between 2 vectors
  123354. */
  123355. export class CrossBlock extends NodeMaterialBlock {
  123356. /**
  123357. * Creates a new CrossBlock
  123358. * @param name defines the block name
  123359. */
  123360. constructor(name: string);
  123361. /**
  123362. * Gets the current class name
  123363. * @returns the class name
  123364. */
  123365. getClassName(): string;
  123366. /**
  123367. * Gets the left operand input component
  123368. */
  123369. readonly left: NodeMaterialConnectionPoint;
  123370. /**
  123371. * Gets the right operand input component
  123372. */
  123373. readonly right: NodeMaterialConnectionPoint;
  123374. /**
  123375. * Gets the output component
  123376. */
  123377. readonly output: NodeMaterialConnectionPoint;
  123378. protected _buildBlock(state: NodeMaterialBuildState): this;
  123379. }
  123380. }
  123381. declare module BABYLON {
  123382. /**
  123383. * Block used to apply a dot product between 2 vectors
  123384. */
  123385. export class DotBlock extends NodeMaterialBlock {
  123386. /**
  123387. * Creates a new DotBlock
  123388. * @param name defines the block name
  123389. */
  123390. constructor(name: string);
  123391. /**
  123392. * Gets the current class name
  123393. * @returns the class name
  123394. */
  123395. getClassName(): string;
  123396. /**
  123397. * Gets the left operand input component
  123398. */
  123399. readonly left: NodeMaterialConnectionPoint;
  123400. /**
  123401. * Gets the right operand input component
  123402. */
  123403. readonly right: NodeMaterialConnectionPoint;
  123404. /**
  123405. * Gets the output component
  123406. */
  123407. readonly output: NodeMaterialConnectionPoint;
  123408. protected _buildBlock(state: NodeMaterialBuildState): this;
  123409. }
  123410. }
  123411. declare module BABYLON {
  123412. /**
  123413. * Block used to remap a float from a range to a new one
  123414. */
  123415. export class RemapBlock extends NodeMaterialBlock {
  123416. /**
  123417. * Gets or sets the source range
  123418. */
  123419. sourceRange: Vector2;
  123420. /**
  123421. * Gets or sets the target range
  123422. */
  123423. targetRange: Vector2;
  123424. /**
  123425. * Creates a new RemapBlock
  123426. * @param name defines the block name
  123427. */
  123428. constructor(name: string);
  123429. /**
  123430. * Gets the current class name
  123431. * @returns the class name
  123432. */
  123433. getClassName(): string;
  123434. /**
  123435. * Gets the input component
  123436. */
  123437. readonly input: NodeMaterialConnectionPoint;
  123438. /**
  123439. * Gets the source min input component
  123440. */
  123441. readonly sourceMin: NodeMaterialConnectionPoint;
  123442. /**
  123443. * Gets the source max input component
  123444. */
  123445. readonly sourceMax: NodeMaterialConnectionPoint;
  123446. /**
  123447. * Gets the target min input component
  123448. */
  123449. readonly targetMin: NodeMaterialConnectionPoint;
  123450. /**
  123451. * Gets the target max input component
  123452. */
  123453. readonly targetMax: NodeMaterialConnectionPoint;
  123454. /**
  123455. * Gets the output component
  123456. */
  123457. readonly output: NodeMaterialConnectionPoint;
  123458. protected _buildBlock(state: NodeMaterialBuildState): this;
  123459. protected _dumpPropertiesCode(): string;
  123460. serialize(): any;
  123461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123462. }
  123463. }
  123464. declare module BABYLON {
  123465. /**
  123466. * Block used to normalize a vector
  123467. */
  123468. export class NormalizeBlock extends NodeMaterialBlock {
  123469. /**
  123470. * Creates a new NormalizeBlock
  123471. * @param name defines the block name
  123472. */
  123473. constructor(name: string);
  123474. /**
  123475. * Gets the current class name
  123476. * @returns the class name
  123477. */
  123478. getClassName(): string;
  123479. /**
  123480. * Gets the input component
  123481. */
  123482. readonly input: NodeMaterialConnectionPoint;
  123483. /**
  123484. * Gets the output component
  123485. */
  123486. readonly output: NodeMaterialConnectionPoint;
  123487. protected _buildBlock(state: NodeMaterialBuildState): this;
  123488. }
  123489. }
  123490. declare module BABYLON {
  123491. /**
  123492. * Operations supported by the Trigonometry block
  123493. */
  123494. export enum TrigonometryBlockOperations {
  123495. /** Cos */
  123496. Cos = 0,
  123497. /** Sin */
  123498. Sin = 1,
  123499. /** Abs */
  123500. Abs = 2,
  123501. /** Exp */
  123502. Exp = 3,
  123503. /** Exp2 */
  123504. Exp2 = 4,
  123505. /** Round */
  123506. Round = 5,
  123507. /** Floor */
  123508. Floor = 6,
  123509. /** Ceiling */
  123510. Ceiling = 7,
  123511. /** Square root */
  123512. Sqrt = 8,
  123513. /** Log */
  123514. Log = 9,
  123515. /** Tangent */
  123516. Tan = 10,
  123517. /** Arc tangent */
  123518. ArcTan = 11,
  123519. /** Arc cosinus */
  123520. ArcCos = 12,
  123521. /** Arc sinus */
  123522. ArcSin = 13,
  123523. /** Fraction */
  123524. Fract = 14,
  123525. /** Sign */
  123526. Sign = 15,
  123527. /** To radians (from degrees) */
  123528. Radians = 16,
  123529. /** To degrees (from radians) */
  123530. Degrees = 17
  123531. }
  123532. /**
  123533. * Block used to apply trigonometry operation to floats
  123534. */
  123535. export class TrigonometryBlock extends NodeMaterialBlock {
  123536. /**
  123537. * Gets or sets the operation applied by the block
  123538. */
  123539. operation: TrigonometryBlockOperations;
  123540. /**
  123541. * Creates a new TrigonometryBlock
  123542. * @param name defines the block name
  123543. */
  123544. constructor(name: string);
  123545. /**
  123546. * Gets the current class name
  123547. * @returns the class name
  123548. */
  123549. getClassName(): string;
  123550. /**
  123551. * Gets the input component
  123552. */
  123553. readonly input: NodeMaterialConnectionPoint;
  123554. /**
  123555. * Gets the output component
  123556. */
  123557. readonly output: NodeMaterialConnectionPoint;
  123558. protected _buildBlock(state: NodeMaterialBuildState): this;
  123559. serialize(): any;
  123560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123561. }
  123562. }
  123563. declare module BABYLON {
  123564. /**
  123565. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123566. */
  123567. export class ColorMergerBlock extends NodeMaterialBlock {
  123568. /**
  123569. * Create a new ColorMergerBlock
  123570. * @param name defines the block name
  123571. */
  123572. constructor(name: string);
  123573. /**
  123574. * Gets the current class name
  123575. * @returns the class name
  123576. */
  123577. getClassName(): string;
  123578. /**
  123579. * Gets the r component (input)
  123580. */
  123581. readonly r: NodeMaterialConnectionPoint;
  123582. /**
  123583. * Gets the g component (input)
  123584. */
  123585. readonly g: NodeMaterialConnectionPoint;
  123586. /**
  123587. * Gets the b component (input)
  123588. */
  123589. readonly b: NodeMaterialConnectionPoint;
  123590. /**
  123591. * Gets the a component (input)
  123592. */
  123593. readonly a: NodeMaterialConnectionPoint;
  123594. /**
  123595. * Gets the rgba component (output)
  123596. */
  123597. readonly rgba: NodeMaterialConnectionPoint;
  123598. /**
  123599. * Gets the rgb component (output)
  123600. */
  123601. readonly rgb: NodeMaterialConnectionPoint;
  123602. protected _buildBlock(state: NodeMaterialBuildState): this;
  123603. }
  123604. }
  123605. declare module BABYLON {
  123606. /**
  123607. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123608. */
  123609. export class VectorMergerBlock extends NodeMaterialBlock {
  123610. /**
  123611. * Create a new VectorMergerBlock
  123612. * @param name defines the block name
  123613. */
  123614. constructor(name: string);
  123615. /**
  123616. * Gets the current class name
  123617. * @returns the class name
  123618. */
  123619. getClassName(): string;
  123620. /**
  123621. * Gets the x component (input)
  123622. */
  123623. readonly x: NodeMaterialConnectionPoint;
  123624. /**
  123625. * Gets the y component (input)
  123626. */
  123627. readonly y: NodeMaterialConnectionPoint;
  123628. /**
  123629. * Gets the z component (input)
  123630. */
  123631. readonly z: NodeMaterialConnectionPoint;
  123632. /**
  123633. * Gets the w component (input)
  123634. */
  123635. readonly w: NodeMaterialConnectionPoint;
  123636. /**
  123637. * Gets the xyzw component (output)
  123638. */
  123639. readonly xyzw: NodeMaterialConnectionPoint;
  123640. /**
  123641. * Gets the xyz component (output)
  123642. */
  123643. readonly xyz: NodeMaterialConnectionPoint;
  123644. /**
  123645. * Gets the xy component (output)
  123646. */
  123647. readonly xy: NodeMaterialConnectionPoint;
  123648. protected _buildBlock(state: NodeMaterialBuildState): this;
  123649. }
  123650. }
  123651. declare module BABYLON {
  123652. /**
  123653. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123654. */
  123655. export class ColorSplitterBlock extends NodeMaterialBlock {
  123656. /**
  123657. * Create a new ColorSplitterBlock
  123658. * @param name defines the block name
  123659. */
  123660. constructor(name: string);
  123661. /**
  123662. * Gets the current class name
  123663. * @returns the class name
  123664. */
  123665. getClassName(): string;
  123666. /**
  123667. * Gets the rgba component (input)
  123668. */
  123669. readonly rgba: NodeMaterialConnectionPoint;
  123670. /**
  123671. * Gets the rgb component (input)
  123672. */
  123673. readonly rgbIn: NodeMaterialConnectionPoint;
  123674. /**
  123675. * Gets the rgb component (output)
  123676. */
  123677. readonly rgbOut: NodeMaterialConnectionPoint;
  123678. /**
  123679. * Gets the r component (output)
  123680. */
  123681. readonly r: NodeMaterialConnectionPoint;
  123682. /**
  123683. * Gets the g component (output)
  123684. */
  123685. readonly g: NodeMaterialConnectionPoint;
  123686. /**
  123687. * Gets the b component (output)
  123688. */
  123689. readonly b: NodeMaterialConnectionPoint;
  123690. /**
  123691. * Gets the a component (output)
  123692. */
  123693. readonly a: NodeMaterialConnectionPoint;
  123694. protected _inputRename(name: string): string;
  123695. protected _outputRename(name: string): string;
  123696. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123697. }
  123698. }
  123699. declare module BABYLON {
  123700. /**
  123701. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123702. */
  123703. export class VectorSplitterBlock extends NodeMaterialBlock {
  123704. /**
  123705. * Create a new VectorSplitterBlock
  123706. * @param name defines the block name
  123707. */
  123708. constructor(name: string);
  123709. /**
  123710. * Gets the current class name
  123711. * @returns the class name
  123712. */
  123713. getClassName(): string;
  123714. /**
  123715. * Gets the xyzw component (input)
  123716. */
  123717. readonly xyzw: NodeMaterialConnectionPoint;
  123718. /**
  123719. * Gets the xyz component (input)
  123720. */
  123721. readonly xyzIn: NodeMaterialConnectionPoint;
  123722. /**
  123723. * Gets the xy component (input)
  123724. */
  123725. readonly xyIn: NodeMaterialConnectionPoint;
  123726. /**
  123727. * Gets the xyz component (output)
  123728. */
  123729. readonly xyzOut: NodeMaterialConnectionPoint;
  123730. /**
  123731. * Gets the xy component (output)
  123732. */
  123733. readonly xyOut: NodeMaterialConnectionPoint;
  123734. /**
  123735. * Gets the x component (output)
  123736. */
  123737. readonly x: NodeMaterialConnectionPoint;
  123738. /**
  123739. * Gets the y component (output)
  123740. */
  123741. readonly y: NodeMaterialConnectionPoint;
  123742. /**
  123743. * Gets the z component (output)
  123744. */
  123745. readonly z: NodeMaterialConnectionPoint;
  123746. /**
  123747. * Gets the w component (output)
  123748. */
  123749. readonly w: NodeMaterialConnectionPoint;
  123750. protected _inputRename(name: string): string;
  123751. protected _outputRename(name: string): string;
  123752. protected _buildBlock(state: NodeMaterialBuildState): this;
  123753. }
  123754. }
  123755. declare module BABYLON {
  123756. /**
  123757. * Block used to lerp between 2 values
  123758. */
  123759. export class LerpBlock extends NodeMaterialBlock {
  123760. /**
  123761. * Creates a new LerpBlock
  123762. * @param name defines the block name
  123763. */
  123764. constructor(name: string);
  123765. /**
  123766. * Gets the current class name
  123767. * @returns the class name
  123768. */
  123769. getClassName(): string;
  123770. /**
  123771. * Gets the left operand input component
  123772. */
  123773. readonly left: NodeMaterialConnectionPoint;
  123774. /**
  123775. * Gets the right operand input component
  123776. */
  123777. readonly right: NodeMaterialConnectionPoint;
  123778. /**
  123779. * Gets the gradient operand input component
  123780. */
  123781. readonly gradient: NodeMaterialConnectionPoint;
  123782. /**
  123783. * Gets the output component
  123784. */
  123785. readonly output: NodeMaterialConnectionPoint;
  123786. protected _buildBlock(state: NodeMaterialBuildState): this;
  123787. }
  123788. }
  123789. declare module BABYLON {
  123790. /**
  123791. * Block used to divide 2 vectors
  123792. */
  123793. export class DivideBlock extends NodeMaterialBlock {
  123794. /**
  123795. * Creates a new DivideBlock
  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 left operand input component
  123806. */
  123807. readonly left: NodeMaterialConnectionPoint;
  123808. /**
  123809. * Gets the right operand input component
  123810. */
  123811. readonly right: NodeMaterialConnectionPoint;
  123812. /**
  123813. * Gets the output component
  123814. */
  123815. readonly output: NodeMaterialConnectionPoint;
  123816. protected _buildBlock(state: NodeMaterialBuildState): this;
  123817. }
  123818. }
  123819. declare module BABYLON {
  123820. /**
  123821. * Block used to subtract 2 vectors
  123822. */
  123823. export class SubtractBlock extends NodeMaterialBlock {
  123824. /**
  123825. * Creates a new SubtractBlock
  123826. * @param name defines the block name
  123827. */
  123828. constructor(name: string);
  123829. /**
  123830. * Gets the current class name
  123831. * @returns the class name
  123832. */
  123833. getClassName(): string;
  123834. /**
  123835. * Gets the left operand input component
  123836. */
  123837. readonly left: NodeMaterialConnectionPoint;
  123838. /**
  123839. * Gets the right operand input component
  123840. */
  123841. readonly right: NodeMaterialConnectionPoint;
  123842. /**
  123843. * Gets the output component
  123844. */
  123845. readonly output: NodeMaterialConnectionPoint;
  123846. protected _buildBlock(state: NodeMaterialBuildState): this;
  123847. }
  123848. }
  123849. declare module BABYLON {
  123850. /**
  123851. * Block used to step a value
  123852. */
  123853. export class StepBlock extends NodeMaterialBlock {
  123854. /**
  123855. * Creates a new StepBlock
  123856. * @param name defines the block name
  123857. */
  123858. constructor(name: string);
  123859. /**
  123860. * Gets the current class name
  123861. * @returns the class name
  123862. */
  123863. getClassName(): string;
  123864. /**
  123865. * Gets the value operand input component
  123866. */
  123867. readonly value: NodeMaterialConnectionPoint;
  123868. /**
  123869. * Gets the edge operand input component
  123870. */
  123871. readonly edge: NodeMaterialConnectionPoint;
  123872. /**
  123873. * Gets the output component
  123874. */
  123875. readonly output: NodeMaterialConnectionPoint;
  123876. protected _buildBlock(state: NodeMaterialBuildState): this;
  123877. }
  123878. }
  123879. declare module BABYLON {
  123880. /**
  123881. * Block used to get the opposite (1 - x) of a value
  123882. */
  123883. export class OneMinusBlock extends NodeMaterialBlock {
  123884. /**
  123885. * Creates a new OneMinusBlock
  123886. * @param name defines the block name
  123887. */
  123888. constructor(name: string);
  123889. /**
  123890. * Gets the current class name
  123891. * @returns the class name
  123892. */
  123893. getClassName(): string;
  123894. /**
  123895. * Gets the input component
  123896. */
  123897. readonly input: NodeMaterialConnectionPoint;
  123898. /**
  123899. * Gets the output component
  123900. */
  123901. readonly output: NodeMaterialConnectionPoint;
  123902. protected _buildBlock(state: NodeMaterialBuildState): this;
  123903. }
  123904. }
  123905. declare module BABYLON {
  123906. /**
  123907. * Block used to get the view direction
  123908. */
  123909. export class ViewDirectionBlock extends NodeMaterialBlock {
  123910. /**
  123911. * Creates a new ViewDirectionBlock
  123912. * @param name defines the block name
  123913. */
  123914. constructor(name: string);
  123915. /**
  123916. * Gets the current class name
  123917. * @returns the class name
  123918. */
  123919. getClassName(): string;
  123920. /**
  123921. * Gets the world position component
  123922. */
  123923. readonly worldPosition: NodeMaterialConnectionPoint;
  123924. /**
  123925. * Gets the camera position component
  123926. */
  123927. readonly cameraPosition: NodeMaterialConnectionPoint;
  123928. /**
  123929. * Gets the output component
  123930. */
  123931. readonly output: NodeMaterialConnectionPoint;
  123932. autoConfigure(material: NodeMaterial): void;
  123933. protected _buildBlock(state: NodeMaterialBuildState): this;
  123934. }
  123935. }
  123936. declare module BABYLON {
  123937. /**
  123938. * Block used to compute fresnel value
  123939. */
  123940. export class FresnelBlock extends NodeMaterialBlock {
  123941. /**
  123942. * Create a new FresnelBlock
  123943. * @param name defines the block name
  123944. */
  123945. constructor(name: string);
  123946. /**
  123947. * Gets the current class name
  123948. * @returns the class name
  123949. */
  123950. getClassName(): string;
  123951. /**
  123952. * Gets the world normal input component
  123953. */
  123954. readonly worldNormal: NodeMaterialConnectionPoint;
  123955. /**
  123956. * Gets the view direction input component
  123957. */
  123958. readonly viewDirection: NodeMaterialConnectionPoint;
  123959. /**
  123960. * Gets the bias input component
  123961. */
  123962. readonly bias: NodeMaterialConnectionPoint;
  123963. /**
  123964. * Gets the camera (or eye) position component
  123965. */
  123966. readonly power: NodeMaterialConnectionPoint;
  123967. /**
  123968. * Gets the fresnel output component
  123969. */
  123970. readonly fresnel: NodeMaterialConnectionPoint;
  123971. autoConfigure(material: NodeMaterial): void;
  123972. protected _buildBlock(state: NodeMaterialBuildState): this;
  123973. }
  123974. }
  123975. declare module BABYLON {
  123976. /**
  123977. * Block used to get the max of 2 values
  123978. */
  123979. export class MaxBlock extends NodeMaterialBlock {
  123980. /**
  123981. * Creates a new MaxBlock
  123982. * @param name defines the block name
  123983. */
  123984. constructor(name: string);
  123985. /**
  123986. * Gets the current class name
  123987. * @returns the class name
  123988. */
  123989. getClassName(): string;
  123990. /**
  123991. * Gets the left operand input component
  123992. */
  123993. readonly left: NodeMaterialConnectionPoint;
  123994. /**
  123995. * Gets the right operand input component
  123996. */
  123997. readonly right: NodeMaterialConnectionPoint;
  123998. /**
  123999. * Gets the output component
  124000. */
  124001. readonly output: NodeMaterialConnectionPoint;
  124002. protected _buildBlock(state: NodeMaterialBuildState): this;
  124003. }
  124004. }
  124005. declare module BABYLON {
  124006. /**
  124007. * Block used to get the min of 2 values
  124008. */
  124009. export class MinBlock extends NodeMaterialBlock {
  124010. /**
  124011. * Creates a new MinBlock
  124012. * @param name defines the block name
  124013. */
  124014. constructor(name: string);
  124015. /**
  124016. * Gets the current class name
  124017. * @returns the class name
  124018. */
  124019. getClassName(): string;
  124020. /**
  124021. * Gets the left operand input component
  124022. */
  124023. readonly left: NodeMaterialConnectionPoint;
  124024. /**
  124025. * Gets the right operand input component
  124026. */
  124027. readonly right: NodeMaterialConnectionPoint;
  124028. /**
  124029. * Gets the output component
  124030. */
  124031. readonly output: NodeMaterialConnectionPoint;
  124032. protected _buildBlock(state: NodeMaterialBuildState): this;
  124033. }
  124034. }
  124035. declare module BABYLON {
  124036. /**
  124037. * Block used to get the distance between 2 values
  124038. */
  124039. export class DistanceBlock extends NodeMaterialBlock {
  124040. /**
  124041. * Creates a new DistanceBlock
  124042. * @param name defines the block name
  124043. */
  124044. constructor(name: string);
  124045. /**
  124046. * Gets the current class name
  124047. * @returns the class name
  124048. */
  124049. getClassName(): string;
  124050. /**
  124051. * Gets the left operand input component
  124052. */
  124053. readonly left: NodeMaterialConnectionPoint;
  124054. /**
  124055. * Gets the right operand input component
  124056. */
  124057. readonly right: NodeMaterialConnectionPoint;
  124058. /**
  124059. * Gets the output component
  124060. */
  124061. readonly output: NodeMaterialConnectionPoint;
  124062. protected _buildBlock(state: NodeMaterialBuildState): this;
  124063. }
  124064. }
  124065. declare module BABYLON {
  124066. /**
  124067. * Block used to get the length of a vector
  124068. */
  124069. export class LengthBlock extends NodeMaterialBlock {
  124070. /**
  124071. * Creates a new LengthBlock
  124072. * @param name defines the block name
  124073. */
  124074. constructor(name: string);
  124075. /**
  124076. * Gets the current class name
  124077. * @returns the class name
  124078. */
  124079. getClassName(): string;
  124080. /**
  124081. * Gets the value input component
  124082. */
  124083. readonly value: NodeMaterialConnectionPoint;
  124084. /**
  124085. * Gets the output component
  124086. */
  124087. readonly output: NodeMaterialConnectionPoint;
  124088. protected _buildBlock(state: NodeMaterialBuildState): this;
  124089. }
  124090. }
  124091. declare module BABYLON {
  124092. /**
  124093. * Block used to get negative version of a value (i.e. x * -1)
  124094. */
  124095. export class NegateBlock extends NodeMaterialBlock {
  124096. /**
  124097. * Creates a new NegateBlock
  124098. * @param name defines the block name
  124099. */
  124100. constructor(name: string);
  124101. /**
  124102. * Gets the current class name
  124103. * @returns the class name
  124104. */
  124105. getClassName(): string;
  124106. /**
  124107. * Gets the value input component
  124108. */
  124109. readonly value: NodeMaterialConnectionPoint;
  124110. /**
  124111. * Gets the output component
  124112. */
  124113. readonly output: NodeMaterialConnectionPoint;
  124114. protected _buildBlock(state: NodeMaterialBuildState): this;
  124115. }
  124116. }
  124117. declare module BABYLON {
  124118. /**
  124119. * Block used to get the value of the first parameter raised to the power of the second
  124120. */
  124121. export class PowBlock extends NodeMaterialBlock {
  124122. /**
  124123. * Creates a new PowBlock
  124124. * @param name defines the block name
  124125. */
  124126. constructor(name: string);
  124127. /**
  124128. * Gets the current class name
  124129. * @returns the class name
  124130. */
  124131. getClassName(): string;
  124132. /**
  124133. * Gets the value operand input component
  124134. */
  124135. readonly value: NodeMaterialConnectionPoint;
  124136. /**
  124137. * Gets the power operand input component
  124138. */
  124139. readonly power: NodeMaterialConnectionPoint;
  124140. /**
  124141. * Gets the output component
  124142. */
  124143. readonly output: NodeMaterialConnectionPoint;
  124144. protected _buildBlock(state: NodeMaterialBuildState): this;
  124145. }
  124146. }
  124147. declare module BABYLON {
  124148. /**
  124149. * Block used to get a random number
  124150. */
  124151. export class RandomNumberBlock extends NodeMaterialBlock {
  124152. /**
  124153. * Creates a new RandomNumberBlock
  124154. * @param name defines the block name
  124155. */
  124156. constructor(name: string);
  124157. /**
  124158. * Gets the current class name
  124159. * @returns the class name
  124160. */
  124161. getClassName(): string;
  124162. /**
  124163. * Gets the seed input component
  124164. */
  124165. readonly seed: NodeMaterialConnectionPoint;
  124166. /**
  124167. * Gets the output component
  124168. */
  124169. readonly output: NodeMaterialConnectionPoint;
  124170. protected _buildBlock(state: NodeMaterialBuildState): this;
  124171. }
  124172. }
  124173. declare module BABYLON {
  124174. /**
  124175. * Block used to compute arc tangent of 2 values
  124176. */
  124177. export class ArcTan2Block extends NodeMaterialBlock {
  124178. /**
  124179. * Creates a new ArcTan2Block
  124180. * @param name defines the block name
  124181. */
  124182. constructor(name: string);
  124183. /**
  124184. * Gets the current class name
  124185. * @returns the class name
  124186. */
  124187. getClassName(): string;
  124188. /**
  124189. * Gets the x operand input component
  124190. */
  124191. readonly x: NodeMaterialConnectionPoint;
  124192. /**
  124193. * Gets the y operand input component
  124194. */
  124195. readonly y: NodeMaterialConnectionPoint;
  124196. /**
  124197. * Gets the output component
  124198. */
  124199. readonly output: NodeMaterialConnectionPoint;
  124200. protected _buildBlock(state: NodeMaterialBuildState): this;
  124201. }
  124202. }
  124203. declare module BABYLON {
  124204. /**
  124205. * Block used to smooth step a value
  124206. */
  124207. export class SmoothStepBlock extends NodeMaterialBlock {
  124208. /**
  124209. * Creates a new SmoothStepBlock
  124210. * @param name defines the block name
  124211. */
  124212. constructor(name: string);
  124213. /**
  124214. * Gets the current class name
  124215. * @returns the class name
  124216. */
  124217. getClassName(): string;
  124218. /**
  124219. * Gets the value operand input component
  124220. */
  124221. readonly value: NodeMaterialConnectionPoint;
  124222. /**
  124223. * Gets the first edge operand input component
  124224. */
  124225. readonly edge0: NodeMaterialConnectionPoint;
  124226. /**
  124227. * Gets the second edge operand input component
  124228. */
  124229. readonly edge1: NodeMaterialConnectionPoint;
  124230. /**
  124231. * Gets the output component
  124232. */
  124233. readonly output: NodeMaterialConnectionPoint;
  124234. protected _buildBlock(state: NodeMaterialBuildState): this;
  124235. }
  124236. }
  124237. declare module BABYLON {
  124238. /**
  124239. * Block used to get the reciprocal (1 / x) of a value
  124240. */
  124241. export class ReciprocalBlock extends NodeMaterialBlock {
  124242. /**
  124243. * Creates a new ReciprocalBlock
  124244. * @param name defines the block name
  124245. */
  124246. constructor(name: string);
  124247. /**
  124248. * Gets the current class name
  124249. * @returns the class name
  124250. */
  124251. getClassName(): string;
  124252. /**
  124253. * Gets the input component
  124254. */
  124255. readonly input: NodeMaterialConnectionPoint;
  124256. /**
  124257. * Gets the output component
  124258. */
  124259. readonly output: NodeMaterialConnectionPoint;
  124260. protected _buildBlock(state: NodeMaterialBuildState): this;
  124261. }
  124262. }
  124263. declare module BABYLON {
  124264. /**
  124265. * Block used to replace a color by another one
  124266. */
  124267. export class ReplaceColorBlock extends NodeMaterialBlock {
  124268. /**
  124269. * Creates a new ReplaceColorBlock
  124270. * @param name defines the block name
  124271. */
  124272. constructor(name: string);
  124273. /**
  124274. * Gets the current class name
  124275. * @returns the class name
  124276. */
  124277. getClassName(): string;
  124278. /**
  124279. * Gets the value input component
  124280. */
  124281. readonly value: NodeMaterialConnectionPoint;
  124282. /**
  124283. * Gets the reference input component
  124284. */
  124285. readonly reference: NodeMaterialConnectionPoint;
  124286. /**
  124287. * Gets the distance input component
  124288. */
  124289. readonly distance: NodeMaterialConnectionPoint;
  124290. /**
  124291. * Gets the replacement input component
  124292. */
  124293. readonly replacement: NodeMaterialConnectionPoint;
  124294. /**
  124295. * Gets the output component
  124296. */
  124297. readonly output: NodeMaterialConnectionPoint;
  124298. protected _buildBlock(state: NodeMaterialBuildState): this;
  124299. }
  124300. }
  124301. declare module BABYLON {
  124302. /**
  124303. * Block used to posterize a value
  124304. * @see https://en.wikipedia.org/wiki/Posterization
  124305. */
  124306. export class PosterizeBlock extends NodeMaterialBlock {
  124307. /**
  124308. * Creates a new PosterizeBlock
  124309. * @param name defines the block name
  124310. */
  124311. constructor(name: string);
  124312. /**
  124313. * Gets the current class name
  124314. * @returns the class name
  124315. */
  124316. getClassName(): string;
  124317. /**
  124318. * Gets the value input component
  124319. */
  124320. readonly value: NodeMaterialConnectionPoint;
  124321. /**
  124322. * Gets the steps input component
  124323. */
  124324. readonly steps: NodeMaterialConnectionPoint;
  124325. /**
  124326. * Gets the output component
  124327. */
  124328. readonly output: NodeMaterialConnectionPoint;
  124329. protected _buildBlock(state: NodeMaterialBuildState): this;
  124330. }
  124331. }
  124332. declare module BABYLON {
  124333. /**
  124334. * Operations supported by the Wave block
  124335. */
  124336. export enum WaveBlockKind {
  124337. /** SawTooth */
  124338. SawTooth = 0,
  124339. /** Square */
  124340. Square = 1,
  124341. /** Triangle */
  124342. Triangle = 2
  124343. }
  124344. /**
  124345. * Block used to apply wave operation to floats
  124346. */
  124347. export class WaveBlock extends NodeMaterialBlock {
  124348. /**
  124349. * Gets or sets the kibnd of wave to be applied by the block
  124350. */
  124351. kind: WaveBlockKind;
  124352. /**
  124353. * Creates a new WaveBlock
  124354. * @param name defines the block name
  124355. */
  124356. constructor(name: string);
  124357. /**
  124358. * Gets the current class name
  124359. * @returns the class name
  124360. */
  124361. getClassName(): string;
  124362. /**
  124363. * Gets the input component
  124364. */
  124365. readonly input: NodeMaterialConnectionPoint;
  124366. /**
  124367. * Gets the output component
  124368. */
  124369. readonly output: NodeMaterialConnectionPoint;
  124370. protected _buildBlock(state: NodeMaterialBuildState): this;
  124371. serialize(): any;
  124372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124373. }
  124374. }
  124375. declare module BABYLON {
  124376. /**
  124377. * Class used to store a color step for the GradientBlock
  124378. */
  124379. export class GradientBlockColorStep {
  124380. /**
  124381. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124382. */
  124383. step: number;
  124384. /**
  124385. * Gets or sets the color associated with this step
  124386. */
  124387. color: Color3;
  124388. /**
  124389. * Creates a new GradientBlockColorStep
  124390. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124391. * @param color defines the color associated with this step
  124392. */
  124393. constructor(
  124394. /**
  124395. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124396. */
  124397. step: number,
  124398. /**
  124399. * Gets or sets the color associated with this step
  124400. */
  124401. color: Color3);
  124402. }
  124403. /**
  124404. * Block used to return a color from a gradient based on an input value between 0 and 1
  124405. */
  124406. export class GradientBlock extends NodeMaterialBlock {
  124407. /**
  124408. * Gets or sets the list of color steps
  124409. */
  124410. colorSteps: GradientBlockColorStep[];
  124411. /**
  124412. * Creates a new GradientBlock
  124413. * @param name defines the block name
  124414. */
  124415. constructor(name: string);
  124416. /**
  124417. * Gets the current class name
  124418. * @returns the class name
  124419. */
  124420. getClassName(): string;
  124421. /**
  124422. * Gets the gradient input component
  124423. */
  124424. readonly gradient: NodeMaterialConnectionPoint;
  124425. /**
  124426. * Gets the output component
  124427. */
  124428. readonly output: NodeMaterialConnectionPoint;
  124429. private _writeColorConstant;
  124430. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124431. serialize(): any;
  124432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124433. protected _dumpPropertiesCode(): string;
  124434. }
  124435. }
  124436. declare module BABYLON {
  124437. /**
  124438. * Block used to normalize lerp between 2 values
  124439. */
  124440. export class NLerpBlock extends NodeMaterialBlock {
  124441. /**
  124442. * Creates a new NLerpBlock
  124443. * @param name defines the block name
  124444. */
  124445. constructor(name: string);
  124446. /**
  124447. * Gets the current class name
  124448. * @returns the class name
  124449. */
  124450. getClassName(): string;
  124451. /**
  124452. * Gets the left operand input component
  124453. */
  124454. readonly left: NodeMaterialConnectionPoint;
  124455. /**
  124456. * Gets the right operand input component
  124457. */
  124458. readonly right: NodeMaterialConnectionPoint;
  124459. /**
  124460. * Gets the gradient operand input component
  124461. */
  124462. readonly gradient: NodeMaterialConnectionPoint;
  124463. /**
  124464. * Gets the output component
  124465. */
  124466. readonly output: NodeMaterialConnectionPoint;
  124467. protected _buildBlock(state: NodeMaterialBuildState): this;
  124468. }
  124469. }
  124470. declare module BABYLON {
  124471. /**
  124472. * Effect Render Options
  124473. */
  124474. export interface IEffectRendererOptions {
  124475. /**
  124476. * Defines the vertices positions.
  124477. */
  124478. positions?: number[];
  124479. /**
  124480. * Defines the indices.
  124481. */
  124482. indices?: number[];
  124483. }
  124484. /**
  124485. * Helper class to render one or more effects
  124486. */
  124487. export class EffectRenderer {
  124488. private engine;
  124489. private static _DefaultOptions;
  124490. private _vertexBuffers;
  124491. private _indexBuffer;
  124492. private _ringBufferIndex;
  124493. private _ringScreenBuffer;
  124494. private _fullscreenViewport;
  124495. private _getNextFrameBuffer;
  124496. /**
  124497. * Creates an effect renderer
  124498. * @param engine the engine to use for rendering
  124499. * @param options defines the options of the effect renderer
  124500. */
  124501. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124502. /**
  124503. * Sets the current viewport in normalized coordinates 0-1
  124504. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124505. */
  124506. setViewport(viewport?: Viewport): void;
  124507. /**
  124508. * Binds the embedded attributes buffer to the effect.
  124509. * @param effect Defines the effect to bind the attributes for
  124510. */
  124511. bindBuffers(effect: Effect): void;
  124512. /**
  124513. * Sets the current effect wrapper to use during draw.
  124514. * The effect needs to be ready before calling this api.
  124515. * This also sets the default full screen position attribute.
  124516. * @param effectWrapper Defines the effect to draw with
  124517. */
  124518. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124519. /**
  124520. * Draws a full screen quad.
  124521. */
  124522. draw(): void;
  124523. /**
  124524. * renders one or more effects to a specified texture
  124525. * @param effectWrappers list of effects to renderer
  124526. * @param outputTexture texture to draw to, if null it will render to the screen
  124527. */
  124528. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124529. /**
  124530. * Disposes of the effect renderer
  124531. */
  124532. dispose(): void;
  124533. }
  124534. /**
  124535. * Options to create an EffectWrapper
  124536. */
  124537. interface EffectWrapperCreationOptions {
  124538. /**
  124539. * Engine to use to create the effect
  124540. */
  124541. engine: ThinEngine;
  124542. /**
  124543. * Fragment shader for the effect
  124544. */
  124545. fragmentShader: string;
  124546. /**
  124547. * Vertex shader for the effect
  124548. */
  124549. vertexShader?: string;
  124550. /**
  124551. * Attributes to use in the shader
  124552. */
  124553. attributeNames?: Array<string>;
  124554. /**
  124555. * Uniforms to use in the shader
  124556. */
  124557. uniformNames?: Array<string>;
  124558. /**
  124559. * Texture sampler names to use in the shader
  124560. */
  124561. samplerNames?: Array<string>;
  124562. /**
  124563. * The friendly name of the effect displayed in Spector.
  124564. */
  124565. name?: string;
  124566. }
  124567. /**
  124568. * Wraps an effect to be used for rendering
  124569. */
  124570. export class EffectWrapper {
  124571. /**
  124572. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124573. */
  124574. onApplyObservable: Observable<{}>;
  124575. /**
  124576. * The underlying effect
  124577. */
  124578. effect: Effect;
  124579. /**
  124580. * Creates an effect to be renderer
  124581. * @param creationOptions options to create the effect
  124582. */
  124583. constructor(creationOptions: EffectWrapperCreationOptions);
  124584. /**
  124585. * Disposes of the effect wrapper
  124586. */
  124587. dispose(): void;
  124588. }
  124589. }
  124590. declare module BABYLON {
  124591. /**
  124592. * Helper class to push actions to a pool of workers.
  124593. */
  124594. export class WorkerPool implements IDisposable {
  124595. private _workerInfos;
  124596. private _pendingActions;
  124597. /**
  124598. * Constructor
  124599. * @param workers Array of workers to use for actions
  124600. */
  124601. constructor(workers: Array<Worker>);
  124602. /**
  124603. * Terminates all workers and clears any pending actions.
  124604. */
  124605. dispose(): void;
  124606. /**
  124607. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124608. * pended until a worker has completed its action.
  124609. * @param action The action to perform. Call onComplete when the action is complete.
  124610. */
  124611. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124612. private _execute;
  124613. }
  124614. }
  124615. declare module BABYLON {
  124616. /**
  124617. * Configuration for Draco compression
  124618. */
  124619. export interface IDracoCompressionConfiguration {
  124620. /**
  124621. * Configuration for the decoder.
  124622. */
  124623. decoder: {
  124624. /**
  124625. * The url to the WebAssembly module.
  124626. */
  124627. wasmUrl?: string;
  124628. /**
  124629. * The url to the WebAssembly binary.
  124630. */
  124631. wasmBinaryUrl?: string;
  124632. /**
  124633. * The url to the fallback JavaScript module.
  124634. */
  124635. fallbackUrl?: string;
  124636. };
  124637. }
  124638. /**
  124639. * Draco compression (https://google.github.io/draco/)
  124640. *
  124641. * This class wraps the Draco module.
  124642. *
  124643. * **Encoder**
  124644. *
  124645. * The encoder is not currently implemented.
  124646. *
  124647. * **Decoder**
  124648. *
  124649. * 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.
  124650. *
  124651. * To update the configuration, use the following code:
  124652. * ```javascript
  124653. * DracoCompression.Configuration = {
  124654. * decoder: {
  124655. * wasmUrl: "<url to the WebAssembly library>",
  124656. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124657. * fallbackUrl: "<url to the fallback JavaScript library>",
  124658. * }
  124659. * };
  124660. * ```
  124661. *
  124662. * 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.
  124663. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124664. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124665. *
  124666. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124667. * ```javascript
  124668. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124669. * ```
  124670. *
  124671. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124672. */
  124673. export class DracoCompression implements IDisposable {
  124674. private _workerPoolPromise?;
  124675. private _decoderModulePromise?;
  124676. /**
  124677. * The configuration. Defaults to the following urls:
  124678. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124679. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124680. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124681. */
  124682. static Configuration: IDracoCompressionConfiguration;
  124683. /**
  124684. * Returns true if the decoder configuration is available.
  124685. */
  124686. static readonly DecoderAvailable: boolean;
  124687. /**
  124688. * Default number of workers to create when creating the draco compression object.
  124689. */
  124690. static DefaultNumWorkers: number;
  124691. private static GetDefaultNumWorkers;
  124692. private static _Default;
  124693. /**
  124694. * Default instance for the draco compression object.
  124695. */
  124696. static readonly Default: DracoCompression;
  124697. /**
  124698. * Constructor
  124699. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124700. */
  124701. constructor(numWorkers?: number);
  124702. /**
  124703. * Stop all async operations and release resources.
  124704. */
  124705. dispose(): void;
  124706. /**
  124707. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124708. * @returns a promise that resolves when ready
  124709. */
  124710. whenReadyAsync(): Promise<void>;
  124711. /**
  124712. * Decode Draco compressed mesh data to vertex data.
  124713. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124714. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124715. * @returns A promise that resolves with the decoded vertex data
  124716. */
  124717. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124718. [kind: string]: number;
  124719. }): Promise<VertexData>;
  124720. }
  124721. }
  124722. declare module BABYLON {
  124723. /**
  124724. * Class for building Constructive Solid Geometry
  124725. */
  124726. export class CSG {
  124727. private polygons;
  124728. /**
  124729. * The world matrix
  124730. */
  124731. matrix: Matrix;
  124732. /**
  124733. * Stores the position
  124734. */
  124735. position: Vector3;
  124736. /**
  124737. * Stores the rotation
  124738. */
  124739. rotation: Vector3;
  124740. /**
  124741. * Stores the rotation quaternion
  124742. */
  124743. rotationQuaternion: Nullable<Quaternion>;
  124744. /**
  124745. * Stores the scaling vector
  124746. */
  124747. scaling: Vector3;
  124748. /**
  124749. * Convert the Mesh to CSG
  124750. * @param mesh The Mesh to convert to CSG
  124751. * @returns A new CSG from the Mesh
  124752. */
  124753. static FromMesh(mesh: Mesh): CSG;
  124754. /**
  124755. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124756. * @param polygons Polygons used to construct a CSG solid
  124757. */
  124758. private static FromPolygons;
  124759. /**
  124760. * Clones, or makes a deep copy, of the CSG
  124761. * @returns A new CSG
  124762. */
  124763. clone(): CSG;
  124764. /**
  124765. * Unions this CSG with another CSG
  124766. * @param csg The CSG to union against this CSG
  124767. * @returns The unioned CSG
  124768. */
  124769. union(csg: CSG): CSG;
  124770. /**
  124771. * Unions this CSG with another CSG in place
  124772. * @param csg The CSG to union against this CSG
  124773. */
  124774. unionInPlace(csg: CSG): void;
  124775. /**
  124776. * Subtracts this CSG with another CSG
  124777. * @param csg The CSG to subtract against this CSG
  124778. * @returns A new CSG
  124779. */
  124780. subtract(csg: CSG): CSG;
  124781. /**
  124782. * Subtracts this CSG with another CSG in place
  124783. * @param csg The CSG to subtact against this CSG
  124784. */
  124785. subtractInPlace(csg: CSG): void;
  124786. /**
  124787. * Intersect this CSG with another CSG
  124788. * @param csg The CSG to intersect against this CSG
  124789. * @returns A new CSG
  124790. */
  124791. intersect(csg: CSG): CSG;
  124792. /**
  124793. * Intersects this CSG with another CSG in place
  124794. * @param csg The CSG to intersect against this CSG
  124795. */
  124796. intersectInPlace(csg: CSG): void;
  124797. /**
  124798. * Return a new CSG solid with solid and empty space switched. This solid is
  124799. * not modified.
  124800. * @returns A new CSG solid with solid and empty space switched
  124801. */
  124802. inverse(): CSG;
  124803. /**
  124804. * Inverses the CSG in place
  124805. */
  124806. inverseInPlace(): void;
  124807. /**
  124808. * This is used to keep meshes transformations so they can be restored
  124809. * when we build back a Babylon Mesh
  124810. * NB : All CSG operations are performed in world coordinates
  124811. * @param csg The CSG to copy the transform attributes from
  124812. * @returns This CSG
  124813. */
  124814. copyTransformAttributes(csg: CSG): CSG;
  124815. /**
  124816. * Build Raw mesh from CSG
  124817. * Coordinates here are in world space
  124818. * @param name The name of the mesh geometry
  124819. * @param scene The Scene
  124820. * @param keepSubMeshes Specifies if the submeshes should be kept
  124821. * @returns A new Mesh
  124822. */
  124823. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124824. /**
  124825. * Build Mesh from CSG taking material and transforms into account
  124826. * @param name The name of the Mesh
  124827. * @param material The material of the Mesh
  124828. * @param scene The Scene
  124829. * @param keepSubMeshes Specifies if submeshes should be kept
  124830. * @returns The new Mesh
  124831. */
  124832. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124833. }
  124834. }
  124835. declare module BABYLON {
  124836. /**
  124837. * Class used to create a trail following a mesh
  124838. */
  124839. export class TrailMesh extends Mesh {
  124840. private _generator;
  124841. private _autoStart;
  124842. private _running;
  124843. private _diameter;
  124844. private _length;
  124845. private _sectionPolygonPointsCount;
  124846. private _sectionVectors;
  124847. private _sectionNormalVectors;
  124848. private _beforeRenderObserver;
  124849. /**
  124850. * @constructor
  124851. * @param name The value used by scene.getMeshByName() to do a lookup.
  124852. * @param generator The mesh to generate a trail.
  124853. * @param scene The scene to add this mesh to.
  124854. * @param diameter Diameter of trailing mesh. Default is 1.
  124855. * @param length Length of trailing mesh. Default is 60.
  124856. * @param autoStart Automatically start trailing mesh. Default true.
  124857. */
  124858. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124859. /**
  124860. * "TrailMesh"
  124861. * @returns "TrailMesh"
  124862. */
  124863. getClassName(): string;
  124864. private _createMesh;
  124865. /**
  124866. * Start trailing mesh.
  124867. */
  124868. start(): void;
  124869. /**
  124870. * Stop trailing mesh.
  124871. */
  124872. stop(): void;
  124873. /**
  124874. * Update trailing mesh geometry.
  124875. */
  124876. update(): void;
  124877. /**
  124878. * Returns a new TrailMesh object.
  124879. * @param name is a string, the name given to the new mesh
  124880. * @param newGenerator use new generator object for cloned trail mesh
  124881. * @returns a new mesh
  124882. */
  124883. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124884. /**
  124885. * Serializes this trail mesh
  124886. * @param serializationObject object to write serialization to
  124887. */
  124888. serialize(serializationObject: any): void;
  124889. /**
  124890. * Parses a serialized trail mesh
  124891. * @param parsedMesh the serialized mesh
  124892. * @param scene the scene to create the trail mesh in
  124893. * @returns the created trail mesh
  124894. */
  124895. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124896. }
  124897. }
  124898. declare module BABYLON {
  124899. /**
  124900. * Class containing static functions to help procedurally build meshes
  124901. */
  124902. export class TiledBoxBuilder {
  124903. /**
  124904. * Creates a box mesh
  124905. * 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)
  124906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124910. * @param name defines the name of the mesh
  124911. * @param options defines the options used to create the mesh
  124912. * @param scene defines the hosting scene
  124913. * @returns the box mesh
  124914. */
  124915. static CreateTiledBox(name: string, options: {
  124916. pattern?: number;
  124917. width?: number;
  124918. height?: number;
  124919. depth?: number;
  124920. tileSize?: number;
  124921. tileWidth?: number;
  124922. tileHeight?: number;
  124923. alignHorizontal?: number;
  124924. alignVertical?: number;
  124925. faceUV?: Vector4[];
  124926. faceColors?: Color4[];
  124927. sideOrientation?: number;
  124928. updatable?: boolean;
  124929. }, scene?: Nullable<Scene>): Mesh;
  124930. }
  124931. }
  124932. declare module BABYLON {
  124933. /**
  124934. * Class containing static functions to help procedurally build meshes
  124935. */
  124936. export class TorusKnotBuilder {
  124937. /**
  124938. * Creates a torus knot mesh
  124939. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124940. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124941. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124942. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124946. * @param name defines the name of the mesh
  124947. * @param options defines the options used to create the mesh
  124948. * @param scene defines the hosting scene
  124949. * @returns the torus knot mesh
  124950. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124951. */
  124952. static CreateTorusKnot(name: string, options: {
  124953. radius?: number;
  124954. tube?: number;
  124955. radialSegments?: number;
  124956. tubularSegments?: number;
  124957. p?: number;
  124958. q?: number;
  124959. updatable?: boolean;
  124960. sideOrientation?: number;
  124961. frontUVs?: Vector4;
  124962. backUVs?: Vector4;
  124963. }, scene: any): Mesh;
  124964. }
  124965. }
  124966. declare module BABYLON {
  124967. /**
  124968. * Polygon
  124969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124970. */
  124971. export class Polygon {
  124972. /**
  124973. * Creates a rectangle
  124974. * @param xmin bottom X coord
  124975. * @param ymin bottom Y coord
  124976. * @param xmax top X coord
  124977. * @param ymax top Y coord
  124978. * @returns points that make the resulting rectation
  124979. */
  124980. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124981. /**
  124982. * Creates a circle
  124983. * @param radius radius of circle
  124984. * @param cx scale in x
  124985. * @param cy scale in y
  124986. * @param numberOfSides number of sides that make up the circle
  124987. * @returns points that make the resulting circle
  124988. */
  124989. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124990. /**
  124991. * Creates a polygon from input string
  124992. * @param input Input polygon data
  124993. * @returns the parsed points
  124994. */
  124995. static Parse(input: string): Vector2[];
  124996. /**
  124997. * Starts building a polygon from x and y coordinates
  124998. * @param x x coordinate
  124999. * @param y y coordinate
  125000. * @returns the started path2
  125001. */
  125002. static StartingAt(x: number, y: number): Path2;
  125003. }
  125004. /**
  125005. * Builds a polygon
  125006. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  125007. */
  125008. export class PolygonMeshBuilder {
  125009. private _points;
  125010. private _outlinepoints;
  125011. private _holes;
  125012. private _name;
  125013. private _scene;
  125014. private _epoints;
  125015. private _eholes;
  125016. private _addToepoint;
  125017. /**
  125018. * Babylon reference to the earcut plugin.
  125019. */
  125020. bjsEarcut: any;
  125021. /**
  125022. * Creates a PolygonMeshBuilder
  125023. * @param name name of the builder
  125024. * @param contours Path of the polygon
  125025. * @param scene scene to add to when creating the mesh
  125026. * @param earcutInjection can be used to inject your own earcut reference
  125027. */
  125028. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  125029. /**
  125030. * Adds a whole within the polygon
  125031. * @param hole Array of points defining the hole
  125032. * @returns this
  125033. */
  125034. addHole(hole: Vector2[]): PolygonMeshBuilder;
  125035. /**
  125036. * Creates the polygon
  125037. * @param updatable If the mesh should be updatable
  125038. * @param depth The depth of the mesh created
  125039. * @returns the created mesh
  125040. */
  125041. build(updatable?: boolean, depth?: number): Mesh;
  125042. /**
  125043. * Creates the polygon
  125044. * @param depth The depth of the mesh created
  125045. * @returns the created VertexData
  125046. */
  125047. buildVertexData(depth?: number): VertexData;
  125048. /**
  125049. * Adds a side to the polygon
  125050. * @param positions points that make the polygon
  125051. * @param normals normals of the polygon
  125052. * @param uvs uvs of the polygon
  125053. * @param indices indices of the polygon
  125054. * @param bounds bounds of the polygon
  125055. * @param points points of the polygon
  125056. * @param depth depth of the polygon
  125057. * @param flip flip of the polygon
  125058. */
  125059. private addSide;
  125060. }
  125061. }
  125062. declare module BABYLON {
  125063. /**
  125064. * Class containing static functions to help procedurally build meshes
  125065. */
  125066. export class PolygonBuilder {
  125067. /**
  125068. * Creates a polygon mesh
  125069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125070. * * 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
  125071. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125074. * * Remember you can only change the shape positions, not their number when updating a polygon
  125075. * @param name defines the name of the mesh
  125076. * @param options defines the options used to create the mesh
  125077. * @param scene defines the hosting scene
  125078. * @param earcutInjection can be used to inject your own earcut reference
  125079. * @returns the polygon mesh
  125080. */
  125081. static CreatePolygon(name: string, options: {
  125082. shape: Vector3[];
  125083. holes?: Vector3[][];
  125084. depth?: number;
  125085. faceUV?: Vector4[];
  125086. faceColors?: Color4[];
  125087. updatable?: boolean;
  125088. sideOrientation?: number;
  125089. frontUVs?: Vector4;
  125090. backUVs?: Vector4;
  125091. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125092. /**
  125093. * Creates an extruded polygon mesh, with depth in the Y direction.
  125094. * * 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)
  125095. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125096. * @param name defines the name of the mesh
  125097. * @param options defines the options used to create the mesh
  125098. * @param scene defines the hosting scene
  125099. * @param earcutInjection can be used to inject your own earcut reference
  125100. * @returns the polygon mesh
  125101. */
  125102. static ExtrudePolygon(name: string, options: {
  125103. shape: Vector3[];
  125104. holes?: Vector3[][];
  125105. depth?: number;
  125106. faceUV?: Vector4[];
  125107. faceColors?: Color4[];
  125108. updatable?: boolean;
  125109. sideOrientation?: number;
  125110. frontUVs?: Vector4;
  125111. backUVs?: Vector4;
  125112. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125113. }
  125114. }
  125115. declare module BABYLON {
  125116. /**
  125117. * Class containing static functions to help procedurally build meshes
  125118. */
  125119. export class LatheBuilder {
  125120. /**
  125121. * Creates lathe mesh.
  125122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125123. * * 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
  125124. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125125. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125126. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125127. * * 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
  125128. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125129. * * 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
  125130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125134. * @param name defines the name of the mesh
  125135. * @param options defines the options used to create the mesh
  125136. * @param scene defines the hosting scene
  125137. * @returns the lathe mesh
  125138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125139. */
  125140. static CreateLathe(name: string, options: {
  125141. shape: Vector3[];
  125142. radius?: number;
  125143. tessellation?: number;
  125144. clip?: number;
  125145. arc?: number;
  125146. closed?: boolean;
  125147. updatable?: boolean;
  125148. sideOrientation?: number;
  125149. frontUVs?: Vector4;
  125150. backUVs?: Vector4;
  125151. cap?: number;
  125152. invertUV?: boolean;
  125153. }, scene?: Nullable<Scene>): Mesh;
  125154. }
  125155. }
  125156. declare module BABYLON {
  125157. /**
  125158. * Class containing static functions to help procedurally build meshes
  125159. */
  125160. export class TiledPlaneBuilder {
  125161. /**
  125162. * Creates a tiled plane mesh
  125163. * * The parameter `pattern` will, depending on value, do nothing or
  125164. * * * flip (reflect about central vertical) alternate tiles across and up
  125165. * * * flip every tile on alternate rows
  125166. * * * rotate (180 degs) alternate tiles across and up
  125167. * * * rotate every tile on alternate rows
  125168. * * * flip and rotate alternate tiles across and up
  125169. * * * flip and rotate every tile on alternate rows
  125170. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  125171. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  125172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125174. * * 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)
  125175. * * 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)
  125176. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125177. * @param name defines the name of the mesh
  125178. * @param options defines the options used to create the mesh
  125179. * @param scene defines the hosting scene
  125180. * @returns the box mesh
  125181. */
  125182. static CreateTiledPlane(name: string, options: {
  125183. pattern?: number;
  125184. tileSize?: number;
  125185. tileWidth?: number;
  125186. tileHeight?: number;
  125187. size?: number;
  125188. width?: number;
  125189. height?: number;
  125190. alignHorizontal?: number;
  125191. alignVertical?: number;
  125192. sideOrientation?: number;
  125193. frontUVs?: Vector4;
  125194. backUVs?: Vector4;
  125195. updatable?: boolean;
  125196. }, scene?: Nullable<Scene>): Mesh;
  125197. }
  125198. }
  125199. declare module BABYLON {
  125200. /**
  125201. * Class containing static functions to help procedurally build meshes
  125202. */
  125203. export class TubeBuilder {
  125204. /**
  125205. * Creates a tube mesh.
  125206. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125207. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125208. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125209. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125210. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125211. * * 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)
  125212. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125213. * * 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
  125214. * * 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
  125215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125219. * @param name defines the name of the mesh
  125220. * @param options defines the options used to create the mesh
  125221. * @param scene defines the hosting scene
  125222. * @returns the tube mesh
  125223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125224. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125225. */
  125226. static CreateTube(name: string, options: {
  125227. path: Vector3[];
  125228. radius?: number;
  125229. tessellation?: number;
  125230. radiusFunction?: {
  125231. (i: number, distance: number): number;
  125232. };
  125233. cap?: number;
  125234. arc?: number;
  125235. updatable?: boolean;
  125236. sideOrientation?: number;
  125237. frontUVs?: Vector4;
  125238. backUVs?: Vector4;
  125239. instance?: Mesh;
  125240. invertUV?: boolean;
  125241. }, scene?: Nullable<Scene>): Mesh;
  125242. }
  125243. }
  125244. declare module BABYLON {
  125245. /**
  125246. * Class containing static functions to help procedurally build meshes
  125247. */
  125248. export class IcoSphereBuilder {
  125249. /**
  125250. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125251. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125252. * * 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`)
  125253. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125254. * * 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
  125255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125258. * @param name defines the name of the mesh
  125259. * @param options defines the options used to create the mesh
  125260. * @param scene defines the hosting scene
  125261. * @returns the icosahedron mesh
  125262. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125263. */
  125264. static CreateIcoSphere(name: string, options: {
  125265. radius?: number;
  125266. radiusX?: number;
  125267. radiusY?: number;
  125268. radiusZ?: number;
  125269. flat?: boolean;
  125270. subdivisions?: number;
  125271. sideOrientation?: number;
  125272. frontUVs?: Vector4;
  125273. backUVs?: Vector4;
  125274. updatable?: boolean;
  125275. }, scene?: Nullable<Scene>): Mesh;
  125276. }
  125277. }
  125278. declare module BABYLON {
  125279. /**
  125280. * Class containing static functions to help procedurally build meshes
  125281. */
  125282. export class DecalBuilder {
  125283. /**
  125284. * Creates a decal mesh.
  125285. * 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
  125286. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125287. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125288. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125289. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125290. * @param name defines the name of the mesh
  125291. * @param sourceMesh defines the mesh where the decal must be applied
  125292. * @param options defines the options used to create the mesh
  125293. * @param scene defines the hosting scene
  125294. * @returns the decal mesh
  125295. * @see https://doc.babylonjs.com/how_to/decals
  125296. */
  125297. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125298. position?: Vector3;
  125299. normal?: Vector3;
  125300. size?: Vector3;
  125301. angle?: number;
  125302. }): Mesh;
  125303. }
  125304. }
  125305. declare module BABYLON {
  125306. /**
  125307. * Class containing static functions to help procedurally build meshes
  125308. */
  125309. export class MeshBuilder {
  125310. /**
  125311. * Creates a box mesh
  125312. * * The parameter `size` sets the size (float) of each box side (default 1)
  125313. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125314. * * 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)
  125315. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125319. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125320. * @param name defines the name of the mesh
  125321. * @param options defines the options used to create the mesh
  125322. * @param scene defines the hosting scene
  125323. * @returns the box mesh
  125324. */
  125325. static CreateBox(name: string, options: {
  125326. size?: number;
  125327. width?: number;
  125328. height?: number;
  125329. depth?: number;
  125330. faceUV?: Vector4[];
  125331. faceColors?: Color4[];
  125332. sideOrientation?: number;
  125333. frontUVs?: Vector4;
  125334. backUVs?: Vector4;
  125335. updatable?: boolean;
  125336. }, scene?: Nullable<Scene>): Mesh;
  125337. /**
  125338. * Creates a tiled box mesh
  125339. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125341. * @param name defines the name of the mesh
  125342. * @param options defines the options used to create the mesh
  125343. * @param scene defines the hosting scene
  125344. * @returns the tiled box mesh
  125345. */
  125346. static CreateTiledBox(name: string, options: {
  125347. pattern?: number;
  125348. size?: number;
  125349. width?: number;
  125350. height?: number;
  125351. depth: number;
  125352. tileSize?: number;
  125353. tileWidth?: number;
  125354. tileHeight?: number;
  125355. faceUV?: Vector4[];
  125356. faceColors?: Color4[];
  125357. alignHorizontal?: number;
  125358. alignVertical?: number;
  125359. sideOrientation?: number;
  125360. updatable?: boolean;
  125361. }, scene?: Nullable<Scene>): Mesh;
  125362. /**
  125363. * Creates a sphere mesh
  125364. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125365. * * 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`)
  125366. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125367. * * 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
  125368. * * 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)
  125369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125372. * @param name defines the name of the mesh
  125373. * @param options defines the options used to create the mesh
  125374. * @param scene defines the hosting scene
  125375. * @returns the sphere mesh
  125376. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125377. */
  125378. static CreateSphere(name: string, options: {
  125379. segments?: number;
  125380. diameter?: number;
  125381. diameterX?: number;
  125382. diameterY?: number;
  125383. diameterZ?: number;
  125384. arc?: number;
  125385. slice?: number;
  125386. sideOrientation?: number;
  125387. frontUVs?: Vector4;
  125388. backUVs?: Vector4;
  125389. updatable?: boolean;
  125390. }, scene?: Nullable<Scene>): Mesh;
  125391. /**
  125392. * Creates a plane polygonal mesh. By default, this is a disc
  125393. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125394. * * 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
  125395. * * 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
  125396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125399. * @param name defines the name of the mesh
  125400. * @param options defines the options used to create the mesh
  125401. * @param scene defines the hosting scene
  125402. * @returns the plane polygonal mesh
  125403. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125404. */
  125405. static CreateDisc(name: string, options: {
  125406. radius?: number;
  125407. tessellation?: number;
  125408. arc?: number;
  125409. updatable?: boolean;
  125410. sideOrientation?: number;
  125411. frontUVs?: Vector4;
  125412. backUVs?: Vector4;
  125413. }, scene?: Nullable<Scene>): Mesh;
  125414. /**
  125415. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125416. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125417. * * 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`)
  125418. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125419. * * 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
  125420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125423. * @param name defines the name of the mesh
  125424. * @param options defines the options used to create the mesh
  125425. * @param scene defines the hosting scene
  125426. * @returns the icosahedron mesh
  125427. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125428. */
  125429. static CreateIcoSphere(name: string, options: {
  125430. radius?: number;
  125431. radiusX?: number;
  125432. radiusY?: number;
  125433. radiusZ?: number;
  125434. flat?: boolean;
  125435. subdivisions?: number;
  125436. sideOrientation?: number;
  125437. frontUVs?: Vector4;
  125438. backUVs?: Vector4;
  125439. updatable?: boolean;
  125440. }, scene?: Nullable<Scene>): Mesh;
  125441. /**
  125442. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125443. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125444. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125445. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125446. * * 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
  125447. * * 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
  125448. * * 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
  125449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125452. * * 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
  125453. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125454. * * 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
  125455. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125457. * @param name defines the name of the mesh
  125458. * @param options defines the options used to create the mesh
  125459. * @param scene defines the hosting scene
  125460. * @returns the ribbon mesh
  125461. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125463. */
  125464. static CreateRibbon(name: string, options: {
  125465. pathArray: Vector3[][];
  125466. closeArray?: boolean;
  125467. closePath?: boolean;
  125468. offset?: number;
  125469. updatable?: boolean;
  125470. sideOrientation?: number;
  125471. frontUVs?: Vector4;
  125472. backUVs?: Vector4;
  125473. instance?: Mesh;
  125474. invertUV?: boolean;
  125475. uvs?: Vector2[];
  125476. colors?: Color4[];
  125477. }, scene?: Nullable<Scene>): Mesh;
  125478. /**
  125479. * Creates a cylinder or a cone mesh
  125480. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125481. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125482. * * 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.
  125483. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125484. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125485. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125486. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125487. * * 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).
  125488. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125489. * * 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).
  125490. * * 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
  125491. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125492. * * 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
  125493. * * 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.
  125494. * * If `enclose` is false, a ring surface is one element.
  125495. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125496. * * 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
  125497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125500. * @param name defines the name of the mesh
  125501. * @param options defines the options used to create the mesh
  125502. * @param scene defines the hosting scene
  125503. * @returns the cylinder mesh
  125504. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125505. */
  125506. static CreateCylinder(name: string, options: {
  125507. height?: number;
  125508. diameterTop?: number;
  125509. diameterBottom?: number;
  125510. diameter?: number;
  125511. tessellation?: number;
  125512. subdivisions?: number;
  125513. arc?: number;
  125514. faceColors?: Color4[];
  125515. faceUV?: Vector4[];
  125516. updatable?: boolean;
  125517. hasRings?: boolean;
  125518. enclose?: boolean;
  125519. cap?: number;
  125520. sideOrientation?: number;
  125521. frontUVs?: Vector4;
  125522. backUVs?: Vector4;
  125523. }, scene?: Nullable<Scene>): Mesh;
  125524. /**
  125525. * Creates a torus mesh
  125526. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125527. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125528. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125532. * @param name defines the name of the mesh
  125533. * @param options defines the options used to create the mesh
  125534. * @param scene defines the hosting scene
  125535. * @returns the torus mesh
  125536. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125537. */
  125538. static CreateTorus(name: string, options: {
  125539. diameter?: number;
  125540. thickness?: number;
  125541. tessellation?: number;
  125542. updatable?: boolean;
  125543. sideOrientation?: number;
  125544. frontUVs?: Vector4;
  125545. backUVs?: Vector4;
  125546. }, scene?: Nullable<Scene>): Mesh;
  125547. /**
  125548. * Creates a torus knot mesh
  125549. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125550. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125551. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125552. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125556. * @param name defines the name of the mesh
  125557. * @param options defines the options used to create the mesh
  125558. * @param scene defines the hosting scene
  125559. * @returns the torus knot mesh
  125560. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125561. */
  125562. static CreateTorusKnot(name: string, options: {
  125563. radius?: number;
  125564. tube?: number;
  125565. radialSegments?: number;
  125566. tubularSegments?: number;
  125567. p?: number;
  125568. q?: number;
  125569. updatable?: boolean;
  125570. sideOrientation?: number;
  125571. frontUVs?: Vector4;
  125572. backUVs?: Vector4;
  125573. }, scene?: Nullable<Scene>): Mesh;
  125574. /**
  125575. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125576. * * 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
  125577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125578. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125579. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125580. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125581. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125582. * * 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
  125583. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125586. * @param name defines the name of the new line system
  125587. * @param options defines the options used to create the line system
  125588. * @param scene defines the hosting scene
  125589. * @returns a new line system mesh
  125590. */
  125591. static CreateLineSystem(name: string, options: {
  125592. lines: Vector3[][];
  125593. updatable?: boolean;
  125594. instance?: Nullable<LinesMesh>;
  125595. colors?: Nullable<Color4[][]>;
  125596. useVertexAlpha?: boolean;
  125597. }, scene: Nullable<Scene>): LinesMesh;
  125598. /**
  125599. * Creates a line mesh
  125600. * 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
  125601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125602. * * The parameter `points` is an array successive Vector3
  125603. * * 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
  125604. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125605. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125606. * * When updating an instance, remember that only point positions can change, not the number of points
  125607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125609. * @param name defines the name of the new line system
  125610. * @param options defines the options used to create the line system
  125611. * @param scene defines the hosting scene
  125612. * @returns a new line mesh
  125613. */
  125614. static CreateLines(name: string, options: {
  125615. points: Vector3[];
  125616. updatable?: boolean;
  125617. instance?: Nullable<LinesMesh>;
  125618. colors?: Color4[];
  125619. useVertexAlpha?: boolean;
  125620. }, scene?: Nullable<Scene>): LinesMesh;
  125621. /**
  125622. * Creates a dashed line mesh
  125623. * * 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
  125624. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125625. * * The parameter `points` is an array successive Vector3
  125626. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125627. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125628. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125629. * * 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
  125630. * * When updating an instance, remember that only point positions can change, not the number of points
  125631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125632. * @param name defines the name of the mesh
  125633. * @param options defines the options used to create the mesh
  125634. * @param scene defines the hosting scene
  125635. * @returns the dashed line mesh
  125636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125637. */
  125638. static CreateDashedLines(name: string, options: {
  125639. points: Vector3[];
  125640. dashSize?: number;
  125641. gapSize?: number;
  125642. dashNb?: number;
  125643. updatable?: boolean;
  125644. instance?: LinesMesh;
  125645. }, scene?: Nullable<Scene>): LinesMesh;
  125646. /**
  125647. * 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.
  125648. * * 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.
  125649. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125650. * * 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.
  125651. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125652. * * 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
  125653. * * 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
  125654. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125659. * @param name defines the name of the mesh
  125660. * @param options defines the options used to create the mesh
  125661. * @param scene defines the hosting scene
  125662. * @returns the extruded shape mesh
  125663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125665. */
  125666. static ExtrudeShape(name: string, options: {
  125667. shape: Vector3[];
  125668. path: Vector3[];
  125669. scale?: number;
  125670. rotation?: number;
  125671. cap?: number;
  125672. updatable?: boolean;
  125673. sideOrientation?: number;
  125674. frontUVs?: Vector4;
  125675. backUVs?: Vector4;
  125676. instance?: Mesh;
  125677. invertUV?: boolean;
  125678. }, scene?: Nullable<Scene>): Mesh;
  125679. /**
  125680. * Creates an custom extruded shape mesh.
  125681. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125682. * * 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.
  125683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125684. * * 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
  125685. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125686. * * 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
  125687. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125688. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125689. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125690. * * 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
  125691. * * 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
  125692. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125697. * @param name defines the name of the mesh
  125698. * @param options defines the options used to create the mesh
  125699. * @param scene defines the hosting scene
  125700. * @returns the custom extruded shape mesh
  125701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125704. */
  125705. static ExtrudeShapeCustom(name: string, options: {
  125706. shape: Vector3[];
  125707. path: Vector3[];
  125708. scaleFunction?: any;
  125709. rotationFunction?: any;
  125710. ribbonCloseArray?: boolean;
  125711. ribbonClosePath?: boolean;
  125712. cap?: number;
  125713. updatable?: boolean;
  125714. sideOrientation?: number;
  125715. frontUVs?: Vector4;
  125716. backUVs?: Vector4;
  125717. instance?: Mesh;
  125718. invertUV?: boolean;
  125719. }, scene?: Nullable<Scene>): Mesh;
  125720. /**
  125721. * Creates lathe mesh.
  125722. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125723. * * 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
  125724. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125725. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125726. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125727. * * 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
  125728. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125729. * * 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
  125730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125734. * @param name defines the name of the mesh
  125735. * @param options defines the options used to create the mesh
  125736. * @param scene defines the hosting scene
  125737. * @returns the lathe mesh
  125738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125739. */
  125740. static CreateLathe(name: string, options: {
  125741. shape: Vector3[];
  125742. radius?: number;
  125743. tessellation?: number;
  125744. clip?: number;
  125745. arc?: number;
  125746. closed?: boolean;
  125747. updatable?: boolean;
  125748. sideOrientation?: number;
  125749. frontUVs?: Vector4;
  125750. backUVs?: Vector4;
  125751. cap?: number;
  125752. invertUV?: boolean;
  125753. }, scene?: Nullable<Scene>): Mesh;
  125754. /**
  125755. * Creates a tiled plane mesh
  125756. * * You can set a limited pattern arrangement with the tiles
  125757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125760. * @param name defines the name of the mesh
  125761. * @param options defines the options used to create the mesh
  125762. * @param scene defines the hosting scene
  125763. * @returns the plane mesh
  125764. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125765. */
  125766. static CreateTiledPlane(name: string, options: {
  125767. pattern?: number;
  125768. tileSize?: number;
  125769. tileWidth?: number;
  125770. tileHeight?: number;
  125771. size?: number;
  125772. width?: number;
  125773. height?: number;
  125774. alignHorizontal?: number;
  125775. alignVertical?: number;
  125776. sideOrientation?: number;
  125777. frontUVs?: Vector4;
  125778. backUVs?: Vector4;
  125779. updatable?: boolean;
  125780. }, scene?: Nullable<Scene>): Mesh;
  125781. /**
  125782. * Creates a plane mesh
  125783. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125784. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125785. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125789. * @param name defines the name of the mesh
  125790. * @param options defines the options used to create the mesh
  125791. * @param scene defines the hosting scene
  125792. * @returns the plane mesh
  125793. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125794. */
  125795. static CreatePlane(name: string, options: {
  125796. size?: number;
  125797. width?: number;
  125798. height?: number;
  125799. sideOrientation?: number;
  125800. frontUVs?: Vector4;
  125801. backUVs?: Vector4;
  125802. updatable?: boolean;
  125803. sourcePlane?: Plane;
  125804. }, scene?: Nullable<Scene>): Mesh;
  125805. /**
  125806. * Creates a ground mesh
  125807. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125808. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125810. * @param name defines the name of the mesh
  125811. * @param options defines the options used to create the mesh
  125812. * @param scene defines the hosting scene
  125813. * @returns the ground mesh
  125814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125815. */
  125816. static CreateGround(name: string, options: {
  125817. width?: number;
  125818. height?: number;
  125819. subdivisions?: number;
  125820. subdivisionsX?: number;
  125821. subdivisionsY?: number;
  125822. updatable?: boolean;
  125823. }, scene?: Nullable<Scene>): Mesh;
  125824. /**
  125825. * Creates a tiled ground mesh
  125826. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125827. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125828. * * 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
  125829. * * 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
  125830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125831. * @param name defines the name of the mesh
  125832. * @param options defines the options used to create the mesh
  125833. * @param scene defines the hosting scene
  125834. * @returns the tiled ground mesh
  125835. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125836. */
  125837. static CreateTiledGround(name: string, options: {
  125838. xmin: number;
  125839. zmin: number;
  125840. xmax: number;
  125841. zmax: number;
  125842. subdivisions?: {
  125843. w: number;
  125844. h: number;
  125845. };
  125846. precision?: {
  125847. w: number;
  125848. h: number;
  125849. };
  125850. updatable?: boolean;
  125851. }, scene?: Nullable<Scene>): Mesh;
  125852. /**
  125853. * Creates a ground mesh from a height map
  125854. * * The parameter `url` sets the URL of the height map image resource.
  125855. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125856. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125857. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125858. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125859. * * 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.
  125860. * * 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).
  125861. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125863. * @param name defines the name of the mesh
  125864. * @param url defines the url to the height map
  125865. * @param options defines the options used to create the mesh
  125866. * @param scene defines the hosting scene
  125867. * @returns the ground mesh
  125868. * @see https://doc.babylonjs.com/babylon101/height_map
  125869. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125870. */
  125871. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125872. width?: number;
  125873. height?: number;
  125874. subdivisions?: number;
  125875. minHeight?: number;
  125876. maxHeight?: number;
  125877. colorFilter?: Color3;
  125878. alphaFilter?: number;
  125879. updatable?: boolean;
  125880. onReady?: (mesh: GroundMesh) => void;
  125881. }, scene?: Nullable<Scene>): GroundMesh;
  125882. /**
  125883. * Creates a polygon mesh
  125884. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125885. * * 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
  125886. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125889. * * Remember you can only change the shape positions, not their number when updating a polygon
  125890. * @param name defines the name of the mesh
  125891. * @param options defines the options used to create the mesh
  125892. * @param scene defines the hosting scene
  125893. * @param earcutInjection can be used to inject your own earcut reference
  125894. * @returns the polygon mesh
  125895. */
  125896. static CreatePolygon(name: string, options: {
  125897. shape: Vector3[];
  125898. holes?: Vector3[][];
  125899. depth?: number;
  125900. faceUV?: Vector4[];
  125901. faceColors?: Color4[];
  125902. updatable?: boolean;
  125903. sideOrientation?: number;
  125904. frontUVs?: Vector4;
  125905. backUVs?: Vector4;
  125906. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125907. /**
  125908. * Creates an extruded polygon mesh, with depth in the Y direction.
  125909. * * 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)
  125910. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125911. * @param name defines the name of the mesh
  125912. * @param options defines the options used to create the mesh
  125913. * @param scene defines the hosting scene
  125914. * @param earcutInjection can be used to inject your own earcut reference
  125915. * @returns the polygon mesh
  125916. */
  125917. static ExtrudePolygon(name: string, options: {
  125918. shape: Vector3[];
  125919. holes?: Vector3[][];
  125920. depth?: number;
  125921. faceUV?: Vector4[];
  125922. faceColors?: Color4[];
  125923. updatable?: boolean;
  125924. sideOrientation?: number;
  125925. frontUVs?: Vector4;
  125926. backUVs?: Vector4;
  125927. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125928. /**
  125929. * Creates a tube mesh.
  125930. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125931. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125932. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125933. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125934. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125935. * * 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)
  125936. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125937. * * 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
  125938. * * 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
  125939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125943. * @param name defines the name of the mesh
  125944. * @param options defines the options used to create the mesh
  125945. * @param scene defines the hosting scene
  125946. * @returns the tube mesh
  125947. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125948. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125949. */
  125950. static CreateTube(name: string, options: {
  125951. path: Vector3[];
  125952. radius?: number;
  125953. tessellation?: number;
  125954. radiusFunction?: {
  125955. (i: number, distance: number): number;
  125956. };
  125957. cap?: number;
  125958. arc?: number;
  125959. updatable?: boolean;
  125960. sideOrientation?: number;
  125961. frontUVs?: Vector4;
  125962. backUVs?: Vector4;
  125963. instance?: Mesh;
  125964. invertUV?: boolean;
  125965. }, scene?: Nullable<Scene>): Mesh;
  125966. /**
  125967. * Creates a polyhedron mesh
  125968. * * 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
  125969. * * The parameter `size` (positive float, default 1) sets the polygon size
  125970. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125971. * * 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`
  125972. * * 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
  125973. * * 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)`)
  125974. * * 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
  125975. * * 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
  125976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125979. * @param name defines the name of the mesh
  125980. * @param options defines the options used to create the mesh
  125981. * @param scene defines the hosting scene
  125982. * @returns the polyhedron mesh
  125983. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125984. */
  125985. static CreatePolyhedron(name: string, options: {
  125986. type?: number;
  125987. size?: number;
  125988. sizeX?: number;
  125989. sizeY?: number;
  125990. sizeZ?: number;
  125991. custom?: any;
  125992. faceUV?: Vector4[];
  125993. faceColors?: Color4[];
  125994. flat?: boolean;
  125995. updatable?: boolean;
  125996. sideOrientation?: number;
  125997. frontUVs?: Vector4;
  125998. backUVs?: Vector4;
  125999. }, scene?: Nullable<Scene>): Mesh;
  126000. /**
  126001. * Creates a decal mesh.
  126002. * 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
  126003. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126004. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126005. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126006. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126007. * @param name defines the name of the mesh
  126008. * @param sourceMesh defines the mesh where the decal must be applied
  126009. * @param options defines the options used to create the mesh
  126010. * @param scene defines the hosting scene
  126011. * @returns the decal mesh
  126012. * @see https://doc.babylonjs.com/how_to/decals
  126013. */
  126014. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126015. position?: Vector3;
  126016. normal?: Vector3;
  126017. size?: Vector3;
  126018. angle?: number;
  126019. }): Mesh;
  126020. }
  126021. }
  126022. declare module BABYLON {
  126023. /**
  126024. * A simplifier interface for future simplification implementations
  126025. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126026. */
  126027. export interface ISimplifier {
  126028. /**
  126029. * Simplification of a given mesh according to the given settings.
  126030. * Since this requires computation, it is assumed that the function runs async.
  126031. * @param settings The settings of the simplification, including quality and distance
  126032. * @param successCallback A callback that will be called after the mesh was simplified.
  126033. * @param errorCallback in case of an error, this callback will be called. optional.
  126034. */
  126035. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  126036. }
  126037. /**
  126038. * Expected simplification settings.
  126039. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  126040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126041. */
  126042. export interface ISimplificationSettings {
  126043. /**
  126044. * Gets or sets the expected quality
  126045. */
  126046. quality: number;
  126047. /**
  126048. * Gets or sets the distance when this optimized version should be used
  126049. */
  126050. distance: number;
  126051. /**
  126052. * Gets an already optimized mesh
  126053. */
  126054. optimizeMesh?: boolean;
  126055. }
  126056. /**
  126057. * Class used to specify simplification options
  126058. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126059. */
  126060. export class SimplificationSettings implements ISimplificationSettings {
  126061. /** expected quality */
  126062. quality: number;
  126063. /** distance when this optimized version should be used */
  126064. distance: number;
  126065. /** already optimized mesh */
  126066. optimizeMesh?: boolean | undefined;
  126067. /**
  126068. * Creates a SimplificationSettings
  126069. * @param quality expected quality
  126070. * @param distance distance when this optimized version should be used
  126071. * @param optimizeMesh already optimized mesh
  126072. */
  126073. constructor(
  126074. /** expected quality */
  126075. quality: number,
  126076. /** distance when this optimized version should be used */
  126077. distance: number,
  126078. /** already optimized mesh */
  126079. optimizeMesh?: boolean | undefined);
  126080. }
  126081. /**
  126082. * Interface used to define a simplification task
  126083. */
  126084. export interface ISimplificationTask {
  126085. /**
  126086. * Array of settings
  126087. */
  126088. settings: Array<ISimplificationSettings>;
  126089. /**
  126090. * Simplification type
  126091. */
  126092. simplificationType: SimplificationType;
  126093. /**
  126094. * Mesh to simplify
  126095. */
  126096. mesh: Mesh;
  126097. /**
  126098. * Callback called on success
  126099. */
  126100. successCallback?: () => void;
  126101. /**
  126102. * Defines if parallel processing can be used
  126103. */
  126104. parallelProcessing: boolean;
  126105. }
  126106. /**
  126107. * Queue used to order the simplification tasks
  126108. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126109. */
  126110. export class SimplificationQueue {
  126111. private _simplificationArray;
  126112. /**
  126113. * Gets a boolean indicating that the process is still running
  126114. */
  126115. running: boolean;
  126116. /**
  126117. * Creates a new queue
  126118. */
  126119. constructor();
  126120. /**
  126121. * Adds a new simplification task
  126122. * @param task defines a task to add
  126123. */
  126124. addTask(task: ISimplificationTask): void;
  126125. /**
  126126. * Execute next task
  126127. */
  126128. executeNext(): void;
  126129. /**
  126130. * Execute a simplification task
  126131. * @param task defines the task to run
  126132. */
  126133. runSimplification(task: ISimplificationTask): void;
  126134. private getSimplifier;
  126135. }
  126136. /**
  126137. * The implemented types of simplification
  126138. * At the moment only Quadratic Error Decimation is implemented
  126139. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126140. */
  126141. export enum SimplificationType {
  126142. /** Quadratic error decimation */
  126143. QUADRATIC = 0
  126144. }
  126145. }
  126146. declare module BABYLON {
  126147. interface Scene {
  126148. /** @hidden (Backing field) */
  126149. _simplificationQueue: SimplificationQueue;
  126150. /**
  126151. * Gets or sets the simplification queue attached to the scene
  126152. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126153. */
  126154. simplificationQueue: SimplificationQueue;
  126155. }
  126156. interface Mesh {
  126157. /**
  126158. * Simplify the mesh according to the given array of settings.
  126159. * Function will return immediately and will simplify async
  126160. * @param settings a collection of simplification settings
  126161. * @param parallelProcessing should all levels calculate parallel or one after the other
  126162. * @param simplificationType the type of simplification to run
  126163. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  126164. * @returns the current mesh
  126165. */
  126166. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  126167. }
  126168. /**
  126169. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  126170. * created in a scene
  126171. */
  126172. export class SimplicationQueueSceneComponent implements ISceneComponent {
  126173. /**
  126174. * The component name helpfull to identify the component in the list of scene components.
  126175. */
  126176. readonly name: string;
  126177. /**
  126178. * The scene the component belongs to.
  126179. */
  126180. scene: Scene;
  126181. /**
  126182. * Creates a new instance of the component for the given scene
  126183. * @param scene Defines the scene to register the component in
  126184. */
  126185. constructor(scene: Scene);
  126186. /**
  126187. * Registers the component in a given scene
  126188. */
  126189. register(): void;
  126190. /**
  126191. * Rebuilds the elements related to this component in case of
  126192. * context lost for instance.
  126193. */
  126194. rebuild(): void;
  126195. /**
  126196. * Disposes the component and the associated ressources
  126197. */
  126198. dispose(): void;
  126199. private _beforeCameraUpdate;
  126200. }
  126201. }
  126202. declare module BABYLON {
  126203. /**
  126204. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126205. */
  126206. export interface INavigationEnginePlugin {
  126207. /**
  126208. * plugin name
  126209. */
  126210. name: string;
  126211. /**
  126212. * Creates a navigation mesh
  126213. * @param meshes array of all the geometry used to compute the navigatio mesh
  126214. * @param parameters bunch of parameters used to filter geometry
  126215. */
  126216. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126217. /**
  126218. * Create a navigation mesh debug mesh
  126219. * @param scene is where the mesh will be added
  126220. * @returns debug display mesh
  126221. */
  126222. createDebugNavMesh(scene: Scene): Mesh;
  126223. /**
  126224. * Get a navigation mesh constrained position, closest to the parameter position
  126225. * @param position world position
  126226. * @returns the closest point to position constrained by the navigation mesh
  126227. */
  126228. getClosestPoint(position: Vector3): Vector3;
  126229. /**
  126230. * Get a navigation mesh constrained position, within a particular radius
  126231. * @param position world position
  126232. * @param maxRadius the maximum distance to the constrained world position
  126233. * @returns the closest point to position constrained by the navigation mesh
  126234. */
  126235. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126236. /**
  126237. * Compute the final position from a segment made of destination-position
  126238. * @param position world position
  126239. * @param destination world position
  126240. * @returns the resulting point along the navmesh
  126241. */
  126242. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126243. /**
  126244. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126245. * @param start world position
  126246. * @param end world position
  126247. * @returns array containing world position composing the path
  126248. */
  126249. computePath(start: Vector3, end: Vector3): Vector3[];
  126250. /**
  126251. * If this plugin is supported
  126252. * @returns true if plugin is supported
  126253. */
  126254. isSupported(): boolean;
  126255. /**
  126256. * Create a new Crowd so you can add agents
  126257. * @param maxAgents the maximum agent count in the crowd
  126258. * @param maxAgentRadius the maximum radius an agent can have
  126259. * @param scene to attach the crowd to
  126260. * @returns the crowd you can add agents to
  126261. */
  126262. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126263. /**
  126264. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126265. * The queries will try to find a solution within those bounds
  126266. * default is (1,1,1)
  126267. * @param extent x,y,z value that define the extent around the queries point of reference
  126268. */
  126269. setDefaultQueryExtent(extent: Vector3): void;
  126270. /**
  126271. * Get the Bounding box extent specified by setDefaultQueryExtent
  126272. * @returns the box extent values
  126273. */
  126274. getDefaultQueryExtent(): Vector3;
  126275. /**
  126276. * Release all resources
  126277. */
  126278. dispose(): void;
  126279. }
  126280. /**
  126281. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126282. */
  126283. export interface ICrowd {
  126284. /**
  126285. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126286. * You can attach anything to that node. The node position is updated in the scene update tick.
  126287. * @param pos world position that will be constrained by the navigation mesh
  126288. * @param parameters agent parameters
  126289. * @param transform hooked to the agent that will be update by the scene
  126290. * @returns agent index
  126291. */
  126292. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126293. /**
  126294. * Returns the agent position in world space
  126295. * @param index agent index returned by addAgent
  126296. * @returns world space position
  126297. */
  126298. getAgentPosition(index: number): Vector3;
  126299. /**
  126300. * Gets the agent velocity in world space
  126301. * @param index agent index returned by addAgent
  126302. * @returns world space velocity
  126303. */
  126304. getAgentVelocity(index: number): Vector3;
  126305. /**
  126306. * remove a particular agent previously created
  126307. * @param index agent index returned by addAgent
  126308. */
  126309. removeAgent(index: number): void;
  126310. /**
  126311. * get the list of all agents attached to this crowd
  126312. * @returns list of agent indices
  126313. */
  126314. getAgents(): number[];
  126315. /**
  126316. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126317. * @param deltaTime in seconds
  126318. */
  126319. update(deltaTime: number): void;
  126320. /**
  126321. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126322. * @param index agent index returned by addAgent
  126323. * @param destination targeted world position
  126324. */
  126325. agentGoto(index: number, destination: Vector3): void;
  126326. /**
  126327. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126328. * The queries will try to find a solution within those bounds
  126329. * default is (1,1,1)
  126330. * @param extent x,y,z value that define the extent around the queries point of reference
  126331. */
  126332. setDefaultQueryExtent(extent: Vector3): void;
  126333. /**
  126334. * Get the Bounding box extent specified by setDefaultQueryExtent
  126335. * @returns the box extent values
  126336. */
  126337. getDefaultQueryExtent(): Vector3;
  126338. /**
  126339. * Release all resources
  126340. */
  126341. dispose(): void;
  126342. }
  126343. /**
  126344. * Configures an agent
  126345. */
  126346. export interface IAgentParameters {
  126347. /**
  126348. * Agent radius. [Limit: >= 0]
  126349. */
  126350. radius: number;
  126351. /**
  126352. * Agent height. [Limit: > 0]
  126353. */
  126354. height: number;
  126355. /**
  126356. * Maximum allowed acceleration. [Limit: >= 0]
  126357. */
  126358. maxAcceleration: number;
  126359. /**
  126360. * Maximum allowed speed. [Limit: >= 0]
  126361. */
  126362. maxSpeed: number;
  126363. /**
  126364. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126365. */
  126366. collisionQueryRange: number;
  126367. /**
  126368. * The path visibility optimization range. [Limit: > 0]
  126369. */
  126370. pathOptimizationRange: number;
  126371. /**
  126372. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126373. */
  126374. separationWeight: number;
  126375. }
  126376. /**
  126377. * Configures the navigation mesh creation
  126378. */
  126379. export interface INavMeshParameters {
  126380. /**
  126381. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126382. */
  126383. cs: number;
  126384. /**
  126385. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126386. */
  126387. ch: number;
  126388. /**
  126389. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126390. */
  126391. walkableSlopeAngle: number;
  126392. /**
  126393. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126394. * be considered walkable. [Limit: >= 3] [Units: vx]
  126395. */
  126396. walkableHeight: number;
  126397. /**
  126398. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126399. */
  126400. walkableClimb: number;
  126401. /**
  126402. * The distance to erode/shrink the walkable area of the heightfield away from
  126403. * obstructions. [Limit: >=0] [Units: vx]
  126404. */
  126405. walkableRadius: number;
  126406. /**
  126407. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126408. */
  126409. maxEdgeLen: number;
  126410. /**
  126411. * The maximum distance a simplfied contour's border edges should deviate
  126412. * the original raw contour. [Limit: >=0] [Units: vx]
  126413. */
  126414. maxSimplificationError: number;
  126415. /**
  126416. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126417. */
  126418. minRegionArea: number;
  126419. /**
  126420. * Any regions with a span count smaller than this value will, if possible,
  126421. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126422. */
  126423. mergeRegionArea: number;
  126424. /**
  126425. * The maximum number of vertices allowed for polygons generated during the
  126426. * contour to polygon conversion process. [Limit: >= 3]
  126427. */
  126428. maxVertsPerPoly: number;
  126429. /**
  126430. * Sets the sampling distance to use when generating the detail mesh.
  126431. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126432. */
  126433. detailSampleDist: number;
  126434. /**
  126435. * The maximum distance the detail mesh surface should deviate from heightfield
  126436. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126437. */
  126438. detailSampleMaxError: number;
  126439. }
  126440. }
  126441. declare module BABYLON {
  126442. /**
  126443. * RecastJS navigation plugin
  126444. */
  126445. export class RecastJSPlugin implements INavigationEnginePlugin {
  126446. /**
  126447. * Reference to the Recast library
  126448. */
  126449. bjsRECAST: any;
  126450. /**
  126451. * plugin name
  126452. */
  126453. name: string;
  126454. /**
  126455. * the first navmesh created. We might extend this to support multiple navmeshes
  126456. */
  126457. navMesh: any;
  126458. /**
  126459. * Initializes the recastJS plugin
  126460. * @param recastInjection can be used to inject your own recast reference
  126461. */
  126462. constructor(recastInjection?: any);
  126463. /**
  126464. * Creates a navigation mesh
  126465. * @param meshes array of all the geometry used to compute the navigatio mesh
  126466. * @param parameters bunch of parameters used to filter geometry
  126467. */
  126468. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126469. /**
  126470. * Create a navigation mesh debug mesh
  126471. * @param scene is where the mesh will be added
  126472. * @returns debug display mesh
  126473. */
  126474. createDebugNavMesh(scene: Scene): Mesh;
  126475. /**
  126476. * Get a navigation mesh constrained position, closest to the parameter position
  126477. * @param position world position
  126478. * @returns the closest point to position constrained by the navigation mesh
  126479. */
  126480. getClosestPoint(position: Vector3): Vector3;
  126481. /**
  126482. * Get a navigation mesh constrained position, within a particular radius
  126483. * @param position world position
  126484. * @param maxRadius the maximum distance to the constrained world position
  126485. * @returns the closest point to position constrained by the navigation mesh
  126486. */
  126487. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126488. /**
  126489. * Compute the final position from a segment made of destination-position
  126490. * @param position world position
  126491. * @param destination world position
  126492. * @returns the resulting point along the navmesh
  126493. */
  126494. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126495. /**
  126496. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126497. * @param start world position
  126498. * @param end world position
  126499. * @returns array containing world position composing the path
  126500. */
  126501. computePath(start: Vector3, end: Vector3): Vector3[];
  126502. /**
  126503. * Create a new Crowd so you can add agents
  126504. * @param maxAgents the maximum agent count in the crowd
  126505. * @param maxAgentRadius the maximum radius an agent can have
  126506. * @param scene to attach the crowd to
  126507. * @returns the crowd you can add agents to
  126508. */
  126509. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126510. /**
  126511. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126512. * The queries will try to find a solution within those bounds
  126513. * default is (1,1,1)
  126514. * @param extent x,y,z value that define the extent around the queries point of reference
  126515. */
  126516. setDefaultQueryExtent(extent: Vector3): void;
  126517. /**
  126518. * Get the Bounding box extent specified by setDefaultQueryExtent
  126519. * @returns the box extent values
  126520. */
  126521. getDefaultQueryExtent(): Vector3;
  126522. /**
  126523. * Disposes
  126524. */
  126525. dispose(): void;
  126526. /**
  126527. * If this plugin is supported
  126528. * @returns true if plugin is supported
  126529. */
  126530. isSupported(): boolean;
  126531. }
  126532. /**
  126533. * Recast detour crowd implementation
  126534. */
  126535. export class RecastJSCrowd implements ICrowd {
  126536. /**
  126537. * Recast/detour plugin
  126538. */
  126539. bjsRECASTPlugin: RecastJSPlugin;
  126540. /**
  126541. * Link to the detour crowd
  126542. */
  126543. recastCrowd: any;
  126544. /**
  126545. * One transform per agent
  126546. */
  126547. transforms: TransformNode[];
  126548. /**
  126549. * All agents created
  126550. */
  126551. agents: number[];
  126552. /**
  126553. * Link to the scene is kept to unregister the crowd from the scene
  126554. */
  126555. private _scene;
  126556. /**
  126557. * Observer for crowd updates
  126558. */
  126559. private _onBeforeAnimationsObserver;
  126560. /**
  126561. * Constructor
  126562. * @param plugin recastJS plugin
  126563. * @param maxAgents the maximum agent count in the crowd
  126564. * @param maxAgentRadius the maximum radius an agent can have
  126565. * @param scene to attach the crowd to
  126566. * @returns the crowd you can add agents to
  126567. */
  126568. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126569. /**
  126570. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126571. * You can attach anything to that node. The node position is updated in the scene update tick.
  126572. * @param pos world position that will be constrained by the navigation mesh
  126573. * @param parameters agent parameters
  126574. * @param transform hooked to the agent that will be update by the scene
  126575. * @returns agent index
  126576. */
  126577. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126578. /**
  126579. * Returns the agent position in world space
  126580. * @param index agent index returned by addAgent
  126581. * @returns world space position
  126582. */
  126583. getAgentPosition(index: number): Vector3;
  126584. /**
  126585. * Returns the agent velocity in world space
  126586. * @param index agent index returned by addAgent
  126587. * @returns world space velocity
  126588. */
  126589. getAgentVelocity(index: number): Vector3;
  126590. /**
  126591. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126592. * @param index agent index returned by addAgent
  126593. * @param destination targeted world position
  126594. */
  126595. agentGoto(index: number, destination: Vector3): void;
  126596. /**
  126597. * remove a particular agent previously created
  126598. * @param index agent index returned by addAgent
  126599. */
  126600. removeAgent(index: number): void;
  126601. /**
  126602. * get the list of all agents attached to this crowd
  126603. * @returns list of agent indices
  126604. */
  126605. getAgents(): number[];
  126606. /**
  126607. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126608. * @param deltaTime in seconds
  126609. */
  126610. update(deltaTime: number): void;
  126611. /**
  126612. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126613. * The queries will try to find a solution within those bounds
  126614. * default is (1,1,1)
  126615. * @param extent x,y,z value that define the extent around the queries point of reference
  126616. */
  126617. setDefaultQueryExtent(extent: Vector3): void;
  126618. /**
  126619. * Get the Bounding box extent specified by setDefaultQueryExtent
  126620. * @returns the box extent values
  126621. */
  126622. getDefaultQueryExtent(): Vector3;
  126623. /**
  126624. * Release all resources
  126625. */
  126626. dispose(): void;
  126627. }
  126628. }
  126629. declare module BABYLON {
  126630. /**
  126631. * Class used to enable access to IndexedDB
  126632. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126633. */
  126634. export class Database implements IOfflineProvider {
  126635. private _callbackManifestChecked;
  126636. private _currentSceneUrl;
  126637. private _db;
  126638. private _enableSceneOffline;
  126639. private _enableTexturesOffline;
  126640. private _manifestVersionFound;
  126641. private _mustUpdateRessources;
  126642. private _hasReachedQuota;
  126643. private _isSupported;
  126644. private _idbFactory;
  126645. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126646. private static IsUASupportingBlobStorage;
  126647. /**
  126648. * Gets a boolean indicating if Database storate is enabled (off by default)
  126649. */
  126650. static IDBStorageEnabled: boolean;
  126651. /**
  126652. * Gets a boolean indicating if scene must be saved in the database
  126653. */
  126654. readonly enableSceneOffline: boolean;
  126655. /**
  126656. * Gets a boolean indicating if textures must be saved in the database
  126657. */
  126658. readonly enableTexturesOffline: boolean;
  126659. /**
  126660. * Creates a new Database
  126661. * @param urlToScene defines the url to load the scene
  126662. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126663. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126664. */
  126665. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126666. private static _ParseURL;
  126667. private static _ReturnFullUrlLocation;
  126668. private _checkManifestFile;
  126669. /**
  126670. * Open the database and make it available
  126671. * @param successCallback defines the callback to call on success
  126672. * @param errorCallback defines the callback to call on error
  126673. */
  126674. open(successCallback: () => void, errorCallback: () => void): void;
  126675. /**
  126676. * Loads an image from the database
  126677. * @param url defines the url to load from
  126678. * @param image defines the target DOM image
  126679. */
  126680. loadImage(url: string, image: HTMLImageElement): void;
  126681. private _loadImageFromDBAsync;
  126682. private _saveImageIntoDBAsync;
  126683. private _checkVersionFromDB;
  126684. private _loadVersionFromDBAsync;
  126685. private _saveVersionIntoDBAsync;
  126686. /**
  126687. * Loads a file from database
  126688. * @param url defines the URL to load from
  126689. * @param sceneLoaded defines a callback to call on success
  126690. * @param progressCallBack defines a callback to call when progress changed
  126691. * @param errorCallback defines a callback to call on error
  126692. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126693. */
  126694. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126695. private _loadFileAsync;
  126696. private _saveFileAsync;
  126697. /**
  126698. * Validates if xhr data is correct
  126699. * @param xhr defines the request to validate
  126700. * @param dataType defines the expected data type
  126701. * @returns true if data is correct
  126702. */
  126703. private static _ValidateXHRData;
  126704. }
  126705. }
  126706. declare module BABYLON {
  126707. /** @hidden */
  126708. export var gpuUpdateParticlesPixelShader: {
  126709. name: string;
  126710. shader: string;
  126711. };
  126712. }
  126713. declare module BABYLON {
  126714. /** @hidden */
  126715. export var gpuUpdateParticlesVertexShader: {
  126716. name: string;
  126717. shader: string;
  126718. };
  126719. }
  126720. declare module BABYLON {
  126721. /** @hidden */
  126722. export var clipPlaneFragmentDeclaration2: {
  126723. name: string;
  126724. shader: string;
  126725. };
  126726. }
  126727. declare module BABYLON {
  126728. /** @hidden */
  126729. export var gpuRenderParticlesPixelShader: {
  126730. name: string;
  126731. shader: string;
  126732. };
  126733. }
  126734. declare module BABYLON {
  126735. /** @hidden */
  126736. export var clipPlaneVertexDeclaration2: {
  126737. name: string;
  126738. shader: string;
  126739. };
  126740. }
  126741. declare module BABYLON {
  126742. /** @hidden */
  126743. export var gpuRenderParticlesVertexShader: {
  126744. name: string;
  126745. shader: string;
  126746. };
  126747. }
  126748. declare module BABYLON {
  126749. /**
  126750. * This represents a GPU particle system in Babylon
  126751. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126752. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126753. */
  126754. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126755. /**
  126756. * The layer mask we are rendering the particles through.
  126757. */
  126758. layerMask: number;
  126759. private _capacity;
  126760. private _activeCount;
  126761. private _currentActiveCount;
  126762. private _accumulatedCount;
  126763. private _renderEffect;
  126764. private _updateEffect;
  126765. private _buffer0;
  126766. private _buffer1;
  126767. private _spriteBuffer;
  126768. private _updateVAO;
  126769. private _renderVAO;
  126770. private _targetIndex;
  126771. private _sourceBuffer;
  126772. private _targetBuffer;
  126773. private _engine;
  126774. private _currentRenderId;
  126775. private _started;
  126776. private _stopped;
  126777. private _timeDelta;
  126778. private _randomTexture;
  126779. private _randomTexture2;
  126780. private _attributesStrideSize;
  126781. private _updateEffectOptions;
  126782. private _randomTextureSize;
  126783. private _actualFrame;
  126784. private readonly _rawTextureWidth;
  126785. /**
  126786. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126787. */
  126788. static readonly IsSupported: boolean;
  126789. /**
  126790. * An event triggered when the system is disposed.
  126791. */
  126792. onDisposeObservable: Observable<GPUParticleSystem>;
  126793. /**
  126794. * Gets the maximum number of particles active at the same time.
  126795. * @returns The max number of active particles.
  126796. */
  126797. getCapacity(): number;
  126798. /**
  126799. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126800. * to override the particles.
  126801. */
  126802. forceDepthWrite: boolean;
  126803. /**
  126804. * Gets or set the number of active particles
  126805. */
  126806. activeParticleCount: number;
  126807. private _preWarmDone;
  126808. /**
  126809. * Is this system ready to be used/rendered
  126810. * @return true if the system is ready
  126811. */
  126812. isReady(): boolean;
  126813. /**
  126814. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126815. * @returns True if it has been started, otherwise false.
  126816. */
  126817. isStarted(): boolean;
  126818. /**
  126819. * Starts the particle system and begins to emit
  126820. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126821. */
  126822. start(delay?: number): void;
  126823. /**
  126824. * Stops the particle system.
  126825. */
  126826. stop(): void;
  126827. /**
  126828. * Remove all active particles
  126829. */
  126830. reset(): void;
  126831. /**
  126832. * Returns the string "GPUParticleSystem"
  126833. * @returns a string containing the class name
  126834. */
  126835. getClassName(): string;
  126836. private _colorGradientsTexture;
  126837. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126838. /**
  126839. * Adds a new color gradient
  126840. * @param gradient defines the gradient to use (between 0 and 1)
  126841. * @param color1 defines the color to affect to the specified gradient
  126842. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126843. * @returns the current particle system
  126844. */
  126845. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126846. /**
  126847. * Remove a specific color gradient
  126848. * @param gradient defines the gradient to remove
  126849. * @returns the current particle system
  126850. */
  126851. removeColorGradient(gradient: number): GPUParticleSystem;
  126852. private _angularSpeedGradientsTexture;
  126853. private _sizeGradientsTexture;
  126854. private _velocityGradientsTexture;
  126855. private _limitVelocityGradientsTexture;
  126856. private _dragGradientsTexture;
  126857. private _addFactorGradient;
  126858. /**
  126859. * Adds a new size gradient
  126860. * @param gradient defines the gradient to use (between 0 and 1)
  126861. * @param factor defines the size factor to affect to the specified gradient
  126862. * @returns the current particle system
  126863. */
  126864. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126865. /**
  126866. * Remove a specific size gradient
  126867. * @param gradient defines the gradient to remove
  126868. * @returns the current particle system
  126869. */
  126870. removeSizeGradient(gradient: number): GPUParticleSystem;
  126871. /**
  126872. * Adds a new angular speed gradient
  126873. * @param gradient defines the gradient to use (between 0 and 1)
  126874. * @param factor defines the angular speed to affect to the specified gradient
  126875. * @returns the current particle system
  126876. */
  126877. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126878. /**
  126879. * Remove a specific angular speed gradient
  126880. * @param gradient defines the gradient to remove
  126881. * @returns the current particle system
  126882. */
  126883. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126884. /**
  126885. * Adds a new velocity gradient
  126886. * @param gradient defines the gradient to use (between 0 and 1)
  126887. * @param factor defines the velocity to affect to the specified gradient
  126888. * @returns the current particle system
  126889. */
  126890. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126891. /**
  126892. * Remove a specific velocity gradient
  126893. * @param gradient defines the gradient to remove
  126894. * @returns the current particle system
  126895. */
  126896. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126897. /**
  126898. * Adds a new limit velocity gradient
  126899. * @param gradient defines the gradient to use (between 0 and 1)
  126900. * @param factor defines the limit velocity value to affect to the specified gradient
  126901. * @returns the current particle system
  126902. */
  126903. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126904. /**
  126905. * Remove a specific limit velocity gradient
  126906. * @param gradient defines the gradient to remove
  126907. * @returns the current particle system
  126908. */
  126909. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126910. /**
  126911. * Adds a new drag gradient
  126912. * @param gradient defines the gradient to use (between 0 and 1)
  126913. * @param factor defines the drag value to affect to the specified gradient
  126914. * @returns the current particle system
  126915. */
  126916. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126917. /**
  126918. * Remove a specific drag gradient
  126919. * @param gradient defines the gradient to remove
  126920. * @returns the current particle system
  126921. */
  126922. removeDragGradient(gradient: number): GPUParticleSystem;
  126923. /**
  126924. * Not supported by GPUParticleSystem
  126925. * @param gradient defines the gradient to use (between 0 and 1)
  126926. * @param factor defines the emit rate value to affect to the specified gradient
  126927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126928. * @returns the current particle system
  126929. */
  126930. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126931. /**
  126932. * Not supported by GPUParticleSystem
  126933. * @param gradient defines the gradient to remove
  126934. * @returns the current particle system
  126935. */
  126936. removeEmitRateGradient(gradient: number): IParticleSystem;
  126937. /**
  126938. * Not supported by GPUParticleSystem
  126939. * @param gradient defines the gradient to use (between 0 and 1)
  126940. * @param factor defines the start size value to affect to the specified gradient
  126941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126942. * @returns the current particle system
  126943. */
  126944. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126945. /**
  126946. * Not supported by GPUParticleSystem
  126947. * @param gradient defines the gradient to remove
  126948. * @returns the current particle system
  126949. */
  126950. removeStartSizeGradient(gradient: number): IParticleSystem;
  126951. /**
  126952. * Not supported by GPUParticleSystem
  126953. * @param gradient defines the gradient to use (between 0 and 1)
  126954. * @param min defines the color remap minimal range
  126955. * @param max defines the color remap maximal range
  126956. * @returns the current particle system
  126957. */
  126958. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126959. /**
  126960. * Not supported by GPUParticleSystem
  126961. * @param gradient defines the gradient to remove
  126962. * @returns the current particle system
  126963. */
  126964. removeColorRemapGradient(): IParticleSystem;
  126965. /**
  126966. * Not supported by GPUParticleSystem
  126967. * @param gradient defines the gradient to use (between 0 and 1)
  126968. * @param min defines the alpha remap minimal range
  126969. * @param max defines the alpha remap maximal range
  126970. * @returns the current particle system
  126971. */
  126972. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126973. /**
  126974. * Not supported by GPUParticleSystem
  126975. * @param gradient defines the gradient to remove
  126976. * @returns the current particle system
  126977. */
  126978. removeAlphaRemapGradient(): IParticleSystem;
  126979. /**
  126980. * Not supported by GPUParticleSystem
  126981. * @param gradient defines the gradient to use (between 0 and 1)
  126982. * @param color defines the color to affect to the specified gradient
  126983. * @returns the current particle system
  126984. */
  126985. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126986. /**
  126987. * Not supported by GPUParticleSystem
  126988. * @param gradient defines the gradient to remove
  126989. * @returns the current particle system
  126990. */
  126991. removeRampGradient(): IParticleSystem;
  126992. /**
  126993. * Not supported by GPUParticleSystem
  126994. * @returns the list of ramp gradients
  126995. */
  126996. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126997. /**
  126998. * Not supported by GPUParticleSystem
  126999. * Gets or sets a boolean indicating that ramp gradients must be used
  127000. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  127001. */
  127002. useRampGradients: boolean;
  127003. /**
  127004. * Not supported by GPUParticleSystem
  127005. * @param gradient defines the gradient to use (between 0 and 1)
  127006. * @param factor defines the life time factor to affect to the specified gradient
  127007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127008. * @returns the current particle system
  127009. */
  127010. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127011. /**
  127012. * Not supported by GPUParticleSystem
  127013. * @param gradient defines the gradient to remove
  127014. * @returns the current particle system
  127015. */
  127016. removeLifeTimeGradient(gradient: number): IParticleSystem;
  127017. /**
  127018. * Instantiates a GPU particle system.
  127019. * 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.
  127020. * @param name The name of the particle system
  127021. * @param options The options used to create the system
  127022. * @param scene The scene the particle system belongs to
  127023. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127024. */
  127025. constructor(name: string, options: Partial<{
  127026. capacity: number;
  127027. randomTextureSize: number;
  127028. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  127029. protected _reset(): void;
  127030. private _createUpdateVAO;
  127031. private _createRenderVAO;
  127032. private _initialize;
  127033. /** @hidden */
  127034. _recreateUpdateEffect(): void;
  127035. /** @hidden */
  127036. _recreateRenderEffect(): void;
  127037. /**
  127038. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  127039. * @param preWarm defines if we are in the pre-warmimg phase
  127040. */
  127041. animate(preWarm?: boolean): void;
  127042. private _createFactorGradientTexture;
  127043. private _createSizeGradientTexture;
  127044. private _createAngularSpeedGradientTexture;
  127045. private _createVelocityGradientTexture;
  127046. private _createLimitVelocityGradientTexture;
  127047. private _createDragGradientTexture;
  127048. private _createColorGradientTexture;
  127049. /**
  127050. * Renders the particle system in its current state
  127051. * @param preWarm defines if the system should only update the particles but not render them
  127052. * @returns the current number of particles
  127053. */
  127054. render(preWarm?: boolean): number;
  127055. /**
  127056. * Rebuilds the particle system
  127057. */
  127058. rebuild(): void;
  127059. private _releaseBuffers;
  127060. private _releaseVAOs;
  127061. /**
  127062. * Disposes the particle system and free the associated resources
  127063. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  127064. */
  127065. dispose(disposeTexture?: boolean): void;
  127066. /**
  127067. * Clones the particle system.
  127068. * @param name The name of the cloned object
  127069. * @param newEmitter The new emitter to use
  127070. * @returns the cloned particle system
  127071. */
  127072. clone(name: string, newEmitter: any): GPUParticleSystem;
  127073. /**
  127074. * Serializes the particle system to a JSON object.
  127075. * @returns the JSON object
  127076. */
  127077. serialize(): any;
  127078. /**
  127079. * Parses a JSON object to create a GPU particle system.
  127080. * @param parsedParticleSystem The JSON object to parse
  127081. * @param scene The scene to create the particle system in
  127082. * @param rootUrl The root url to use to load external dependencies like texture
  127083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  127084. * @returns the parsed GPU particle system
  127085. */
  127086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  127087. }
  127088. }
  127089. declare module BABYLON {
  127090. /**
  127091. * Represents a set of particle systems working together to create a specific effect
  127092. */
  127093. export class ParticleSystemSet implements IDisposable {
  127094. /**
  127095. * Gets or sets base Assets URL
  127096. */
  127097. static BaseAssetsUrl: string;
  127098. private _emitterCreationOptions;
  127099. private _emitterNode;
  127100. /**
  127101. * Gets the particle system list
  127102. */
  127103. systems: IParticleSystem[];
  127104. /**
  127105. * Gets the emitter node used with this set
  127106. */
  127107. readonly emitterNode: Nullable<TransformNode>;
  127108. /**
  127109. * Creates a new emitter mesh as a sphere
  127110. * @param options defines the options used to create the sphere
  127111. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  127112. * @param scene defines the hosting scene
  127113. */
  127114. setEmitterAsSphere(options: {
  127115. diameter: number;
  127116. segments: number;
  127117. color: Color3;
  127118. }, renderingGroupId: number, scene: Scene): void;
  127119. /**
  127120. * Starts all particle systems of the set
  127121. * @param emitter defines an optional mesh to use as emitter for the particle systems
  127122. */
  127123. start(emitter?: AbstractMesh): void;
  127124. /**
  127125. * Release all associated resources
  127126. */
  127127. dispose(): void;
  127128. /**
  127129. * Serialize the set into a JSON compatible object
  127130. * @returns a JSON compatible representation of the set
  127131. */
  127132. serialize(): any;
  127133. /**
  127134. * Parse a new ParticleSystemSet from a serialized source
  127135. * @param data defines a JSON compatible representation of the set
  127136. * @param scene defines the hosting scene
  127137. * @param gpu defines if we want GPU particles or CPU particles
  127138. * @returns a new ParticleSystemSet
  127139. */
  127140. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  127141. }
  127142. }
  127143. declare module BABYLON {
  127144. /**
  127145. * This class is made for on one-liner static method to help creating particle system set.
  127146. */
  127147. export class ParticleHelper {
  127148. /**
  127149. * Gets or sets base Assets URL
  127150. */
  127151. static BaseAssetsUrl: string;
  127152. /**
  127153. * Create a default particle system that you can tweak
  127154. * @param emitter defines the emitter to use
  127155. * @param capacity defines the system capacity (default is 500 particles)
  127156. * @param scene defines the hosting scene
  127157. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  127158. * @returns the new Particle system
  127159. */
  127160. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  127161. /**
  127162. * This is the main static method (one-liner) of this helper to create different particle systems
  127163. * @param type This string represents the type to the particle system to create
  127164. * @param scene The scene where the particle system should live
  127165. * @param gpu If the system will use gpu
  127166. * @returns the ParticleSystemSet created
  127167. */
  127168. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  127169. /**
  127170. * Static function used to export a particle system to a ParticleSystemSet variable.
  127171. * Please note that the emitter shape is not exported
  127172. * @param systems defines the particle systems to export
  127173. * @returns the created particle system set
  127174. */
  127175. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  127176. }
  127177. }
  127178. declare module BABYLON {
  127179. interface Engine {
  127180. /**
  127181. * Create an effect to use with particle systems.
  127182. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  127183. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  127184. * @param uniformsNames defines a list of attribute names
  127185. * @param samplers defines an array of string used to represent textures
  127186. * @param defines defines the string containing the defines to use to compile the shaders
  127187. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  127188. * @param onCompiled defines a function to call when the effect creation is successful
  127189. * @param onError defines a function to call when the effect creation has failed
  127190. * @returns the new Effect
  127191. */
  127192. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  127193. }
  127194. interface Mesh {
  127195. /**
  127196. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  127197. * @returns an array of IParticleSystem
  127198. */
  127199. getEmittedParticleSystems(): IParticleSystem[];
  127200. /**
  127201. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127202. * @returns an array of IParticleSystem
  127203. */
  127204. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127205. }
  127206. /**
  127207. * @hidden
  127208. */
  127209. export var _IDoNeedToBeInTheBuild: number;
  127210. }
  127211. declare module BABYLON {
  127212. /** Defines the 4 color options */
  127213. export enum PointColor {
  127214. /** color value */
  127215. Color = 2,
  127216. /** uv value */
  127217. UV = 1,
  127218. /** random value */
  127219. Random = 0,
  127220. /** stated value */
  127221. Stated = 3
  127222. }
  127223. /**
  127224. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127225. * 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.
  127226. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127227. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127228. *
  127229. * Full documentation here : TO BE ENTERED
  127230. */
  127231. export class PointsCloudSystem implements IDisposable {
  127232. /**
  127233. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127234. * Example : var p = SPS.particles[i];
  127235. */
  127236. particles: CloudPoint[];
  127237. /**
  127238. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127239. */
  127240. nbParticles: number;
  127241. /**
  127242. * This a counter for your own usage. It's not set by any SPS functions.
  127243. */
  127244. counter: number;
  127245. /**
  127246. * The PCS name. This name is also given to the underlying mesh.
  127247. */
  127248. name: string;
  127249. /**
  127250. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127251. */
  127252. mesh: Mesh;
  127253. /**
  127254. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127255. * Please read :
  127256. */
  127257. vars: any;
  127258. /**
  127259. * @hidden
  127260. */
  127261. _size: number;
  127262. private _scene;
  127263. private _promises;
  127264. private _positions;
  127265. private _indices;
  127266. private _normals;
  127267. private _colors;
  127268. private _uvs;
  127269. private _indices32;
  127270. private _positions32;
  127271. private _colors32;
  127272. private _uvs32;
  127273. private _updatable;
  127274. private _isVisibilityBoxLocked;
  127275. private _alwaysVisible;
  127276. private _groups;
  127277. private _groupCounter;
  127278. private _computeParticleColor;
  127279. private _computeParticleTexture;
  127280. private _computeParticleRotation;
  127281. private _computeBoundingBox;
  127282. private _isReady;
  127283. /**
  127284. * Creates a PCS (Points Cloud System) object
  127285. * @param name (String) is the PCS name, this will be the underlying mesh name
  127286. * @param pointSize (number) is the size for each point
  127287. * @param scene (Scene) is the scene in which the PCS is added
  127288. * @param options defines the options of the PCS e.g.
  127289. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127290. */
  127291. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127292. updatable?: boolean;
  127293. });
  127294. /**
  127295. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127296. * If no points were added to the PCS, the returned mesh is just a single point.
  127297. * @returns a promise for the created mesh
  127298. */
  127299. buildMeshAsync(): Promise<Mesh>;
  127300. /**
  127301. * @hidden
  127302. */
  127303. private _buildMesh;
  127304. private _addParticle;
  127305. private _randomUnitVector;
  127306. private _getColorIndicesForCoord;
  127307. private _setPointsColorOrUV;
  127308. private _colorFromTexture;
  127309. private _calculateDensity;
  127310. /**
  127311. * Adds points to the PCS in random positions within a unit sphere
  127312. * @param nb (positive integer) the number of particles to be created from this model
  127313. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127314. * @returns the number of groups in the system
  127315. */
  127316. addPoints(nb: number, pointFunction?: any): number;
  127317. /**
  127318. * Adds points to the PCS from the surface of the model shape
  127319. * @param mesh is any Mesh object that will be used as a surface model for the points
  127320. * @param nb (positive integer) the number of particles to be created from this model
  127321. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127322. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127323. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127324. * @returns the number of groups in the system
  127325. */
  127326. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127327. /**
  127328. * Adds points to the PCS inside the model shape
  127329. * @param mesh is any Mesh object that will be used as a surface model for the points
  127330. * @param nb (positive integer) the number of particles to be created from this model
  127331. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127332. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127333. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127334. * @returns the number of groups in the system
  127335. */
  127336. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127337. /**
  127338. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127339. * This method calls `updateParticle()` for each particle of the SPS.
  127340. * For an animated SPS, it is usually called within the render loop.
  127341. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127342. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127343. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127344. * @returns the PCS.
  127345. */
  127346. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127347. /**
  127348. * Disposes the PCS.
  127349. */
  127350. dispose(): void;
  127351. /**
  127352. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127353. * doc :
  127354. * @returns the PCS.
  127355. */
  127356. refreshVisibleSize(): PointsCloudSystem;
  127357. /**
  127358. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127359. * @param size the size (float) of the visibility box
  127360. * note : this doesn't lock the PCS mesh bounding box.
  127361. * doc :
  127362. */
  127363. setVisibilityBox(size: number): void;
  127364. /**
  127365. * Gets whether the PCS is always visible or not
  127366. * doc :
  127367. */
  127368. /**
  127369. * Sets the PCS as always visible or not
  127370. * doc :
  127371. */
  127372. isAlwaysVisible: boolean;
  127373. /**
  127374. * Tells to `setParticles()` to compute the particle rotations or not
  127375. * Default value : false. The PCS is faster when it's set to false
  127376. * Note : particle rotations are only applied to parent particles
  127377. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127378. */
  127379. computeParticleRotation: boolean;
  127380. /**
  127381. * Tells to `setParticles()` to compute the particle colors or not.
  127382. * Default value : true. The PCS is faster when it's set to false.
  127383. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127384. */
  127385. /**
  127386. * Gets if `setParticles()` computes the particle colors or not.
  127387. * Default value : false. The PCS is faster when it's set to false.
  127388. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127389. */
  127390. computeParticleColor: boolean;
  127391. /**
  127392. * Gets if `setParticles()` computes the particle textures or not.
  127393. * Default value : false. The PCS is faster when it's set to false.
  127394. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127395. */
  127396. computeParticleTexture: boolean;
  127397. /**
  127398. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127399. */
  127400. /**
  127401. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127402. */
  127403. computeBoundingBox: boolean;
  127404. /**
  127405. * This function does nothing. It may be overwritten to set all the particle first values.
  127406. * The PCS doesn't call this function, you may have to call it by your own.
  127407. * doc :
  127408. */
  127409. initParticles(): void;
  127410. /**
  127411. * This function does nothing. It may be overwritten to recycle a particle
  127412. * The PCS doesn't call this function, you can to call it
  127413. * doc :
  127414. * @param particle The particle to recycle
  127415. * @returns the recycled particle
  127416. */
  127417. recycleParticle(particle: CloudPoint): CloudPoint;
  127418. /**
  127419. * Updates a particle : this function should be overwritten by the user.
  127420. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127421. * doc :
  127422. * @example : just set a particle position or velocity and recycle conditions
  127423. * @param particle The particle to update
  127424. * @returns the updated particle
  127425. */
  127426. updateParticle(particle: CloudPoint): CloudPoint;
  127427. /**
  127428. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127429. * This does nothing and may be overwritten by the user.
  127430. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127431. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127432. * @param update the boolean update value actually passed to setParticles()
  127433. */
  127434. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127435. /**
  127436. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127437. * This will be passed three parameters.
  127438. * This does nothing and may be overwritten by the user.
  127439. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127440. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127441. * @param update the boolean update value actually passed to setParticles()
  127442. */
  127443. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127444. }
  127445. }
  127446. declare module BABYLON {
  127447. /**
  127448. * Represents one particle of a points cloud system.
  127449. */
  127450. export class CloudPoint {
  127451. /**
  127452. * particle global index
  127453. */
  127454. idx: number;
  127455. /**
  127456. * The color of the particle
  127457. */
  127458. color: Nullable<Color4>;
  127459. /**
  127460. * The world space position of the particle.
  127461. */
  127462. position: Vector3;
  127463. /**
  127464. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127465. */
  127466. rotation: Vector3;
  127467. /**
  127468. * The world space rotation quaternion of the particle.
  127469. */
  127470. rotationQuaternion: Nullable<Quaternion>;
  127471. /**
  127472. * The uv of the particle.
  127473. */
  127474. uv: Nullable<Vector2>;
  127475. /**
  127476. * The current speed of the particle.
  127477. */
  127478. velocity: Vector3;
  127479. /**
  127480. * The pivot point in the particle local space.
  127481. */
  127482. pivot: Vector3;
  127483. /**
  127484. * Must the particle be translated from its pivot point in its local space ?
  127485. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127486. * Default : false
  127487. */
  127488. translateFromPivot: boolean;
  127489. /**
  127490. * Index of this particle in the global "positions" array (Internal use)
  127491. * @hidden
  127492. */
  127493. _pos: number;
  127494. /**
  127495. * @hidden Index of this particle in the global "indices" array (Internal use)
  127496. */
  127497. _ind: number;
  127498. /**
  127499. * Group this particle belongs to
  127500. */
  127501. _group: PointsGroup;
  127502. /**
  127503. * Group id of this particle
  127504. */
  127505. groupId: number;
  127506. /**
  127507. * Index of the particle in its group id (Internal use)
  127508. */
  127509. idxInGroup: number;
  127510. /**
  127511. * @hidden Particle BoundingInfo object (Internal use)
  127512. */
  127513. _boundingInfo: BoundingInfo;
  127514. /**
  127515. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127516. */
  127517. _pcs: PointsCloudSystem;
  127518. /**
  127519. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127520. */
  127521. _stillInvisible: boolean;
  127522. /**
  127523. * @hidden Last computed particle rotation matrix
  127524. */
  127525. _rotationMatrix: number[];
  127526. /**
  127527. * Parent particle Id, if any.
  127528. * Default null.
  127529. */
  127530. parentId: Nullable<number>;
  127531. /**
  127532. * @hidden Internal global position in the PCS.
  127533. */
  127534. _globalPosition: Vector3;
  127535. /**
  127536. * Creates a Point Cloud object.
  127537. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127538. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127539. * @param group (PointsGroup) is the group the particle belongs to
  127540. * @param groupId (integer) is the group identifier in the PCS.
  127541. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127542. * @param pcs defines the PCS it is associated to
  127543. */
  127544. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127545. /**
  127546. * get point size
  127547. */
  127548. /**
  127549. * Set point size
  127550. */
  127551. size: Vector3;
  127552. /**
  127553. * Legacy support, changed quaternion to rotationQuaternion
  127554. */
  127555. /**
  127556. * Legacy support, changed quaternion to rotationQuaternion
  127557. */
  127558. quaternion: Nullable<Quaternion>;
  127559. /**
  127560. * Returns a boolean. True if the particle intersects a mesh, else false
  127561. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127562. * @param target is the object (point or mesh) what the intersection is computed against
  127563. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127564. * @returns true if it intersects
  127565. */
  127566. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127567. /**
  127568. * get the rotation matrix of the particle
  127569. * @hidden
  127570. */
  127571. getRotationMatrix(m: Matrix): void;
  127572. }
  127573. /**
  127574. * Represents a group of points in a points cloud system
  127575. * * PCS internal tool, don't use it manually.
  127576. */
  127577. export class PointsGroup {
  127578. /**
  127579. * The group id
  127580. * @hidden
  127581. */
  127582. groupID: number;
  127583. /**
  127584. * image data for group (internal use)
  127585. * @hidden
  127586. */
  127587. _groupImageData: Nullable<ArrayBufferView>;
  127588. /**
  127589. * Image Width (internal use)
  127590. * @hidden
  127591. */
  127592. _groupImgWidth: number;
  127593. /**
  127594. * Image Height (internal use)
  127595. * @hidden
  127596. */
  127597. _groupImgHeight: number;
  127598. /**
  127599. * Custom position function (internal use)
  127600. * @hidden
  127601. */
  127602. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127603. /**
  127604. * density per facet for surface points
  127605. * @hidden
  127606. */
  127607. _groupDensity: number[];
  127608. /**
  127609. * Only when points are colored by texture carries pointer to texture list array
  127610. * @hidden
  127611. */
  127612. _textureNb: number;
  127613. /**
  127614. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127615. * PCS internal tool, don't use it manually.
  127616. * @hidden
  127617. */
  127618. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127619. }
  127620. }
  127621. declare module BABYLON {
  127622. interface Scene {
  127623. /** @hidden (Backing field) */
  127624. _physicsEngine: Nullable<IPhysicsEngine>;
  127625. /**
  127626. * Gets the current physics engine
  127627. * @returns a IPhysicsEngine or null if none attached
  127628. */
  127629. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127630. /**
  127631. * Enables physics to the current scene
  127632. * @param gravity defines the scene's gravity for the physics engine
  127633. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127634. * @return a boolean indicating if the physics engine was initialized
  127635. */
  127636. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127637. /**
  127638. * Disables and disposes the physics engine associated with the scene
  127639. */
  127640. disablePhysicsEngine(): void;
  127641. /**
  127642. * Gets a boolean indicating if there is an active physics engine
  127643. * @returns a boolean indicating if there is an active physics engine
  127644. */
  127645. isPhysicsEnabled(): boolean;
  127646. /**
  127647. * Deletes a physics compound impostor
  127648. * @param compound defines the compound to delete
  127649. */
  127650. deleteCompoundImpostor(compound: any): void;
  127651. /**
  127652. * An event triggered when physic simulation is about to be run
  127653. */
  127654. onBeforePhysicsObservable: Observable<Scene>;
  127655. /**
  127656. * An event triggered when physic simulation has been done
  127657. */
  127658. onAfterPhysicsObservable: Observable<Scene>;
  127659. }
  127660. interface AbstractMesh {
  127661. /** @hidden */
  127662. _physicsImpostor: Nullable<PhysicsImpostor>;
  127663. /**
  127664. * Gets or sets impostor used for physic simulation
  127665. * @see http://doc.babylonjs.com/features/physics_engine
  127666. */
  127667. physicsImpostor: Nullable<PhysicsImpostor>;
  127668. /**
  127669. * Gets the current physics impostor
  127670. * @see http://doc.babylonjs.com/features/physics_engine
  127671. * @returns a physics impostor or null
  127672. */
  127673. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127674. /** Apply a physic impulse to the mesh
  127675. * @param force defines the force to apply
  127676. * @param contactPoint defines where to apply the force
  127677. * @returns the current mesh
  127678. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127679. */
  127680. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127681. /**
  127682. * Creates a physic joint between two meshes
  127683. * @param otherMesh defines the other mesh to use
  127684. * @param pivot1 defines the pivot to use on this mesh
  127685. * @param pivot2 defines the pivot to use on the other mesh
  127686. * @param options defines additional options (can be plugin dependent)
  127687. * @returns the current mesh
  127688. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127689. */
  127690. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127691. /** @hidden */
  127692. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127693. }
  127694. /**
  127695. * Defines the physics engine scene component responsible to manage a physics engine
  127696. */
  127697. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127698. /**
  127699. * The component name helpful to identify the component in the list of scene components.
  127700. */
  127701. readonly name: string;
  127702. /**
  127703. * The scene the component belongs to.
  127704. */
  127705. scene: Scene;
  127706. /**
  127707. * Creates a new instance of the component for the given scene
  127708. * @param scene Defines the scene to register the component in
  127709. */
  127710. constructor(scene: Scene);
  127711. /**
  127712. * Registers the component in a given scene
  127713. */
  127714. register(): void;
  127715. /**
  127716. * Rebuilds the elements related to this component in case of
  127717. * context lost for instance.
  127718. */
  127719. rebuild(): void;
  127720. /**
  127721. * Disposes the component and the associated ressources
  127722. */
  127723. dispose(): void;
  127724. }
  127725. }
  127726. declare module BABYLON {
  127727. /**
  127728. * A helper for physics simulations
  127729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127730. */
  127731. export class PhysicsHelper {
  127732. private _scene;
  127733. private _physicsEngine;
  127734. /**
  127735. * Initializes the Physics helper
  127736. * @param scene Babylon.js scene
  127737. */
  127738. constructor(scene: Scene);
  127739. /**
  127740. * Applies a radial explosion impulse
  127741. * @param origin the origin of the explosion
  127742. * @param radiusOrEventOptions the radius or the options of radial explosion
  127743. * @param strength the explosion strength
  127744. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127745. * @returns A physics radial explosion event, or null
  127746. */
  127747. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127748. /**
  127749. * Applies a radial explosion force
  127750. * @param origin the origin of the explosion
  127751. * @param radiusOrEventOptions the radius or the options of radial explosion
  127752. * @param strength the explosion strength
  127753. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127754. * @returns A physics radial explosion event, or null
  127755. */
  127756. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127757. /**
  127758. * Creates a gravitational field
  127759. * @param origin the origin of the explosion
  127760. * @param radiusOrEventOptions the radius or the options of radial explosion
  127761. * @param strength the explosion strength
  127762. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127763. * @returns A physics gravitational field event, or null
  127764. */
  127765. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127766. /**
  127767. * Creates a physics updraft event
  127768. * @param origin the origin of the updraft
  127769. * @param radiusOrEventOptions the radius or the options of the updraft
  127770. * @param strength the strength of the updraft
  127771. * @param height the height of the updraft
  127772. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127773. * @returns A physics updraft event, or null
  127774. */
  127775. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127776. /**
  127777. * Creates a physics vortex event
  127778. * @param origin the of the vortex
  127779. * @param radiusOrEventOptions the radius or the options of the vortex
  127780. * @param strength the strength of the vortex
  127781. * @param height the height of the vortex
  127782. * @returns a Physics vortex event, or null
  127783. * A physics vortex event or null
  127784. */
  127785. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127786. }
  127787. /**
  127788. * Represents a physics radial explosion event
  127789. */
  127790. class PhysicsRadialExplosionEvent {
  127791. private _scene;
  127792. private _options;
  127793. private _sphere;
  127794. private _dataFetched;
  127795. /**
  127796. * Initializes a radial explosioin event
  127797. * @param _scene BabylonJS scene
  127798. * @param _options The options for the vortex event
  127799. */
  127800. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127801. /**
  127802. * Returns the data related to the radial explosion event (sphere).
  127803. * @returns The radial explosion event data
  127804. */
  127805. getData(): PhysicsRadialExplosionEventData;
  127806. /**
  127807. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127808. * @param impostor A physics imposter
  127809. * @param origin the origin of the explosion
  127810. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127811. */
  127812. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127813. /**
  127814. * Triggers affecterd impostors callbacks
  127815. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127816. */
  127817. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127818. /**
  127819. * Disposes the sphere.
  127820. * @param force Specifies if the sphere should be disposed by force
  127821. */
  127822. dispose(force?: boolean): void;
  127823. /*** Helpers ***/
  127824. private _prepareSphere;
  127825. private _intersectsWithSphere;
  127826. }
  127827. /**
  127828. * Represents a gravitational field event
  127829. */
  127830. class PhysicsGravitationalFieldEvent {
  127831. private _physicsHelper;
  127832. private _scene;
  127833. private _origin;
  127834. private _options;
  127835. private _tickCallback;
  127836. private _sphere;
  127837. private _dataFetched;
  127838. /**
  127839. * Initializes the physics gravitational field event
  127840. * @param _physicsHelper A physics helper
  127841. * @param _scene BabylonJS scene
  127842. * @param _origin The origin position of the gravitational field event
  127843. * @param _options The options for the vortex event
  127844. */
  127845. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127846. /**
  127847. * Returns the data related to the gravitational field event (sphere).
  127848. * @returns A gravitational field event
  127849. */
  127850. getData(): PhysicsGravitationalFieldEventData;
  127851. /**
  127852. * Enables the gravitational field.
  127853. */
  127854. enable(): void;
  127855. /**
  127856. * Disables the gravitational field.
  127857. */
  127858. disable(): void;
  127859. /**
  127860. * Disposes the sphere.
  127861. * @param force The force to dispose from the gravitational field event
  127862. */
  127863. dispose(force?: boolean): void;
  127864. private _tick;
  127865. }
  127866. /**
  127867. * Represents a physics updraft event
  127868. */
  127869. class PhysicsUpdraftEvent {
  127870. private _scene;
  127871. private _origin;
  127872. private _options;
  127873. private _physicsEngine;
  127874. private _originTop;
  127875. private _originDirection;
  127876. private _tickCallback;
  127877. private _cylinder;
  127878. private _cylinderPosition;
  127879. private _dataFetched;
  127880. /**
  127881. * Initializes the physics updraft event
  127882. * @param _scene BabylonJS scene
  127883. * @param _origin The origin position of the updraft
  127884. * @param _options The options for the updraft event
  127885. */
  127886. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127887. /**
  127888. * Returns the data related to the updraft event (cylinder).
  127889. * @returns A physics updraft event
  127890. */
  127891. getData(): PhysicsUpdraftEventData;
  127892. /**
  127893. * Enables the updraft.
  127894. */
  127895. enable(): void;
  127896. /**
  127897. * Disables the updraft.
  127898. */
  127899. disable(): void;
  127900. /**
  127901. * Disposes the cylinder.
  127902. * @param force Specifies if the updraft should be disposed by force
  127903. */
  127904. dispose(force?: boolean): void;
  127905. private getImpostorHitData;
  127906. private _tick;
  127907. /*** Helpers ***/
  127908. private _prepareCylinder;
  127909. private _intersectsWithCylinder;
  127910. }
  127911. /**
  127912. * Represents a physics vortex event
  127913. */
  127914. class PhysicsVortexEvent {
  127915. private _scene;
  127916. private _origin;
  127917. private _options;
  127918. private _physicsEngine;
  127919. private _originTop;
  127920. private _tickCallback;
  127921. private _cylinder;
  127922. private _cylinderPosition;
  127923. private _dataFetched;
  127924. /**
  127925. * Initializes the physics vortex event
  127926. * @param _scene The BabylonJS scene
  127927. * @param _origin The origin position of the vortex
  127928. * @param _options The options for the vortex event
  127929. */
  127930. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127931. /**
  127932. * Returns the data related to the vortex event (cylinder).
  127933. * @returns The physics vortex event data
  127934. */
  127935. getData(): PhysicsVortexEventData;
  127936. /**
  127937. * Enables the vortex.
  127938. */
  127939. enable(): void;
  127940. /**
  127941. * Disables the cortex.
  127942. */
  127943. disable(): void;
  127944. /**
  127945. * Disposes the sphere.
  127946. * @param force
  127947. */
  127948. dispose(force?: boolean): void;
  127949. private getImpostorHitData;
  127950. private _tick;
  127951. /*** Helpers ***/
  127952. private _prepareCylinder;
  127953. private _intersectsWithCylinder;
  127954. }
  127955. /**
  127956. * Options fot the radial explosion event
  127957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127958. */
  127959. export class PhysicsRadialExplosionEventOptions {
  127960. /**
  127961. * The radius of the sphere for the radial explosion.
  127962. */
  127963. radius: number;
  127964. /**
  127965. * The strenth of the explosion.
  127966. */
  127967. strength: number;
  127968. /**
  127969. * The strenght of the force in correspondence to the distance of the affected object
  127970. */
  127971. falloff: PhysicsRadialImpulseFalloff;
  127972. /**
  127973. * Sphere options for the radial explosion.
  127974. */
  127975. sphere: {
  127976. segments: number;
  127977. diameter: number;
  127978. };
  127979. /**
  127980. * Sphere options for the radial explosion.
  127981. */
  127982. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127983. }
  127984. /**
  127985. * Options fot the updraft event
  127986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127987. */
  127988. export class PhysicsUpdraftEventOptions {
  127989. /**
  127990. * The radius of the cylinder for the vortex
  127991. */
  127992. radius: number;
  127993. /**
  127994. * The strenth of the updraft.
  127995. */
  127996. strength: number;
  127997. /**
  127998. * The height of the cylinder for the updraft.
  127999. */
  128000. height: number;
  128001. /**
  128002. * The mode for the the updraft.
  128003. */
  128004. updraftMode: PhysicsUpdraftMode;
  128005. }
  128006. /**
  128007. * Options fot the vortex event
  128008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128009. */
  128010. export class PhysicsVortexEventOptions {
  128011. /**
  128012. * The radius of the cylinder for the vortex
  128013. */
  128014. radius: number;
  128015. /**
  128016. * The strenth of the vortex.
  128017. */
  128018. strength: number;
  128019. /**
  128020. * The height of the cylinder for the vortex.
  128021. */
  128022. height: number;
  128023. /**
  128024. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  128025. */
  128026. centripetalForceThreshold: number;
  128027. /**
  128028. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  128029. */
  128030. centripetalForceMultiplier: number;
  128031. /**
  128032. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  128033. */
  128034. centrifugalForceMultiplier: number;
  128035. /**
  128036. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  128037. */
  128038. updraftForceMultiplier: number;
  128039. }
  128040. /**
  128041. * The strenght of the force in correspondence to the distance of the affected object
  128042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128043. */
  128044. export enum PhysicsRadialImpulseFalloff {
  128045. /** Defines that impulse is constant in strength across it's whole radius */
  128046. Constant = 0,
  128047. /** Defines that impulse gets weaker if it's further from the origin */
  128048. Linear = 1
  128049. }
  128050. /**
  128051. * The strength of the force in correspondence to the distance of the affected object
  128052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128053. */
  128054. export enum PhysicsUpdraftMode {
  128055. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  128056. Center = 0,
  128057. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  128058. Perpendicular = 1
  128059. }
  128060. /**
  128061. * Interface for a physics hit data
  128062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128063. */
  128064. export interface PhysicsHitData {
  128065. /**
  128066. * The force applied at the contact point
  128067. */
  128068. force: Vector3;
  128069. /**
  128070. * The contact point
  128071. */
  128072. contactPoint: Vector3;
  128073. /**
  128074. * The distance from the origin to the contact point
  128075. */
  128076. distanceFromOrigin: number;
  128077. }
  128078. /**
  128079. * Interface for radial explosion event data
  128080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128081. */
  128082. export interface PhysicsRadialExplosionEventData {
  128083. /**
  128084. * A sphere used for the radial explosion event
  128085. */
  128086. sphere: Mesh;
  128087. }
  128088. /**
  128089. * Interface for gravitational field event data
  128090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128091. */
  128092. export interface PhysicsGravitationalFieldEventData {
  128093. /**
  128094. * A sphere mesh used for the gravitational field event
  128095. */
  128096. sphere: Mesh;
  128097. }
  128098. /**
  128099. * Interface for updraft event data
  128100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128101. */
  128102. export interface PhysicsUpdraftEventData {
  128103. /**
  128104. * A cylinder used for the updraft event
  128105. */
  128106. cylinder: Mesh;
  128107. }
  128108. /**
  128109. * Interface for vortex event data
  128110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128111. */
  128112. export interface PhysicsVortexEventData {
  128113. /**
  128114. * A cylinder used for the vortex event
  128115. */
  128116. cylinder: Mesh;
  128117. }
  128118. /**
  128119. * Interface for an affected physics impostor
  128120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128121. */
  128122. export interface PhysicsAffectedImpostorWithData {
  128123. /**
  128124. * The impostor affected by the effect
  128125. */
  128126. impostor: PhysicsImpostor;
  128127. /**
  128128. * The data about the hit/horce from the explosion
  128129. */
  128130. hitData: PhysicsHitData;
  128131. }
  128132. }
  128133. declare module BABYLON {
  128134. /** @hidden */
  128135. export var blackAndWhitePixelShader: {
  128136. name: string;
  128137. shader: string;
  128138. };
  128139. }
  128140. declare module BABYLON {
  128141. /**
  128142. * Post process used to render in black and white
  128143. */
  128144. export class BlackAndWhitePostProcess extends PostProcess {
  128145. /**
  128146. * Linear about to convert he result to black and white (default: 1)
  128147. */
  128148. degree: number;
  128149. /**
  128150. * Creates a black and white post process
  128151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  128152. * @param name The name of the effect.
  128153. * @param options The required width/height ratio to downsize to before computing the render pass.
  128154. * @param camera The camera to apply the render pass to.
  128155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128156. * @param engine The engine which the post process will be applied. (default: current engine)
  128157. * @param reusable If the post process can be reused on the same frame. (default: false)
  128158. */
  128159. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128160. }
  128161. }
  128162. declare module BABYLON {
  128163. /**
  128164. * This represents a set of one or more post processes in Babylon.
  128165. * A post process can be used to apply a shader to a texture after it is rendered.
  128166. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128167. */
  128168. export class PostProcessRenderEffect {
  128169. private _postProcesses;
  128170. private _getPostProcesses;
  128171. private _singleInstance;
  128172. private _cameras;
  128173. private _indicesForCamera;
  128174. /**
  128175. * Name of the effect
  128176. * @hidden
  128177. */
  128178. _name: string;
  128179. /**
  128180. * Instantiates a post process render effect.
  128181. * A post process can be used to apply a shader to a texture after it is rendered.
  128182. * @param engine The engine the effect is tied to
  128183. * @param name The name of the effect
  128184. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  128185. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  128186. */
  128187. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  128188. /**
  128189. * Checks if all the post processes in the effect are supported.
  128190. */
  128191. readonly isSupported: boolean;
  128192. /**
  128193. * Updates the current state of the effect
  128194. * @hidden
  128195. */
  128196. _update(): void;
  128197. /**
  128198. * Attaches the effect on cameras
  128199. * @param cameras The camera to attach to.
  128200. * @hidden
  128201. */
  128202. _attachCameras(cameras: Camera): void;
  128203. /**
  128204. * Attaches the effect on cameras
  128205. * @param cameras The camera to attach to.
  128206. * @hidden
  128207. */
  128208. _attachCameras(cameras: Camera[]): void;
  128209. /**
  128210. * Detaches the effect on cameras
  128211. * @param cameras The camera to detatch from.
  128212. * @hidden
  128213. */
  128214. _detachCameras(cameras: Camera): void;
  128215. /**
  128216. * Detatches the effect on cameras
  128217. * @param cameras The camera to detatch from.
  128218. * @hidden
  128219. */
  128220. _detachCameras(cameras: Camera[]): void;
  128221. /**
  128222. * Enables the effect on given cameras
  128223. * @param cameras The camera to enable.
  128224. * @hidden
  128225. */
  128226. _enable(cameras: Camera): void;
  128227. /**
  128228. * Enables the effect on given cameras
  128229. * @param cameras The camera to enable.
  128230. * @hidden
  128231. */
  128232. _enable(cameras: Nullable<Camera[]>): void;
  128233. /**
  128234. * Disables the effect on the given cameras
  128235. * @param cameras The camera to disable.
  128236. * @hidden
  128237. */
  128238. _disable(cameras: Camera): void;
  128239. /**
  128240. * Disables the effect on the given cameras
  128241. * @param cameras The camera to disable.
  128242. * @hidden
  128243. */
  128244. _disable(cameras: Nullable<Camera[]>): void;
  128245. /**
  128246. * Gets a list of the post processes contained in the effect.
  128247. * @param camera The camera to get the post processes on.
  128248. * @returns The list of the post processes in the effect.
  128249. */
  128250. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128251. }
  128252. }
  128253. declare module BABYLON {
  128254. /** @hidden */
  128255. export var extractHighlightsPixelShader: {
  128256. name: string;
  128257. shader: string;
  128258. };
  128259. }
  128260. declare module BABYLON {
  128261. /**
  128262. * 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.
  128263. */
  128264. export class ExtractHighlightsPostProcess extends PostProcess {
  128265. /**
  128266. * The luminance threshold, pixels below this value will be set to black.
  128267. */
  128268. threshold: number;
  128269. /** @hidden */
  128270. _exposure: number;
  128271. /**
  128272. * Post process which has the input texture to be used when performing highlight extraction
  128273. * @hidden
  128274. */
  128275. _inputPostProcess: Nullable<PostProcess>;
  128276. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128277. }
  128278. }
  128279. declare module BABYLON {
  128280. /** @hidden */
  128281. export var bloomMergePixelShader: {
  128282. name: string;
  128283. shader: string;
  128284. };
  128285. }
  128286. declare module BABYLON {
  128287. /**
  128288. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128289. */
  128290. export class BloomMergePostProcess extends PostProcess {
  128291. /** Weight of the bloom to be added to the original input. */
  128292. weight: number;
  128293. /**
  128294. * Creates a new instance of @see BloomMergePostProcess
  128295. * @param name The name of the effect.
  128296. * @param originalFromInput Post process which's input will be used for the merge.
  128297. * @param blurred Blurred highlights post process which's output will be used.
  128298. * @param weight Weight of the bloom to be added to the original input.
  128299. * @param options The required width/height ratio to downsize to before computing the render pass.
  128300. * @param camera The camera to apply the render pass to.
  128301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128302. * @param engine The engine which the post process will be applied. (default: current engine)
  128303. * @param reusable If the post process can be reused on the same frame. (default: false)
  128304. * @param textureType Type of textures used when performing the post process. (default: 0)
  128305. * @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)
  128306. */
  128307. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128308. /** Weight of the bloom to be added to the original input. */
  128309. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128310. }
  128311. }
  128312. declare module BABYLON {
  128313. /**
  128314. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128315. */
  128316. export class BloomEffect extends PostProcessRenderEffect {
  128317. private bloomScale;
  128318. /**
  128319. * @hidden Internal
  128320. */
  128321. _effects: Array<PostProcess>;
  128322. /**
  128323. * @hidden Internal
  128324. */
  128325. _downscale: ExtractHighlightsPostProcess;
  128326. private _blurX;
  128327. private _blurY;
  128328. private _merge;
  128329. /**
  128330. * The luminance threshold to find bright areas of the image to bloom.
  128331. */
  128332. threshold: number;
  128333. /**
  128334. * The strength of the bloom.
  128335. */
  128336. weight: number;
  128337. /**
  128338. * Specifies the size of the bloom blur kernel, relative to the final output size
  128339. */
  128340. kernel: number;
  128341. /**
  128342. * Creates a new instance of @see BloomEffect
  128343. * @param scene The scene the effect belongs to.
  128344. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128345. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128346. * @param bloomWeight The the strength of bloom.
  128347. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128348. * @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)
  128349. */
  128350. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128351. /**
  128352. * Disposes each of the internal effects for a given camera.
  128353. * @param camera The camera to dispose the effect on.
  128354. */
  128355. disposeEffects(camera: Camera): void;
  128356. /**
  128357. * @hidden Internal
  128358. */
  128359. _updateEffects(): void;
  128360. /**
  128361. * Internal
  128362. * @returns if all the contained post processes are ready.
  128363. * @hidden
  128364. */
  128365. _isReady(): boolean;
  128366. }
  128367. }
  128368. declare module BABYLON {
  128369. /** @hidden */
  128370. export var chromaticAberrationPixelShader: {
  128371. name: string;
  128372. shader: string;
  128373. };
  128374. }
  128375. declare module BABYLON {
  128376. /**
  128377. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128378. */
  128379. export class ChromaticAberrationPostProcess extends PostProcess {
  128380. /**
  128381. * The amount of seperation of rgb channels (default: 30)
  128382. */
  128383. aberrationAmount: number;
  128384. /**
  128385. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128386. */
  128387. radialIntensity: number;
  128388. /**
  128389. * 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))
  128390. */
  128391. direction: Vector2;
  128392. /**
  128393. * 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))
  128394. */
  128395. centerPosition: Vector2;
  128396. /**
  128397. * Creates a new instance ChromaticAberrationPostProcess
  128398. * @param name The name of the effect.
  128399. * @param screenWidth The width of the screen to apply the effect on.
  128400. * @param screenHeight The height of the screen to apply the effect on.
  128401. * @param options The required width/height ratio to downsize to before computing the render pass.
  128402. * @param camera The camera to apply the render pass to.
  128403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128404. * @param engine The engine which the post process will be applied. (default: current engine)
  128405. * @param reusable If the post process can be reused on the same frame. (default: false)
  128406. * @param textureType Type of textures used when performing the post process. (default: 0)
  128407. * @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)
  128408. */
  128409. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128410. }
  128411. }
  128412. declare module BABYLON {
  128413. /** @hidden */
  128414. export var circleOfConfusionPixelShader: {
  128415. name: string;
  128416. shader: string;
  128417. };
  128418. }
  128419. declare module BABYLON {
  128420. /**
  128421. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128422. */
  128423. export class CircleOfConfusionPostProcess extends PostProcess {
  128424. /**
  128425. * 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.
  128426. */
  128427. lensSize: number;
  128428. /**
  128429. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128430. */
  128431. fStop: number;
  128432. /**
  128433. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128434. */
  128435. focusDistance: number;
  128436. /**
  128437. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128438. */
  128439. focalLength: number;
  128440. private _depthTexture;
  128441. /**
  128442. * Creates a new instance CircleOfConfusionPostProcess
  128443. * @param name The name of the effect.
  128444. * @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.
  128445. * @param options The required width/height ratio to downsize to before computing the render pass.
  128446. * @param camera The camera to apply the render pass to.
  128447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128448. * @param engine The engine which the post process will be applied. (default: current engine)
  128449. * @param reusable If the post process can be reused on the same frame. (default: false)
  128450. * @param textureType Type of textures used when performing the post process. (default: 0)
  128451. * @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)
  128452. */
  128453. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128454. /**
  128455. * 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.
  128456. */
  128457. depthTexture: RenderTargetTexture;
  128458. }
  128459. }
  128460. declare module BABYLON {
  128461. /** @hidden */
  128462. export var colorCorrectionPixelShader: {
  128463. name: string;
  128464. shader: string;
  128465. };
  128466. }
  128467. declare module BABYLON {
  128468. /**
  128469. *
  128470. * This post-process allows the modification of rendered colors by using
  128471. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128472. *
  128473. * The object needs to be provided an url to a texture containing the color
  128474. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128475. * Use an image editing software to tweak the LUT to match your needs.
  128476. *
  128477. * For an example of a color LUT, see here:
  128478. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128479. * For explanations on color grading, see here:
  128480. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128481. *
  128482. */
  128483. export class ColorCorrectionPostProcess extends PostProcess {
  128484. private _colorTableTexture;
  128485. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128486. }
  128487. }
  128488. declare module BABYLON {
  128489. /** @hidden */
  128490. export var convolutionPixelShader: {
  128491. name: string;
  128492. shader: string;
  128493. };
  128494. }
  128495. declare module BABYLON {
  128496. /**
  128497. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128498. * input texture to perform effects such as edge detection or sharpening
  128499. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128500. */
  128501. export class ConvolutionPostProcess extends PostProcess {
  128502. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128503. kernel: number[];
  128504. /**
  128505. * Creates a new instance ConvolutionPostProcess
  128506. * @param name The name of the effect.
  128507. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128508. * @param options The required width/height ratio to downsize to before computing the render pass.
  128509. * @param camera The camera to apply the render pass to.
  128510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128511. * @param engine The engine which the post process will be applied. (default: current engine)
  128512. * @param reusable If the post process can be reused on the same frame. (default: false)
  128513. * @param textureType Type of textures used when performing the post process. (default: 0)
  128514. */
  128515. constructor(name: string,
  128516. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128517. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128518. /**
  128519. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128520. */
  128521. static EdgeDetect0Kernel: number[];
  128522. /**
  128523. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128524. */
  128525. static EdgeDetect1Kernel: number[];
  128526. /**
  128527. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128528. */
  128529. static EdgeDetect2Kernel: number[];
  128530. /**
  128531. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128532. */
  128533. static SharpenKernel: number[];
  128534. /**
  128535. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128536. */
  128537. static EmbossKernel: number[];
  128538. /**
  128539. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128540. */
  128541. static GaussianKernel: number[];
  128542. }
  128543. }
  128544. declare module BABYLON {
  128545. /**
  128546. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128547. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128548. * based on samples that have a large difference in distance than the center pixel.
  128549. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128550. */
  128551. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128552. direction: Vector2;
  128553. /**
  128554. * Creates a new instance CircleOfConfusionPostProcess
  128555. * @param name The name of the effect.
  128556. * @param scene The scene the effect belongs to.
  128557. * @param direction The direction the blur should be applied.
  128558. * @param kernel The size of the kernel used to blur.
  128559. * @param options The required width/height ratio to downsize to before computing the render pass.
  128560. * @param camera The camera to apply the render pass to.
  128561. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128562. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128563. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128564. * @param engine The engine which the post process will be applied. (default: current engine)
  128565. * @param reusable If the post process can be reused on the same frame. (default: false)
  128566. * @param textureType Type of textures used when performing the post process. (default: 0)
  128567. * @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)
  128568. */
  128569. 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);
  128570. }
  128571. }
  128572. declare module BABYLON {
  128573. /** @hidden */
  128574. export var depthOfFieldMergePixelShader: {
  128575. name: string;
  128576. shader: string;
  128577. };
  128578. }
  128579. declare module BABYLON {
  128580. /**
  128581. * Options to be set when merging outputs from the default pipeline.
  128582. */
  128583. export class DepthOfFieldMergePostProcessOptions {
  128584. /**
  128585. * The original image to merge on top of
  128586. */
  128587. originalFromInput: PostProcess;
  128588. /**
  128589. * Parameters to perform the merge of the depth of field effect
  128590. */
  128591. depthOfField?: {
  128592. circleOfConfusion: PostProcess;
  128593. blurSteps: Array<PostProcess>;
  128594. };
  128595. /**
  128596. * Parameters to perform the merge of bloom effect
  128597. */
  128598. bloom?: {
  128599. blurred: PostProcess;
  128600. weight: number;
  128601. };
  128602. }
  128603. /**
  128604. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128605. */
  128606. export class DepthOfFieldMergePostProcess extends PostProcess {
  128607. private blurSteps;
  128608. /**
  128609. * Creates a new instance of DepthOfFieldMergePostProcess
  128610. * @param name The name of the effect.
  128611. * @param originalFromInput Post process which's input will be used for the merge.
  128612. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128613. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128614. * @param options The required width/height ratio to downsize to before computing the render pass.
  128615. * @param camera The camera to apply the render pass to.
  128616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128617. * @param engine The engine which the post process will be applied. (default: current engine)
  128618. * @param reusable If the post process can be reused on the same frame. (default: false)
  128619. * @param textureType Type of textures used when performing the post process. (default: 0)
  128620. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  128621. */
  128622. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128623. /**
  128624. * Updates the effect with the current post process compile time values and recompiles the shader.
  128625. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128626. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128627. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128628. * @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
  128629. * @param onCompiled Called when the shader has been compiled.
  128630. * @param onError Called if there is an error when compiling a shader.
  128631. */
  128632. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128633. }
  128634. }
  128635. declare module BABYLON {
  128636. /**
  128637. * Specifies the level of max blur that should be applied when using the depth of field effect
  128638. */
  128639. export enum DepthOfFieldEffectBlurLevel {
  128640. /**
  128641. * Subtle blur
  128642. */
  128643. Low = 0,
  128644. /**
  128645. * Medium blur
  128646. */
  128647. Medium = 1,
  128648. /**
  128649. * Large blur
  128650. */
  128651. High = 2
  128652. }
  128653. /**
  128654. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128655. */
  128656. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128657. private _circleOfConfusion;
  128658. /**
  128659. * @hidden Internal, blurs from high to low
  128660. */
  128661. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128662. private _depthOfFieldBlurY;
  128663. private _dofMerge;
  128664. /**
  128665. * @hidden Internal post processes in depth of field effect
  128666. */
  128667. _effects: Array<PostProcess>;
  128668. /**
  128669. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128670. */
  128671. focalLength: number;
  128672. /**
  128673. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128674. */
  128675. fStop: number;
  128676. /**
  128677. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128678. */
  128679. focusDistance: number;
  128680. /**
  128681. * 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.
  128682. */
  128683. lensSize: number;
  128684. /**
  128685. * Creates a new instance DepthOfFieldEffect
  128686. * @param scene The scene the effect belongs to.
  128687. * @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.
  128688. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128689. * @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)
  128690. */
  128691. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128692. /**
  128693. * Get the current class name of the current effet
  128694. * @returns "DepthOfFieldEffect"
  128695. */
  128696. getClassName(): string;
  128697. /**
  128698. * 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.
  128699. */
  128700. depthTexture: RenderTargetTexture;
  128701. /**
  128702. * Disposes each of the internal effects for a given camera.
  128703. * @param camera The camera to dispose the effect on.
  128704. */
  128705. disposeEffects(camera: Camera): void;
  128706. /**
  128707. * @hidden Internal
  128708. */
  128709. _updateEffects(): void;
  128710. /**
  128711. * Internal
  128712. * @returns if all the contained post processes are ready.
  128713. * @hidden
  128714. */
  128715. _isReady(): boolean;
  128716. }
  128717. }
  128718. declare module BABYLON {
  128719. /** @hidden */
  128720. export var displayPassPixelShader: {
  128721. name: string;
  128722. shader: string;
  128723. };
  128724. }
  128725. declare module BABYLON {
  128726. /**
  128727. * DisplayPassPostProcess which produces an output the same as it's input
  128728. */
  128729. export class DisplayPassPostProcess extends PostProcess {
  128730. /**
  128731. * Creates the DisplayPassPostProcess
  128732. * @param name The name of the effect.
  128733. * @param options The required width/height ratio to downsize to before computing the render pass.
  128734. * @param camera The camera to apply the render pass to.
  128735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128736. * @param engine The engine which the post process will be applied. (default: current engine)
  128737. * @param reusable If the post process can be reused on the same frame. (default: false)
  128738. */
  128739. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128740. }
  128741. }
  128742. declare module BABYLON {
  128743. /** @hidden */
  128744. export var filterPixelShader: {
  128745. name: string;
  128746. shader: string;
  128747. };
  128748. }
  128749. declare module BABYLON {
  128750. /**
  128751. * Applies a kernel filter to the image
  128752. */
  128753. export class FilterPostProcess extends PostProcess {
  128754. /** The matrix to be applied to the image */
  128755. kernelMatrix: Matrix;
  128756. /**
  128757. *
  128758. * @param name The name of the effect.
  128759. * @param kernelMatrix The matrix to be applied to the image
  128760. * @param options The required width/height ratio to downsize to before computing the render pass.
  128761. * @param camera The camera to apply the render pass to.
  128762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128763. * @param engine The engine which the post process will be applied. (default: current engine)
  128764. * @param reusable If the post process can be reused on the same frame. (default: false)
  128765. */
  128766. constructor(name: string,
  128767. /** The matrix to be applied to the image */
  128768. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128769. }
  128770. }
  128771. declare module BABYLON {
  128772. /** @hidden */
  128773. export var fxaaPixelShader: {
  128774. name: string;
  128775. shader: string;
  128776. };
  128777. }
  128778. declare module BABYLON {
  128779. /** @hidden */
  128780. export var fxaaVertexShader: {
  128781. name: string;
  128782. shader: string;
  128783. };
  128784. }
  128785. declare module BABYLON {
  128786. /**
  128787. * Fxaa post process
  128788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128789. */
  128790. export class FxaaPostProcess extends PostProcess {
  128791. /** @hidden */
  128792. texelWidth: number;
  128793. /** @hidden */
  128794. texelHeight: number;
  128795. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128796. private _getDefines;
  128797. }
  128798. }
  128799. declare module BABYLON {
  128800. /** @hidden */
  128801. export var grainPixelShader: {
  128802. name: string;
  128803. shader: string;
  128804. };
  128805. }
  128806. declare module BABYLON {
  128807. /**
  128808. * The GrainPostProcess adds noise to the image at mid luminance levels
  128809. */
  128810. export class GrainPostProcess extends PostProcess {
  128811. /**
  128812. * The intensity of the grain added (default: 30)
  128813. */
  128814. intensity: number;
  128815. /**
  128816. * If the grain should be randomized on every frame
  128817. */
  128818. animated: boolean;
  128819. /**
  128820. * Creates a new instance of @see GrainPostProcess
  128821. * @param name The name of the effect.
  128822. * @param options The required width/height ratio to downsize to before computing the render pass.
  128823. * @param camera The camera to apply the render pass to.
  128824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128825. * @param engine The engine which the post process will be applied. (default: current engine)
  128826. * @param reusable If the post process can be reused on the same frame. (default: false)
  128827. * @param textureType Type of textures used when performing the post process. (default: 0)
  128828. * @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)
  128829. */
  128830. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128831. }
  128832. }
  128833. declare module BABYLON {
  128834. /** @hidden */
  128835. export var highlightsPixelShader: {
  128836. name: string;
  128837. shader: string;
  128838. };
  128839. }
  128840. declare module BABYLON {
  128841. /**
  128842. * Extracts highlights from the image
  128843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128844. */
  128845. export class HighlightsPostProcess extends PostProcess {
  128846. /**
  128847. * Extracts highlights from the image
  128848. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128849. * @param name The name of the effect.
  128850. * @param options The required width/height ratio to downsize to before computing the render pass.
  128851. * @param camera The camera to apply the render pass to.
  128852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128853. * @param engine The engine which the post process will be applied. (default: current engine)
  128854. * @param reusable If the post process can be reused on the same frame. (default: false)
  128855. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128856. */
  128857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128858. }
  128859. }
  128860. declare module BABYLON {
  128861. /** @hidden */
  128862. export var mrtFragmentDeclaration: {
  128863. name: string;
  128864. shader: string;
  128865. };
  128866. }
  128867. declare module BABYLON {
  128868. /** @hidden */
  128869. export var geometryPixelShader: {
  128870. name: string;
  128871. shader: string;
  128872. };
  128873. }
  128874. declare module BABYLON {
  128875. /** @hidden */
  128876. export var geometryVertexShader: {
  128877. name: string;
  128878. shader: string;
  128879. };
  128880. }
  128881. declare module BABYLON {
  128882. /** @hidden */
  128883. interface ISavedTransformationMatrix {
  128884. world: Matrix;
  128885. viewProjection: Matrix;
  128886. }
  128887. /**
  128888. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128889. */
  128890. export class GeometryBufferRenderer {
  128891. /**
  128892. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128893. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128894. */
  128895. static readonly POSITION_TEXTURE_TYPE: number;
  128896. /**
  128897. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128898. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128899. */
  128900. static readonly VELOCITY_TEXTURE_TYPE: number;
  128901. /**
  128902. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128903. * in order to compute objects velocities when enableVelocity is set to "true"
  128904. * @hidden
  128905. */
  128906. _previousTransformationMatrices: {
  128907. [index: number]: ISavedTransformationMatrix;
  128908. };
  128909. /**
  128910. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128911. * in order to compute objects velocities when enableVelocity is set to "true"
  128912. * @hidden
  128913. */
  128914. _previousBonesTransformationMatrices: {
  128915. [index: number]: Float32Array;
  128916. };
  128917. /**
  128918. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128919. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128920. */
  128921. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128922. private _scene;
  128923. private _multiRenderTarget;
  128924. private _ratio;
  128925. private _enablePosition;
  128926. private _enableVelocity;
  128927. private _positionIndex;
  128928. private _velocityIndex;
  128929. protected _effect: Effect;
  128930. protected _cachedDefines: string;
  128931. /**
  128932. * Set the render list (meshes to be rendered) used in the G buffer.
  128933. */
  128934. renderList: Mesh[];
  128935. /**
  128936. * Gets wether or not G buffer are supported by the running hardware.
  128937. * This requires draw buffer supports
  128938. */
  128939. readonly isSupported: boolean;
  128940. /**
  128941. * Returns the index of the given texture type in the G-Buffer textures array
  128942. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128943. * @returns the index of the given texture type in the G-Buffer textures array
  128944. */
  128945. getTextureIndex(textureType: number): number;
  128946. /**
  128947. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128948. */
  128949. /**
  128950. * Sets whether or not objects positions are enabled for the G buffer.
  128951. */
  128952. enablePosition: boolean;
  128953. /**
  128954. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128955. */
  128956. /**
  128957. * Sets wether or not objects velocities are enabled for the G buffer.
  128958. */
  128959. enableVelocity: boolean;
  128960. /**
  128961. * Gets the scene associated with the buffer.
  128962. */
  128963. readonly scene: Scene;
  128964. /**
  128965. * Gets the ratio used by the buffer during its creation.
  128966. * How big is the buffer related to the main canvas.
  128967. */
  128968. readonly ratio: number;
  128969. /** @hidden */
  128970. static _SceneComponentInitialization: (scene: Scene) => void;
  128971. /**
  128972. * Creates a new G Buffer for the scene
  128973. * @param scene The scene the buffer belongs to
  128974. * @param ratio How big is the buffer related to the main canvas.
  128975. */
  128976. constructor(scene: Scene, ratio?: number);
  128977. /**
  128978. * Checks wether everything is ready to render a submesh to the G buffer.
  128979. * @param subMesh the submesh to check readiness for
  128980. * @param useInstances is the mesh drawn using instance or not
  128981. * @returns true if ready otherwise false
  128982. */
  128983. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128984. /**
  128985. * Gets the current underlying G Buffer.
  128986. * @returns the buffer
  128987. */
  128988. getGBuffer(): MultiRenderTarget;
  128989. /**
  128990. * Gets the number of samples used to render the buffer (anti aliasing).
  128991. */
  128992. /**
  128993. * Sets the number of samples used to render the buffer (anti aliasing).
  128994. */
  128995. samples: number;
  128996. /**
  128997. * Disposes the renderer and frees up associated resources.
  128998. */
  128999. dispose(): void;
  129000. protected _createRenderTargets(): void;
  129001. private _copyBonesTransformationMatrices;
  129002. }
  129003. }
  129004. declare module BABYLON {
  129005. interface Scene {
  129006. /** @hidden (Backing field) */
  129007. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129008. /**
  129009. * Gets or Sets the current geometry buffer associated to the scene.
  129010. */
  129011. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129012. /**
  129013. * Enables a GeometryBufferRender and associates it with the scene
  129014. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  129015. * @returns the GeometryBufferRenderer
  129016. */
  129017. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129018. /**
  129019. * Disables the GeometryBufferRender associated with the scene
  129020. */
  129021. disableGeometryBufferRenderer(): void;
  129022. }
  129023. /**
  129024. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129025. * in several rendering techniques.
  129026. */
  129027. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  129028. /**
  129029. * The component name helpful to identify the component in the list of scene components.
  129030. */
  129031. readonly name: string;
  129032. /**
  129033. * The scene the component belongs to.
  129034. */
  129035. scene: Scene;
  129036. /**
  129037. * Creates a new instance of the component for the given scene
  129038. * @param scene Defines the scene to register the component in
  129039. */
  129040. constructor(scene: Scene);
  129041. /**
  129042. * Registers the component in a given scene
  129043. */
  129044. register(): void;
  129045. /**
  129046. * Rebuilds the elements related to this component in case of
  129047. * context lost for instance.
  129048. */
  129049. rebuild(): void;
  129050. /**
  129051. * Disposes the component and the associated ressources
  129052. */
  129053. dispose(): void;
  129054. private _gatherRenderTargets;
  129055. }
  129056. }
  129057. declare module BABYLON {
  129058. /** @hidden */
  129059. export var motionBlurPixelShader: {
  129060. name: string;
  129061. shader: string;
  129062. };
  129063. }
  129064. declare module BABYLON {
  129065. /**
  129066. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  129067. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  129068. * As an example, all you have to do is to create the post-process:
  129069. * var mb = new BABYLON.MotionBlurPostProcess(
  129070. * 'mb', // The name of the effect.
  129071. * scene, // The scene containing the objects to blur according to their velocity.
  129072. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  129073. * camera // The camera to apply the render pass to.
  129074. * );
  129075. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  129076. */
  129077. export class MotionBlurPostProcess extends PostProcess {
  129078. /**
  129079. * Defines how much the image is blurred by the movement. Default value is equal to 1
  129080. */
  129081. motionStrength: number;
  129082. /**
  129083. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  129084. */
  129085. /**
  129086. * Sets the number of iterations to be used for motion blur quality
  129087. */
  129088. motionBlurSamples: number;
  129089. private _motionBlurSamples;
  129090. private _geometryBufferRenderer;
  129091. /**
  129092. * Creates a new instance MotionBlurPostProcess
  129093. * @param name The name of the effect.
  129094. * @param scene The scene containing the objects to blur according to their velocity.
  129095. * @param options The required width/height ratio to downsize to before computing the render pass.
  129096. * @param camera The camera to apply the render pass to.
  129097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129098. * @param engine The engine which the post process will be applied. (default: current engine)
  129099. * @param reusable If the post process can be reused on the same frame. (default: false)
  129100. * @param textureType Type of textures used when performing the post process. (default: 0)
  129101. * @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)
  129102. */
  129103. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129104. /**
  129105. * Excludes the given skinned mesh from computing bones velocities.
  129106. * 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.
  129107. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  129108. */
  129109. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129110. /**
  129111. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  129112. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  129113. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  129114. */
  129115. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129116. /**
  129117. * Disposes the post process.
  129118. * @param camera The camera to dispose the post process on.
  129119. */
  129120. dispose(camera?: Camera): void;
  129121. }
  129122. }
  129123. declare module BABYLON {
  129124. /** @hidden */
  129125. export var refractionPixelShader: {
  129126. name: string;
  129127. shader: string;
  129128. };
  129129. }
  129130. declare module BABYLON {
  129131. /**
  129132. * Post process which applies a refractin texture
  129133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129134. */
  129135. export class RefractionPostProcess extends PostProcess {
  129136. /** the base color of the refraction (used to taint the rendering) */
  129137. color: Color3;
  129138. /** simulated refraction depth */
  129139. depth: number;
  129140. /** the coefficient of the base color (0 to remove base color tainting) */
  129141. colorLevel: number;
  129142. private _refTexture;
  129143. private _ownRefractionTexture;
  129144. /**
  129145. * Gets or sets the refraction texture
  129146. * Please note that you are responsible for disposing the texture if you set it manually
  129147. */
  129148. refractionTexture: Texture;
  129149. /**
  129150. * Initializes the RefractionPostProcess
  129151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129152. * @param name The name of the effect.
  129153. * @param refractionTextureUrl Url of the refraction texture to use
  129154. * @param color the base color of the refraction (used to taint the rendering)
  129155. * @param depth simulated refraction depth
  129156. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  129157. * @param camera The camera to apply the render pass to.
  129158. * @param options The required width/height ratio to downsize to before computing the render pass.
  129159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129160. * @param engine The engine which the post process will be applied. (default: current engine)
  129161. * @param reusable If the post process can be reused on the same frame. (default: false)
  129162. */
  129163. constructor(name: string, refractionTextureUrl: string,
  129164. /** the base color of the refraction (used to taint the rendering) */
  129165. color: Color3,
  129166. /** simulated refraction depth */
  129167. depth: number,
  129168. /** the coefficient of the base color (0 to remove base color tainting) */
  129169. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129170. /**
  129171. * Disposes of the post process
  129172. * @param camera Camera to dispose post process on
  129173. */
  129174. dispose(camera: Camera): void;
  129175. }
  129176. }
  129177. declare module BABYLON {
  129178. /** @hidden */
  129179. export var sharpenPixelShader: {
  129180. name: string;
  129181. shader: string;
  129182. };
  129183. }
  129184. declare module BABYLON {
  129185. /**
  129186. * The SharpenPostProcess applies a sharpen kernel to every pixel
  129187. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129188. */
  129189. export class SharpenPostProcess extends PostProcess {
  129190. /**
  129191. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  129192. */
  129193. colorAmount: number;
  129194. /**
  129195. * How much sharpness should be applied (default: 0.3)
  129196. */
  129197. edgeAmount: number;
  129198. /**
  129199. * Creates a new instance ConvolutionPostProcess
  129200. * @param name The name of the effect.
  129201. * @param options The required width/height ratio to downsize to before computing the render pass.
  129202. * @param camera The camera to apply the render pass to.
  129203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129204. * @param engine The engine which the post process will be applied. (default: current engine)
  129205. * @param reusable If the post process can be reused on the same frame. (default: false)
  129206. * @param textureType Type of textures used when performing the post process. (default: 0)
  129207. * @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)
  129208. */
  129209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129210. }
  129211. }
  129212. declare module BABYLON {
  129213. /**
  129214. * PostProcessRenderPipeline
  129215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129216. */
  129217. export class PostProcessRenderPipeline {
  129218. private engine;
  129219. private _renderEffects;
  129220. private _renderEffectsForIsolatedPass;
  129221. /**
  129222. * List of inspectable custom properties (used by the Inspector)
  129223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129224. */
  129225. inspectableCustomProperties: IInspectable[];
  129226. /**
  129227. * @hidden
  129228. */
  129229. protected _cameras: Camera[];
  129230. /** @hidden */
  129231. _name: string;
  129232. /**
  129233. * Gets pipeline name
  129234. */
  129235. readonly name: string;
  129236. /** Gets the list of attached cameras */
  129237. readonly cameras: Camera[];
  129238. /**
  129239. * Initializes a PostProcessRenderPipeline
  129240. * @param engine engine to add the pipeline to
  129241. * @param name name of the pipeline
  129242. */
  129243. constructor(engine: Engine, name: string);
  129244. /**
  129245. * Gets the class name
  129246. * @returns "PostProcessRenderPipeline"
  129247. */
  129248. getClassName(): string;
  129249. /**
  129250. * If all the render effects in the pipeline are supported
  129251. */
  129252. readonly isSupported: boolean;
  129253. /**
  129254. * Adds an effect to the pipeline
  129255. * @param renderEffect the effect to add
  129256. */
  129257. addEffect(renderEffect: PostProcessRenderEffect): void;
  129258. /** @hidden */
  129259. _rebuild(): void;
  129260. /** @hidden */
  129261. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129262. /** @hidden */
  129263. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129264. /** @hidden */
  129265. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129266. /** @hidden */
  129267. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129268. /** @hidden */
  129269. _attachCameras(cameras: Camera, unique: boolean): void;
  129270. /** @hidden */
  129271. _attachCameras(cameras: Camera[], unique: boolean): void;
  129272. /** @hidden */
  129273. _detachCameras(cameras: Camera): void;
  129274. /** @hidden */
  129275. _detachCameras(cameras: Nullable<Camera[]>): void;
  129276. /** @hidden */
  129277. _update(): void;
  129278. /** @hidden */
  129279. _reset(): void;
  129280. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129281. /**
  129282. * Disposes of the pipeline
  129283. */
  129284. dispose(): void;
  129285. }
  129286. }
  129287. declare module BABYLON {
  129288. /**
  129289. * PostProcessRenderPipelineManager class
  129290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129291. */
  129292. export class PostProcessRenderPipelineManager {
  129293. private _renderPipelines;
  129294. /**
  129295. * Initializes a PostProcessRenderPipelineManager
  129296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129297. */
  129298. constructor();
  129299. /**
  129300. * Gets the list of supported render pipelines
  129301. */
  129302. readonly supportedPipelines: PostProcessRenderPipeline[];
  129303. /**
  129304. * Adds a pipeline to the manager
  129305. * @param renderPipeline The pipeline to add
  129306. */
  129307. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129308. /**
  129309. * Attaches a camera to the pipeline
  129310. * @param renderPipelineName The name of the pipeline to attach to
  129311. * @param cameras the camera to attach
  129312. * @param unique if the camera can be attached multiple times to the pipeline
  129313. */
  129314. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129315. /**
  129316. * Detaches a camera from the pipeline
  129317. * @param renderPipelineName The name of the pipeline to detach from
  129318. * @param cameras the camera to detach
  129319. */
  129320. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129321. /**
  129322. * Enables an effect by name on a pipeline
  129323. * @param renderPipelineName the name of the pipeline to enable the effect in
  129324. * @param renderEffectName the name of the effect to enable
  129325. * @param cameras the cameras that the effect should be enabled on
  129326. */
  129327. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129328. /**
  129329. * Disables an effect by name on a pipeline
  129330. * @param renderPipelineName the name of the pipeline to disable the effect in
  129331. * @param renderEffectName the name of the effect to disable
  129332. * @param cameras the cameras that the effect should be disabled on
  129333. */
  129334. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129335. /**
  129336. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129337. */
  129338. update(): void;
  129339. /** @hidden */
  129340. _rebuild(): void;
  129341. /**
  129342. * Disposes of the manager and pipelines
  129343. */
  129344. dispose(): void;
  129345. }
  129346. }
  129347. declare module BABYLON {
  129348. interface Scene {
  129349. /** @hidden (Backing field) */
  129350. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129351. /**
  129352. * Gets the postprocess render pipeline manager
  129353. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129354. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129355. */
  129356. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129357. }
  129358. /**
  129359. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129360. */
  129361. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129362. /**
  129363. * The component name helpfull to identify the component in the list of scene components.
  129364. */
  129365. readonly name: string;
  129366. /**
  129367. * The scene the component belongs to.
  129368. */
  129369. scene: Scene;
  129370. /**
  129371. * Creates a new instance of the component for the given scene
  129372. * @param scene Defines the scene to register the component in
  129373. */
  129374. constructor(scene: Scene);
  129375. /**
  129376. * Registers the component in a given scene
  129377. */
  129378. register(): void;
  129379. /**
  129380. * Rebuilds the elements related to this component in case of
  129381. * context lost for instance.
  129382. */
  129383. rebuild(): void;
  129384. /**
  129385. * Disposes the component and the associated ressources
  129386. */
  129387. dispose(): void;
  129388. private _gatherRenderTargets;
  129389. }
  129390. }
  129391. declare module BABYLON {
  129392. /**
  129393. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129394. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129395. */
  129396. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129397. private _scene;
  129398. private _camerasToBeAttached;
  129399. /**
  129400. * ID of the sharpen post process,
  129401. */
  129402. private readonly SharpenPostProcessId;
  129403. /**
  129404. * @ignore
  129405. * ID of the image processing post process;
  129406. */
  129407. readonly ImageProcessingPostProcessId: string;
  129408. /**
  129409. * @ignore
  129410. * ID of the Fast Approximate Anti-Aliasing post process;
  129411. */
  129412. readonly FxaaPostProcessId: string;
  129413. /**
  129414. * ID of the chromatic aberration post process,
  129415. */
  129416. private readonly ChromaticAberrationPostProcessId;
  129417. /**
  129418. * ID of the grain post process
  129419. */
  129420. private readonly GrainPostProcessId;
  129421. /**
  129422. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129423. */
  129424. sharpen: SharpenPostProcess;
  129425. private _sharpenEffect;
  129426. private bloom;
  129427. /**
  129428. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129429. */
  129430. depthOfField: DepthOfFieldEffect;
  129431. /**
  129432. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129433. */
  129434. fxaa: FxaaPostProcess;
  129435. /**
  129436. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129437. */
  129438. imageProcessing: ImageProcessingPostProcess;
  129439. /**
  129440. * Chromatic aberration post process which will shift rgb colors in the image
  129441. */
  129442. chromaticAberration: ChromaticAberrationPostProcess;
  129443. private _chromaticAberrationEffect;
  129444. /**
  129445. * Grain post process which add noise to the image
  129446. */
  129447. grain: GrainPostProcess;
  129448. private _grainEffect;
  129449. /**
  129450. * Glow post process which adds a glow to emissive areas of the image
  129451. */
  129452. private _glowLayer;
  129453. /**
  129454. * Animations which can be used to tweak settings over a period of time
  129455. */
  129456. animations: Animation[];
  129457. private _imageProcessingConfigurationObserver;
  129458. private _sharpenEnabled;
  129459. private _bloomEnabled;
  129460. private _depthOfFieldEnabled;
  129461. private _depthOfFieldBlurLevel;
  129462. private _fxaaEnabled;
  129463. private _imageProcessingEnabled;
  129464. private _defaultPipelineTextureType;
  129465. private _bloomScale;
  129466. private _chromaticAberrationEnabled;
  129467. private _grainEnabled;
  129468. private _buildAllowed;
  129469. /**
  129470. * Gets active scene
  129471. */
  129472. readonly scene: Scene;
  129473. /**
  129474. * Enable or disable the sharpen process from the pipeline
  129475. */
  129476. sharpenEnabled: boolean;
  129477. private _resizeObserver;
  129478. private _hardwareScaleLevel;
  129479. private _bloomKernel;
  129480. /**
  129481. * Specifies the size of the bloom blur kernel, relative to the final output size
  129482. */
  129483. bloomKernel: number;
  129484. /**
  129485. * Specifies the weight of the bloom in the final rendering
  129486. */
  129487. private _bloomWeight;
  129488. /**
  129489. * Specifies the luma threshold for the area that will be blurred by the bloom
  129490. */
  129491. private _bloomThreshold;
  129492. private _hdr;
  129493. /**
  129494. * The strength of the bloom.
  129495. */
  129496. bloomWeight: number;
  129497. /**
  129498. * The strength of the bloom.
  129499. */
  129500. bloomThreshold: number;
  129501. /**
  129502. * The scale of the bloom, lower value will provide better performance.
  129503. */
  129504. bloomScale: number;
  129505. /**
  129506. * Enable or disable the bloom from the pipeline
  129507. */
  129508. bloomEnabled: boolean;
  129509. private _rebuildBloom;
  129510. /**
  129511. * If the depth of field is enabled.
  129512. */
  129513. depthOfFieldEnabled: boolean;
  129514. /**
  129515. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129516. */
  129517. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129518. /**
  129519. * If the anti aliasing is enabled.
  129520. */
  129521. fxaaEnabled: boolean;
  129522. private _samples;
  129523. /**
  129524. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129525. */
  129526. samples: number;
  129527. /**
  129528. * If image processing is enabled.
  129529. */
  129530. imageProcessingEnabled: boolean;
  129531. /**
  129532. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129533. */
  129534. glowLayerEnabled: boolean;
  129535. /**
  129536. * Gets the glow layer (or null if not defined)
  129537. */
  129538. readonly glowLayer: Nullable<GlowLayer>;
  129539. /**
  129540. * Enable or disable the chromaticAberration process from the pipeline
  129541. */
  129542. chromaticAberrationEnabled: boolean;
  129543. /**
  129544. * Enable or disable the grain process from the pipeline
  129545. */
  129546. grainEnabled: boolean;
  129547. /**
  129548. * @constructor
  129549. * @param name - The rendering pipeline name (default: "")
  129550. * @param hdr - If high dynamic range textures should be used (default: true)
  129551. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129552. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129553. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129554. */
  129555. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129556. /**
  129557. * Get the class name
  129558. * @returns "DefaultRenderingPipeline"
  129559. */
  129560. getClassName(): string;
  129561. /**
  129562. * Force the compilation of the entire pipeline.
  129563. */
  129564. prepare(): void;
  129565. private _hasCleared;
  129566. private _prevPostProcess;
  129567. private _prevPrevPostProcess;
  129568. private _setAutoClearAndTextureSharing;
  129569. private _depthOfFieldSceneObserver;
  129570. private _buildPipeline;
  129571. private _disposePostProcesses;
  129572. /**
  129573. * Adds a camera to the pipeline
  129574. * @param camera the camera to be added
  129575. */
  129576. addCamera(camera: Camera): void;
  129577. /**
  129578. * Removes a camera from the pipeline
  129579. * @param camera the camera to remove
  129580. */
  129581. removeCamera(camera: Camera): void;
  129582. /**
  129583. * Dispose of the pipeline and stop all post processes
  129584. */
  129585. dispose(): void;
  129586. /**
  129587. * Serialize the rendering pipeline (Used when exporting)
  129588. * @returns the serialized object
  129589. */
  129590. serialize(): any;
  129591. /**
  129592. * Parse the serialized pipeline
  129593. * @param source Source pipeline.
  129594. * @param scene The scene to load the pipeline to.
  129595. * @param rootUrl The URL of the serialized pipeline.
  129596. * @returns An instantiated pipeline from the serialized object.
  129597. */
  129598. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129599. }
  129600. }
  129601. declare module BABYLON {
  129602. /** @hidden */
  129603. export var lensHighlightsPixelShader: {
  129604. name: string;
  129605. shader: string;
  129606. };
  129607. }
  129608. declare module BABYLON {
  129609. /** @hidden */
  129610. export var depthOfFieldPixelShader: {
  129611. name: string;
  129612. shader: string;
  129613. };
  129614. }
  129615. declare module BABYLON {
  129616. /**
  129617. * BABYLON.JS Chromatic Aberration GLSL Shader
  129618. * Author: Olivier Guyot
  129619. * Separates very slightly R, G and B colors on the edges of the screen
  129620. * Inspired by Francois Tarlier & Martins Upitis
  129621. */
  129622. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129623. /**
  129624. * @ignore
  129625. * The chromatic aberration PostProcess id in the pipeline
  129626. */
  129627. LensChromaticAberrationEffect: string;
  129628. /**
  129629. * @ignore
  129630. * The highlights enhancing PostProcess id in the pipeline
  129631. */
  129632. HighlightsEnhancingEffect: string;
  129633. /**
  129634. * @ignore
  129635. * The depth-of-field PostProcess id in the pipeline
  129636. */
  129637. LensDepthOfFieldEffect: string;
  129638. private _scene;
  129639. private _depthTexture;
  129640. private _grainTexture;
  129641. private _chromaticAberrationPostProcess;
  129642. private _highlightsPostProcess;
  129643. private _depthOfFieldPostProcess;
  129644. private _edgeBlur;
  129645. private _grainAmount;
  129646. private _chromaticAberration;
  129647. private _distortion;
  129648. private _highlightsGain;
  129649. private _highlightsThreshold;
  129650. private _dofDistance;
  129651. private _dofAperture;
  129652. private _dofDarken;
  129653. private _dofPentagon;
  129654. private _blurNoise;
  129655. /**
  129656. * @constructor
  129657. *
  129658. * Effect parameters are as follow:
  129659. * {
  129660. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129661. * edge_blur: number; // from 0 to x (1 for realism)
  129662. * distortion: number; // from 0 to x (1 for realism)
  129663. * grain_amount: number; // from 0 to 1
  129664. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129665. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129666. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129667. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129668. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129669. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129670. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129671. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129672. * }
  129673. * Note: if an effect parameter is unset, effect is disabled
  129674. *
  129675. * @param name The rendering pipeline name
  129676. * @param parameters - An object containing all parameters (see above)
  129677. * @param scene The scene linked to this pipeline
  129678. * @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)
  129679. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129680. */
  129681. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129682. /**
  129683. * Get the class name
  129684. * @returns "LensRenderingPipeline"
  129685. */
  129686. getClassName(): string;
  129687. /**
  129688. * Gets associated scene
  129689. */
  129690. readonly scene: Scene;
  129691. /**
  129692. * Gets or sets the edge blur
  129693. */
  129694. edgeBlur: number;
  129695. /**
  129696. * Gets or sets the grain amount
  129697. */
  129698. grainAmount: number;
  129699. /**
  129700. * Gets or sets the chromatic aberration amount
  129701. */
  129702. chromaticAberration: number;
  129703. /**
  129704. * Gets or sets the depth of field aperture
  129705. */
  129706. dofAperture: number;
  129707. /**
  129708. * Gets or sets the edge distortion
  129709. */
  129710. edgeDistortion: number;
  129711. /**
  129712. * Gets or sets the depth of field distortion
  129713. */
  129714. dofDistortion: number;
  129715. /**
  129716. * Gets or sets the darken out of focus amount
  129717. */
  129718. darkenOutOfFocus: number;
  129719. /**
  129720. * Gets or sets a boolean indicating if blur noise is enabled
  129721. */
  129722. blurNoise: boolean;
  129723. /**
  129724. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129725. */
  129726. pentagonBokeh: boolean;
  129727. /**
  129728. * Gets or sets the highlight grain amount
  129729. */
  129730. highlightsGain: number;
  129731. /**
  129732. * Gets or sets the highlight threshold
  129733. */
  129734. highlightsThreshold: number;
  129735. /**
  129736. * Sets the amount of blur at the edges
  129737. * @param amount blur amount
  129738. */
  129739. setEdgeBlur(amount: number): void;
  129740. /**
  129741. * Sets edge blur to 0
  129742. */
  129743. disableEdgeBlur(): void;
  129744. /**
  129745. * Sets the amout of grain
  129746. * @param amount Amount of grain
  129747. */
  129748. setGrainAmount(amount: number): void;
  129749. /**
  129750. * Set grain amount to 0
  129751. */
  129752. disableGrain(): void;
  129753. /**
  129754. * Sets the chromatic aberration amount
  129755. * @param amount amount of chromatic aberration
  129756. */
  129757. setChromaticAberration(amount: number): void;
  129758. /**
  129759. * Sets chromatic aberration amount to 0
  129760. */
  129761. disableChromaticAberration(): void;
  129762. /**
  129763. * Sets the EdgeDistortion amount
  129764. * @param amount amount of EdgeDistortion
  129765. */
  129766. setEdgeDistortion(amount: number): void;
  129767. /**
  129768. * Sets edge distortion to 0
  129769. */
  129770. disableEdgeDistortion(): void;
  129771. /**
  129772. * Sets the FocusDistance amount
  129773. * @param amount amount of FocusDistance
  129774. */
  129775. setFocusDistance(amount: number): void;
  129776. /**
  129777. * Disables depth of field
  129778. */
  129779. disableDepthOfField(): void;
  129780. /**
  129781. * Sets the Aperture amount
  129782. * @param amount amount of Aperture
  129783. */
  129784. setAperture(amount: number): void;
  129785. /**
  129786. * Sets the DarkenOutOfFocus amount
  129787. * @param amount amount of DarkenOutOfFocus
  129788. */
  129789. setDarkenOutOfFocus(amount: number): void;
  129790. private _pentagonBokehIsEnabled;
  129791. /**
  129792. * Creates a pentagon bokeh effect
  129793. */
  129794. enablePentagonBokeh(): void;
  129795. /**
  129796. * Disables the pentagon bokeh effect
  129797. */
  129798. disablePentagonBokeh(): void;
  129799. /**
  129800. * Enables noise blur
  129801. */
  129802. enableNoiseBlur(): void;
  129803. /**
  129804. * Disables noise blur
  129805. */
  129806. disableNoiseBlur(): void;
  129807. /**
  129808. * Sets the HighlightsGain amount
  129809. * @param amount amount of HighlightsGain
  129810. */
  129811. setHighlightsGain(amount: number): void;
  129812. /**
  129813. * Sets the HighlightsThreshold amount
  129814. * @param amount amount of HighlightsThreshold
  129815. */
  129816. setHighlightsThreshold(amount: number): void;
  129817. /**
  129818. * Disables highlights
  129819. */
  129820. disableHighlights(): void;
  129821. /**
  129822. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129823. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129824. */
  129825. dispose(disableDepthRender?: boolean): void;
  129826. private _createChromaticAberrationPostProcess;
  129827. private _createHighlightsPostProcess;
  129828. private _createDepthOfFieldPostProcess;
  129829. private _createGrainTexture;
  129830. }
  129831. }
  129832. declare module BABYLON {
  129833. /** @hidden */
  129834. export var ssao2PixelShader: {
  129835. name: string;
  129836. shader: string;
  129837. };
  129838. }
  129839. declare module BABYLON {
  129840. /** @hidden */
  129841. export var ssaoCombinePixelShader: {
  129842. name: string;
  129843. shader: string;
  129844. };
  129845. }
  129846. declare module BABYLON {
  129847. /**
  129848. * Render pipeline to produce ssao effect
  129849. */
  129850. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129851. /**
  129852. * @ignore
  129853. * The PassPostProcess id in the pipeline that contains the original scene color
  129854. */
  129855. SSAOOriginalSceneColorEffect: string;
  129856. /**
  129857. * @ignore
  129858. * The SSAO PostProcess id in the pipeline
  129859. */
  129860. SSAORenderEffect: string;
  129861. /**
  129862. * @ignore
  129863. * The horizontal blur PostProcess id in the pipeline
  129864. */
  129865. SSAOBlurHRenderEffect: string;
  129866. /**
  129867. * @ignore
  129868. * The vertical blur PostProcess id in the pipeline
  129869. */
  129870. SSAOBlurVRenderEffect: string;
  129871. /**
  129872. * @ignore
  129873. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129874. */
  129875. SSAOCombineRenderEffect: string;
  129876. /**
  129877. * The output strength of the SSAO post-process. Default value is 1.0.
  129878. */
  129879. totalStrength: number;
  129880. /**
  129881. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129882. */
  129883. maxZ: number;
  129884. /**
  129885. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129886. */
  129887. minZAspect: number;
  129888. private _samples;
  129889. /**
  129890. * Number of samples used for the SSAO calculations. Default value is 8
  129891. */
  129892. samples: number;
  129893. private _textureSamples;
  129894. /**
  129895. * Number of samples to use for antialiasing
  129896. */
  129897. textureSamples: number;
  129898. /**
  129899. * Ratio object used for SSAO ratio and blur ratio
  129900. */
  129901. private _ratio;
  129902. /**
  129903. * Dynamically generated sphere sampler.
  129904. */
  129905. private _sampleSphere;
  129906. /**
  129907. * Blur filter offsets
  129908. */
  129909. private _samplerOffsets;
  129910. private _expensiveBlur;
  129911. /**
  129912. * If bilateral blur should be used
  129913. */
  129914. expensiveBlur: boolean;
  129915. /**
  129916. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129917. */
  129918. radius: number;
  129919. /**
  129920. * The base color of the SSAO post-process
  129921. * The final result is "base + ssao" between [0, 1]
  129922. */
  129923. base: number;
  129924. /**
  129925. * Support test.
  129926. */
  129927. static readonly IsSupported: boolean;
  129928. private _scene;
  129929. private _depthTexture;
  129930. private _normalTexture;
  129931. private _randomTexture;
  129932. private _originalColorPostProcess;
  129933. private _ssaoPostProcess;
  129934. private _blurHPostProcess;
  129935. private _blurVPostProcess;
  129936. private _ssaoCombinePostProcess;
  129937. /**
  129938. * Gets active scene
  129939. */
  129940. readonly scene: Scene;
  129941. /**
  129942. * @constructor
  129943. * @param name The rendering pipeline name
  129944. * @param scene The scene linked to this pipeline
  129945. * @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 }
  129946. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129947. */
  129948. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129949. /**
  129950. * Get the class name
  129951. * @returns "SSAO2RenderingPipeline"
  129952. */
  129953. getClassName(): string;
  129954. /**
  129955. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129956. */
  129957. dispose(disableGeometryBufferRenderer?: boolean): void;
  129958. private _createBlurPostProcess;
  129959. /** @hidden */
  129960. _rebuild(): void;
  129961. private _bits;
  129962. private _radicalInverse_VdC;
  129963. private _hammersley;
  129964. private _hemisphereSample_uniform;
  129965. private _generateHemisphere;
  129966. private _createSSAOPostProcess;
  129967. private _createSSAOCombinePostProcess;
  129968. private _createRandomTexture;
  129969. /**
  129970. * Serialize the rendering pipeline (Used when exporting)
  129971. * @returns the serialized object
  129972. */
  129973. serialize(): any;
  129974. /**
  129975. * Parse the serialized pipeline
  129976. * @param source Source pipeline.
  129977. * @param scene The scene to load the pipeline to.
  129978. * @param rootUrl The URL of the serialized pipeline.
  129979. * @returns An instantiated pipeline from the serialized object.
  129980. */
  129981. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129982. }
  129983. }
  129984. declare module BABYLON {
  129985. /** @hidden */
  129986. export var ssaoPixelShader: {
  129987. name: string;
  129988. shader: string;
  129989. };
  129990. }
  129991. declare module BABYLON {
  129992. /**
  129993. * Render pipeline to produce ssao effect
  129994. */
  129995. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129996. /**
  129997. * @ignore
  129998. * The PassPostProcess id in the pipeline that contains the original scene color
  129999. */
  130000. SSAOOriginalSceneColorEffect: string;
  130001. /**
  130002. * @ignore
  130003. * The SSAO PostProcess id in the pipeline
  130004. */
  130005. SSAORenderEffect: string;
  130006. /**
  130007. * @ignore
  130008. * The horizontal blur PostProcess id in the pipeline
  130009. */
  130010. SSAOBlurHRenderEffect: string;
  130011. /**
  130012. * @ignore
  130013. * The vertical blur PostProcess id in the pipeline
  130014. */
  130015. SSAOBlurVRenderEffect: string;
  130016. /**
  130017. * @ignore
  130018. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130019. */
  130020. SSAOCombineRenderEffect: string;
  130021. /**
  130022. * The output strength of the SSAO post-process. Default value is 1.0.
  130023. */
  130024. totalStrength: number;
  130025. /**
  130026. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  130027. */
  130028. radius: number;
  130029. /**
  130030. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  130031. * Must not be equal to fallOff and superior to fallOff.
  130032. * Default value is 0.0075
  130033. */
  130034. area: number;
  130035. /**
  130036. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  130037. * Must not be equal to area and inferior to area.
  130038. * Default value is 0.000001
  130039. */
  130040. fallOff: number;
  130041. /**
  130042. * The base color of the SSAO post-process
  130043. * The final result is "base + ssao" between [0, 1]
  130044. */
  130045. base: number;
  130046. private _scene;
  130047. private _depthTexture;
  130048. private _randomTexture;
  130049. private _originalColorPostProcess;
  130050. private _ssaoPostProcess;
  130051. private _blurHPostProcess;
  130052. private _blurVPostProcess;
  130053. private _ssaoCombinePostProcess;
  130054. private _firstUpdate;
  130055. /**
  130056. * Gets active scene
  130057. */
  130058. readonly scene: Scene;
  130059. /**
  130060. * @constructor
  130061. * @param name - The rendering pipeline name
  130062. * @param scene - The scene linked to this pipeline
  130063. * @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 }
  130064. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  130065. */
  130066. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130067. /**
  130068. * Get the class name
  130069. * @returns "SSAORenderingPipeline"
  130070. */
  130071. getClassName(): string;
  130072. /**
  130073. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130074. */
  130075. dispose(disableDepthRender?: boolean): void;
  130076. private _createBlurPostProcess;
  130077. /** @hidden */
  130078. _rebuild(): void;
  130079. private _createSSAOPostProcess;
  130080. private _createSSAOCombinePostProcess;
  130081. private _createRandomTexture;
  130082. }
  130083. }
  130084. declare module BABYLON {
  130085. /** @hidden */
  130086. export var standardPixelShader: {
  130087. name: string;
  130088. shader: string;
  130089. };
  130090. }
  130091. declare module BABYLON {
  130092. /**
  130093. * Standard rendering pipeline
  130094. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130095. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  130096. */
  130097. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130098. /**
  130099. * Public members
  130100. */
  130101. /**
  130102. * Post-process which contains the original scene color before the pipeline applies all the effects
  130103. */
  130104. originalPostProcess: Nullable<PostProcess>;
  130105. /**
  130106. * Post-process used to down scale an image x4
  130107. */
  130108. downSampleX4PostProcess: Nullable<PostProcess>;
  130109. /**
  130110. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  130111. */
  130112. brightPassPostProcess: Nullable<PostProcess>;
  130113. /**
  130114. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  130115. */
  130116. blurHPostProcesses: PostProcess[];
  130117. /**
  130118. * Post-process array storing all the vertical blur post-processes used by the pipeline
  130119. */
  130120. blurVPostProcesses: PostProcess[];
  130121. /**
  130122. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  130123. */
  130124. textureAdderPostProcess: Nullable<PostProcess>;
  130125. /**
  130126. * Post-process used to create volumetric lighting effect
  130127. */
  130128. volumetricLightPostProcess: Nullable<PostProcess>;
  130129. /**
  130130. * Post-process used to smooth the previous volumetric light post-process on the X axis
  130131. */
  130132. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  130133. /**
  130134. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  130135. */
  130136. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  130137. /**
  130138. * Post-process used to merge the volumetric light effect and the real scene color
  130139. */
  130140. volumetricLightMergePostProces: Nullable<PostProcess>;
  130141. /**
  130142. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  130143. */
  130144. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  130145. /**
  130146. * Base post-process used to calculate the average luminance of the final image for HDR
  130147. */
  130148. luminancePostProcess: Nullable<PostProcess>;
  130149. /**
  130150. * Post-processes used to create down sample post-processes in order to get
  130151. * the average luminance of the final image for HDR
  130152. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  130153. */
  130154. luminanceDownSamplePostProcesses: PostProcess[];
  130155. /**
  130156. * Post-process used to create a HDR effect (light adaptation)
  130157. */
  130158. hdrPostProcess: Nullable<PostProcess>;
  130159. /**
  130160. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  130161. */
  130162. textureAdderFinalPostProcess: Nullable<PostProcess>;
  130163. /**
  130164. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  130165. */
  130166. lensFlareFinalPostProcess: Nullable<PostProcess>;
  130167. /**
  130168. * Post-process used to merge the final HDR post-process and the real scene color
  130169. */
  130170. hdrFinalPostProcess: Nullable<PostProcess>;
  130171. /**
  130172. * Post-process used to create a lens flare effect
  130173. */
  130174. lensFlarePostProcess: Nullable<PostProcess>;
  130175. /**
  130176. * Post-process that merges the result of the lens flare post-process and the real scene color
  130177. */
  130178. lensFlareComposePostProcess: Nullable<PostProcess>;
  130179. /**
  130180. * Post-process used to create a motion blur effect
  130181. */
  130182. motionBlurPostProcess: Nullable<PostProcess>;
  130183. /**
  130184. * Post-process used to create a depth of field effect
  130185. */
  130186. depthOfFieldPostProcess: Nullable<PostProcess>;
  130187. /**
  130188. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130189. */
  130190. fxaaPostProcess: Nullable<FxaaPostProcess>;
  130191. /**
  130192. * Represents the brightness threshold in order to configure the illuminated surfaces
  130193. */
  130194. brightThreshold: number;
  130195. /**
  130196. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  130197. */
  130198. blurWidth: number;
  130199. /**
  130200. * Sets if the blur for highlighted surfaces must be only horizontal
  130201. */
  130202. horizontalBlur: boolean;
  130203. /**
  130204. * Gets the overall exposure used by the pipeline
  130205. */
  130206. /**
  130207. * Sets the overall exposure used by the pipeline
  130208. */
  130209. exposure: number;
  130210. /**
  130211. * Texture used typically to simulate "dirty" on camera lens
  130212. */
  130213. lensTexture: Nullable<Texture>;
  130214. /**
  130215. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130216. */
  130217. volumetricLightCoefficient: number;
  130218. /**
  130219. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130220. */
  130221. volumetricLightPower: number;
  130222. /**
  130223. * Used the set the blur intensity to smooth the volumetric lights
  130224. */
  130225. volumetricLightBlurScale: number;
  130226. /**
  130227. * Light (spot or directional) used to generate the volumetric lights rays
  130228. * The source light must have a shadow generate so the pipeline can get its
  130229. * depth map
  130230. */
  130231. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130232. /**
  130233. * For eye adaptation, represents the minimum luminance the eye can see
  130234. */
  130235. hdrMinimumLuminance: number;
  130236. /**
  130237. * For eye adaptation, represents the decrease luminance speed
  130238. */
  130239. hdrDecreaseRate: number;
  130240. /**
  130241. * For eye adaptation, represents the increase luminance speed
  130242. */
  130243. hdrIncreaseRate: number;
  130244. /**
  130245. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130246. */
  130247. /**
  130248. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130249. */
  130250. hdrAutoExposure: boolean;
  130251. /**
  130252. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130253. */
  130254. lensColorTexture: Nullable<Texture>;
  130255. /**
  130256. * The overall strengh for the lens flare effect
  130257. */
  130258. lensFlareStrength: number;
  130259. /**
  130260. * Dispersion coefficient for lens flare ghosts
  130261. */
  130262. lensFlareGhostDispersal: number;
  130263. /**
  130264. * Main lens flare halo width
  130265. */
  130266. lensFlareHaloWidth: number;
  130267. /**
  130268. * Based on the lens distortion effect, defines how much the lens flare result
  130269. * is distorted
  130270. */
  130271. lensFlareDistortionStrength: number;
  130272. /**
  130273. * Configures the blur intensity used for for lens flare (halo)
  130274. */
  130275. lensFlareBlurWidth: number;
  130276. /**
  130277. * Lens star texture must be used to simulate rays on the flares and is available
  130278. * in the documentation
  130279. */
  130280. lensStarTexture: Nullable<Texture>;
  130281. /**
  130282. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130283. * flare effect by taking account of the dirt texture
  130284. */
  130285. lensFlareDirtTexture: Nullable<Texture>;
  130286. /**
  130287. * Represents the focal length for the depth of field effect
  130288. */
  130289. depthOfFieldDistance: number;
  130290. /**
  130291. * Represents the blur intensity for the blurred part of the depth of field effect
  130292. */
  130293. depthOfFieldBlurWidth: number;
  130294. /**
  130295. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130296. */
  130297. /**
  130298. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130299. */
  130300. motionStrength: number;
  130301. /**
  130302. * Gets wether or not the motion blur post-process is object based or screen based.
  130303. */
  130304. /**
  130305. * Sets wether or not the motion blur post-process should be object based or screen based
  130306. */
  130307. objectBasedMotionBlur: boolean;
  130308. /**
  130309. * List of animations for the pipeline (IAnimatable implementation)
  130310. */
  130311. animations: Animation[];
  130312. /**
  130313. * Private members
  130314. */
  130315. private _scene;
  130316. private _currentDepthOfFieldSource;
  130317. private _basePostProcess;
  130318. private _fixedExposure;
  130319. private _currentExposure;
  130320. private _hdrAutoExposure;
  130321. private _hdrCurrentLuminance;
  130322. private _motionStrength;
  130323. private _isObjectBasedMotionBlur;
  130324. private _floatTextureType;
  130325. private _camerasToBeAttached;
  130326. private _ratio;
  130327. private _bloomEnabled;
  130328. private _depthOfFieldEnabled;
  130329. private _vlsEnabled;
  130330. private _lensFlareEnabled;
  130331. private _hdrEnabled;
  130332. private _motionBlurEnabled;
  130333. private _fxaaEnabled;
  130334. private _motionBlurSamples;
  130335. private _volumetricLightStepsCount;
  130336. private _samples;
  130337. /**
  130338. * @ignore
  130339. * Specifies if the bloom pipeline is enabled
  130340. */
  130341. BloomEnabled: boolean;
  130342. /**
  130343. * @ignore
  130344. * Specifies if the depth of field pipeline is enabed
  130345. */
  130346. DepthOfFieldEnabled: boolean;
  130347. /**
  130348. * @ignore
  130349. * Specifies if the lens flare pipeline is enabed
  130350. */
  130351. LensFlareEnabled: boolean;
  130352. /**
  130353. * @ignore
  130354. * Specifies if the HDR pipeline is enabled
  130355. */
  130356. HDREnabled: boolean;
  130357. /**
  130358. * @ignore
  130359. * Specifies if the volumetric lights scattering effect is enabled
  130360. */
  130361. VLSEnabled: boolean;
  130362. /**
  130363. * @ignore
  130364. * Specifies if the motion blur effect is enabled
  130365. */
  130366. MotionBlurEnabled: boolean;
  130367. /**
  130368. * Specifies if anti-aliasing is enabled
  130369. */
  130370. fxaaEnabled: boolean;
  130371. /**
  130372. * Specifies the number of steps used to calculate the volumetric lights
  130373. * Typically in interval [50, 200]
  130374. */
  130375. volumetricLightStepsCount: number;
  130376. /**
  130377. * Specifies the number of samples used for the motion blur effect
  130378. * Typically in interval [16, 64]
  130379. */
  130380. motionBlurSamples: number;
  130381. /**
  130382. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130383. */
  130384. samples: number;
  130385. /**
  130386. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130387. * @constructor
  130388. * @param name The rendering pipeline name
  130389. * @param scene The scene linked to this pipeline
  130390. * @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)
  130391. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130392. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130393. */
  130394. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130395. private _buildPipeline;
  130396. private _createDownSampleX4PostProcess;
  130397. private _createBrightPassPostProcess;
  130398. private _createBlurPostProcesses;
  130399. private _createTextureAdderPostProcess;
  130400. private _createVolumetricLightPostProcess;
  130401. private _createLuminancePostProcesses;
  130402. private _createHdrPostProcess;
  130403. private _createLensFlarePostProcess;
  130404. private _createDepthOfFieldPostProcess;
  130405. private _createMotionBlurPostProcess;
  130406. private _getDepthTexture;
  130407. private _disposePostProcesses;
  130408. /**
  130409. * Dispose of the pipeline and stop all post processes
  130410. */
  130411. dispose(): void;
  130412. /**
  130413. * Serialize the rendering pipeline (Used when exporting)
  130414. * @returns the serialized object
  130415. */
  130416. serialize(): any;
  130417. /**
  130418. * Parse the serialized pipeline
  130419. * @param source Source pipeline.
  130420. * @param scene The scene to load the pipeline to.
  130421. * @param rootUrl The URL of the serialized pipeline.
  130422. * @returns An instantiated pipeline from the serialized object.
  130423. */
  130424. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130425. /**
  130426. * Luminance steps
  130427. */
  130428. static LuminanceSteps: number;
  130429. }
  130430. }
  130431. declare module BABYLON {
  130432. /** @hidden */
  130433. export var tonemapPixelShader: {
  130434. name: string;
  130435. shader: string;
  130436. };
  130437. }
  130438. declare module BABYLON {
  130439. /** Defines operator used for tonemapping */
  130440. export enum TonemappingOperator {
  130441. /** Hable */
  130442. Hable = 0,
  130443. /** Reinhard */
  130444. Reinhard = 1,
  130445. /** HejiDawson */
  130446. HejiDawson = 2,
  130447. /** Photographic */
  130448. Photographic = 3
  130449. }
  130450. /**
  130451. * Defines a post process to apply tone mapping
  130452. */
  130453. export class TonemapPostProcess extends PostProcess {
  130454. private _operator;
  130455. /** Defines the required exposure adjustement */
  130456. exposureAdjustment: number;
  130457. /**
  130458. * Creates a new TonemapPostProcess
  130459. * @param name defines the name of the postprocess
  130460. * @param _operator defines the operator to use
  130461. * @param exposureAdjustment defines the required exposure adjustement
  130462. * @param camera defines the camera to use (can be null)
  130463. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130464. * @param engine defines the hosting engine (can be ignore if camera is set)
  130465. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130466. */
  130467. constructor(name: string, _operator: TonemappingOperator,
  130468. /** Defines the required exposure adjustement */
  130469. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130470. }
  130471. }
  130472. declare module BABYLON {
  130473. /** @hidden */
  130474. export var depthVertexShader: {
  130475. name: string;
  130476. shader: string;
  130477. };
  130478. }
  130479. declare module BABYLON {
  130480. /** @hidden */
  130481. export var volumetricLightScatteringPixelShader: {
  130482. name: string;
  130483. shader: string;
  130484. };
  130485. }
  130486. declare module BABYLON {
  130487. /** @hidden */
  130488. export var volumetricLightScatteringPassVertexShader: {
  130489. name: string;
  130490. shader: string;
  130491. };
  130492. }
  130493. declare module BABYLON {
  130494. /** @hidden */
  130495. export var volumetricLightScatteringPassPixelShader: {
  130496. name: string;
  130497. shader: string;
  130498. };
  130499. }
  130500. declare module BABYLON {
  130501. /**
  130502. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130503. */
  130504. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130505. private _volumetricLightScatteringPass;
  130506. private _volumetricLightScatteringRTT;
  130507. private _viewPort;
  130508. private _screenCoordinates;
  130509. private _cachedDefines;
  130510. /**
  130511. * If not undefined, the mesh position is computed from the attached node position
  130512. */
  130513. attachedNode: {
  130514. position: Vector3;
  130515. };
  130516. /**
  130517. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130518. */
  130519. customMeshPosition: Vector3;
  130520. /**
  130521. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130522. */
  130523. useCustomMeshPosition: boolean;
  130524. /**
  130525. * If the post-process should inverse the light scattering direction
  130526. */
  130527. invert: boolean;
  130528. /**
  130529. * The internal mesh used by the post-process
  130530. */
  130531. mesh: Mesh;
  130532. /**
  130533. * @hidden
  130534. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130535. */
  130536. useDiffuseColor: boolean;
  130537. /**
  130538. * Array containing the excluded meshes not rendered in the internal pass
  130539. */
  130540. excludedMeshes: AbstractMesh[];
  130541. /**
  130542. * Controls the overall intensity of the post-process
  130543. */
  130544. exposure: number;
  130545. /**
  130546. * Dissipates each sample's contribution in range [0, 1]
  130547. */
  130548. decay: number;
  130549. /**
  130550. * Controls the overall intensity of each sample
  130551. */
  130552. weight: number;
  130553. /**
  130554. * Controls the density of each sample
  130555. */
  130556. density: number;
  130557. /**
  130558. * @constructor
  130559. * @param name The post-process name
  130560. * @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)
  130561. * @param camera The camera that the post-process will be attached to
  130562. * @param mesh The mesh used to create the light scattering
  130563. * @param samples The post-process quality, default 100
  130564. * @param samplingModeThe post-process filtering mode
  130565. * @param engine The babylon engine
  130566. * @param reusable If the post-process is reusable
  130567. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130568. */
  130569. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130570. /**
  130571. * Returns the string "VolumetricLightScatteringPostProcess"
  130572. * @returns "VolumetricLightScatteringPostProcess"
  130573. */
  130574. getClassName(): string;
  130575. private _isReady;
  130576. /**
  130577. * Sets the new light position for light scattering effect
  130578. * @param position The new custom light position
  130579. */
  130580. setCustomMeshPosition(position: Vector3): void;
  130581. /**
  130582. * Returns the light position for light scattering effect
  130583. * @return Vector3 The custom light position
  130584. */
  130585. getCustomMeshPosition(): Vector3;
  130586. /**
  130587. * Disposes the internal assets and detaches the post-process from the camera
  130588. */
  130589. dispose(camera: Camera): void;
  130590. /**
  130591. * Returns the render target texture used by the post-process
  130592. * @return the render target texture used by the post-process
  130593. */
  130594. getPass(): RenderTargetTexture;
  130595. private _meshExcluded;
  130596. private _createPass;
  130597. private _updateMeshScreenCoordinates;
  130598. /**
  130599. * Creates a default mesh for the Volumeric Light Scattering post-process
  130600. * @param name The mesh name
  130601. * @param scene The scene where to create the mesh
  130602. * @return the default mesh
  130603. */
  130604. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130605. }
  130606. }
  130607. declare module BABYLON {
  130608. interface Scene {
  130609. /** @hidden (Backing field) */
  130610. _boundingBoxRenderer: BoundingBoxRenderer;
  130611. /** @hidden (Backing field) */
  130612. _forceShowBoundingBoxes: boolean;
  130613. /**
  130614. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130615. */
  130616. forceShowBoundingBoxes: boolean;
  130617. /**
  130618. * Gets the bounding box renderer associated with the scene
  130619. * @returns a BoundingBoxRenderer
  130620. */
  130621. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130622. }
  130623. interface AbstractMesh {
  130624. /** @hidden (Backing field) */
  130625. _showBoundingBox: boolean;
  130626. /**
  130627. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130628. */
  130629. showBoundingBox: boolean;
  130630. }
  130631. /**
  130632. * Component responsible of rendering the bounding box of the meshes in a scene.
  130633. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130634. */
  130635. export class BoundingBoxRenderer implements ISceneComponent {
  130636. /**
  130637. * The component name helpfull to identify the component in the list of scene components.
  130638. */
  130639. readonly name: string;
  130640. /**
  130641. * The scene the component belongs to.
  130642. */
  130643. scene: Scene;
  130644. /**
  130645. * Color of the bounding box lines placed in front of an object
  130646. */
  130647. frontColor: Color3;
  130648. /**
  130649. * Color of the bounding box lines placed behind an object
  130650. */
  130651. backColor: Color3;
  130652. /**
  130653. * Defines if the renderer should show the back lines or not
  130654. */
  130655. showBackLines: boolean;
  130656. /**
  130657. * @hidden
  130658. */
  130659. renderList: SmartArray<BoundingBox>;
  130660. private _colorShader;
  130661. private _vertexBuffers;
  130662. private _indexBuffer;
  130663. private _fillIndexBuffer;
  130664. private _fillIndexData;
  130665. /**
  130666. * Instantiates a new bounding box renderer in a scene.
  130667. * @param scene the scene the renderer renders in
  130668. */
  130669. constructor(scene: Scene);
  130670. /**
  130671. * Registers the component in a given scene
  130672. */
  130673. register(): void;
  130674. private _evaluateSubMesh;
  130675. private _activeMesh;
  130676. private _prepareRessources;
  130677. private _createIndexBuffer;
  130678. /**
  130679. * Rebuilds the elements related to this component in case of
  130680. * context lost for instance.
  130681. */
  130682. rebuild(): void;
  130683. /**
  130684. * @hidden
  130685. */
  130686. reset(): void;
  130687. /**
  130688. * Render the bounding boxes of a specific rendering group
  130689. * @param renderingGroupId defines the rendering group to render
  130690. */
  130691. render(renderingGroupId: number): void;
  130692. /**
  130693. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130694. * @param mesh Define the mesh to render the occlusion bounding box for
  130695. */
  130696. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130697. /**
  130698. * Dispose and release the resources attached to this renderer.
  130699. */
  130700. dispose(): void;
  130701. }
  130702. }
  130703. declare module BABYLON {
  130704. /** @hidden */
  130705. export var depthPixelShader: {
  130706. name: string;
  130707. shader: string;
  130708. };
  130709. }
  130710. declare module BABYLON {
  130711. /**
  130712. * This represents a depth renderer in Babylon.
  130713. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130714. */
  130715. export class DepthRenderer {
  130716. private _scene;
  130717. private _depthMap;
  130718. private _effect;
  130719. private readonly _storeNonLinearDepth;
  130720. private readonly _clearColor;
  130721. /** Get if the depth renderer is using packed depth or not */
  130722. readonly isPacked: boolean;
  130723. private _cachedDefines;
  130724. private _camera;
  130725. /**
  130726. * Specifiess that the depth renderer will only be used within
  130727. * the camera it is created for.
  130728. * This can help forcing its rendering during the camera processing.
  130729. */
  130730. useOnlyInActiveCamera: boolean;
  130731. /** @hidden */
  130732. static _SceneComponentInitialization: (scene: Scene) => void;
  130733. /**
  130734. * Instantiates a depth renderer
  130735. * @param scene The scene the renderer belongs to
  130736. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130737. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130738. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130739. */
  130740. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130741. /**
  130742. * Creates the depth rendering effect and checks if the effect is ready.
  130743. * @param subMesh The submesh to be used to render the depth map of
  130744. * @param useInstances If multiple world instances should be used
  130745. * @returns if the depth renderer is ready to render the depth map
  130746. */
  130747. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130748. /**
  130749. * Gets the texture which the depth map will be written to.
  130750. * @returns The depth map texture
  130751. */
  130752. getDepthMap(): RenderTargetTexture;
  130753. /**
  130754. * Disposes of the depth renderer.
  130755. */
  130756. dispose(): void;
  130757. }
  130758. }
  130759. declare module BABYLON {
  130760. interface Scene {
  130761. /** @hidden (Backing field) */
  130762. _depthRenderer: {
  130763. [id: string]: DepthRenderer;
  130764. };
  130765. /**
  130766. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130767. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130768. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130769. * @returns the created depth renderer
  130770. */
  130771. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130772. /**
  130773. * Disables a depth renderer for a given camera
  130774. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130775. */
  130776. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130777. }
  130778. /**
  130779. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130780. * in several rendering techniques.
  130781. */
  130782. export class DepthRendererSceneComponent implements ISceneComponent {
  130783. /**
  130784. * The component name helpfull to identify the component in the list of scene components.
  130785. */
  130786. readonly name: string;
  130787. /**
  130788. * The scene the component belongs to.
  130789. */
  130790. scene: Scene;
  130791. /**
  130792. * Creates a new instance of the component for the given scene
  130793. * @param scene Defines the scene to register the component in
  130794. */
  130795. constructor(scene: Scene);
  130796. /**
  130797. * Registers the component in a given scene
  130798. */
  130799. register(): void;
  130800. /**
  130801. * Rebuilds the elements related to this component in case of
  130802. * context lost for instance.
  130803. */
  130804. rebuild(): void;
  130805. /**
  130806. * Disposes the component and the associated ressources
  130807. */
  130808. dispose(): void;
  130809. private _gatherRenderTargets;
  130810. private _gatherActiveCameraRenderTargets;
  130811. }
  130812. }
  130813. declare module BABYLON {
  130814. /** @hidden */
  130815. export var outlinePixelShader: {
  130816. name: string;
  130817. shader: string;
  130818. };
  130819. }
  130820. declare module BABYLON {
  130821. /** @hidden */
  130822. export var outlineVertexShader: {
  130823. name: string;
  130824. shader: string;
  130825. };
  130826. }
  130827. declare module BABYLON {
  130828. interface Scene {
  130829. /** @hidden */
  130830. _outlineRenderer: OutlineRenderer;
  130831. /**
  130832. * Gets the outline renderer associated with the scene
  130833. * @returns a OutlineRenderer
  130834. */
  130835. getOutlineRenderer(): OutlineRenderer;
  130836. }
  130837. interface AbstractMesh {
  130838. /** @hidden (Backing field) */
  130839. _renderOutline: boolean;
  130840. /**
  130841. * Gets or sets a boolean indicating if the outline must be rendered as well
  130842. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130843. */
  130844. renderOutline: boolean;
  130845. /** @hidden (Backing field) */
  130846. _renderOverlay: boolean;
  130847. /**
  130848. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130849. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130850. */
  130851. renderOverlay: boolean;
  130852. }
  130853. /**
  130854. * This class is responsible to draw bothe outline/overlay of meshes.
  130855. * It should not be used directly but through the available method on mesh.
  130856. */
  130857. export class OutlineRenderer implements ISceneComponent {
  130858. /**
  130859. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130860. */
  130861. private static _StencilReference;
  130862. /**
  130863. * The name of the component. Each component must have a unique name.
  130864. */
  130865. name: string;
  130866. /**
  130867. * The scene the component belongs to.
  130868. */
  130869. scene: Scene;
  130870. /**
  130871. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130872. */
  130873. zOffset: number;
  130874. private _engine;
  130875. private _effect;
  130876. private _cachedDefines;
  130877. private _savedDepthWrite;
  130878. /**
  130879. * Instantiates a new outline renderer. (There could be only one per scene).
  130880. * @param scene Defines the scene it belongs to
  130881. */
  130882. constructor(scene: Scene);
  130883. /**
  130884. * Register the component to one instance of a scene.
  130885. */
  130886. register(): void;
  130887. /**
  130888. * Rebuilds the elements related to this component in case of
  130889. * context lost for instance.
  130890. */
  130891. rebuild(): void;
  130892. /**
  130893. * Disposes the component and the associated ressources.
  130894. */
  130895. dispose(): void;
  130896. /**
  130897. * Renders the outline in the canvas.
  130898. * @param subMesh Defines the sumesh to render
  130899. * @param batch Defines the batch of meshes in case of instances
  130900. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130901. */
  130902. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130903. /**
  130904. * Returns whether or not the outline renderer is ready for a given submesh.
  130905. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130906. * @param subMesh Defines the submesh to check readyness for
  130907. * @param useInstances Defines wheter wee are trying to render instances or not
  130908. * @returns true if ready otherwise false
  130909. */
  130910. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130911. private _beforeRenderingMesh;
  130912. private _afterRenderingMesh;
  130913. }
  130914. }
  130915. declare module BABYLON {
  130916. /**
  130917. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130918. * @see http://doc.babylonjs.com/babylon101/sprites
  130919. */
  130920. export class SpritePackedManager extends SpriteManager {
  130921. /** defines the packed manager's name */
  130922. name: string;
  130923. /**
  130924. * Creates a new sprite manager from a packed sprite sheet
  130925. * @param name defines the manager's name
  130926. * @param imgUrl defines the sprite sheet url
  130927. * @param capacity defines the maximum allowed number of sprites
  130928. * @param scene defines the hosting scene
  130929. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130930. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130931. * @param samplingMode defines the smapling mode to use with spritesheet
  130932. * @param fromPacked set to true; do not alter
  130933. */
  130934. constructor(
  130935. /** defines the packed manager's name */
  130936. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130937. }
  130938. }
  130939. declare module BABYLON {
  130940. /**
  130941. * Defines the list of states available for a task inside a AssetsManager
  130942. */
  130943. export enum AssetTaskState {
  130944. /**
  130945. * Initialization
  130946. */
  130947. INIT = 0,
  130948. /**
  130949. * Running
  130950. */
  130951. RUNNING = 1,
  130952. /**
  130953. * Done
  130954. */
  130955. DONE = 2,
  130956. /**
  130957. * Error
  130958. */
  130959. ERROR = 3
  130960. }
  130961. /**
  130962. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130963. */
  130964. export abstract class AbstractAssetTask {
  130965. /**
  130966. * Task name
  130967. */ name: string;
  130968. /**
  130969. * Callback called when the task is successful
  130970. */
  130971. onSuccess: (task: any) => void;
  130972. /**
  130973. * Callback called when the task is not successful
  130974. */
  130975. onError: (task: any, message?: string, exception?: any) => void;
  130976. /**
  130977. * Creates a new AssetsManager
  130978. * @param name defines the name of the task
  130979. */
  130980. constructor(
  130981. /**
  130982. * Task name
  130983. */ name: string);
  130984. private _isCompleted;
  130985. private _taskState;
  130986. private _errorObject;
  130987. /**
  130988. * Get if the task is completed
  130989. */
  130990. readonly isCompleted: boolean;
  130991. /**
  130992. * Gets the current state of the task
  130993. */
  130994. readonly taskState: AssetTaskState;
  130995. /**
  130996. * Gets the current error object (if task is in error)
  130997. */
  130998. readonly errorObject: {
  130999. message?: string;
  131000. exception?: any;
  131001. };
  131002. /**
  131003. * Internal only
  131004. * @hidden
  131005. */
  131006. _setErrorObject(message?: string, exception?: any): void;
  131007. /**
  131008. * Execute the current task
  131009. * @param scene defines the scene where you want your assets to be loaded
  131010. * @param onSuccess is a callback called when the task is successfully executed
  131011. * @param onError is a callback called if an error occurs
  131012. */
  131013. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131014. /**
  131015. * Execute the current task
  131016. * @param scene defines the scene where you want your assets to be loaded
  131017. * @param onSuccess is a callback called when the task is successfully executed
  131018. * @param onError is a callback called if an error occurs
  131019. */
  131020. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131021. /**
  131022. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131023. * This can be used with failed tasks that have the reason for failure fixed.
  131024. */
  131025. reset(): void;
  131026. private onErrorCallback;
  131027. private onDoneCallback;
  131028. }
  131029. /**
  131030. * Define the interface used by progress events raised during assets loading
  131031. */
  131032. export interface IAssetsProgressEvent {
  131033. /**
  131034. * Defines the number of remaining tasks to process
  131035. */
  131036. remainingCount: number;
  131037. /**
  131038. * Defines the total number of tasks
  131039. */
  131040. totalCount: number;
  131041. /**
  131042. * Defines the task that was just processed
  131043. */
  131044. task: AbstractAssetTask;
  131045. }
  131046. /**
  131047. * Class used to share progress information about assets loading
  131048. */
  131049. export class AssetsProgressEvent implements IAssetsProgressEvent {
  131050. /**
  131051. * Defines the number of remaining tasks to process
  131052. */
  131053. remainingCount: number;
  131054. /**
  131055. * Defines the total number of tasks
  131056. */
  131057. totalCount: number;
  131058. /**
  131059. * Defines the task that was just processed
  131060. */
  131061. task: AbstractAssetTask;
  131062. /**
  131063. * Creates a AssetsProgressEvent
  131064. * @param remainingCount defines the number of remaining tasks to process
  131065. * @param totalCount defines the total number of tasks
  131066. * @param task defines the task that was just processed
  131067. */
  131068. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  131069. }
  131070. /**
  131071. * Define a task used by AssetsManager to load meshes
  131072. */
  131073. export class MeshAssetTask extends AbstractAssetTask {
  131074. /**
  131075. * Defines the name of the task
  131076. */
  131077. name: string;
  131078. /**
  131079. * Defines the list of mesh's names you want to load
  131080. */
  131081. meshesNames: any;
  131082. /**
  131083. * Defines the root url to use as a base to load your meshes and associated resources
  131084. */
  131085. rootUrl: string;
  131086. /**
  131087. * Defines the filename of the scene to load from
  131088. */
  131089. sceneFilename: string;
  131090. /**
  131091. * Gets the list of loaded meshes
  131092. */
  131093. loadedMeshes: Array<AbstractMesh>;
  131094. /**
  131095. * Gets the list of loaded particle systems
  131096. */
  131097. loadedParticleSystems: Array<IParticleSystem>;
  131098. /**
  131099. * Gets the list of loaded skeletons
  131100. */
  131101. loadedSkeletons: Array<Skeleton>;
  131102. /**
  131103. * Gets the list of loaded animation groups
  131104. */
  131105. loadedAnimationGroups: Array<AnimationGroup>;
  131106. /**
  131107. * Callback called when the task is successful
  131108. */
  131109. onSuccess: (task: MeshAssetTask) => void;
  131110. /**
  131111. * Callback called when the task is successful
  131112. */
  131113. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  131114. /**
  131115. * Creates a new MeshAssetTask
  131116. * @param name defines the name of the task
  131117. * @param meshesNames defines the list of mesh's names you want to load
  131118. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  131119. * @param sceneFilename defines the filename of the scene to load from
  131120. */
  131121. constructor(
  131122. /**
  131123. * Defines the name of the task
  131124. */
  131125. name: string,
  131126. /**
  131127. * Defines the list of mesh's names you want to load
  131128. */
  131129. meshesNames: any,
  131130. /**
  131131. * Defines the root url to use as a base to load your meshes and associated resources
  131132. */
  131133. rootUrl: string,
  131134. /**
  131135. * Defines the filename of the scene to load from
  131136. */
  131137. sceneFilename: string);
  131138. /**
  131139. * Execute the current task
  131140. * @param scene defines the scene where you want your assets to be loaded
  131141. * @param onSuccess is a callback called when the task is successfully executed
  131142. * @param onError is a callback called if an error occurs
  131143. */
  131144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131145. }
  131146. /**
  131147. * Define a task used by AssetsManager to load text content
  131148. */
  131149. export class TextFileAssetTask extends AbstractAssetTask {
  131150. /**
  131151. * Defines the name of the task
  131152. */
  131153. name: string;
  131154. /**
  131155. * Defines the location of the file to load
  131156. */
  131157. url: string;
  131158. /**
  131159. * Gets the loaded text string
  131160. */
  131161. text: string;
  131162. /**
  131163. * Callback called when the task is successful
  131164. */
  131165. onSuccess: (task: TextFileAssetTask) => void;
  131166. /**
  131167. * Callback called when the task is successful
  131168. */
  131169. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  131170. /**
  131171. * Creates a new TextFileAssetTask object
  131172. * @param name defines the name of the task
  131173. * @param url defines the location of the file to load
  131174. */
  131175. constructor(
  131176. /**
  131177. * Defines the name of the task
  131178. */
  131179. name: string,
  131180. /**
  131181. * Defines the location of the file to load
  131182. */
  131183. url: string);
  131184. /**
  131185. * Execute the current task
  131186. * @param scene defines the scene where you want your assets to be loaded
  131187. * @param onSuccess is a callback called when the task is successfully executed
  131188. * @param onError is a callback called if an error occurs
  131189. */
  131190. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131191. }
  131192. /**
  131193. * Define a task used by AssetsManager to load binary data
  131194. */
  131195. export class BinaryFileAssetTask extends AbstractAssetTask {
  131196. /**
  131197. * Defines the name of the task
  131198. */
  131199. name: string;
  131200. /**
  131201. * Defines the location of the file to load
  131202. */
  131203. url: string;
  131204. /**
  131205. * Gets the lodaded data (as an array buffer)
  131206. */
  131207. data: ArrayBuffer;
  131208. /**
  131209. * Callback called when the task is successful
  131210. */
  131211. onSuccess: (task: BinaryFileAssetTask) => void;
  131212. /**
  131213. * Callback called when the task is successful
  131214. */
  131215. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131216. /**
  131217. * Creates a new BinaryFileAssetTask object
  131218. * @param name defines the name of the new task
  131219. * @param url defines the location of the file to load
  131220. */
  131221. constructor(
  131222. /**
  131223. * Defines the name of the task
  131224. */
  131225. name: string,
  131226. /**
  131227. * Defines the location of the file to load
  131228. */
  131229. url: string);
  131230. /**
  131231. * Execute the current task
  131232. * @param scene defines the scene where you want your assets to be loaded
  131233. * @param onSuccess is a callback called when the task is successfully executed
  131234. * @param onError is a callback called if an error occurs
  131235. */
  131236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131237. }
  131238. /**
  131239. * Define a task used by AssetsManager to load images
  131240. */
  131241. export class ImageAssetTask extends AbstractAssetTask {
  131242. /**
  131243. * Defines the name of the task
  131244. */
  131245. name: string;
  131246. /**
  131247. * Defines the location of the image to load
  131248. */
  131249. url: string;
  131250. /**
  131251. * Gets the loaded images
  131252. */
  131253. image: HTMLImageElement;
  131254. /**
  131255. * Callback called when the task is successful
  131256. */
  131257. onSuccess: (task: ImageAssetTask) => void;
  131258. /**
  131259. * Callback called when the task is successful
  131260. */
  131261. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131262. /**
  131263. * Creates a new ImageAssetTask
  131264. * @param name defines the name of the task
  131265. * @param url defines the location of the image to load
  131266. */
  131267. constructor(
  131268. /**
  131269. * Defines the name of the task
  131270. */
  131271. name: string,
  131272. /**
  131273. * Defines the location of the image to load
  131274. */
  131275. url: string);
  131276. /**
  131277. * Execute the current task
  131278. * @param scene defines the scene where you want your assets to be loaded
  131279. * @param onSuccess is a callback called when the task is successfully executed
  131280. * @param onError is a callback called if an error occurs
  131281. */
  131282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131283. }
  131284. /**
  131285. * Defines the interface used by texture loading tasks
  131286. */
  131287. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131288. /**
  131289. * Gets the loaded texture
  131290. */
  131291. texture: TEX;
  131292. }
  131293. /**
  131294. * Define a task used by AssetsManager to load 2D textures
  131295. */
  131296. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131297. /**
  131298. * Defines the name of the task
  131299. */
  131300. name: string;
  131301. /**
  131302. * Defines the location of the file to load
  131303. */
  131304. url: string;
  131305. /**
  131306. * Defines if mipmap should not be generated (default is false)
  131307. */
  131308. noMipmap?: boolean | undefined;
  131309. /**
  131310. * Defines if texture must be inverted on Y axis (default is false)
  131311. */
  131312. invertY?: boolean | undefined;
  131313. /**
  131314. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131315. */
  131316. samplingMode: number;
  131317. /**
  131318. * Gets the loaded texture
  131319. */
  131320. texture: Texture;
  131321. /**
  131322. * Callback called when the task is successful
  131323. */
  131324. onSuccess: (task: TextureAssetTask) => void;
  131325. /**
  131326. * Callback called when the task is successful
  131327. */
  131328. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131329. /**
  131330. * Creates a new TextureAssetTask object
  131331. * @param name defines the name of the task
  131332. * @param url defines the location of the file to load
  131333. * @param noMipmap defines if mipmap should not be generated (default is false)
  131334. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131335. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131336. */
  131337. constructor(
  131338. /**
  131339. * Defines the name of the task
  131340. */
  131341. name: string,
  131342. /**
  131343. * Defines the location of the file to load
  131344. */
  131345. url: string,
  131346. /**
  131347. * Defines if mipmap should not be generated (default is false)
  131348. */
  131349. noMipmap?: boolean | undefined,
  131350. /**
  131351. * Defines if texture must be inverted on Y axis (default is false)
  131352. */
  131353. invertY?: boolean | undefined,
  131354. /**
  131355. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131356. */
  131357. samplingMode?: number);
  131358. /**
  131359. * Execute the current task
  131360. * @param scene defines the scene where you want your assets to be loaded
  131361. * @param onSuccess is a callback called when the task is successfully executed
  131362. * @param onError is a callback called if an error occurs
  131363. */
  131364. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131365. }
  131366. /**
  131367. * Define a task used by AssetsManager to load cube textures
  131368. */
  131369. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131370. /**
  131371. * Defines the name of the task
  131372. */
  131373. name: string;
  131374. /**
  131375. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131376. */
  131377. url: string;
  131378. /**
  131379. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131380. */
  131381. extensions?: string[] | undefined;
  131382. /**
  131383. * Defines if mipmaps should not be generated (default is false)
  131384. */
  131385. noMipmap?: boolean | undefined;
  131386. /**
  131387. * Defines the explicit list of files (undefined by default)
  131388. */
  131389. files?: string[] | undefined;
  131390. /**
  131391. * Gets the loaded texture
  131392. */
  131393. texture: CubeTexture;
  131394. /**
  131395. * Callback called when the task is successful
  131396. */
  131397. onSuccess: (task: CubeTextureAssetTask) => void;
  131398. /**
  131399. * Callback called when the task is successful
  131400. */
  131401. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131402. /**
  131403. * Creates a new CubeTextureAssetTask
  131404. * @param name defines the name of the task
  131405. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131406. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131407. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131408. * @param files defines the explicit list of files (undefined by default)
  131409. */
  131410. constructor(
  131411. /**
  131412. * Defines the name of the task
  131413. */
  131414. name: string,
  131415. /**
  131416. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131417. */
  131418. url: string,
  131419. /**
  131420. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131421. */
  131422. extensions?: string[] | undefined,
  131423. /**
  131424. * Defines if mipmaps should not be generated (default is false)
  131425. */
  131426. noMipmap?: boolean | undefined,
  131427. /**
  131428. * Defines the explicit list of files (undefined by default)
  131429. */
  131430. files?: string[] | undefined);
  131431. /**
  131432. * Execute the current task
  131433. * @param scene defines the scene where you want your assets to be loaded
  131434. * @param onSuccess is a callback called when the task is successfully executed
  131435. * @param onError is a callback called if an error occurs
  131436. */
  131437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131438. }
  131439. /**
  131440. * Define a task used by AssetsManager to load HDR cube textures
  131441. */
  131442. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131443. /**
  131444. * Defines the name of the task
  131445. */
  131446. name: string;
  131447. /**
  131448. * Defines the location of the file to load
  131449. */
  131450. url: string;
  131451. /**
  131452. * Defines the desired size (the more it increases the longer the generation will be)
  131453. */
  131454. size: number;
  131455. /**
  131456. * Defines if mipmaps should not be generated (default is false)
  131457. */
  131458. noMipmap: boolean;
  131459. /**
  131460. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131461. */
  131462. generateHarmonics: boolean;
  131463. /**
  131464. * 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)
  131465. */
  131466. gammaSpace: boolean;
  131467. /**
  131468. * Internal Use Only
  131469. */
  131470. reserved: boolean;
  131471. /**
  131472. * Gets the loaded texture
  131473. */
  131474. texture: HDRCubeTexture;
  131475. /**
  131476. * Callback called when the task is successful
  131477. */
  131478. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131479. /**
  131480. * Callback called when the task is successful
  131481. */
  131482. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131483. /**
  131484. * Creates a new HDRCubeTextureAssetTask object
  131485. * @param name defines the name of the task
  131486. * @param url defines the location of the file to load
  131487. * @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.
  131488. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131489. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131490. * @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)
  131491. * @param reserved Internal use only
  131492. */
  131493. constructor(
  131494. /**
  131495. * Defines the name of the task
  131496. */
  131497. name: string,
  131498. /**
  131499. * Defines the location of the file to load
  131500. */
  131501. url: string,
  131502. /**
  131503. * Defines the desired size (the more it increases the longer the generation will be)
  131504. */
  131505. size: number,
  131506. /**
  131507. * Defines if mipmaps should not be generated (default is false)
  131508. */
  131509. noMipmap?: boolean,
  131510. /**
  131511. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131512. */
  131513. generateHarmonics?: boolean,
  131514. /**
  131515. * 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)
  131516. */
  131517. gammaSpace?: boolean,
  131518. /**
  131519. * Internal Use Only
  131520. */
  131521. reserved?: boolean);
  131522. /**
  131523. * Execute the current task
  131524. * @param scene defines the scene where you want your assets to be loaded
  131525. * @param onSuccess is a callback called when the task is successfully executed
  131526. * @param onError is a callback called if an error occurs
  131527. */
  131528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131529. }
  131530. /**
  131531. * Define a task used by AssetsManager to load Equirectangular cube textures
  131532. */
  131533. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131534. /**
  131535. * Defines the name of the task
  131536. */
  131537. name: string;
  131538. /**
  131539. * Defines the location of the file to load
  131540. */
  131541. url: string;
  131542. /**
  131543. * Defines the desired size (the more it increases the longer the generation will be)
  131544. */
  131545. size: number;
  131546. /**
  131547. * Defines if mipmaps should not be generated (default is false)
  131548. */
  131549. noMipmap: boolean;
  131550. /**
  131551. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131552. * but the standard material would require them in Gamma space) (default is true)
  131553. */
  131554. gammaSpace: boolean;
  131555. /**
  131556. * Gets the loaded texture
  131557. */
  131558. texture: EquiRectangularCubeTexture;
  131559. /**
  131560. * Callback called when the task is successful
  131561. */
  131562. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131563. /**
  131564. * Callback called when the task is successful
  131565. */
  131566. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131567. /**
  131568. * Creates a new EquiRectangularCubeTextureAssetTask object
  131569. * @param name defines the name of the task
  131570. * @param url defines the location of the file to load
  131571. * @param size defines the desired size (the more it increases the longer the generation will be)
  131572. * If the size is omitted this implies you are using a preprocessed cubemap.
  131573. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131574. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131575. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131576. * (default is true)
  131577. */
  131578. constructor(
  131579. /**
  131580. * Defines the name of the task
  131581. */
  131582. name: string,
  131583. /**
  131584. * Defines the location of the file to load
  131585. */
  131586. url: string,
  131587. /**
  131588. * Defines the desired size (the more it increases the longer the generation will be)
  131589. */
  131590. size: number,
  131591. /**
  131592. * Defines if mipmaps should not be generated (default is false)
  131593. */
  131594. noMipmap?: boolean,
  131595. /**
  131596. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131597. * but the standard material would require them in Gamma space) (default is true)
  131598. */
  131599. gammaSpace?: boolean);
  131600. /**
  131601. * Execute the current task
  131602. * @param scene defines the scene where you want your assets to be loaded
  131603. * @param onSuccess is a callback called when the task is successfully executed
  131604. * @param onError is a callback called if an error occurs
  131605. */
  131606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131607. }
  131608. /**
  131609. * This class can be used to easily import assets into a scene
  131610. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131611. */
  131612. export class AssetsManager {
  131613. private _scene;
  131614. private _isLoading;
  131615. protected _tasks: AbstractAssetTask[];
  131616. protected _waitingTasksCount: number;
  131617. protected _totalTasksCount: number;
  131618. /**
  131619. * Callback called when all tasks are processed
  131620. */
  131621. onFinish: (tasks: AbstractAssetTask[]) => void;
  131622. /**
  131623. * Callback called when a task is successful
  131624. */
  131625. onTaskSuccess: (task: AbstractAssetTask) => void;
  131626. /**
  131627. * Callback called when a task had an error
  131628. */
  131629. onTaskError: (task: AbstractAssetTask) => void;
  131630. /**
  131631. * Callback called when a task is done (whatever the result is)
  131632. */
  131633. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131634. /**
  131635. * Observable called when all tasks are processed
  131636. */
  131637. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131638. /**
  131639. * Observable called when a task had an error
  131640. */
  131641. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131642. /**
  131643. * Observable called when all tasks were executed
  131644. */
  131645. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131646. /**
  131647. * Observable called when a task is done (whatever the result is)
  131648. */
  131649. onProgressObservable: Observable<IAssetsProgressEvent>;
  131650. /**
  131651. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131652. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131653. */
  131654. useDefaultLoadingScreen: boolean;
  131655. /**
  131656. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131657. * when all assets have been downloaded.
  131658. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131659. */
  131660. autoHideLoadingUI: boolean;
  131661. /**
  131662. * Creates a new AssetsManager
  131663. * @param scene defines the scene to work on
  131664. */
  131665. constructor(scene: Scene);
  131666. /**
  131667. * Add a MeshAssetTask to the list of active tasks
  131668. * @param taskName defines the name of the new task
  131669. * @param meshesNames defines the name of meshes to load
  131670. * @param rootUrl defines the root url to use to locate files
  131671. * @param sceneFilename defines the filename of the scene file
  131672. * @returns a new MeshAssetTask object
  131673. */
  131674. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131675. /**
  131676. * Add a TextFileAssetTask to the list of active tasks
  131677. * @param taskName defines the name of the new task
  131678. * @param url defines the url of the file to load
  131679. * @returns a new TextFileAssetTask object
  131680. */
  131681. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131682. /**
  131683. * Add a BinaryFileAssetTask to the list of active tasks
  131684. * @param taskName defines the name of the new task
  131685. * @param url defines the url of the file to load
  131686. * @returns a new BinaryFileAssetTask object
  131687. */
  131688. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131689. /**
  131690. * Add a ImageAssetTask to the list of active tasks
  131691. * @param taskName defines the name of the new task
  131692. * @param url defines the url of the file to load
  131693. * @returns a new ImageAssetTask object
  131694. */
  131695. addImageTask(taskName: string, url: string): ImageAssetTask;
  131696. /**
  131697. * Add a TextureAssetTask to the list of active tasks
  131698. * @param taskName defines the name of the new task
  131699. * @param url defines the url of the file to load
  131700. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131701. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131702. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131703. * @returns a new TextureAssetTask object
  131704. */
  131705. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131706. /**
  131707. * Add a CubeTextureAssetTask to the list of active tasks
  131708. * @param taskName defines the name of the new task
  131709. * @param url defines the url of the file to load
  131710. * @param extensions defines the extension to use to load the cube map (can be null)
  131711. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131712. * @param files defines the list of files to load (can be null)
  131713. * @returns a new CubeTextureAssetTask object
  131714. */
  131715. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131716. /**
  131717. *
  131718. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131719. * @param taskName defines the name of the new task
  131720. * @param url defines the url of the file to load
  131721. * @param size defines the size you want for the cubemap (can be null)
  131722. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131723. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131724. * @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)
  131725. * @param reserved Internal use only
  131726. * @returns a new HDRCubeTextureAssetTask object
  131727. */
  131728. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131729. /**
  131730. *
  131731. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131732. * @param taskName defines the name of the new task
  131733. * @param url defines the url of the file to load
  131734. * @param size defines the size you want for the cubemap (can be null)
  131735. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131736. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131737. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131738. * @returns a new EquiRectangularCubeTextureAssetTask object
  131739. */
  131740. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131741. /**
  131742. * Remove a task from the assets manager.
  131743. * @param task the task to remove
  131744. */
  131745. removeTask(task: AbstractAssetTask): void;
  131746. private _decreaseWaitingTasksCount;
  131747. private _runTask;
  131748. /**
  131749. * Reset the AssetsManager and remove all tasks
  131750. * @return the current instance of the AssetsManager
  131751. */
  131752. reset(): AssetsManager;
  131753. /**
  131754. * Start the loading process
  131755. * @return the current instance of the AssetsManager
  131756. */
  131757. load(): AssetsManager;
  131758. /**
  131759. * Start the loading process as an async operation
  131760. * @return a promise returning the list of failed tasks
  131761. */
  131762. loadAsync(): Promise<void>;
  131763. }
  131764. }
  131765. declare module BABYLON {
  131766. /**
  131767. * Wrapper class for promise with external resolve and reject.
  131768. */
  131769. export class Deferred<T> {
  131770. /**
  131771. * The promise associated with this deferred object.
  131772. */
  131773. readonly promise: Promise<T>;
  131774. private _resolve;
  131775. private _reject;
  131776. /**
  131777. * The resolve method of the promise associated with this deferred object.
  131778. */
  131779. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131780. /**
  131781. * The reject method of the promise associated with this deferred object.
  131782. */
  131783. readonly reject: (reason?: any) => void;
  131784. /**
  131785. * Constructor for this deferred object.
  131786. */
  131787. constructor();
  131788. }
  131789. }
  131790. declare module BABYLON {
  131791. /**
  131792. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131793. */
  131794. export class MeshExploder {
  131795. private _centerMesh;
  131796. private _meshes;
  131797. private _meshesOrigins;
  131798. private _toCenterVectors;
  131799. private _scaledDirection;
  131800. private _newPosition;
  131801. private _centerPosition;
  131802. /**
  131803. * Explodes meshes from a center mesh.
  131804. * @param meshes The meshes to explode.
  131805. * @param centerMesh The mesh to be center of explosion.
  131806. */
  131807. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131808. private _setCenterMesh;
  131809. /**
  131810. * Get class name
  131811. * @returns "MeshExploder"
  131812. */
  131813. getClassName(): string;
  131814. /**
  131815. * "Exploded meshes"
  131816. * @returns Array of meshes with the centerMesh at index 0.
  131817. */
  131818. getMeshes(): Array<Mesh>;
  131819. /**
  131820. * Explodes meshes giving a specific direction
  131821. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131822. */
  131823. explode(direction?: number): void;
  131824. }
  131825. }
  131826. declare module BABYLON {
  131827. /**
  131828. * Class used to help managing file picking and drag'n'drop
  131829. */
  131830. export class FilesInput {
  131831. /**
  131832. * List of files ready to be loaded
  131833. */
  131834. static readonly FilesToLoad: {
  131835. [key: string]: File;
  131836. };
  131837. /**
  131838. * Callback called when a file is processed
  131839. */
  131840. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131841. private _engine;
  131842. private _currentScene;
  131843. private _sceneLoadedCallback;
  131844. private _progressCallback;
  131845. private _additionalRenderLoopLogicCallback;
  131846. private _textureLoadingCallback;
  131847. private _startingProcessingFilesCallback;
  131848. private _onReloadCallback;
  131849. private _errorCallback;
  131850. private _elementToMonitor;
  131851. private _sceneFileToLoad;
  131852. private _filesToLoad;
  131853. /**
  131854. * Creates a new FilesInput
  131855. * @param engine defines the rendering engine
  131856. * @param scene defines the hosting scene
  131857. * @param sceneLoadedCallback callback called when scene is loaded
  131858. * @param progressCallback callback called to track progress
  131859. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131860. * @param textureLoadingCallback callback called when a texture is loading
  131861. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131862. * @param onReloadCallback callback called when a reload is requested
  131863. * @param errorCallback callback call if an error occurs
  131864. */
  131865. 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);
  131866. private _dragEnterHandler;
  131867. private _dragOverHandler;
  131868. private _dropHandler;
  131869. /**
  131870. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131871. * @param elementToMonitor defines the DOM element to track
  131872. */
  131873. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131874. /**
  131875. * Release all associated resources
  131876. */
  131877. dispose(): void;
  131878. private renderFunction;
  131879. private drag;
  131880. private drop;
  131881. private _traverseFolder;
  131882. private _processFiles;
  131883. /**
  131884. * Load files from a drop event
  131885. * @param event defines the drop event to use as source
  131886. */
  131887. loadFiles(event: any): void;
  131888. private _processReload;
  131889. /**
  131890. * Reload the current scene from the loaded files
  131891. */
  131892. reload(): void;
  131893. }
  131894. }
  131895. declare module BABYLON {
  131896. /**
  131897. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131899. */
  131900. export class SceneOptimization {
  131901. /**
  131902. * Defines the priority of this optimization (0 by default which means first in the list)
  131903. */
  131904. priority: number;
  131905. /**
  131906. * Gets a string describing the action executed by the current optimization
  131907. * @returns description string
  131908. */
  131909. getDescription(): string;
  131910. /**
  131911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131912. * @param scene defines the current scene where to apply this optimization
  131913. * @param optimizer defines the current optimizer
  131914. * @returns true if everything that can be done was applied
  131915. */
  131916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131917. /**
  131918. * Creates the SceneOptimization object
  131919. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131920. * @param desc defines the description associated with the optimization
  131921. */
  131922. constructor(
  131923. /**
  131924. * Defines the priority of this optimization (0 by default which means first in the list)
  131925. */
  131926. priority?: number);
  131927. }
  131928. /**
  131929. * Defines an optimization used to reduce the size of render target textures
  131930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131931. */
  131932. export class TextureOptimization extends SceneOptimization {
  131933. /**
  131934. * Defines the priority of this optimization (0 by default which means first in the list)
  131935. */
  131936. priority: number;
  131937. /**
  131938. * 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
  131939. */
  131940. maximumSize: number;
  131941. /**
  131942. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131943. */
  131944. step: number;
  131945. /**
  131946. * Gets a string describing the action executed by the current optimization
  131947. * @returns description string
  131948. */
  131949. getDescription(): string;
  131950. /**
  131951. * Creates the TextureOptimization object
  131952. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131953. * @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
  131954. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131955. */
  131956. constructor(
  131957. /**
  131958. * Defines the priority of this optimization (0 by default which means first in the list)
  131959. */
  131960. priority?: number,
  131961. /**
  131962. * 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
  131963. */
  131964. maximumSize?: number,
  131965. /**
  131966. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131967. */
  131968. step?: number);
  131969. /**
  131970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131971. * @param scene defines the current scene where to apply this optimization
  131972. * @param optimizer defines the current optimizer
  131973. * @returns true if everything that can be done was applied
  131974. */
  131975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131976. }
  131977. /**
  131978. * Defines an optimization used to increase or decrease the rendering resolution
  131979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131980. */
  131981. export class HardwareScalingOptimization extends SceneOptimization {
  131982. /**
  131983. * Defines the priority of this optimization (0 by default which means first in the list)
  131984. */
  131985. priority: number;
  131986. /**
  131987. * Defines the maximum scale to use (2 by default)
  131988. */
  131989. maximumScale: number;
  131990. /**
  131991. * Defines the step to use between two passes (0.5 by default)
  131992. */
  131993. step: number;
  131994. private _currentScale;
  131995. private _directionOffset;
  131996. /**
  131997. * Gets a string describing the action executed by the current optimization
  131998. * @return description string
  131999. */
  132000. getDescription(): string;
  132001. /**
  132002. * Creates the HardwareScalingOptimization object
  132003. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132004. * @param maximumScale defines the maximum scale to use (2 by default)
  132005. * @param step defines the step to use between two passes (0.5 by default)
  132006. */
  132007. constructor(
  132008. /**
  132009. * Defines the priority of this optimization (0 by default which means first in the list)
  132010. */
  132011. priority?: number,
  132012. /**
  132013. * Defines the maximum scale to use (2 by default)
  132014. */
  132015. maximumScale?: number,
  132016. /**
  132017. * Defines the step to use between two passes (0.5 by default)
  132018. */
  132019. step?: number);
  132020. /**
  132021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132022. * @param scene defines the current scene where to apply this optimization
  132023. * @param optimizer defines the current optimizer
  132024. * @returns true if everything that can be done was applied
  132025. */
  132026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132027. }
  132028. /**
  132029. * Defines an optimization used to remove shadows
  132030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132031. */
  132032. export class ShadowsOptimization extends SceneOptimization {
  132033. /**
  132034. * Gets a string describing the action executed by the current optimization
  132035. * @return description string
  132036. */
  132037. getDescription(): string;
  132038. /**
  132039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132040. * @param scene defines the current scene where to apply this optimization
  132041. * @param optimizer defines the current optimizer
  132042. * @returns true if everything that can be done was applied
  132043. */
  132044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132045. }
  132046. /**
  132047. * Defines an optimization used to turn post-processes off
  132048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132049. */
  132050. export class PostProcessesOptimization extends SceneOptimization {
  132051. /**
  132052. * Gets a string describing the action executed by the current optimization
  132053. * @return description string
  132054. */
  132055. getDescription(): string;
  132056. /**
  132057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132058. * @param scene defines the current scene where to apply this optimization
  132059. * @param optimizer defines the current optimizer
  132060. * @returns true if everything that can be done was applied
  132061. */
  132062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132063. }
  132064. /**
  132065. * Defines an optimization used to turn lens flares off
  132066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132067. */
  132068. export class LensFlaresOptimization extends SceneOptimization {
  132069. /**
  132070. * Gets a string describing the action executed by the current optimization
  132071. * @return description string
  132072. */
  132073. getDescription(): string;
  132074. /**
  132075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132076. * @param scene defines the current scene where to apply this optimization
  132077. * @param optimizer defines the current optimizer
  132078. * @returns true if everything that can be done was applied
  132079. */
  132080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132081. }
  132082. /**
  132083. * Defines an optimization based on user defined callback.
  132084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132085. */
  132086. export class CustomOptimization extends SceneOptimization {
  132087. /**
  132088. * Callback called to apply the custom optimization.
  132089. */
  132090. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  132091. /**
  132092. * Callback called to get custom description
  132093. */
  132094. onGetDescription: () => string;
  132095. /**
  132096. * Gets a string describing the action executed by the current optimization
  132097. * @returns description string
  132098. */
  132099. getDescription(): string;
  132100. /**
  132101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132102. * @param scene defines the current scene where to apply this optimization
  132103. * @param optimizer defines the current optimizer
  132104. * @returns true if everything that can be done was applied
  132105. */
  132106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132107. }
  132108. /**
  132109. * Defines an optimization used to turn particles off
  132110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132111. */
  132112. export class ParticlesOptimization extends SceneOptimization {
  132113. /**
  132114. * Gets a string describing the action executed by the current optimization
  132115. * @return description string
  132116. */
  132117. getDescription(): string;
  132118. /**
  132119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132120. * @param scene defines the current scene where to apply this optimization
  132121. * @param optimizer defines the current optimizer
  132122. * @returns true if everything that can be done was applied
  132123. */
  132124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132125. }
  132126. /**
  132127. * Defines an optimization used to turn render targets off
  132128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132129. */
  132130. export class RenderTargetsOptimization extends SceneOptimization {
  132131. /**
  132132. * Gets a string describing the action executed by the current optimization
  132133. * @return description string
  132134. */
  132135. getDescription(): string;
  132136. /**
  132137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132138. * @param scene defines the current scene where to apply this optimization
  132139. * @param optimizer defines the current optimizer
  132140. * @returns true if everything that can be done was applied
  132141. */
  132142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132143. }
  132144. /**
  132145. * Defines an optimization used to merge meshes with compatible materials
  132146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132147. */
  132148. export class MergeMeshesOptimization extends SceneOptimization {
  132149. private static _UpdateSelectionTree;
  132150. /**
  132151. * Gets or sets a boolean which defines if optimization octree has to be updated
  132152. */
  132153. /**
  132154. * Gets or sets a boolean which defines if optimization octree has to be updated
  132155. */
  132156. static UpdateSelectionTree: boolean;
  132157. /**
  132158. * Gets a string describing the action executed by the current optimization
  132159. * @return description string
  132160. */
  132161. getDescription(): string;
  132162. private _canBeMerged;
  132163. /**
  132164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132165. * @param scene defines the current scene where to apply this optimization
  132166. * @param optimizer defines the current optimizer
  132167. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  132168. * @returns true if everything that can be done was applied
  132169. */
  132170. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  132171. }
  132172. /**
  132173. * Defines a list of options used by SceneOptimizer
  132174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132175. */
  132176. export class SceneOptimizerOptions {
  132177. /**
  132178. * Defines the target frame rate to reach (60 by default)
  132179. */
  132180. targetFrameRate: number;
  132181. /**
  132182. * Defines the interval between two checkes (2000ms by default)
  132183. */
  132184. trackerDuration: number;
  132185. /**
  132186. * Gets the list of optimizations to apply
  132187. */
  132188. optimizations: SceneOptimization[];
  132189. /**
  132190. * Creates a new list of options used by SceneOptimizer
  132191. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  132192. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  132193. */
  132194. constructor(
  132195. /**
  132196. * Defines the target frame rate to reach (60 by default)
  132197. */
  132198. targetFrameRate?: number,
  132199. /**
  132200. * Defines the interval between two checkes (2000ms by default)
  132201. */
  132202. trackerDuration?: number);
  132203. /**
  132204. * Add a new optimization
  132205. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132206. * @returns the current SceneOptimizerOptions
  132207. */
  132208. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132209. /**
  132210. * Add a new custom optimization
  132211. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132212. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132213. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132214. * @returns the current SceneOptimizerOptions
  132215. */
  132216. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132217. /**
  132218. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132219. * @param targetFrameRate defines the target frame rate (60 by default)
  132220. * @returns a SceneOptimizerOptions object
  132221. */
  132222. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132223. /**
  132224. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132225. * @param targetFrameRate defines the target frame rate (60 by default)
  132226. * @returns a SceneOptimizerOptions object
  132227. */
  132228. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132229. /**
  132230. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132231. * @param targetFrameRate defines the target frame rate (60 by default)
  132232. * @returns a SceneOptimizerOptions object
  132233. */
  132234. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132235. }
  132236. /**
  132237. * Class used to run optimizations in order to reach a target frame rate
  132238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132239. */
  132240. export class SceneOptimizer implements IDisposable {
  132241. private _isRunning;
  132242. private _options;
  132243. private _scene;
  132244. private _currentPriorityLevel;
  132245. private _targetFrameRate;
  132246. private _trackerDuration;
  132247. private _currentFrameRate;
  132248. private _sceneDisposeObserver;
  132249. private _improvementMode;
  132250. /**
  132251. * Defines an observable called when the optimizer reaches the target frame rate
  132252. */
  132253. onSuccessObservable: Observable<SceneOptimizer>;
  132254. /**
  132255. * Defines an observable called when the optimizer enables an optimization
  132256. */
  132257. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132258. /**
  132259. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132260. */
  132261. onFailureObservable: Observable<SceneOptimizer>;
  132262. /**
  132263. * Gets a boolean indicating if the optimizer is in improvement mode
  132264. */
  132265. readonly isInImprovementMode: boolean;
  132266. /**
  132267. * Gets the current priority level (0 at start)
  132268. */
  132269. readonly currentPriorityLevel: number;
  132270. /**
  132271. * Gets the current frame rate checked by the SceneOptimizer
  132272. */
  132273. readonly currentFrameRate: number;
  132274. /**
  132275. * Gets or sets the current target frame rate (60 by default)
  132276. */
  132277. /**
  132278. * Gets or sets the current target frame rate (60 by default)
  132279. */
  132280. targetFrameRate: number;
  132281. /**
  132282. * Gets or sets the current interval between two checks (every 2000ms by default)
  132283. */
  132284. /**
  132285. * Gets or sets the current interval between two checks (every 2000ms by default)
  132286. */
  132287. trackerDuration: number;
  132288. /**
  132289. * Gets the list of active optimizations
  132290. */
  132291. readonly optimizations: SceneOptimization[];
  132292. /**
  132293. * Creates a new SceneOptimizer
  132294. * @param scene defines the scene to work on
  132295. * @param options defines the options to use with the SceneOptimizer
  132296. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132297. * @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)
  132298. */
  132299. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132300. /**
  132301. * Stops the current optimizer
  132302. */
  132303. stop(): void;
  132304. /**
  132305. * Reset the optimizer to initial step (current priority level = 0)
  132306. */
  132307. reset(): void;
  132308. /**
  132309. * Start the optimizer. By default it will try to reach a specific framerate
  132310. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132311. */
  132312. start(): void;
  132313. private _checkCurrentState;
  132314. /**
  132315. * Release all resources
  132316. */
  132317. dispose(): void;
  132318. /**
  132319. * Helper function to create a SceneOptimizer with one single line of code
  132320. * @param scene defines the scene to work on
  132321. * @param options defines the options to use with the SceneOptimizer
  132322. * @param onSuccess defines a callback to call on success
  132323. * @param onFailure defines a callback to call on failure
  132324. * @returns the new SceneOptimizer object
  132325. */
  132326. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132327. }
  132328. }
  132329. declare module BABYLON {
  132330. /**
  132331. * Class used to serialize a scene into a string
  132332. */
  132333. export class SceneSerializer {
  132334. /**
  132335. * Clear cache used by a previous serialization
  132336. */
  132337. static ClearCache(): void;
  132338. /**
  132339. * Serialize a scene into a JSON compatible object
  132340. * @param scene defines the scene to serialize
  132341. * @returns a JSON compatible object
  132342. */
  132343. static Serialize(scene: Scene): any;
  132344. /**
  132345. * Serialize a mesh into a JSON compatible object
  132346. * @param toSerialize defines the mesh to serialize
  132347. * @param withParents defines if parents must be serialized as well
  132348. * @param withChildren defines if children must be serialized as well
  132349. * @returns a JSON compatible object
  132350. */
  132351. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132352. }
  132353. }
  132354. declare module BABYLON {
  132355. /**
  132356. * Class used to host texture specific utilities
  132357. */
  132358. export class TextureTools {
  132359. /**
  132360. * Uses the GPU to create a copy texture rescaled at a given size
  132361. * @param texture Texture to copy from
  132362. * @param width defines the desired width
  132363. * @param height defines the desired height
  132364. * @param useBilinearMode defines if bilinear mode has to be used
  132365. * @return the generated texture
  132366. */
  132367. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132368. }
  132369. }
  132370. declare module BABYLON {
  132371. /**
  132372. * This represents the different options available for the video capture.
  132373. */
  132374. export interface VideoRecorderOptions {
  132375. /** Defines the mime type of the video. */
  132376. mimeType: string;
  132377. /** Defines the FPS the video should be recorded at. */
  132378. fps: number;
  132379. /** Defines the chunk size for the recording data. */
  132380. recordChunckSize: number;
  132381. /** The audio tracks to attach to the recording. */
  132382. audioTracks?: MediaStreamTrack[];
  132383. }
  132384. /**
  132385. * This can help with recording videos from BabylonJS.
  132386. * This is based on the available WebRTC functionalities of the browser.
  132387. *
  132388. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132389. */
  132390. export class VideoRecorder {
  132391. private static readonly _defaultOptions;
  132392. /**
  132393. * Returns whether or not the VideoRecorder is available in your browser.
  132394. * @param engine Defines the Babylon Engine.
  132395. * @returns true if supported otherwise false.
  132396. */
  132397. static IsSupported(engine: Engine): boolean;
  132398. private readonly _options;
  132399. private _canvas;
  132400. private _mediaRecorder;
  132401. private _recordedChunks;
  132402. private _fileName;
  132403. private _resolve;
  132404. private _reject;
  132405. /**
  132406. * True when a recording is already in progress.
  132407. */
  132408. readonly isRecording: boolean;
  132409. /**
  132410. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132411. * @param engine Defines the BabylonJS Engine you wish to record.
  132412. * @param options Defines options that can be used to customize the capture.
  132413. */
  132414. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132415. /**
  132416. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132417. */
  132418. stopRecording(): void;
  132419. /**
  132420. * Starts recording the canvas for a max duration specified in parameters.
  132421. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132422. * If null no automatic download will start and you can rely on the promise to get the data back.
  132423. * @param maxDuration Defines the maximum recording time in seconds.
  132424. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132425. * @return A promise callback at the end of the recording with the video data in Blob.
  132426. */
  132427. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132428. /**
  132429. * Releases internal resources used during the recording.
  132430. */
  132431. dispose(): void;
  132432. private _handleDataAvailable;
  132433. private _handleError;
  132434. private _handleStop;
  132435. }
  132436. }
  132437. declare module BABYLON {
  132438. /**
  132439. * Class containing a set of static utilities functions for screenshots
  132440. */
  132441. export class ScreenshotTools {
  132442. /**
  132443. * Captures a screenshot of the current rendering
  132444. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132445. * @param engine defines the rendering engine
  132446. * @param camera defines the source camera
  132447. * @param size This parameter can be set to a single number or to an object with the
  132448. * following (optional) properties: precision, width, height. If a single number is passed,
  132449. * it will be used for both width and height. If an object is passed, the screenshot size
  132450. * will be derived from the parameters. The precision property is a multiplier allowing
  132451. * rendering at a higher or lower resolution
  132452. * @param successCallback defines the callback receives a single parameter which contains the
  132453. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132454. * src parameter of an <img> to display it
  132455. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132456. * Check your browser for supported MIME types
  132457. */
  132458. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132459. /**
  132460. * Captures a screenshot of the current rendering
  132461. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132462. * @param engine defines the rendering engine
  132463. * @param camera defines the source camera
  132464. * @param size This parameter can be set to a single number or to an object with the
  132465. * following (optional) properties: precision, width, height. If a single number is passed,
  132466. * it will be used for both width and height. If an object is passed, the screenshot size
  132467. * will be derived from the parameters. The precision property is a multiplier allowing
  132468. * rendering at a higher or lower resolution
  132469. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132470. * Check your browser for supported MIME types
  132471. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132472. * to the src parameter of an <img> to display it
  132473. */
  132474. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132475. /**
  132476. * Generates an image screenshot from the specified camera.
  132477. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132478. * @param engine The engine to use for rendering
  132479. * @param camera The camera to use for rendering
  132480. * @param size This parameter can be set to a single number or to an object with the
  132481. * following (optional) properties: precision, width, height. If a single number is passed,
  132482. * it will be used for both width and height. If an object is passed, the screenshot size
  132483. * will be derived from the parameters. The precision property is a multiplier allowing
  132484. * rendering at a higher or lower resolution
  132485. * @param successCallback The callback receives a single parameter which contains the
  132486. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132487. * src parameter of an <img> to display it
  132488. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132489. * Check your browser for supported MIME types
  132490. * @param samples Texture samples (default: 1)
  132491. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132492. * @param fileName A name for for the downloaded file.
  132493. */
  132494. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132495. /**
  132496. * Generates an image screenshot from the specified camera.
  132497. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132498. * @param engine The engine to use for rendering
  132499. * @param camera The camera to use for rendering
  132500. * @param size This parameter can be set to a single number or to an object with the
  132501. * following (optional) properties: precision, width, height. If a single number is passed,
  132502. * it will be used for both width and height. If an object is passed, the screenshot size
  132503. * will be derived from the parameters. The precision property is a multiplier allowing
  132504. * rendering at a higher or lower resolution
  132505. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132506. * Check your browser for supported MIME types
  132507. * @param samples Texture samples (default: 1)
  132508. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132509. * @param fileName A name for for the downloaded file.
  132510. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132511. * to the src parameter of an <img> to display it
  132512. */
  132513. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132514. /**
  132515. * Gets height and width for screenshot size
  132516. * @private
  132517. */
  132518. private static _getScreenshotSize;
  132519. }
  132520. }
  132521. declare module BABYLON {
  132522. /**
  132523. * Interface for a data buffer
  132524. */
  132525. export interface IDataBuffer {
  132526. /**
  132527. * Reads bytes from the data buffer.
  132528. * @param byteOffset The byte offset to read
  132529. * @param byteLength The byte length to read
  132530. * @returns A promise that resolves when the bytes are read
  132531. */
  132532. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132533. /**
  132534. * The byte length of the buffer.
  132535. */
  132536. readonly byteLength: number;
  132537. }
  132538. /**
  132539. * Utility class for reading from a data buffer
  132540. */
  132541. export class DataReader {
  132542. /**
  132543. * The data buffer associated with this data reader.
  132544. */
  132545. readonly buffer: IDataBuffer;
  132546. /**
  132547. * The current byte offset from the beginning of the data buffer.
  132548. */
  132549. byteOffset: number;
  132550. private _dataView;
  132551. private _dataByteOffset;
  132552. /**
  132553. * Constructor
  132554. * @param buffer The buffer to read
  132555. */
  132556. constructor(buffer: IDataBuffer);
  132557. /**
  132558. * Loads the given byte length.
  132559. * @param byteLength The byte length to load
  132560. * @returns A promise that resolves when the load is complete
  132561. */
  132562. loadAsync(byteLength: number): Promise<void>;
  132563. /**
  132564. * Read a unsigned 32-bit integer from the currently loaded data range.
  132565. * @returns The 32-bit integer read
  132566. */
  132567. readUint32(): number;
  132568. /**
  132569. * Read a byte array from the currently loaded data range.
  132570. * @param byteLength The byte length to read
  132571. * @returns The byte array read
  132572. */
  132573. readUint8Array(byteLength: number): Uint8Array;
  132574. /**
  132575. * Read a string from the currently loaded data range.
  132576. * @param byteLength The byte length to read
  132577. * @returns The string read
  132578. */
  132579. readString(byteLength: number): string;
  132580. /**
  132581. * Skips the given byte length the currently loaded data range.
  132582. * @param byteLength The byte length to skip
  132583. */
  132584. skipBytes(byteLength: number): void;
  132585. }
  132586. }
  132587. declare module BABYLON {
  132588. /**
  132589. * A cursor which tracks a point on a path
  132590. */
  132591. export class PathCursor {
  132592. private path;
  132593. /**
  132594. * Stores path cursor callbacks for when an onchange event is triggered
  132595. */
  132596. private _onchange;
  132597. /**
  132598. * The value of the path cursor
  132599. */
  132600. value: number;
  132601. /**
  132602. * The animation array of the path cursor
  132603. */
  132604. animations: Animation[];
  132605. /**
  132606. * Initializes the path cursor
  132607. * @param path The path to track
  132608. */
  132609. constructor(path: Path2);
  132610. /**
  132611. * Gets the cursor point on the path
  132612. * @returns A point on the path cursor at the cursor location
  132613. */
  132614. getPoint(): Vector3;
  132615. /**
  132616. * Moves the cursor ahead by the step amount
  132617. * @param step The amount to move the cursor forward
  132618. * @returns This path cursor
  132619. */
  132620. moveAhead(step?: number): PathCursor;
  132621. /**
  132622. * Moves the cursor behind by the step amount
  132623. * @param step The amount to move the cursor back
  132624. * @returns This path cursor
  132625. */
  132626. moveBack(step?: number): PathCursor;
  132627. /**
  132628. * Moves the cursor by the step amount
  132629. * If the step amount is greater than one, an exception is thrown
  132630. * @param step The amount to move the cursor
  132631. * @returns This path cursor
  132632. */
  132633. move(step: number): PathCursor;
  132634. /**
  132635. * Ensures that the value is limited between zero and one
  132636. * @returns This path cursor
  132637. */
  132638. private ensureLimits;
  132639. /**
  132640. * Runs onchange callbacks on change (used by the animation engine)
  132641. * @returns This path cursor
  132642. */
  132643. private raiseOnChange;
  132644. /**
  132645. * Executes a function on change
  132646. * @param f A path cursor onchange callback
  132647. * @returns This path cursor
  132648. */
  132649. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132650. }
  132651. }
  132652. declare module BABYLON {
  132653. /** @hidden */
  132654. export var blurPixelShader: {
  132655. name: string;
  132656. shader: string;
  132657. };
  132658. }
  132659. declare module BABYLON {
  132660. /** @hidden */
  132661. export var pointCloudVertexDeclaration: {
  132662. name: string;
  132663. shader: string;
  132664. };
  132665. }
  132666. // Mixins
  132667. interface Window {
  132668. mozIndexedDB: IDBFactory;
  132669. webkitIndexedDB: IDBFactory;
  132670. msIndexedDB: IDBFactory;
  132671. webkitURL: typeof URL;
  132672. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132673. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132674. WebGLRenderingContext: WebGLRenderingContext;
  132675. MSGesture: MSGesture;
  132676. CANNON: any;
  132677. AudioContext: AudioContext;
  132678. webkitAudioContext: AudioContext;
  132679. PointerEvent: any;
  132680. Math: Math;
  132681. Uint8Array: Uint8ArrayConstructor;
  132682. Float32Array: Float32ArrayConstructor;
  132683. mozURL: typeof URL;
  132684. msURL: typeof URL;
  132685. VRFrameData: any; // WebVR, from specs 1.1
  132686. DracoDecoderModule: any;
  132687. setImmediate(handler: (...args: any[]) => void): number;
  132688. }
  132689. interface HTMLCanvasElement {
  132690. requestPointerLock(): void;
  132691. msRequestPointerLock?(): void;
  132692. mozRequestPointerLock?(): void;
  132693. webkitRequestPointerLock?(): void;
  132694. /** Track wether a record is in progress */
  132695. isRecording: boolean;
  132696. /** Capture Stream method defined by some browsers */
  132697. captureStream(fps?: number): MediaStream;
  132698. }
  132699. interface CanvasRenderingContext2D {
  132700. msImageSmoothingEnabled: boolean;
  132701. }
  132702. interface MouseEvent {
  132703. mozMovementX: number;
  132704. mozMovementY: number;
  132705. webkitMovementX: number;
  132706. webkitMovementY: number;
  132707. msMovementX: number;
  132708. msMovementY: number;
  132709. }
  132710. interface Navigator {
  132711. mozGetVRDevices: (any: any) => any;
  132712. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132713. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132714. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132715. webkitGetGamepads(): Gamepad[];
  132716. msGetGamepads(): Gamepad[];
  132717. webkitGamepads(): Gamepad[];
  132718. }
  132719. interface HTMLVideoElement {
  132720. mozSrcObject: any;
  132721. }
  132722. interface Math {
  132723. fround(x: number): number;
  132724. imul(a: number, b: number): number;
  132725. }
  132726. interface WebGLRenderingContext {
  132727. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132728. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132729. vertexAttribDivisor(index: number, divisor: number): void;
  132730. createVertexArray(): any;
  132731. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132732. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132733. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132734. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132735. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132736. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132737. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132738. // Queries
  132739. createQuery(): WebGLQuery;
  132740. deleteQuery(query: WebGLQuery): void;
  132741. beginQuery(target: number, query: WebGLQuery): void;
  132742. endQuery(target: number): void;
  132743. getQueryParameter(query: WebGLQuery, pname: number): any;
  132744. getQuery(target: number, pname: number): any;
  132745. MAX_SAMPLES: number;
  132746. RGBA8: number;
  132747. READ_FRAMEBUFFER: number;
  132748. DRAW_FRAMEBUFFER: number;
  132749. UNIFORM_BUFFER: number;
  132750. HALF_FLOAT_OES: number;
  132751. RGBA16F: number;
  132752. RGBA32F: number;
  132753. R32F: number;
  132754. RG32F: number;
  132755. RGB32F: number;
  132756. R16F: number;
  132757. RG16F: number;
  132758. RGB16F: number;
  132759. RED: number;
  132760. RG: number;
  132761. R8: number;
  132762. RG8: number;
  132763. UNSIGNED_INT_24_8: number;
  132764. DEPTH24_STENCIL8: number;
  132765. MIN: number;
  132766. MAX: number;
  132767. /* Multiple Render Targets */
  132768. drawBuffers(buffers: number[]): void;
  132769. readBuffer(src: number): void;
  132770. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132771. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132772. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132773. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132774. // Occlusion Query
  132775. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132776. ANY_SAMPLES_PASSED: number;
  132777. QUERY_RESULT_AVAILABLE: number;
  132778. QUERY_RESULT: number;
  132779. }
  132780. interface WebGLProgram {
  132781. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132782. }
  132783. interface EXT_disjoint_timer_query {
  132784. QUERY_COUNTER_BITS_EXT: number;
  132785. TIME_ELAPSED_EXT: number;
  132786. TIMESTAMP_EXT: number;
  132787. GPU_DISJOINT_EXT: number;
  132788. QUERY_RESULT_EXT: number;
  132789. QUERY_RESULT_AVAILABLE_EXT: number;
  132790. queryCounterEXT(query: WebGLQuery, target: number): void;
  132791. createQueryEXT(): WebGLQuery;
  132792. beginQueryEXT(target: number, query: WebGLQuery): void;
  132793. endQueryEXT(target: number): void;
  132794. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132795. deleteQueryEXT(query: WebGLQuery): void;
  132796. }
  132797. interface WebGLUniformLocation {
  132798. _currentState: any;
  132799. }
  132800. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132801. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132802. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132803. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132804. interface WebGLRenderingContext {
  132805. readonly RASTERIZER_DISCARD: number;
  132806. readonly DEPTH_COMPONENT24: number;
  132807. readonly TEXTURE_3D: number;
  132808. readonly TEXTURE_2D_ARRAY: number;
  132809. readonly TEXTURE_COMPARE_FUNC: number;
  132810. readonly TEXTURE_COMPARE_MODE: number;
  132811. readonly COMPARE_REF_TO_TEXTURE: number;
  132812. readonly TEXTURE_WRAP_R: number;
  132813. readonly HALF_FLOAT: number;
  132814. readonly RGB8: number;
  132815. readonly RED_INTEGER: number;
  132816. readonly RG_INTEGER: number;
  132817. readonly RGB_INTEGER: number;
  132818. readonly RGBA_INTEGER: number;
  132819. readonly R8_SNORM: number;
  132820. readonly RG8_SNORM: number;
  132821. readonly RGB8_SNORM: number;
  132822. readonly RGBA8_SNORM: number;
  132823. readonly R8I: number;
  132824. readonly RG8I: number;
  132825. readonly RGB8I: number;
  132826. readonly RGBA8I: number;
  132827. readonly R8UI: number;
  132828. readonly RG8UI: number;
  132829. readonly RGB8UI: number;
  132830. readonly RGBA8UI: number;
  132831. readonly R16I: number;
  132832. readonly RG16I: number;
  132833. readonly RGB16I: number;
  132834. readonly RGBA16I: number;
  132835. readonly R16UI: number;
  132836. readonly RG16UI: number;
  132837. readonly RGB16UI: number;
  132838. readonly RGBA16UI: number;
  132839. readonly R32I: number;
  132840. readonly RG32I: number;
  132841. readonly RGB32I: number;
  132842. readonly RGBA32I: number;
  132843. readonly R32UI: number;
  132844. readonly RG32UI: number;
  132845. readonly RGB32UI: number;
  132846. readonly RGBA32UI: number;
  132847. readonly RGB10_A2UI: number;
  132848. readonly R11F_G11F_B10F: number;
  132849. readonly RGB9_E5: number;
  132850. readonly RGB10_A2: number;
  132851. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132852. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132853. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132854. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132855. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132856. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132857. 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;
  132858. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132859. readonly TRANSFORM_FEEDBACK: number;
  132860. readonly INTERLEAVED_ATTRIBS: number;
  132861. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132862. createTransformFeedback(): WebGLTransformFeedback;
  132863. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132864. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132865. beginTransformFeedback(primitiveMode: number): void;
  132866. endTransformFeedback(): void;
  132867. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132868. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132869. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132870. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132871. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132872. }
  132873. interface ImageBitmap {
  132874. readonly width: number;
  132875. readonly height: number;
  132876. close(): void;
  132877. }
  132878. interface WebGLQuery extends WebGLObject {
  132879. }
  132880. declare var WebGLQuery: {
  132881. prototype: WebGLQuery;
  132882. new(): WebGLQuery;
  132883. };
  132884. interface WebGLSampler extends WebGLObject {
  132885. }
  132886. declare var WebGLSampler: {
  132887. prototype: WebGLSampler;
  132888. new(): WebGLSampler;
  132889. };
  132890. interface WebGLSync extends WebGLObject {
  132891. }
  132892. declare var WebGLSync: {
  132893. prototype: WebGLSync;
  132894. new(): WebGLSync;
  132895. };
  132896. interface WebGLTransformFeedback extends WebGLObject {
  132897. }
  132898. declare var WebGLTransformFeedback: {
  132899. prototype: WebGLTransformFeedback;
  132900. new(): WebGLTransformFeedback;
  132901. };
  132902. interface WebGLVertexArrayObject extends WebGLObject {
  132903. }
  132904. declare var WebGLVertexArrayObject: {
  132905. prototype: WebGLVertexArrayObject;
  132906. new(): WebGLVertexArrayObject;
  132907. };
  132908. // Type definitions for WebVR API
  132909. // Project: https://w3c.github.io/webvr/
  132910. // Definitions by: six a <https://github.com/lostfictions>
  132911. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132912. interface VRDisplay extends EventTarget {
  132913. /**
  132914. * Dictionary of capabilities describing the VRDisplay.
  132915. */
  132916. readonly capabilities: VRDisplayCapabilities;
  132917. /**
  132918. * z-depth defining the far plane of the eye view frustum
  132919. * enables mapping of values in the render target depth
  132920. * attachment to scene coordinates. Initially set to 10000.0.
  132921. */
  132922. depthFar: number;
  132923. /**
  132924. * z-depth defining the near plane of the eye view frustum
  132925. * enables mapping of values in the render target depth
  132926. * attachment to scene coordinates. Initially set to 0.01.
  132927. */
  132928. depthNear: number;
  132929. /**
  132930. * An identifier for this distinct VRDisplay. Used as an
  132931. * association point in the Gamepad API.
  132932. */
  132933. readonly displayId: number;
  132934. /**
  132935. * A display name, a user-readable name identifying it.
  132936. */
  132937. readonly displayName: string;
  132938. readonly isConnected: boolean;
  132939. readonly isPresenting: boolean;
  132940. /**
  132941. * If this VRDisplay supports room-scale experiences, the optional
  132942. * stage attribute contains details on the room-scale parameters.
  132943. */
  132944. readonly stageParameters: VRStageParameters | null;
  132945. /**
  132946. * Passing the value returned by `requestAnimationFrame` to
  132947. * `cancelAnimationFrame` will unregister the callback.
  132948. * @param handle Define the hanle of the request to cancel
  132949. */
  132950. cancelAnimationFrame(handle: number): void;
  132951. /**
  132952. * Stops presenting to the VRDisplay.
  132953. * @returns a promise to know when it stopped
  132954. */
  132955. exitPresent(): Promise<void>;
  132956. /**
  132957. * Return the current VREyeParameters for the given eye.
  132958. * @param whichEye Define the eye we want the parameter for
  132959. * @returns the eye parameters
  132960. */
  132961. getEyeParameters(whichEye: string): VREyeParameters;
  132962. /**
  132963. * Populates the passed VRFrameData with the information required to render
  132964. * the current frame.
  132965. * @param frameData Define the data structure to populate
  132966. * @returns true if ok otherwise false
  132967. */
  132968. getFrameData(frameData: VRFrameData): boolean;
  132969. /**
  132970. * Get the layers currently being presented.
  132971. * @returns the list of VR layers
  132972. */
  132973. getLayers(): VRLayer[];
  132974. /**
  132975. * Return a VRPose containing the future predicted pose of the VRDisplay
  132976. * when the current frame will be presented. The value returned will not
  132977. * change until JavaScript has returned control to the browser.
  132978. *
  132979. * The VRPose will contain the position, orientation, velocity,
  132980. * and acceleration of each of these properties.
  132981. * @returns the pose object
  132982. */
  132983. getPose(): VRPose;
  132984. /**
  132985. * Return the current instantaneous pose of the VRDisplay, with no
  132986. * prediction applied.
  132987. * @returns the current instantaneous pose
  132988. */
  132989. getImmediatePose(): VRPose;
  132990. /**
  132991. * The callback passed to `requestAnimationFrame` will be called
  132992. * any time a new frame should be rendered. When the VRDisplay is
  132993. * presenting the callback will be called at the native refresh
  132994. * rate of the HMD. When not presenting this function acts
  132995. * identically to how window.requestAnimationFrame acts. Content should
  132996. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132997. * asynchronously from other displays and at differing refresh rates.
  132998. * @param callback Define the eaction to run next frame
  132999. * @returns the request handle it
  133000. */
  133001. requestAnimationFrame(callback: FrameRequestCallback): number;
  133002. /**
  133003. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  133004. * Repeat calls while already presenting will update the VRLayers being displayed.
  133005. * @param layers Define the list of layer to present
  133006. * @returns a promise to know when the request has been fulfilled
  133007. */
  133008. requestPresent(layers: VRLayer[]): Promise<void>;
  133009. /**
  133010. * Reset the pose for this display, treating its current position and
  133011. * orientation as the "origin/zero" values. VRPose.position,
  133012. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  133013. * updated when calling resetPose(). This should be called in only
  133014. * sitting-space experiences.
  133015. */
  133016. resetPose(): void;
  133017. /**
  133018. * The VRLayer provided to the VRDisplay will be captured and presented
  133019. * in the HMD. Calling this function has the same effect on the source
  133020. * canvas as any other operation that uses its source image, and canvases
  133021. * created without preserveDrawingBuffer set to true will be cleared.
  133022. * @param pose Define the pose to submit
  133023. */
  133024. submitFrame(pose?: VRPose): void;
  133025. }
  133026. declare var VRDisplay: {
  133027. prototype: VRDisplay;
  133028. new(): VRDisplay;
  133029. };
  133030. interface VRLayer {
  133031. leftBounds?: number[] | Float32Array | null;
  133032. rightBounds?: number[] | Float32Array | null;
  133033. source?: HTMLCanvasElement | null;
  133034. }
  133035. interface VRDisplayCapabilities {
  133036. readonly canPresent: boolean;
  133037. readonly hasExternalDisplay: boolean;
  133038. readonly hasOrientation: boolean;
  133039. readonly hasPosition: boolean;
  133040. readonly maxLayers: number;
  133041. }
  133042. interface VREyeParameters {
  133043. /** @deprecated */
  133044. readonly fieldOfView: VRFieldOfView;
  133045. readonly offset: Float32Array;
  133046. readonly renderHeight: number;
  133047. readonly renderWidth: number;
  133048. }
  133049. interface VRFieldOfView {
  133050. readonly downDegrees: number;
  133051. readonly leftDegrees: number;
  133052. readonly rightDegrees: number;
  133053. readonly upDegrees: number;
  133054. }
  133055. interface VRFrameData {
  133056. readonly leftProjectionMatrix: Float32Array;
  133057. readonly leftViewMatrix: Float32Array;
  133058. readonly pose: VRPose;
  133059. readonly rightProjectionMatrix: Float32Array;
  133060. readonly rightViewMatrix: Float32Array;
  133061. readonly timestamp: number;
  133062. }
  133063. interface VRPose {
  133064. readonly angularAcceleration: Float32Array | null;
  133065. readonly angularVelocity: Float32Array | null;
  133066. readonly linearAcceleration: Float32Array | null;
  133067. readonly linearVelocity: Float32Array | null;
  133068. readonly orientation: Float32Array | null;
  133069. readonly position: Float32Array | null;
  133070. readonly timestamp: number;
  133071. }
  133072. interface VRStageParameters {
  133073. sittingToStandingTransform?: Float32Array;
  133074. sizeX?: number;
  133075. sizeY?: number;
  133076. }
  133077. interface Navigator {
  133078. getVRDisplays(): Promise<VRDisplay[]>;
  133079. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  133080. }
  133081. interface Window {
  133082. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  133083. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  133084. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  133085. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133086. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133087. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  133088. }
  133089. interface Gamepad {
  133090. readonly displayId: number;
  133091. }
  133092. type XRSessionMode =
  133093. | "inline"
  133094. | "immersive-vr"
  133095. | "immersive-ar";
  133096. type XRReferenceSpaceType =
  133097. | "viewer"
  133098. | "local"
  133099. | "local-floor"
  133100. | "bounded-floor"
  133101. | "unbounded";
  133102. type XREnvironmentBlendMode =
  133103. | "opaque"
  133104. | "additive"
  133105. | "alpha-blend";
  133106. type XRVisibilityState =
  133107. | "visible"
  133108. | "visible-blurred"
  133109. | "hidden";
  133110. type XRHandedness =
  133111. | "none"
  133112. | "left"
  133113. | "right";
  133114. type XRTargetRayMode =
  133115. | "gaze"
  133116. | "tracked-pointer"
  133117. | "screen";
  133118. type XREye =
  133119. | "none"
  133120. | "left"
  133121. | "right";
  133122. interface XRSpace extends EventTarget {
  133123. }
  133124. interface XRRenderState {
  133125. depthNear?: number;
  133126. depthFar?: number;
  133127. inlineVerticalFieldOfView?: number;
  133128. baseLayer?: XRWebGLLayer;
  133129. }
  133130. interface XRInputSource {
  133131. handedness: XRHandedness;
  133132. targetRayMode: XRTargetRayMode;
  133133. targetRaySpace: XRSpace;
  133134. gripSpace: XRSpace | undefined;
  133135. gamepad: Gamepad | undefined;
  133136. profiles: Array<string>;
  133137. }
  133138. interface XRSession {
  133139. addEventListener: Function;
  133140. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  133141. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  133142. requestAnimationFrame: Function;
  133143. end(): Promise<void>;
  133144. renderState: XRRenderState;
  133145. inputSources: Array<XRInputSource>;
  133146. }
  133147. interface XRReferenceSpace extends XRSpace {
  133148. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  133149. onreset: any;
  133150. }
  133151. interface XRFrame {
  133152. session: XRSession;
  133153. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  133154. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  133155. }
  133156. interface XRViewerPose extends XRPose {
  133157. views: Array<XRView>;
  133158. }
  133159. interface XRPose {
  133160. transform: XRRigidTransform;
  133161. emulatedPosition: boolean;
  133162. }
  133163. declare var XRWebGLLayer: {
  133164. prototype: XRWebGLLayer;
  133165. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  133166. };
  133167. interface XRWebGLLayer {
  133168. framebuffer: WebGLFramebuffer;
  133169. framebufferWidth: number;
  133170. framebufferHeight: number;
  133171. getViewport: Function;
  133172. }
  133173. interface XRRigidTransform {
  133174. position: DOMPointReadOnly;
  133175. orientation: DOMPointReadOnly;
  133176. matrix: Float32Array;
  133177. inverse: XRRigidTransform;
  133178. }
  133179. interface XRView {
  133180. eye: XREye;
  133181. projectionMatrix: Float32Array;
  133182. transform: XRRigidTransform;
  133183. }
  133184. interface XRInputSourceChangeEvent {
  133185. session: XRSession;
  133186. removed: Array<XRInputSource>;
  133187. added: Array<XRInputSource>;
  133188. }